/* Clean dark theme, inspired by Wordle. */
:root {
  --bg: #121213;
  --surface: #1a1a1b;
  --surface-2: #262628;
  --border: #3a3a3c;
  --border-strong: #565758;
  --key: #818384;
  --text: #ffffff;
  --text-soft: #d7dadc;
  --muted: #818384;
  --correct: #538d4e;
  --artist: #b59f3b;
  --wrong: #a6403d;
  --skip: #3a3a3c;
  --radius: 4px;
  --maxw: 500px;
  --font: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-display: "Suez One", "Heebo", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--text-soft); }
/* keyboard focus: a soft white ring instead of the browser's blue box; none for mouse/touch */
:focus-visible { outline: 2px solid var(--text-soft); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.modal-body:focus { outline: none; }
button:disabled { cursor: not-allowed; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- header ---------- */
.topbar { border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 56px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
}
.topbar-side { display: flex; gap: 2px; }
.topbar-side.end { justify-content: flex-end; }
.logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.15rem, 5.4vw, 2rem);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}
/* the colorful $#*% in the title, drawn like the site icon */
.grawlix {
  display: inline-block;
  unicode-bidi: isolate;
  font-family: 'Bangers', var(--font-display);
  font-size: 1.15em;
  letter-spacing: .03em;
  line-height: 1;
  margin-inline: .04em;
  transform: rotate(-8deg) translateY(-.03em);
  text-shadow: .045em .045em 0 #000;
}
.grawlix i { font-style: normal; }
.grawlix .g1 { color: #6aaa64; }
.grawlix .g2 { color: #c9b458; }
.grawlix .g3 { color: #e0605c; }
.grawlix .g4 { color: #ffffff; }
.icon-btn {
  width: 40px; height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-soft);
  display: grid; place-items: center;
}
.icon-btn:hover { color: var(--text); background: var(--surface); }
#btn-sound .ic-off { display: none; }
#btn-sound[aria-pressed="false"] .ic-on { display: none; }
#btn-sound[aria-pressed="false"] .ic-off { display: block; }
#btn-sound[aria-pressed="false"] { color: var(--muted); }

.app {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 16px env(safe-area-inset-bottom);
}

/* ---------- genre tabs ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 6px 0 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  position: relative;
  padding: 12px 2px 10px;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 700;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text-soft); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.tab .dot {
  display: inline-block;
  width: 7px; height: 7px;
  margin-inline-end: 5px;
  border-radius: 50%;
  vertical-align: middle;
  position: relative; top: -1px;
}
.tab .dot.won { background: var(--correct); }
.tab .dot.lost { background: var(--wrong); }

/* ---------- board ---------- */
.board { flex: 1; padding: 6px 0 12px; }
.game-meta {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .3px;
  margin: 10px 0 12px;
}
.attempts {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 6px;
}
.attempt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  font-weight: 700;
  font-size: .97rem;
}
.attempt.current { border-color: var(--border-strong); }
.attempt .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attempt .txt small { font-weight: 400; opacity: .85; }
.attempt .badge { font-size: .75rem; font-weight: 500; white-space: nowrap; opacity: .9; }
.attempt.empty .badge, .attempt.empty .txt { color: var(--muted); font-weight: 500; }
.attempt.current .badge, .attempt.current .txt { color: var(--muted); }
.attempt.wrong   { background: var(--wrong);   border-color: var(--wrong); }
.attempt.artist  { background: var(--artist);  border-color: var(--artist); }
.attempt.correct { background: var(--correct); border-color: var(--correct); }
.attempt.skip    { background: var(--skip);    border-color: var(--skip); color: var(--text-soft); }
.attempt.reveal  { animation: flip .45s ease-out; }
@keyframes flip {
  0%   { transform: rotateX(-90deg); }
  100% { transform: rotateX(0); }
}
.shake { animation: shake .4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* ---------- result ---------- */
/* notice card in the board (e.g. a genre with no songs yet) */
.result {
  margin-top: 18px;
  padding: 20px 16px;
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}
.result h2 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* result dialog: covers most of the screen */
.modal.modal-result {
  width: min(94vw, 480px);
  height: min(90dvh, 780px);
  max-height: none;
}
.modal-result .modal-body {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  padding-top: 34px;
}
.result-view { text-align: center; }
.result-view h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.9rem; }
.result-view .song-name { font-size: 1.5rem; font-weight: 800; margin: 18px 0 2px; }
.result-view .song-artist { color: var(--text-soft); font-size: 1.05rem; margin-bottom: 14px; }
.result-view .btn-replay { height: 40px; padding: 0 18px; border-radius: 999px; background: var(--surface-2); font-size: .9rem; }
.result-view .squares { display: flex; gap: 6px; justify-content: center; margin: 20px 0 18px; }
.result-view .squares i { width: 26px; height: 26px; border-radius: 3px; background: var(--border); }
.result-view .squares i.correct { background: var(--correct); }
.result-view .squares i.artist { background: var(--artist); }
.result-view .squares i.wrong { background: var(--wrong); }
.result-view .squares i.skip { background: var(--key); }
.result-view .btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.result-view .btns .btn { min-width: 140px; }
.done-row .btn { width: 100%; }
.section-title {
  margin: 26px 0 8px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text-soft);
}
.countdown { color: var(--muted); font-size: .85rem; margin-top: 20px; }
.countdown b { display: block; color: var(--text); font-size: 1.8rem; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 1px; }

.dist { display: grid; gap: 4px; text-align: start; }
.dist-row { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 6px; font-size: .8rem; }
.dist-row .lbl { color: var(--text-soft); direction: ltr; text-align: end; }
.dist-bar {
  display: inline-block;
  min-width: 22px;
  padding: 2px 7px;
  background: var(--border);
  font-weight: 700;
  text-align: end;
}
.dist-bar.hl { background: var(--correct); }
.dist-bar.hl.lost { background: var(--wrong); }

/* ---------- controls (bottom) ---------- */
.controls {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to bottom, transparent, var(--bg) 16px);
  padding: 20px 0 14px;
}
.timeline {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.timeline-unlocked, .timeline-progress {
  position: absolute; inset: 0 0 0 auto;
  width: 0;
}
.timeline-unlocked { background: var(--border-strong); transition: width .35s ease; }
.timeline-progress { background: var(--text); }
.timeline-marks { position: absolute; inset: 0; }
.timeline-marks i {
  position: absolute; top: 0; bottom: 0;
  width: 2px; margin-right: -1px;
  background: var(--bg);
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin: 12px 0;
}
.time-label { font-weight: 700; font-size: .95rem; text-align: center; }
.time-label.muted { font-weight: 500; }
.play-btn {
  position: relative;
  width: 62px; height: 62px;
  border-radius: 50%;
  border: none;
  background: var(--text);
  color: var(--bg);
  display: grid; place-items: center;
  transition: transform .1s ease, background .15s;
}
.play-btn:hover { background: var(--text-soft); }
.play-btn:active { transform: scale(.93); }
.play-btn .ic-play { margin-left: 3px; }
.play-btn .ic-stop, .play-btn .spinner { display: none; }
.play-btn.playing .ic-play { display: none; }
.play-btn.playing .ic-stop { display: block; }
.play-btn.loading .ic-play { display: none; }
.play-btn.loading .spinner { display: block; }
.spinner {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,.2);
  border-top-color: var(--bg);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.search-wrap { position: relative; }
#guess-input {
  width: 100%;
  height: 50px;
  padding: 0 14px 0 42px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  font-weight: 500;
  outline: none;
  transition: border-color .15s;
}
#guess-input::placeholder { color: var(--muted); font-weight: 400; }
#guess-input:focus { border-color: var(--border-strong); }
#guess-input.picked { border-color: var(--correct); }
.clear-btn {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  border: none; border-radius: 50%;
  background: var(--border);
  font-size: 1.05rem;
  line-height: 1;
}

.suggestions {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 -8px 28px rgba(0,0,0,.5);
  z-index: 10;
}
.suggestions li {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.25;
  user-select: none;
  -webkit-user-select: none;
}
.suggestions li + li[role=option] { margin-top: 1px; }
.suggestions li .t { font-weight: 700; }
.suggestions li .a { color: var(--muted); font-size: .85rem; margin-top: 1px; }
.suggestions li[aria-selected="true"] { background: var(--surface-2); }
.suggestions li:active { background: var(--border); }
@media (hover: hover) {
  .suggestions li[role=option]:hover { background: var(--surface-2); }
}
.suggestions .note { color: var(--muted); font-size: .85rem; cursor: default; }

.action-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  margin-top: 8px;
}
.btn {
  height: 50px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--key);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  transition: filter .15s, background .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { filter: brightness(.92); }
.btn-primary { background: var(--correct); }
.btn-primary:disabled { background: var(--surface-2); color: var(--muted); }
.btn-danger { background: transparent; box-shadow: inset 0 0 0 2px var(--wrong); color: #f08b88; }
.btn.wide { width: 100%; margin-top: 16px; }
#btn-skip { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
#btn-skip small { font-weight: 500; font-size: .72rem; opacity: .85; }

/* ---------- modals ---------- */
.modal {
  width: min(92vw, 420px);
  max-height: 88dvh;
  padding: 0;
  border: 1px solid var(--surface);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 4px 23px rgba(0,0,0,.4);
}
.modal[open] { animation: rise .25s ease-out; }
.modal::backdrop { background: rgba(0,0,0,.55); }
.modal-body { position: relative; padding: 26px 22px 22px; }
.modal h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.6rem;
  text-align: center;
}
.modal .lead { margin: 0 0 12px; font-weight: 500; }
.modal-close {
  position: absolute; top: 12px; left: 12px;
  width: 32px; height: 32px;
  border: none; background: none;
  color: var(--text-soft);
  font-size: 1.6rem; line-height: 1;
}
.help-list { padding-inline-start: 20px; margin: 0 0 16px; display: grid; gap: 8px; line-height: 1.45; }
.legend {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 14px 0; margin-bottom: 12px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.legend div { display: flex; align-items: center; gap: 8px; }
.sq { width: 20px; height: 20px; border-radius: 3px; display: inline-block; flex: none; }
.sq-correct { background: var(--correct); }
.sq-artist  { background: var(--artist); }
.sq-wrong   { background: var(--wrong); }
.sq-skip    { background: var(--key); }

.stats-tabs { display: flex; gap: 5px; justify-content: center; margin-bottom: 18px; }
.stats-tabs button {
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: none;
  font-size: .8rem; font-weight: 500; color: var(--text-soft);
  white-space: nowrap;
}
.stats-tabs button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.stat-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; }
.stat-nums b { display: block; font-size: 2.1rem; font-weight: 400; line-height: 1.1; }
.stat-nums span { color: var(--text-soft); font-size: .72rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 70px; left: 50%;
  transform: translate(-50%, -10px);
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer, legal links, first-visit notice ---------- */
.site-footer { text-align: center; font-size: .78rem; color: var(--muted); padding: 4px 0 18px; }
.site-footer a, .legal-links a { color: var(--muted); }
.legal-links { text-align: center; font-size: .8rem; color: var(--muted); margin-top: 14px; }
.notice {
  position: fixed;
  inset: auto 12px calc(12px + env(safe-area-inset-bottom)) 12px;
  max-width: 476px;
  margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  font-size: .85rem;
  line-height: 1.45;
  z-index: 50;
}
.notice p { margin: 0; flex: 1; }
.notice .btn { height: 40px; flex: none; }

/* everyone's results (result dialog) */
.global-box { margin-top: 4px; }
.global-box .muted { font-size: .8rem; }
.dist-bar .pct { font-weight: 400; opacity: .8; margin-inline-start: 4px; }

@media (min-width: 700px) {
  .topbar-inner { height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- legal pages ---------- */
a.logo { color: var(--text); text-decoration: none; }
a.icon-btn { text-decoration: none; font-size: 1.3rem; }
.doc { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 8px 18px 30px; line-height: 1.7; }
.doc h1 { font-family: var(--font-display); font-weight: 400; font-size: 2rem; margin: 18px 0 4px; }
.doc h2 { font-size: 1.15rem; margin: 26px 0 6px; }
.doc ul { padding-inline-start: 22px; }
.doc li { margin: 4px 0; }
.doc a { color: var(--text); }
.doc-box { margin-top: 30px; padding: 16px; border-radius: 8px; background: var(--surface); }
.doc-box h2 { margin-top: 0; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-actions .btn { height: 44px; }
.btn.armed { background: var(--wrong); color: #fff; box-shadow: none; }
