:root {
  --ink: #0a0a0a;
  --paper: #fafafa;
  --muted: #8a8a8a;
  --line: #e4e4e4;
  --accent: #0a0a0a;
  --radius: 14px;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Make the [hidden] attribute always win over element display rules (e.g. .combo-won,
   .combo-body use display:flex, which would otherwise override hidden and leak stale
   winner names/inputs into the next round's cards). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 32px 0;
  animation: fade 0.25s ease;
}
.screen.active { display: flex; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Brand ---------- */
.brand { text-align: center; margin-bottom: 24px; }
.wordmark-img {
  display: block;
  width: 300px;
  max-width: 82%;
  height: auto;
  margin: 0 auto 4px;
  /* logo art is near-white line work on transparent; invert to ink for the light UI */
  filter: invert(1);
}
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}
.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 92px; height: 92px;
  background: var(--ink);
  color: #fff;
  border-radius: 22px;
  font-family: var(--serif);
  font-size: 60px;
  line-height: 1;
  font-style: italic;
  margin-bottom: 20px;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 44px;
  letter-spacing: -0.02em;
  margin: 0;
}
.tagline { color: var(--muted); font-size: 16px; margin: 8px 0 0; }

.home-actions { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  width: 100%;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn:disabled { opacity: 0.4; cursor: default; }
.small-btn { font-size: 14px; padding: 12px; margin-top: 4px; }

/* Persistent footer that sits at the bottom of every screen */
.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 calc(env(safe-area-inset-bottom) + 16px);
}

/* Host-only end-game control */
.end-game-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 99px;
  cursor: pointer;
}
.end-game-btn:active { transform: scale(0.97); }

/* Subtle black-and-white "Listen To My Music" link — thin outline pill */
.music-link {
  display: inline-block;
  text-decoration: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.music-link:hover { color: var(--ink); border-color: var(--ink); }
.music-link:active { transform: scale(0.97); }

.back {
  align-self: flex-start;
  background: none; border: none;
  color: var(--muted);
  font-size: 16px;
  padding: 0;
  cursor: pointer;
  position: absolute;
  top: 28px;
}
.screen-title { font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0; }
.kicker { text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--muted); margin: 0; }
.muted { color: var(--muted); font-size: 15px; }
.error { color: #c0392b; font-size: 14px; min-height: 18px; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 14px; color: var(--muted); }
input[type="text"], input[type="tel"] {
  appearance: none;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 18px;
  font-family: var(--sans);
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus { outline: none; border-color: var(--ink); }
input.input-error, input.input-error:focus { border-color: #c0392b; }
.code-input { font-size: 32px; letter-spacing: 0.4em; text-align: center; font-family: var(--serif); }

.count-picker { display: flex; gap: 8px; }
.count {
  flex: 1;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 14px 0;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}
.count.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Lobby ---------- */
.big-code {
  font-family: var(--serif);
  font-size: 72px;
  letter-spacing: 0.12em;
  text-align: center;
  margin: 4px 0;
}
.players { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.players li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 17px;
  background: #fff;
}
.players li .badge { font-size: 12px; color: var(--muted); }
.players li.disconnected { opacity: 0.45; }
.players li .host-tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }

/* ---------- Choosing ---------- */
.letter-input {
  font-family: var(--serif);
  font-size: 96px;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
  width: 100%;
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  margin: 0 auto 8px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Countdown / reveal ---------- */
#screen-countdown { align-items: center; }
.reveal-letters {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-family: var(--serif);
}
.reveal-letters span {
  font-size: 120px;
  line-height: 1;
}
.reveal-letters.small span { font-size: 64px; }
.countdown-num {
  font-family: var(--serif);
  font-size: 140px;
  line-height: 1;
  animation: pop 1s ease infinite;
}
@keyframes pop { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: 0.7; } }

/* ---------- Playing ---------- */
.combos { display: flex; flex-direction: column; gap: 16px; }
.combo {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #fff;
}
.combo-key {
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.combo-body { display: flex; gap: 8px; }
/* `display:flex` above overrides the [hidden] attribute, so hiding needs this explicit rule.
   Without it, the input/Enter row stays visible on won AND skipped combos. */
.combo-body[hidden] { display: none; }
.combo-input { flex: 1; }
.btn-go {
  width: auto;
  padding: 0 22px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  border: none;
  font-size: 16px;
}
.combo.pending { opacity: 0.7; }

/* Pass control — small, sits under the input inside the card */
.combo-pass {
  display: block;
  margin: 10px auto 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.combo-pass.passed { color: var(--ink); font-weight: 600; text-decoration: none; }
.combo-pass:disabled { cursor: default; }
/* When skipped, the Pass control becomes the "SKIPPED" status label in the same spot */
.combo-pass.skipped-label {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

/* Skipped combo — grayed out and out of the round */
.combo.skipped-combo { opacity: 0.55; background: #f4f4f4; }
.combo-won {
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.combo-won .plus { color: var(--muted); font-family: var(--serif); }
.combo-won .who-name { font-family: var(--serif); }
.combo-won .answer { font-size: 14px; color: var(--muted); font-weight: 400; }
.sweep-tag {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-top: 6px;
}
.combo-msg { font-size: 13px; color: #c0392b; min-height: 16px; margin: 8px 0 0; }
.combo-msg.checking { color: var(--muted); }
.notice { text-align: center; color: var(--muted); font-size: 14px; min-height: 18px; }

/* ---------- Results ---------- */
.result-rows { display: flex; flex-direction: column; gap: 10px; }
.result-row {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
}
.result-row .rk { font-family: var(--serif); font-size: 22px; }
.result-row .rwho { font-weight: 600; }
.result-row .rname { color: var(--muted); font-size: 14px; }
.result-row.unclaimed { opacity: 0.55; }
.scoreboard { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 6px; }
.scoreboard li {
  display: flex; justify-content: space-between;
  padding: 10px 14px;
  font-size: 16px;
}
.scoreboard li .pts { font-family: var(--serif); font-weight: 600; }
.scoreboard li.leader { background: var(--ink); color: #fff; border-radius: 10px; }
