:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --stage: #0f172a;
  --spot: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------ header */

.tp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tp-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
}

.tp-brand-name {
  font-weight: 800;
}

.tp-brand-sub {
  font-size: 13px;
  color: var(--muted);
}

.tp-tracks {
  display: inline-flex;
  padding: 4px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tp-track-btn {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
}

.tp-track-btn.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

/* ------------------------------------------------------------ layout */

.tp-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.tp-player,
.tp-playlist {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.tp-player {
  padding: 18px;
  min-width: 0;
}

.tp-pill-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tp-pill-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}

.tp-pill-title {
  margin: 2px 0 0;
  font-size: 22px;
}

.tp-pill-time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* ------------------------------------------------------------ stage */

.tp-stage {
  position: relative;
  background: var(--stage);
  border-radius: 12px;
  overflow: hidden;
  height: min(68vh, 720px);
  display: grid;
  place-items: center;
  padding: 14px;
}

.tp-screen {
  position: relative;
  height: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tp-screen.mobile {
  padding: 12px 6px;
  background: #1f2937;
  border-radius: 34px;
  box-shadow: 0 0 0 2px #374151, 0 20px 40px rgba(0, 0, 0, 0.45);
}

.tp-frame {
  position: relative;
  max-height: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: 6px;
  transform-origin: 50% 50%;
  transition: transform 7s ease-out;
}

.tp-screen.mobile .tp-frame {
  border-radius: 24px;
}

.tp-frame.zoom {
  transform: scale(1.045);
}

.tp-frame img {
  display: block;
  max-height: calc(min(68vh, 720px) - 28px);
  max-width: 100%;
  height: auto;
  width: auto;
  user-select: none;
}

.tp-screen.mobile .tp-frame img {
  max-height: calc(min(68vh, 720px) - 52px);
}

.tp-frame.fade img {
  animation: tp-fade 0.45s ease;
}

@keyframes tp-fade {
  from {
    opacity: 0.25;
  }
  to {
    opacity: 1;
  }
}

.tp-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tp-spot {
  position: absolute;
  border: 3px solid var(--spot);
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.5s ease 0.4s;
}

.tp-spot.dim {
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.42);
}

.tp-spot.show {
  opacity: 1;
  animation: tp-pulse 1.6s ease-in-out 0.9s 2;
}

@keyframes tp-pulse {
  50% {
    border-color: #fde68a;
    transform: scale(1.012);
  }
}

.tp-cursor {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -2px 0 0 -3px;
  transition: left 1.6s cubic-bezier(0.45, 0, 0.2, 1), top 1.6s cubic-bezier(0.45, 0, 0.2, 1);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
  z-index: 3;
}

.tp-cursor.slow {
  transition-duration: 2.6s;
}

.tp-cursor svg {
  width: 100%;
  height: 100%;
}

.tp-ghost {
  position: absolute;
  left: 18px;
  top: 20px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
  opacity: 0.92;
}

.tp-ripple {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  animation: tp-ripple 0.7s ease-out forwards;
  z-index: 2;
}

@keyframes tp-ripple {
  from {
    transform: scale(0.3);
    opacity: 1;
  }
  to {
    transform: scale(1.8);
    opacity: 0;
  }
}

.tp-bigplay {
  position: absolute;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 0;
  background: rgba(79, 70, 229, 0.92);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.tp-bigplay svg {
  width: 40px;
  height: 40px;
  fill: currentColor;
  margin-left: 4px;
}

/* ------------------------------------------------------------ fine pillola */

.tp-endcard {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(3px);
  color: #fff;
  text-align: center;
  padding: 24px;
  z-index: 5;
}

.tp-endcard-box {
  max-width: 460px;
}

.tp-endcard h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.tp-endcard p {
  margin: 0 0 18px;
  color: #cbd5e1;
}

.tp-endcard-next {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.tp-endcard-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.tp-countdown {
  display: block;
  height: 4px;
  margin: 0 auto 18px;
  width: 220px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.tp-countdown span {
  display: block;
  height: 100%;
  background: #a5b4fc;
  animation: tp-count linear forwards;
}

@keyframes tp-count {
  from {
    width: 100%;
  }
  to {
    width: 0;
  }
}

/* ------------------------------------------------------------ didascalia e controlli */

.tp-caption {
  min-height: 3.2em;
  margin: 14px 2px 10px;
  font-size: 18px;
  line-height: 1.5;
}

.tp-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.tp-seg {
  flex: 1;
  height: 8px;
  border: 0;
  padding: 0;
  border-radius: 4px;
  background: #e5e7eb;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.tp-seg span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--primary);
}

.tp-seg.done span {
  width: 100%;
}

.tp-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tp-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tp-btn:hover {
  border-color: #a5b4fc;
  background: var(--primary-soft);
}

.tp-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.tp-btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  min-width: 52px;
}

.tp-btn-primary:hover {
  background: var(--primary-dark);
}

.tp-endcard .tp-btn {
  height: 42px;
}

.tp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

/* ------------------------------------------------------------ playlist */

.tp-playlist {
  padding: 18px;
  align-self: start;
  position: sticky;
  top: 20px;
}

.tp-playlist-head h2 {
  margin: 0;
  font-size: 18px;
}

.tp-playlist-head p {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.tp-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tp-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.tp-item:hover {
  background: var(--primary-soft);
}

.tp-item.active {
  background: var(--primary-soft);
  border-color: #c7d2fe;
}

.tp-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.tp-item.active .tp-num {
  background: var(--primary);
  color: #fff;
}

.tp-item.seen .tp-num {
  background: #dcfce7;
  color: var(--success);
}

.tp-item-title {
  font-weight: 700;
  font-size: 14px;
}

.tp-item-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.tp-item-dur {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tp-hint {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

kbd {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #f9fafb;
  font-family: inherit;
  font-size: 11px;
}

/* ------------------------------------------------------------ schermo intero e mobile */

.tp-player:fullscreen {
  border-radius: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
}

.tp-player:fullscreen .tp-stage {
  flex: 1;
  height: auto;
}

.tp-player:fullscreen .tp-frame img {
  max-height: calc(100vh - 260px);
}

@media (max-width: 1000px) {
  .tp-main {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .tp-playlist {
    position: static;
  }

  .tp-header {
    padding: 12px 16px;
  }

  .tp-stage {
    height: auto;
    min-height: 220px;
    padding: 8px;
  }

  .tp-frame img,
  .tp-screen.mobile .tp-frame img {
    max-height: 70vh;
  }

  .tp-caption {
    font-size: 16px;
  }

  .tp-pill-title {
    font-size: 18px;
  }

  .tp-bigplay {
    width: 60px;
    height: 60px;
  }

  .tp-bigplay svg {
    width: 28px;
    height: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tp-frame,
  .tp-cursor,
  .tp-spot {
    transition: none;
  }

  .tp-frame.zoom {
    transform: none;
  }
}
