/* The phone pages: join, and every game step. House style (DESIGN.md), always dark. On a laptop or a tablet,
   the step sits beside the room (the invite code, who's in, the scores). */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; } /* no double-tap zoom while playing */
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.4;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.page {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  /* Room at the bottom for Safari's floating toolbar, so the last button can scroll clear of it. */
  padding: max(24px, env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.page.play > .main, .page.play > .side { display: flex; flex-direction: column; gap: 22px; }
.page.play > .main { flex-grow: 1; }
.page.play:has(> .side:not(.wide-only)) > .main { flex-grow: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack-l { display: flex; flex-direction: column; gap: 12px; }
.push { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wide-only { display: none !important; }

.meta { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0; }
.meta-s { font-size: 11px; }
.accent { color: var(--accent); }
h1 { margin: 0; font-size: 34px; line-height: 1.05; font-weight: 800; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 24px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.lede { margin: 0; font-size: 15px; line-height: 1.45; color: var(--text-muted); }
.soft { margin: 0; font-size: 15px; line-height: 1.45; color: var(--text-soft); }
.small { margin: 0; font-size: 12px; line-height: 1.45; color: var(--text-muted); text-align: center; }
.small.left { text-align: left; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px 0 4px; border-radius: 9999px;
  background: var(--pc, var(--surface)); color: var(--background);
  font-size: 15px; font-weight: 600; white-space: nowrap;
}
.pill-critter { width: 28px; }
.tag { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }

/* Your critter beside the title, as the TV will show you. */
.hero { display: flex; align-items: center; gap: 16px; }
.hero > .stack { flex: 1; min-width: 0; }
.me { flex-shrink: 0; }
.me .critter { cursor: pointer; }
.me-critter { width: 88px; box-shadow: 0 0 0 4px var(--background), 0 0 0 6px var(--line-strong); }

label.meta, legend.meta { display: block; margin-bottom: 8px; padding: 0; }
fieldset { margin: 0; padding: 0; border: 0; }
input[type="text"], input[type="password"] {
  width: 100%; height: 52px; padding: 0 16px; border-radius: var(--radius-card);
  border: 2px solid var(--line); background: var(--surface); font-size: 17px;
  transition: border-color 0.2s ease;
}
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--accent); outline: none; }
input.code { height: 64px; font-size: 34px; font-weight: 800; letter-spacing: 0.3em; text-transform: uppercase; }
select {
  width: 100%; height: 52px; padding: 0 14px; border-radius: var(--radius-card);
  border: 2px solid var(--line); background: var(--surface); font-size: 17px;
}

/* Picking your critter: a ring for the picked one, which springs up; taken ones faded. */
.colours { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px 12px; padding: 4px; }
.colours .pick {
  position: relative; padding: 0; border: 0; background: none; border-radius: 9999px; aspect-ratio: 1;
  transition: transform 0.45s cubic-bezier(0.3, 1.8, 0.4, 1);
}
.colours .pick { display: block; line-height: 0; } /* the critter fills the button exactly, so the ring is centred */
.colours .pick .critter { display: block; width: 100%; }
.colours .pick::after {
  content: ""; position: absolute; inset: -5px; border-radius: 9999px; border: 3px solid var(--accent);
  opacity: 0; scale: 0.9; transition: opacity 0.2s ease, scale 0.45s cubic-bezier(0.3, 1.8, 0.4, 1);
}
.colours .pick[aria-pressed="true"] { transform: scale(1.08); }
.colours .pick[aria-pressed="true"]::after { opacity: 1; scale: 1; }
.colours .pick.taken { opacity: 0.25; filter: grayscale(0.9); cursor: not-allowed; }
@media (hover: hover) { .colours .pick:not(.taken):hover { transform: translateY(-3px); } .colours .pick[aria-pressed="true"]:hover { transform: scale(1.08) translateY(-3px); } }

/* Buttons and cards spring: down quickly when pressed, back with a little overshoot. */
.btn, .pick-card, .choices button, .icon-btn, .word-card {
  transition: transform 0.45s cubic-bezier(0.3, 1.8, 0.4, 1), background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.btn:active:not(:disabled), .pick-card:active:not(:disabled), .choices button:active, .icon-btn:active, .colours .pick:active:not(.taken) {
  transform: scale(0.95); transition-duration: 0.08s; transition-timing-function: ease-out;
}
.btn {
  width: 100%; min-height: 50px; padding: 0 20px; border-radius: 9999px; border: 0;
  background: var(--accent); color: var(--accent-text); font-size: 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.quiet { background: transparent; color: var(--text-muted); min-height: 44px; font-weight: 400; font-size: 15px; }

.card { background: var(--surface); border-radius: var(--radius-card); padding: 14px; }
.error {
  margin: 0; padding: 12px 14px; border-radius: var(--radius-row);
  background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border); font-size: 14px;
}
.banner {
  position: sticky; top: 0; z-index: 2; margin: -8px 0 0;
  padding: 10px 14px; border-radius: var(--radius-row);
  background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border); font-size: 14px;
}

/* The invite: the room's QR for a friend's camera, and the letters for typing. */
.invite {
  display: flex; align-items: center; gap: 16px; padding: 14px; border-radius: var(--radius-tile);
  background: var(--surface); border: 1px solid var(--line);
}
.qr-mini { flex-shrink: 0; width: 132px; height: 132px; padding: 8px; border-radius: 16px; background: var(--paper); }
.qr-mini svg { display: block; width: 100%; height: 100%; }
.qr-mini path { fill: var(--background); }
.invite-text { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.invite-code { margin: 0; font-size: 40px; line-height: 1; font-weight: 800; letter-spacing: 0.14em; color: var(--accent); }
.invite-lede { margin: 0; font-size: 13px; line-height: 1.4; color: var(--text-muted); }

/* Your word: a card that flips over to hide it, and back. */
.word-card { min-height: 210px; perspective: 1200px; cursor: pointer; border-radius: var(--radius-tile); }
.word-card .faces {
  position: relative; min-height: 210px; transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.word-card.flipped .faces { transform: rotateY(180deg); }
.word-card .face {
  position: absolute; inset: 0; padding: 22px 18px; border-radius: var(--radius-tile); backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border);
}
.word-card.odd .face.front { background: var(--surface); border-color: var(--line-strong); }
.word-card .face.back { transform: rotateY(180deg); background: var(--surface); border-color: var(--line); }
.word { margin: 0; font-size: 44px; line-height: 1.05; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto; }
.flip-btn { width: auto; align-self: center; min-height: 44px; font-size: 14px; margin-top: -10px; }

/* Rows of players: their critter, their name. */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
  min-height: 56px; padding: 8px 8px 8px 10px; border-radius: var(--radius-row); background: var(--surface);
  display: flex; align-items: center; gap: 12px; border: 2px solid transparent; transition: border-color 0.3s ease;
}
.list li.now { border-color: var(--accent); }
.row-critter { width: 40px; }
.row-name { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; }
.row-name svg { fill: var(--crown); }
/* The Plus badge (motion.js plusBadge): a coral seal on the dark, a dark one on a player's colour. */
.plus-badge { flex-shrink: 0; width: 18px; height: 18px; }
.plus-badge .seal { fill: var(--seal, var(--accent)); }
.plus-badge .star { fill: var(--star, var(--background)); }
.pill .plus-badge { --seal: var(--background); --star: var(--text); width: 17px; height: 17px; }
.list .detail { flex-grow: 1; font-size: 13px; color: var(--text-muted); }
.list .score { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding-right: 6px; }
.list .rank { width: 20px; text-align: center; font-family: var(--mono); font-size: 13px; color: var(--text-muted); }
.done-tick { width: 30px; height: 30px; margin-right: 4px; border-radius: 9999px; background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }
.done-tick svg { width: 16px; height: 16px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 9999px; border: 0; background: transparent; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; padding: 0;
}

/* Whose turn: their critter, ringed and pulsing when it's yours. */
.turn { display: flex; align-items: center; gap: 16px; }
.turn h2, .turn .lede, .turn .stack { flex: 1; min-width: 0; }
.turn-ring { flex-shrink: 0; padding: 4px; border-radius: 9999px; border: 3px solid var(--line-strong); font-size: 14px; }
.turn.mine .turn-ring { border-color: var(--accent); }
.turn-critter { width: 72px; cursor: pointer; }

/* Voting: a card per player, their critter big; the chosen one ringed. */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choices button {
  padding: 16px 10px 14px; border-radius: var(--radius-card); border: 2px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.choices button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft-bg); }
.choice-critter { width: 76px; }
.choice-name { font-size: 16px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Seven or more to choose from: three across, so up to eleven still fit on one screen. */
.choices.many { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choices.many button { padding: 12px 6px 10px; gap: 6px; }
.choices.many .choice-critter { width: 58px; }
.choices.many .choice-name { font-size: 15px; }

/* The winner, crowned. */
.winner { position: relative; align-self: center; margin-top: 34px; }
.winner .turn-ring { border-color: var(--crown); padding: 6px; }
.winner .turn-critter { width: 120px; }
.winner-crown { position: absolute; z-index: 2; top: -42px; left: 50%; width: 64px; margin-left: -32px; }
.winner-crown svg { display: block; width: 100%; height: auto; fill: var(--crown); }
.the-word { display: inline-block; color: var(--accent); }
.result-points { margin: 0; font-size: 40px; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); }

/* The host's game picker. */
.pick-list { display: flex; flex-direction: column; gap: 10px; }
.pick-card {
  width: 100%; padding: 10px; border-radius: var(--radius-card); border: 2px solid transparent; background: var(--surface);
  display: flex; align-items: center; gap: 12px; text-align: left;
}
.pick-art { width: 64px; height: 64px; flex-shrink: 0; border-radius: 16px; background: var(--pc); display: flex; align-items: center; justify-content: center; }
.pick-art img { width: 56px; height: 56px; object-fit: contain; }
.pick-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pick-text strong { font-size: 17px; }
.pick-text > span { font-size: 13px; color: var(--text-muted); }
.pick-chevron { flex-shrink: 0; margin-right: 4px; color: var(--text-muted); }

/* Tonight's game, once chosen: one card with its settings and Start; the other games behind "Change game". */
.tonight-game {
  display: flex; flex-direction: column; gap: 14px; padding: 14px;
  border-radius: var(--radius-card); background: var(--surface); border: 2px solid var(--accent-soft-border);
}
.tonight-head { display: flex; align-items: center; gap: 14px; }
.tonight-game .pick-art { width: 76px; height: 76px; border-radius: 18px; }
.tonight-game .pick-art img { width: 66px; height: 66px; }
.tonight-game .pick-text strong { font-size: 20px; }
.tonight-game .pick-options { padding: 0; border: 0; background: transparent; }
.tonight-game .small { margin: -4px 0 0; }
.plus-tag { color: var(--accent); }
.tonight-game .btn svg { margin-right: 8px; vertical-align: -3px; }
.change-game { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-soft); font-weight: 600; }
.change-game svg { transition: transform 0.25s ease; }
.change-game[aria-expanded="true"] svg { transform: rotate(180deg); }
.hidden { display: none !important; }

/* A laptop or a tablet: the forms sit in a card in the middle; a game puts the step beside the room. */
@media (min-width: 820px) {
  h1 { font-size: 44px; }
  .page.form {
    max-width: 560px; min-height: auto; margin: 48px auto; padding: 36px;
    border-radius: 28px; background: var(--surface); border: 1px solid var(--line);
  }
  .page.form input[type="text"], .page.form select { background: var(--background); }
  .page.form .me-critter { width: 112px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--line-strong); }
  .page.play {
    max-width: 1080px; padding: 40px 40px 64px;
    display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto 1fr; gap: 28px 48px; align-content: start;
  }
  .page.play > .top, .page.play > .banner { grid-column: 1 / -1; }
  .page.play > .main { grid-column: 1; min-height: 0; }
  .page.play > .side { grid-column: 2; position: sticky; top: 24px; align-self: start; }
  /* A step with nothing beside it (most of Pass the doodle): one column in the middle, not an empty right half. */
  .page.play:not(:has(> .side)) { grid-template-columns: minmax(0, 680px); justify-content: center; }
  .page.play .push { margin-top: 8px; }
  .wide-only { display: flex !important; }
  .me-critter { width: 120px; }
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .qr-mini { width: 156px; height: 156px; }
  .invite { flex-direction: column; align-items: flex-start; }
  .word-card, .word-card .faces { min-height: 260px; }
  .word { font-size: 56px; }
}

/* Public rooms: the footer with the badge and Report, the report sheet, and the host's public option. */
.public-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.page.play > .public-foot { grid-column: 1 / -1; }
.public-badge { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.public-foot .btn.quiet { width: auto; min-height: 40px; padding: 0 12px; font-size: 14px; }
.banner.ok { background: var(--success-soft); border-color: var(--success); }
.sheet-shade {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: var(--glass); padding: 16px;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 90dvh; overflow: auto; padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 24px; background: var(--surface); border: 1px solid var(--line-strong);
  display: flex; flex-direction: column; gap: 14px; animation: sheet-up 0.32s cubic-bezier(0.3, 1.2, 0.5, 1);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.report-people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.report-person {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; border-radius: var(--radius-row);
  border: 2px solid var(--line); background: var(--background); text-align: left; font-weight: 600;
}
.report-person[aria-pressed="true"], .chip-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft-bg); }
.report-reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { min-height: 40px; padding: 0 14px; border-radius: 9999px; border: 2px solid var(--line); background: var(--background); font-weight: 600; font-size: 14px; }
.checkline { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text-soft); }
.checkline input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.checkline > span { display: flex; flex-direction: column; gap: 2px; }
.public-choice { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--line); }
.page.form .public-choice { background: var(--background); }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

/* The host's Sound on the TV: a speaker at the top, and its sheet of songs. */
.top-end { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tvsound-btn { margin-right: -10px; color: var(--text-soft); }
.song-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.song-pick {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 48px; padding: 8px 12px;
  border-radius: var(--radius-row); border: 2px solid var(--line); background: var(--background); text-align: left; color: var(--text);
}
.song-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft-bg); }
.song-name { font-weight: 600; font-size: 15px; }
.song-pick .small { display: flex; align-items: center; gap: 4px; }
.song-pick .small svg { width: 14px; height: 14px; flex-shrink: 0; }

/* A game's settings on tonight's game card: switches and choices, then its Start. */
.pick-options { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--accent-soft-border); }
.opt-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 10px 12px;
  border-radius: var(--radius-row); border: 0; background: var(--background); text-align: left;
}
.opt-text { display: flex; flex-direction: column; gap: 2px; }
.opt-text strong { font-size: 15px; }
.opt-text span { font-size: 13px; color: var(--text-muted); }
.opt-switch { flex-shrink: 0; width: 48px; height: 28px; border-radius: 9999px; background: var(--line-strong); position: relative; transition: background-color 0.2s; }
.opt-switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 9999px; background: var(--paper); transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); }
.opt-toggle[aria-checked="true"] .opt-switch { background: var(--accent); }
.opt-toggle[aria-checked="true"] .opt-switch i { transform: translateX(20px); }
.opt-choice { display: flex; flex-direction: column; gap: 8px; }
.opt-seg { display: flex; padding: 3px; border-radius: 12px; background: var(--background); }
.opt-seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--text-soft); font-weight: 600; font-size: 14px; }
.opt-seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
