:root {
  color-scheme: dark;
  --bg: #07111f;
  --tv-bg: #050814;
  --panel: rgba(10, 18, 36, 0.88);
  --tv-panel: rgba(7, 12, 24, 0.8);
  --text: #f4f7ff;
  --muted: #a5b4d6;
  --accent: #38bdf8;
  --accent-strong: #22c55e;
  --danger: #fb7185;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.2), transparent 28%),
    radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.14), transparent 24%),
    linear-gradient(160deg, var(--bg), #0b1224);
}

body.tv-page {
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.2), transparent 28%),
    radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.14), transparent 24%),
    linear-gradient(160deg, var(--tv-bg), #0b1224);
}

.main-layout {
  display: flex;
  gap: 24px;
  align-items: stretch;
  justify-content: center;
}

.tv-stage {
  flex: 1;
}

.spotify {
  flex: 0 0 380px;
}

@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
  }

  .spotify {
    flex: 1;
    width: 100%;
  }
}

.shell,
.tv-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel,
.tv-stage {
  width: min(100%, 720px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  position: relative;
  overflow: hidden;
}

.tv-stage {
  width: min(100%, 1100px);
  min-height: 72vh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  background: var(--tv-panel);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.76rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
}

.tv-stage h1 {
  font-size: clamp(2.8rem, 7vw, 5rem);
}

.lead {
  margin: 10px 0 24px;
  color: var(--muted);
}

.counter-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 20px;
}

.counter-display {
  display: grid;
  gap: 14px;
  margin-top: 24px;
  padding: 30px 42px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.03);
}

.counter-box span,
.counter-display span,
.tv-note,
.message,
label {
  color: var(--muted);
}

.counter-label {
  font-size: clamp(1.6875rem, 7.875vw, 3.375rem);
  line-height: 1;
  font-weight: 700;
}

.counter-display span {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.counter-box strong {
  font-size: clamp(3rem, 14vw, 6rem);
  line-height: 1;
}

.counter-display strong {
  font-size: clamp(5rem, 20vw, 10rem);
  line-height: 0.92;
}

.tv-note {
  margin: 18px 0 0;
  max-width: 38rem;
}

.primary-action,
.actions button {
  appearance: none;
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.primary-action {
  width: 100%;
  margin-bottom: 16px;
  font-size: 1.15rem;
  background: var(--accent);
  color: #07111f;
}

.quick-increments {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.quick-increments button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 0;
  font-weight: 800;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.quick-custom {
  margin-bottom: 16px;
}

.quick-custom-row {
  display: grid;
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.quick-custom-row .primary-action {
  margin: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.actions button {
  flex: 1 1 120px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.actions button[data-action="set"] {
  background: var(--accent-strong);
  color: #06110b;
}

.actions button[data-action="decrement"] {
  background: var(--danger);
  color: #20060d;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

details.advanced {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.03);
}

summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1rem;
}

.message {
  min-height: 1.4em;
  margin: 18px 0 0;
}

.message[data-state="error"] {
  color: var(--danger);
}


@keyframes counterBounce {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.12);
  }
  60% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

.confirm-dialog {
  width: min(92vw, 420px);

  padding: 32px;

  border: 1px solid var(--border);
  border-radius: 28px;

  background: var(--panel);

  color: var(--text);

  backdrop-filter: blur(14px);

  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);

  overflow: hidden;
}

.confirm-dialog::backdrop {
  background:
    radial-gradient(circle, rgba(56, 189, 248, 0.12), transparent),
    rgba(5, 8, 20, 0.72);

  backdrop-filter: blur(6px);
}

.confirm-dialog h3 {
  margin: 0 0 16px;

  font-size: 1.35rem;

  color: var(--text);
}

.confirm-dialog p {
  margin: 0 0 28px;

  color: var(--muted);

  line-height: 1.6;
}

.dialog-actions {
  display: flex;

  gap: 12px;
}

.dialog-actions button {
  flex: 1;

  appearance: none;
  -webkit-appearance: none;

  border: 0;

  border-radius: 18px;

  padding: 14px 18px;

  height: 52px;
  min-height: 52px;
  max-height: 52px;

  box-sizing: border-box;

  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  transition: transform 0.15s ease, filter 0.15s ease;
}

.dialog-actions button[value="cancel"] {
  background: var(--danger);
  color: #20060d;

  border: none;
}

.dialog-actions button[value="confirm"] {
  background: var(--accent-strong);
  color: #06110b;

  border: none;
}

.dialog-actions button:hover {
  transform: translateY(-1px);

  filter: brightness(1.05);
}

@media (max-width: 640px) {
  .panel,
  .tv-stage {
    padding: 24px;
  }

  .tv-shell {
    padding: 16px;
  }

  .tv-stage {
    min-height: 80vh;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .counter-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .quick-increments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-custom-row {
    grid-template-columns: 1fr;
  }

  .confirm-dialog {
    padding: 24px;
  }

  .dialog-actions {
    flex-direction: column;
  }
}

/* =========================
   SPOTIFY PLAYER CONTAINER
========================= */

.spotify {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 30px;
}

#player {
  width: 360px;
  background: rgba(18, 18, 18, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 18px;
  padding: 20px;
  color: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#player {
	position: relative;
	overflow: hidden;
}

#player::before,
#player::after {
	content: "";
	position: absolute;
	inset: -50px;
	filter: blur(140px);
	transition: opacity 1.5s ease, background 1.5s ease;
	z-index: 0;
}

#player::before {
	background: var(--bg-current, #121212);
	opacity: 1;
}

#player::after {
	background: var(--bg-next, #121212);
	opacity: 0;
}

#player.fade::after {
	opacity: .35;
}

#player.fade::before {
	opacity: 0;
}

#player>* {
	position: relative;
	z-index: 1;
}

/* =========================
   PLAYLIST INFO
========================= */

#playlist-name {
  font-size: 12px;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* =========================
   COVER IMAGE
========================= */

#cover {
  width: 100%;
  height: 240px;
  object-fit: contain;
  background: transparent;
  border-radius: 14px;
}

/* =========================
   TEXT INFO
========================= */

#title {
  font-size: 20px;
  font-weight: 700;
  margin-top: 8px;
}

#artist {
  font-size: 14px;
  opacity: 0.7;
  margin-bottom: 12px;
}

#title,
#artist {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

/* =========================
   PROGRESS BAR
========================= */

#progress-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  margin: 10px 0 5px;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1db954, #1ed760);
  border-radius: 10px;
  transition: width 0.2s linear;
}

/* =========================
   TIME
========================= */

#time {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 15px;
  align-self: stretch;
}

#time span {
  flex: 0 0 auto;
}

/* =========================
   CONTROLS
========================= */

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

#player button {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: white;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  margin: 0;
  cursor: pointer;
  transition: 0.2s ease;
  font-size: 16px;
}

#player button:hover {
  background: rgba(29, 185, 84, 0.25);
  transform: scale(1.05);
}

#play {
  width: 55px;
  height: 55px;
  font-size: 18px;
  background: rgba(29, 185, 84, 0.2);
  border: 1px solid rgba(29, 185, 84, 0.4);
}

#play:hover {
  background: rgba(29, 185, 84, 0.35);
}
