/* Pair Play. Colours are variables; screens set --gc (game colour) and --pc (player colour) through the CSSOM. */
:root {
  --bg: #16122a;
  --bg-hi: #201936;
  --card: #2a2148;
  --card-hi: #352a5c;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f7f3ff;
  --dim: #b9b0d6;
  --faint: #8378a8;
  --ink: #1b1430;
  --sun: #ffc93c;
  --good: #3ddc84;
  --bad: #ff5d5d;
  --warn: #ff9f43;
  --font: ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 17px/1.4 var(--font);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
h1, h2, h3, p, ul, ol, figure { margin: 0; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.noscript { padding: 40px 24px; text-align: center; }

/* ---------- screens ---------- */
#app { position: fixed; inset: 0; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: enter 0.18s ease-out;
}
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 18px 24px; }
.scroll > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 60px; }
.topbar-title { flex: 1; text-align: center; font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bottom-bar { display: flex; gap: 10px; width: 100%; max-width: 596px; margin: 0 auto; padding: 10px 18px 16px; }
.bottom-bar .btn { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px;
  border-radius: 16px; background: var(--card-hi); color: var(--text); font-size: 18px; font-weight: 800;
  text-align: center; text-decoration: none; transition: transform 0.08s, filter 0.08s;
}
.btn:active { transform: scale(0.97); filter: brightness(1.12); }
.btn.primary { background: var(--gc, var(--sun)); color: var(--ink); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.big { min-height: 60px; border-radius: 20px; font-size: 21px; }
.btn.small { min-height: 42px; padding: 0 16px; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--card); color: var(--text); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { transform: scale(0.93); }
.icon-spacer { width: 44px; flex: none; }

/* ---------- home ---------- */
.home-head { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 596px; margin: 0 auto; padding: 12px 14px 6px 16px; }
.logo { width: 48px; height: 48px; flex: none; }
.logo svg { width: 100%; height: 100%; }
.wordmark { flex: 1; font-size: 31px; font-weight: 900; letter-spacing: -0.5px; }
.wordmark span { margin-left: 7px; color: var(--sun); }
.duo { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px; width: 100%; margin-top: 6px; padding: 12px; border-radius: 20px; background: var(--bg-hi); }
.chip { max-width: 40%; padding: 6px 14px; border-radius: 999px; background: var(--pc); color: var(--ink); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs { color: var(--faint); font-size: 14px; font-weight: 800; text-transform: uppercase; }
.duo-hint { flex-basis: 100%; text-align: center; color: var(--faint); font-size: 14px; }
.section-title { margin-top: 24px; color: var(--dim); font-size: 14px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.section-sub { margin: 2px 0 12px; color: var(--faint); font-size: 15px; }
.cards { display: grid; gap: 12px; }
.card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border-radius: 22px; background: var(--card); text-align: left; transition: transform 0.08s; }
.card:active { transform: scale(0.98); }
.card-icon { width: 54px; height: 54px; flex: none; display: grid; place-items: center; border-radius: 16px; background: var(--gc); color: var(--ink); }
.card-icon svg { width: 30px; height: 30px; }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-text b { font-size: 20px; font-weight: 900; line-height: 1.15; }
.card-text span { color: var(--dim); font-size: 15px; line-height: 1.3; }
.card.hero { padding: 18px 16px; background: var(--gc); color: var(--ink); box-shadow: 0 12px 28px -14px var(--gc); }
.card.hero .card-icon { width: 62px; height: 62px; border-radius: 18px; background: rgba(255, 255, 255, 0.38); }
.card.hero .card-icon svg { width: 34px; height: 34px; }
.card.hero .card-text b { font-size: 23px; }
.card.hero .card-text span { color: rgba(27, 20, 48, 0.78); }
.chev { font-size: 36px; font-weight: 700; line-height: 1; opacity: 0.55; }
.card.soon { padding: 12px 14px; background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.card.soon .card-icon { width: 44px; height: 44px; border-radius: 13px; }
.card.soon .card-icon svg { width: 24px; height: 24px; }
.card.soon .card-text b { font-size: 17px; }
.card.soon .card-text span { font-size: 14px; }
.pill { flex: none; padding: 4px 9px; border-radius: 999px; background: var(--card-hi); color: var(--dim); font-size: 12px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; }
.foot { margin-top: 28px; text-align: center; color: var(--faint); font-size: 13px; }

/* ---------- setup, how to play, settings ---------- */
.hero-head { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 4px 0 8px; text-align: center; }
.hero-head h1 { font-size: 30px; font-weight: 900; }
.hero-head p { max-width: 340px; color: var(--dim); }
.card-icon.big { width: 84px; height: 84px; border-radius: 26px; }
.card-icon.big svg { width: 46px; height: 46px; }
.opt { margin-top: 18px; }
.opt-label, .group { margin-bottom: 8px; color: var(--dim); font-size: 14px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.group { margin-top: 24px; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--bg-hi); }
.seg button { flex: 1; min-height: 46px; border-radius: 12px; color: var(--dim); font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 42px; padding: 0 14px; border-radius: 999px; background: var(--bg-hi); color: var(--dim); font-size: 16px; font-weight: 700; }
.seg button[aria-pressed="true"], .chips button[aria-pressed="true"] { background: var(--gc, var(--sun)); color: var(--ink); }
.record { margin-top: 22px; text-align: center; color: var(--dim); font-size: 15px; }
.record:empty { display: none; }
.steps { display: grid; gap: 12px; margin-top: 8px; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding: 14px 16px 14px 62px; border-radius: 18px; background: var(--card); line-height: 1.4; counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; left: 14px; top: 12px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--gc); color: var(--ink); font-weight: 900; }
.tip { margin-top: 16px; text-align: center; color: var(--dim); font-size: 15px; }
.field { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--card); box-shadow: inset 5px 0 0 var(--pc); }
.field-label { width: 76px; flex: none; color: var(--dim); font-size: 15px; font-weight: 700; }
.field input { flex: 1; min-width: 0; height: 46px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--bg-hi); color: var(--text); font-size: 18px; font-weight: 700; outline: none; }
.field input:focus { box-shadow: 0 0 0 2px var(--pc); }
.field input::placeholder { color: var(--faint); }
.tally { display: grid; gap: 6px; margin-bottom: 12px; }
.tally-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--card); font-size: 15px; }
.tally-row b { overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.about { color: var(--dim); font-size: 15px; }

/* ---------- pass the phone ---------- */
.handoff { background: var(--pc); color: var(--ink); }
.handoff .icon-btn { background: rgba(27, 20, 48, 0.14); color: var(--ink); }
/* Centred with auto margins rather than justify-content, so on a short landscape screen the top can still be scrolled to. */
.handoff-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 24px; text-align: center; }
.handoff-body > :first-child { margin-top: auto; }
.handoff-body > :last-child { margin-bottom: auto; }
.kicker { font-size: 15px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; opacity: 0.78; }
.handoff-name { max-width: 100%; font-size: clamp(36px, min(13vw, 12vh), 84px); font-weight: 900; line-height: 1.05; overflow-wrap: anywhere; }
.handoff-line { max-width: 420px; font-size: 20px; font-weight: 700; }
.handoff .btn { background: var(--ink); color: #fff; }
.choose-title { font-size: clamp(30px, 9vw, 44px); font-weight: 900; }
.word-choices { display: grid; gap: 12px; width: 100%; max-width: 420px; margin: 8px 0; }
.word-choice { min-height: 86px; padding: 10px 16px; border-radius: 22px; background: var(--ink); color: #fff; font-size: 28px; font-weight: 900; transition: transform 0.08s; }
.word-choice:active { transform: scale(0.97); }
@media (orientation: landscape) and (max-height: 520px) {
  .word-choices { grid-template-columns: 1fr 1fr; max-width: 560px; }
  .word-choice { min-height: 70px; font-size: 24px; }
}

/* ---------- timer and countdown ---------- */
.timer { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.timer-bar { flex: 1; height: 10px; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.14); }
.timer-bar i { display: block; height: 100%; border-radius: 99px; background: var(--good); transform-origin: left center; transition: transform 0.1s linear; }
.timer-digits { min-width: 56px; text-align: right; font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer.warn .timer-bar i { background: var(--bad); }
.timer.warn .timer-digits { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.countdown { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; color: var(--gc, var(--sun)); font-size: clamp(90px, 30vmin, 220px); font-weight: 900; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.35); pointer-events: none; }
.countdown.pop { animation: pop 0.8s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(1.5); } 25% { opacity: 1; transform: scale(1); } to { opacity: 0.85; transform: scale(0.9); } }

/* ---------- scores and results ---------- */
.scores { display: flex; gap: 10px; width: 100%; }
.score { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-radius: 16px; background: var(--card); box-shadow: inset 0 -4px 0 var(--pc); }
.score.on { background: var(--card-hi); }
.score-name { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.score-pts { color: var(--pc); font-size: 26px; font-weight: 900; }
.results-head { display: grid; justify-items: center; gap: 10px; padding: 8px 0 18px; text-align: center; }
.result-big { max-width: 100%; font-size: clamp(40px, 12vw, 66px); font-weight: 900; line-height: 1.05; overflow-wrap: anywhere; }
.result-big.tinted { color: var(--pc); }
.result-sub { color: var(--dim); font-size: 15px; }
.center { margin-top: 10px; text-align: center; }
.wordlist { display: grid; gap: 6px; padding: 0; list-style: none; }
.wordlist li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; background: var(--card); color: var(--dim); font-weight: 700; }
.wordlist li.ok { color: var(--text); }
.mark { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--card-hi); font-size: 14px; }
.wordlist li.ok .mark { background: var(--good); color: var(--ink); }

/* ---------- dialogs and toasts ---------- */
#layer { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(10, 7, 22, 0.74); pointer-events: auto; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: min(360px, 100%); display: grid; gap: 12px; padding: 22px; border-radius: 24px; background: var(--card); text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.dialog h3 { font-size: 22px; font-weight: 900; }
.dialog p { color: var(--dim); }
.dialog-btns { display: flex; gap: 10px; margin-top: 6px; }
.dialog-btns .btn { flex: 1; padding: 0 12px; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 30; max-width: calc(100vw - 40px);
  padding: 12px 18px; border-radius: 14px; background: rgba(0, 0, 0, 0.85); color: #fff; font-weight: 700; text-align: center;
  opacity: 0; transform: translate(-50%, 16px); transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Thinking Cap ---------- */
.cap-play { overflow: hidden; padding: 0; background: #120d24; }
.cap-stage { position: absolute; left: 50%; top: 50%; display: flex; flex-direction: column; overflow: hidden; background: radial-gradient(circle at 50% 40%, #2c2152, #140f29 75%); }
.cap-zones { position: absolute; inset: 0; display: flex; }
.cap-zone { flex: 1; display: flex; align-items: flex-end; padding: 0 28px 22px; color: rgba(255, 255, 255, 0.42); font-size: 16px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }
.cap-zone.ok { justify-content: flex-end; }
.cap-zone:active { background: rgba(255, 255, 255, 0.06); }
.cap-bar { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 12px 18px 0; }
.cap-play .icon-btn { background: rgba(255, 255, 255, 0.1); }
.cap-count { min-width: 56px; text-align: right; color: var(--good); font-size: 22px; font-weight: 900; }
.cap-wordbox { position: relative; z-index: 1; flex: 1; min-height: 0; display: flex; align-items: center; padding: 6px 32px 56px; pointer-events: none; }
.cap-word { width: 100%; text-align: center; font-weight: 900; line-height: 1.04; overflow-wrap: normal; word-break: keep-all; }
.cap-flash { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--ink); font-size: clamp(48px, 15vmin, 130px); font-weight: 900; opacity: 0; pointer-events: none; transition: opacity 0.12s; }
.cap-flash.show { opacity: 1; }
.cap-flash.ok { background: var(--good); }
.cap-flash.pass { background: var(--warn); }
.cap-flash.end { background: var(--bad); color: #fff; }
/* Not turned: the page itself is sideways, so keep clear of the notch and home bar. Turned: they sit at the stage's ends. */
.cap-stage:not(.turned) .cap-bar { padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); }
.cap-stage:not(.turned) .cap-wordbox { padding-left: max(32px, env(safe-area-inset-left)); padding-right: max(32px, env(safe-area-inset-right)); }
.cap-stage:not(.turned) .cap-zone { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
.cap-stage:not(.turned) .cap-zone.pass { padding-left: max(28px, env(safe-area-inset-left)); }
.cap-stage:not(.turned) .cap-zone.ok { padding-right: max(28px, env(safe-area-inset-right)); }
.cap-stage.turned .cap-bar, .cap-stage.turned .cap-wordbox, .cap-stage.turned .cap-zone { padding-left: 56px; padding-right: 56px; }

/* ---------- Doodle Dash ---------- */
.dd-play { background: #1d1636; }
.dd-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.dd-got { min-height: 44px; padding: 0 16px; border-radius: 14px; background: var(--good); color: var(--ink); font-weight: 900; white-space: nowrap; }
.dd-got:disabled { opacity: 0.4; }
.dd-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 4px 8px; }
.dd-canvas { display: block; border-radius: 18px; background: #fffdf8; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); touch-action: none; }
.dd-bubble { position: absolute; top: 14px; left: 50%; z-index: 4; max-width: 90%; padding: 10px 18px; border-radius: 16px; background: var(--ink); color: #fff; font-size: 26px; font-weight: 900; text-align: center; transform: translateX(-50%); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); pointer-events: none; }
.dd-flash { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; border-radius: 18px; background: rgba(255, 93, 93, 0.9); color: #fff; font-size: clamp(44px, 13vw, 90px); font-weight: 900; animation: fade 0.15s; }
.dd-flash.ok { background: rgba(61, 220, 132, 0.92); color: var(--ink); }
.dd-tools { display: grid; gap: 8px; padding: 8px 10px 12px; }
.dd-row { display: flex; align-items: center; justify-content: center; gap: 7px; }
.swatch { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px #1d1636, 0 0 0 5px #fff; }
.tool { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--card); color: var(--text); }
.tool svg { width: 22px; height: 22px; }
.tool[aria-pressed="true"] { background: #fff; color: var(--ink); }
.tool:active { transform: scale(0.93); }
.dot { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.dd-giveup { min-height: 42px; padding: 0 12px; border-radius: 14px; color: var(--dim); font-size: 15px; font-weight: 800; box-shadow: inset 0 0 0 2px var(--line); white-space: nowrap; }
@media (max-width: 380px) {
  .dd-row { gap: 5px; }
  .tool { width: 38px; height: 38px; }
  .swatch { width: 34px; height: 34px; }
}
/* Phone held sideways: canvas on the left, clock and tools in a column on the right, so the canvas stays big. */
@media (orientation: landscape) and (max-height: 520px) {
  .dd-play { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; grid-template-areas: "wrap top" "wrap tools"; }
  .dd-top { grid-area: top; }
  .dd-wrap { grid-area: wrap; min-width: 0; }
  .dd-tools { grid-area: tools; align-content: start; }
}
.doodle-big { display: flex; justify-content: center; }
.doodle-big canvas { width: min(100%, 320px); height: auto; border-radius: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.doodle { display: grid; gap: 6px; padding: 8px; border-radius: 18px; background: var(--card); box-shadow: inset 0 -4px 0 var(--pc); }
.doodle canvas { display: block; width: 100%; height: auto; border-radius: 12px; }
.doodle figcaption { display: grid; gap: 1px; padding: 0 4px 6px; }
.doodle b { font-size: 16px; }
.doodle span { color: var(--dim); font-size: 13px; }
.doodle.miss b { color: var(--dim); }

/* ---------- 404 page ---------- */
.notfound { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.notfound h1 { font-size: 34px; font-weight: 900; }
.notfound p { color: var(--dim); }
