/* Wrongly: mobile-first, big touch targets, readable from across a living room. */

:root {
  --bg: #1d1240;
  --bg-glow: #33206e;
  --surface: #2c1d5e;
  --surface-2: #3a2878;
  --line: rgb(255 255 255 / 0.12);
  --text: #fff8ec;
  --muted: #c3b6ec;
  --accent: #ffd23f;
  --accent-shadow: #c99a00;
  --accent-ink: #241047;
  --near: #34d399;
  --wild: #38bdf8;
  --frozen: #a5b4c8;
  --oops: #fb5172;
  --result-ink: #10091f;
  --radius: 18px;
  --font: 'Fredoka', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(120% 60% at 50% 0%, var(--bg-glow), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  container-type: inline-size; /* big type scales with this column (cqi), not the window */
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.loading,
.error {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.small {
  color: var(--muted);
  font-size: 15px;
}

/* --- Logo and hero -------------------------------------------------------- */

.logo {
  margin: 0;
  color: var(--accent);
  font-size: clamp(64px, 20cqi, 104px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  transform: rotate(-4deg);
  text-shadow: 0 6px 0 rgb(0 0 0 / 0.3);
}

.hero {
  padding: 24px 0 8px;
  text-align: center;
}

.tagline {
  margin: 20px 0 0;
  font-size: 20px;
  color: var(--muted);
}

.tagline em {
  color: var(--oops);
  font-style: normal;
  font-weight: 700;
}

/* --- Buttons --------------------------------------------------------------- */

.btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: 0;
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 600;
  transition: transform 0.08s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary,
.btn--go {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 0 var(--accent-shadow);
}

.btn--secondary {
  background: var(--surface-2);
}

.btn--huge {
  padding: 22px;
  font-size: 26px;
}

.btn--go {
  padding: 28px;
  border-radius: 28px;
  font-size: clamp(56px, 18cqi, 80px);
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 0 var(--accent-shadow);
}

.btn--go:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--accent-shadow);
}

.link-btn {
  align-self: center;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 16px;
  text-decoration: underline;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

/* --- Cards and forms ------------------------------------------------------- */

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card h2,
.card > summary {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.card h2 {
  margin-bottom: 12px;
}

details > summary {
  cursor: pointer;
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

.card > summary {
  display: flex;
  justify-content: space-between;
}

.card > summary::after {
  content: '+';
  color: var(--muted);
}

.card[open] > summary {
  margin-bottom: 12px;
}

.card[open] > summary::after {
  content: '–';
}

.player-list {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.player-row__name {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.band-chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 15px;
}

.empty {
  color: var(--muted);
}

.add-player {
  display: grid;
  gap: 10px;
}

input[type='text'] {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-size: 20px; /* 16px+ stops iOS zooming in on focus */
}

input[type='text']:focus {
  border-color: var(--accent);
  outline: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.seg {
  position: relative;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg span {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.seg small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.seg input:checked + span {
  border-color: var(--accent);
  background: rgb(255 210 63 / 0.12);
}

.seg input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.field,
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.field {
  justify-content: space-between;
}

select {
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 18px;
}

.setting-note {
  margin: -4px 0 4px 36px;
}

.toggle input {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}

.rules {
  margin: 0;
  padding-left: 22px;
}

.rules li + li {
  margin-top: 6px;
}

.score-table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
}

.score-table td {
  padding: 8px 4px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.score-table__emoji {
  width: 40px;
  font-size: 26px;
}

.score-table__pts {
  font-size: 20px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

/* --- In-game chrome -------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chips {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  white-space: nowrap;
}

.chip--current {
  border-color: var(--accent);
}

.chip__score {
  color: var(--accent);
  font-weight: 700;
}

.toast {
  display: flex;
  flex-wrap: wrap; /* the buttons drop below the text when there isn't room */
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 10px 10px 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--muted);
  border-radius: 14px;
  background: rgb(0 0 0 / 0.3);
  animation: slide-in 0.25s ease-out;
}

.toast--near { border-left-color: var(--near); }
.toast--wild { border-left-color: var(--wild); }
.toast--frozen,
.toast--repeat { border-left-color: var(--frozen); }
.toast--oops { border-left-color: var(--oops); }

.toast__heard {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.toast > span:first-child {
  flex: 1 1 180px;
}

.toast__actions {
  display: flex;
  flex: none;
  gap: 6px;
  margin-left: auto;
}

.toast__button {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  font-weight: 600;
}

@keyframes slide-in {
  from { transform: translateY(-8px); opacity: 0; }
}

/* --- Screens --------------------------------------------------------------- */

.screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.headline {
  margin: 0;
  font-size: clamp(30px, 9cqi, 44px);
  line-height: 1.1;
}

.hint {
  margin: auto 0 0; /* sits just above Go, which stays down at thumb height */
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

/* Pick a theme */

.pack-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.pack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 120px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}

.pack:active {
  border-color: var(--accent);
  transform: scale(0.97);
}

.pack__emoji {
  font-size: 36px;
}

.pack__name {
  font-size: 22px;
  font-weight: 700;
}

.pack__meta {
  color: var(--muted);
  font-size: 15px;
}

.more > summary {
  padding: 8px 0 12px;
  color: var(--muted);
  text-decoration: underline;
}

/* Question */

.question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px; /* room for the timer, so nothing moves when Go is tapped */
}

.question {
  margin: 0;
  font-size: clamp(36px, 12.5cqi, 64px);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

.question--waiting {
  color: var(--muted);
}

/* What the microphone hears, live during the countdown. Holds its space so nothing jumps. */
.heard-live {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 22px;
  font-weight: 600;
}

.answer-key {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.answer-key div {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
}

.answer-key dt {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.answer-key .answer-key__heard {
  grid-column: 1 / -1;
}

.answer-key dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 600;
}

/* Timer and grading */

.timer {
  display: grid;
  flex: none;
  place-items: center;
  min-width: 64px;
  height: 64px;
  padding: 0 14px;
  border: 3px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 34px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.timer--reading {
  border-color: var(--line);
  font-size: 26px;
  animation: pulse 0.8s ease-in-out infinite alternate;
}

.timer--done {
  border-color: var(--oops);
  background: var(--oops);
  color: var(--result-ink);
  font-size: 24px;
  animation: pop 0.35s ease-out;
}

@keyframes pulse {
  to { opacity: 0.35; }
}

.pop {
  animation: pop 0.35s ease-out;
}

@keyframes pop {
  from { transform: scale(1.35); opacity: 0.4; }
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 112px;
  padding: 14px 8px;
  border: 0;
  border-radius: var(--radius);
  color: var(--result-ink);
}

.result:active {
  transform: scale(0.96);
}

.result--near { background: var(--near); }
.result--wild { background: var(--wild); }
.result--frozen { background: var(--frozen); }
.result--oops { background: var(--oops); }

.result__emoji {
  font-size: 34px;
  line-height: 1.1;
}

.result__label {
  font-size: 19px; /* "Randomly wrong" fits on one line on a phone */
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

.result__hint {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
}

.result__points {
  font-size: 18px;
  font-weight: 600;
  opacity: 0.75;
}

/* Scores */

.emoji-line {
  margin: 0;
  font-size: 30px;
  letter-spacing: 2px;
  overflow-wrap: anywhere;
}

.tally {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  list-style: none;
}

.scoreboard {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scoreboard li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
}

.scoreboard__place {
  color: var(--muted);
  font-weight: 700;
}

.scoreboard__name {
  font-size: 20px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.scoreboard__score {
  color: var(--accent);
  font-size: 26px;
  font-weight: 700;
}

.scoreboard__line {
  grid-column: 2 / -1;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.actions {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
}

.trophy {
  margin: 8px 0 0;
  font-size: 88px;
  line-height: 1;
  text-align: center;
}

.screen--game-end .headline {
  text-align: center;
}

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