:root {
  --bg: #12101d;
  --bg-card: #1d1a2e;
  --bg-soft: #262238;
  --fg: #f2eefb;
  --muted: #9a93b5;
  --accent: #a06bff;
  --accent-2: #ff5f9e;
  --ok: #37d99a;
  --danger: #ff5470;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 50% -10%, #2b1c4d 0%, var(--bg) 60%);
  color: var(--fg);
  min-height: 100vh;
}

a { color: var(--accent); }
h1, h2 { margin: 0 0 0.4rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.error { color: var(--danger); }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }

/* ------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: filter 0.15s, transform 0.05s;
  background: var(--bg-soft);
  color: var(--fg);
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid #3d3757; color: var(--fg); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn:disabled { opacity: 0.35; cursor: default; }

input[type="text"], input[type="password"] {
  font: inherit;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #3d3757;
  background: var(--bg-soft);
  color: var(--fg);
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { display: block; font-size: 0.85rem; color: var(--muted); }
label input { margin-top: 0.3rem; }

/* ------------------------------------------------------------- home */

.home {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.home-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.home-card .logo { font-size: 3rem; margin-bottom: 0.5rem; }
.home-card p { line-height: 1.5; }

/* ------------------------------------------------------------- game */

.game {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.game-header { text-align: center; }
.theme-label {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.7rem;
  color: var(--accent-2);
}
.theme-name { font-size: 2rem; }
.theme-desc { color: var(--muted); margin: 0.2rem 0 0; }

.song-dots { display: flex; justify-content: center; gap: 0.45rem; }
.dot {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid #3d3757;
  background: var(--bg-soft);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.dot.current { border-color: var(--accent); color: var(--fg); box-shadow: 0 0 0 3px rgba(160, 107, 255, 0.25); }
.dot.done { background: var(--ok); border-color: var(--ok); color: #0b2b1f; }

.player-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.song-counter { font-size: 1.25rem; font-weight: 600; }
.song-counter .of { color: var(--muted); font-weight: 400; }

.disc {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at center, #211d33 0 4px, #191529 4px 8px);
  border: 4px solid #322c4d;
  display: grid;
  place-items: center;
}
.disc-center {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.disc.spinning { animation: spin 2.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.play-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(160, 107, 255, 0.45);
}
.play-btn:active { transform: scale(0.95); }
.play-btn svg[hidden] { display: none; }

.progress { width: 100%; }
.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s linear;
}
.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}
.status-line { margin: 0; color: var(--muted); font-size: 0.9rem; text-align: center; }

.hints, .answer {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.hints h2, .answer h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}
.hints ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.hints li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  color: var(--muted);
  opacity: 0.55;
}
.hints li.revealed { color: var(--fg); opacity: 1; }
.hint-time-tag {
  flex: 0 0 auto;
  font-size: 0.75rem;
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  color: var(--accent);
}
.answer { border: 1px solid var(--ok); }
.answer p { margin: 0; font-size: 1.2rem; font-weight: 600; }

.game-nav { display: flex; justify-content: space-between; gap: 0.5rem; }

/* Keep the YouTube iframe technically visible (mobile browsers refuse to
   play display:none video) but out of sight. */
#yt-holder {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  overflow: hidden;
  pointer-events: none;
}
#yt-holder.visible {
  left: 50%;
  right: auto;
  bottom: 1rem;
  transform: translateX(-50%);
  width: min(92vw, 360px);
  height: auto;
  aspect-ratio: 16 / 9;
  opacity: 1;
  pointer-events: auto;
  z-index: 50;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
#yt-holder iframe { width: 100%; height: 100%; border-radius: inherit; }

.video-toggle {
  font: inherit;
  font-size: 0.8rem;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.video-toggle:hover { color: var(--fg); }

/* ------------------------------------------------------------- admin */

.admin {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.admin-header h1 { font-size: 1.4rem; }
.admin-header a { text-decoration: none; color: inherit; }

.cookies-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
}
.cookies-box summary {
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cookies-box p { margin: 0.75rem 0 0; }
.cookies-box form { margin-top: 0.9rem; }
.cookies-box textarea {
  font: inherit;
  font-family: monospace;
  font-size: 0.8rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #3d3757;
  background: var(--bg-soft);
  color: var(--fg);
  resize: vertical;
}
.cookies-box input[type="file"] { color: var(--muted); }
.success { color: var(--ok); }

.new-theme {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius);
}
.new-theme input { flex: 1 1 200px; }

.theme-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.theme-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.theme-item-main { display: flex; flex-direction: column; gap: 0.15rem; }
.theme-item-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.theme-meta, .song-editor {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.song-form { display: flex; flex-direction: column; gap: 0.9rem; }
.song-form .row label { flex: 1 1 140px; }
.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid #3d3757;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  color: var(--muted);
  vertical-align: middle;
}
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.busy { border-color: var(--accent); color: var(--accent); }
.tag.err { border-color: var(--danger); color: var(--danger); }
.inline-form { display: inline-block; margin-left: 0.5rem; }
.btn-small { padding: 0.25rem 0.7rem; font-size: 0.8rem; }
.song-editor h2 { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.hints-editor {
  border: 1px solid #3d3757;
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.hints-editor legend { padding: 0 0.4rem; font-size: 0.85rem; color: var(--muted); }
.hint-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.hint-row { display: flex; gap: 0.5rem; }
.hint-row .hint-time { flex: 0 0 4.5rem; }
.hint-row .hint-text { flex: 1; }
.add-hint { align-self: flex-start; }

/* ------------------------------------------------------------- card / print */

.card-preview {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}
.toolbar { display: flex; gap: 0.6rem; align-self: stretch; justify-content: space-between; }

.theme-card {
  background: #fff;
  color: #171227;
  border-radius: 18px;
  padding: 14px;
  width: 320px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.theme-card-inner {
  border: 3px solid #171227;
  border-radius: 12px;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}
.theme-card-label { font-size: 0.7rem; letter-spacing: 0.3em; color: #a06bff; font-weight: 700; }
.theme-card-inner h1 { font-size: 1.9rem; }
.theme-card-inner p { margin: 0; color: #5c5470; font-size: 0.9rem; }
.theme-card-inner img { width: 200px; height: 200px; image-rendering: pixelated; }
.theme-card-hint { font-size: 0.75rem; color: #5c5470; letter-spacing: 0.1em; text-transform: uppercase; }

@media print {
  body { background: #fff; }
  .print-hide { display: none !important; }
  .theme-card { box-shadow: none; }
}
