/* Layout: the home page is one centred column (max 1080px): a brand bar, a two-column hero
   (copy on the left, an example chat on the right) that stacks on phones, a 3 x 2 grid of game
   cards, and a three-up "how every game works" row. Each game opens as a one-screen app in the
   same page, inside its own themed frame (airmail for Where am I from?). */
:root {
  --paper: #E9EEF6;    /* page */
  --surface: #F8FAFD;  /* cards, letter sheet */
  --note: #FFFFFF;     /* chat bubbles, inputs */
  --ink: #141B33;      /* navy ink */
  --ink-2: #4D5874;    /* secondary ink */
  --rule: #CAD3E3;
  --pip: #CAD3E3;      /* an unlit hint */
  --lit: #E9A100;      /* marigold: a lit hint, the brand mark */
  --die-bg: #141B33;
  --die-dot: #F2B01E;
  --red: #C7342B;      /* airmail red: wrong guesses, last seconds */
  --blue: #2246A3;     /* airmail blue: actions, your guesses, the clock */
  --on-blue: #FFFFFF;
  --green: #1B7A49;    /* found it */
  --amber: #A86B12;    /* hints lost to the clock */
  --skip: #97A3BC;
  --g-animals: #2E7D4F;
  --g-food: #C2412A;
  --g-landmarks: #0E7490;
  --g-cars: #B8460E;
  --g-people: #6D4BC4;
  --scrim: #141B338C;
  --shadow: 0 1px 0 #141B3310, 0 18px 40px -22px #141B3366;
  --board-bg: #141B33;   /* the room-code board */
  --board-tile: #24305A;
  --board-ink: #FFC53D;
  --board-dim: #A9B4CE;
  --font-display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-flag: "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", sans-serif;
  --step--1: .8125rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.4rem;
  --step-3: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem);
  --step-4: clamp(2.5rem, 1.5rem + 4vw, 4.4rem);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0D1530; --surface: #141E3B; --note: #1B2747; --ink: #E6EBF6; --ink-2: #A3AFC9; --rule: #2A385F;
    --pip: #34416A; --lit: #FFC53D; --die-bg: #FFC53D; --die-dot: #0D1530;
    --red: #F1665B; --blue: #8BA9FF; --on-blue: #0D1530; --green: #5AD195; --amber: #F2B544; --skip: #5D6A8A;
    --g-animals: #6CC791; --g-food: #F08A72; --g-landmarks: #4FC3D9; --g-cars: #F59E5B; --g-people: #A98BF0;
    --scrim: #050A18B3; --shadow: 0 1px 0 #00000040, 0 18px 40px -20px #000000B3;
    --board-bg: #060B1C; --board-tile: #1B2747; --board-ink: #FFC53D; --board-dim: #8E9AB7;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0D1530; --surface: #141E3B; --note: #1B2747; --ink: #E6EBF6; --ink-2: #A3AFC9; --rule: #2A385F;
  --pip: #34416A; --lit: #FFC53D; --die-bg: #FFC53D; --die-dot: #0D1530;
  --red: #F1665B; --blue: #8BA9FF; --on-blue: #0D1530; --green: #5AD195; --amber: #F2B544; --skip: #5D6A8A;
  --g-animals: #6CC791; --g-food: #F08A72; --g-landmarks: #4FC3D9; --g-cars: #F59E5B; --g-people: #A98BF0;
  --scrim: #050A18B3; --shadow: 0 1px 0 #00000040, 0 18px 40px -20px #000000B3;
  --board-bg: #060B1C; --board-tile: #1B2747; --board-ink: #FFC53D; --board-dim: #8E9AB7;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
  padding-inline: 16px;
  padding-block: 0;
}
body[data-view="wamf"] { height: 100%; }
p, h1, h2, h3, ol, ul, figure { margin: 0; }
a { color: var(--blue); }
button, select, input { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
/* Rooms can be switched off on the home page while they're being tried out live. */
[data-rooms="off"] .rooms-only { display: none !important; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.flag { font-family: var(--font-flag); font-weight: 400; line-height: 1; }
:where(a, button, input, select):focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.die {
  flex: none;
  width: 34px; height: 34px;
  padding: 7px 8px;
  border-radius: 9px;
  background: var(--die-bg);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px 8px;
}
.die i { border-radius: 50%; background: var(--die-dot); animation: pip-in .32s cubic-bezier(.2, 1.5, .4, 1) both; }
.die i:nth-child(2) { animation-delay: .08s; }
.die i:nth-child(3) { animation-delay: .16s; }
.die i:nth-child(4) { animation-delay: .24s; }
.die i:nth-child(5) { animation-delay: .32s; }
.die i:nth-child(6) { animation-delay: .40s; }
@keyframes pip-in { from { transform: scale(.35); opacity: .35; } to { transform: none; opacity: 1; } }
.die.sm { width: 26px; height: 26px; padding: 5px 6px; border-radius: 7px; gap: 2px 6px; }
.wordmark { font-family: var(--font-display); font-weight: 800; font-stretch: 78%; font-size: 1.4rem; letter-spacing: -.01em; line-height: 1; }
.brand.small .wordmark { font-size: 1.1rem; }
.brand .back { width: 18px; height: 18px; color: var(--ink-2); }

/* ---------- Shared controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 18px;
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.btn-primary { background: var(--blue); color: var(--on-blue); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-lg { padding: 15px 22px; font-size: var(--step-1); border-radius: 14px; }
.btn:disabled, .linkish:disabled { opacity: .5; cursor: not-allowed; }
.chip {
  display: inline-block;
  font-size: var(--step--1);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip b { color: var(--ink); }
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--ink-2); }
.icon-btn svg { width: 20px; height: 20px; }

/* Hint pips: the meter in every game */
.pips { display: inline-flex; gap: 4px; }
.pip { width: 14px; height: 6px; border-radius: 3px; background: var(--pip); }
.pip.on { background: var(--ink); }
.pip.wrong { background: var(--red); }
.pip.skip { background: var(--skip); }
.pip.time, .pip.left { background: var(--amber); }
.pip.right { background: var(--green); }

/* Chat bubbles */
.msg { max-width: min(86%, 30rem); padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; }
.msg.t { align-self: flex-start; background: var(--note); border: 1px solid var(--rule); border-bottom-left-radius: 4px; }
.msg.you { align-self: flex-end; background: var(--blue); color: var(--on-blue); border-bottom-right-radius: 4px; font-weight: 700; }
.msg .label { display: block; font-size: var(--step--1); font-weight: 700; color: var(--ink-2); margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.msg .clue { display: block; margin-top: 6px; font-weight: 700; color: var(--blue); }
.msg.win { border: 1.5px solid var(--green); }
.msg.lose { border: 1.5px solid var(--red); }
.msg.warn { border: 1.5px dashed var(--amber); }
.fresh { animation: rise .24s ease-out; }
@keyframes rise { from { transform: translateY(8px); opacity: .2; } to { transform: none; opacity: 1; } }
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 15px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); animation: blink 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* Passport stamp */
.stamp {
  color: var(--green);
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 9.5rem;
  max-width: 12rem;
  padding: 8px 12px 9px;
  border: 3px solid currentColor;
  outline: 1.5px solid currentColor;
  outline-offset: 3px;
  border-radius: 10px;
  transform: rotate(-7deg);
  font-family: var(--font-display);
  text-transform: uppercase;
  text-align: center;
  line-height: 1.05;
  filter: url(#ink);
}
.stamp.lost { color: var(--red); }
.stamp-top { font-size: .78rem; font-weight: 800; letter-spacing: .16em; }
.stamp-country { font-size: 1.35rem; font-weight: 800; font-stretch: 75%; letter-spacing: .02em; text-wrap: balance; }
.stamp-meta { font-size: .7rem; font-weight: 700; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
.thunk { animation: thunk .34s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes thunk { from { transform: rotate(-16deg) scale(1.8); opacity: 0; } to { transform: rotate(-7deg) scale(1); opacity: 1; } }

/* ---------- Home ---------- */
.hub { max-width: 1080px; margin-inline: auto; padding-block: 18px 40px; display: grid; gap: clamp(40px, 6vw, 72px); }
.hub-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hub-main { display: grid; gap: clamp(56px, 8vw, 96px); }

.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.hero-copy { display: grid; gap: 20px; align-content: start; }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 76%;
  font-size: var(--step-4);
  line-height: .93;
  letter-spacing: -.02em;
  text-wrap: balance;
  max-width: 11ch;
}
.lead { font-size: var(--step-1); color: var(--ink-2); max-width: 34rem; }
.hero-actions { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.hero-note { color: var(--ink-2); font-size: var(--step--1); }

.demo { background: var(--surface); border: 1px solid var(--rule); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.demo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.demo-who { font-family: var(--font-display); font-weight: 700; }
.demo-chat { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.demo-cap { padding: 0 16px 14px; color: var(--ink-2); font-size: var(--step--1); }

.section-title { font-family: var(--font-display); font-weight: 800; font-stretch: 80%; font-size: var(--step-3); line-height: 1.05; margin-bottom: 18px; }

.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.game-card {
  --accent: var(--ink-2);
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 8px;
  padding: 20px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  min-width: 0;
}
.game-card h3 { font-family: var(--font-display); font-weight: 800; font-stretch: 85%; font-size: 1.45rem; line-height: 1.1; }
.game-card p { color: var(--ink-2); }
.card-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.card-icon svg { width: 26px; height: 26px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.game-card.live {
  --accent: var(--blue);
  padding: 20px 16px 16px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    repeating-linear-gradient(135deg, var(--red) 0 12px, var(--surface) 12px 19px, var(--blue) 19px 31px, var(--surface) 31px 38px) border-box;
  border: 6px solid transparent;
  box-shadow: var(--shadow);
}
.game-card.soon .chip { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: transparent; }
.game-card.animals { --accent: var(--g-animals); }
.game-card.food { --accent: var(--g-food); }
.game-card.landmarks { --accent: var(--g-landmarks); }
.game-card.cars { --accent: var(--g-cars); }
.game-card.people { --accent: var(--g-people); }

.how-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 28px; }
.how-item { display: grid; gap: 8px; align-content: start; }
.how-item h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); }
.how-item p { color: var(--ink-2); }
.how-visual { height: 64px; display: flex; align-items: center; }
.pips.big .pip { width: 26px; height: 10px; border-radius: 5px; }
.pips.big { gap: 6px; }
.clock-demo { display: grid; gap: 6px; width: min(100%, 220px); }
.clock-demo .track { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.clock-demo .track i { display: block; height: 100%; width: 58%; background: var(--blue); }
.clock-demo span { font-size: var(--step--1); font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stamp.mini { min-width: 0; padding: 5px 10px 6px; transform: rotate(-6deg); }
.stamp.mini .stamp-country { font-size: 1.05rem; }

.hub-foot { color: var(--ink-2); font-size: var(--step--1); border-top: 1px solid var(--rule); padding-top: 16px; }

@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .how-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .game-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-actions .btn { flex: 1; }
}

/* ---------- Game: Where am I from? ---------- */
.wamf { height: 100%; }
.wamf .app {
  height: 100%;
  min-height: 560px;
  max-width: 640px;
  margin-inline: auto;
  padding-block: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tools { display: flex; gap: 8px; flex: none; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }
.game-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 78%;
  font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.4rem);
  line-height: .95;
  letter-spacing: -.015em;
}
.score { display: flex; gap: 6px; flex-wrap: wrap; }

.envelope {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 7px;
  border-radius: 14px;
  background: repeating-linear-gradient(135deg, var(--red) 0 14px, var(--surface) 14px 22px, var(--blue) 22px 36px, var(--surface) 36px 44px);
  box-shadow: var(--shadow);
}
.letter { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-radius: 9px; overflow: hidden; }

.traveller { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.avatar {
  width: 56px; height: 64px; flex: none; padding: 5px;
  /* perforated postage-stamp edge: the holes show the sheet behind */
  background: radial-gradient(circle, transparent 2.5px, var(--note) 2.8px) -4px -4px / 8px 8px;
}
.avatar-face {
  height: 100%;
  display: grid; place-items: center;
  background: var(--paper);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  color: var(--blue);
}
.avatar-face .flag { font-size: 1.9rem; }
.who { flex: 1; min-width: 0; }
.who-name { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); line-height: 1.15; }
.who-sub { color: var(--ink-2); font-size: var(--step--1); }
.meter { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.worth { font-size: var(--step--1); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Hint text can't be selected or copied. */
.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.composer { position: relative; border-top: 1px solid var(--rule); padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.clock { position: absolute; left: 0; right: 0; top: -1px; height: 4px; background: var(--rule); }
.clock-fill { display: block; height: 100%; width: 100%; background: var(--blue); transform-origin: left center; }
.clock.low .clock-fill { background: var(--red); }
.guess-row { display: flex; gap: 8px; }
.field { flex: 1; min-width: 0; position: relative; }
.guess-input {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  background: var(--note);
  color: var(--ink);
}
.guess-input::placeholder { color: var(--ink-2); }
.guess-input:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 28%, transparent); }
.hint-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; }
.status { font-size: var(--step--1); font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.status.low, .status.err { color: var(--red); }
.linkish {
  margin-left: auto;
  background: none; border: 0; padding: 4px 0;
  color: var(--blue); font-weight: 700; font-size: var(--step--1);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.suggest {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(100% + 6px);
  max-height: min(264px, 42vh);
  overflow-y: auto;
  padding: 4px;
  margin: 0;
  list-style: none;
  background: var(--note);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.suggest li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.suggest li[aria-selected="true"] { background: var(--paper); }
.suggest .flag { font-size: 1.25rem; }
.suggest .alt { color: var(--ink-2); font-size: var(--step--1); }

.panel { border-top: 1px solid var(--rule); padding: 16px; background: var(--surface); display: grid; gap: 12px; }
.panel .rules { padding-left: 1.1em; display: grid; gap: 4px; color: var(--ink-2); }
.panel .rules b { color: var(--ink); }
.panel-row { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
.panel-note { color: var(--ink-2); font-size: var(--step--1); }
.pool-pick { display: inline-flex; align-items: center; gap: 8px; }
.pool-pick label { color: var(--ink-2); font-size: var(--step--1); font-weight: 700; }
.select-wrap { position: relative; display: inline-block; max-width: 100%; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px; top: 50%;
  width: 7px; height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--rule);
  background: var(--note);
  color: var(--ink);
  font-weight: 700;
  padding: 9px 34px 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  max-width: 100%;
}
.loading { color: var(--ink-2); }
.text-btn {
  background: none; border: 0; padding: 0;
  color: var(--blue); font-weight: 700; font-size: inherit;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

.result { grid-template-columns: auto minmax(0, 1fr); gap: 14px 20px; align-items: center; }
.result-copy { min-width: 0; display: grid; gap: 4px; }
.result-copy h2 { font-family: var(--font-display); font-weight: 800; font-size: var(--step-2); line-height: 1.1; text-wrap: balance; }
.result-copy p { color: var(--ink-2); }
.result .actions, .result .panel-note, .result .panel-row { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 430px) {
  .result { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .result .stamp { justify-self: center; margin-block: 4px; }
  .actions .btn { flex: 1; }
  .pool-pick label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Sheets and toast ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: var(--scrim); }
.sheet {
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  overflow: auto;
  padding: 20px 20px 18px;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.sheet h2 { font-family: var(--font-display); font-weight: 800; font-size: var(--step-2); line-height: 1.1; }
.sheet h3 { font-size: var(--step-0); }
.sheet ul { padding-left: 1.2em; display: grid; gap: 8px; }
.sheet .muted { color: var(--ink-2); font-size: var(--step--1); }
.sheet .btn { justify-self: start; }
.found-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.big { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.regions { list-style: none; padding: 0 !important; display: grid; gap: 6px; margin-top: 14px; }
.regions li { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) 3.4rem; align-items: center; gap: 10px; font-size: var(--step--1); }
.regions .track { height: 8px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.regions .track i { display: block; height: 100%; background: var(--green); }
.regions .n { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.figures div { display: grid; justify-items: center; text-align: center; gap: 2px; }
.fig { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.cap { font-size: var(--step--1); color: var(--ink-2); }
.stamps-title { margin: 16px 0 8px; }
.stamps { display: flex; flex-wrap: wrap; gap: 4px; font-size: 1.5rem; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  box-shadow: var(--shadow);
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  overflow-wrap: anywhere;
}

/* ---------- Play together (home page) ---------- */
.together { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 56px); align-items: center; }
.together-copy { display: grid; gap: 12px; align-content: start; }
.together-copy .section-title { margin-bottom: 4px; }
.together-copy p { color: var(--ink-2); max-width: 34rem; }
.together-copy .hero-actions { margin-top: 8px; }
.together-demo { display: grid; gap: 12px; }
.demo-scores .row { pointer-events: none; }
@media (max-width: 860px) { .together { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Rooms ---------- */
body[data-room="game"] { height: 100%; }
.room { min-height: 100%; }
body[data-room="game"] .room { height: 100%; }
.room-app { max-width: 1080px; margin-inline: auto; padding-block: 12px 32px; display: flex; flex-direction: column; gap: 14px; }
body[data-room="game"] .room-app { height: 100%; min-height: 560px; padding-block: 12px; }
.conn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid currentColor; color: var(--amber);
  font-size: var(--step--1); font-weight: 700; white-space: nowrap;
}
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1s infinite ease-in-out; }
.eyebrow { font-size: var(--step--1); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.room-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 78%;
  font-size: clamp(2.1rem, 1.5rem + 2.6vw, 3.3rem);
  line-height: .95;
  letter-spacing: -.015em;
  text-wrap: balance;
}
.muted { color: var(--ink-2); }

/* Code, nickname, loading and "closed" cards */
.room-card { width: 100%; max-width: 560px; margin: clamp(20px, 7vh, 72px) auto 0; display: grid; gap: 14px; }
.room-card .lead { max-width: none; }
.join-form { display: flex; gap: 10px; margin-top: 6px; }
.big-input {
  flex: 1; min-width: 0;
  font-size: 1.25rem;
  padding: 13px 16px;
  border: 1.5px solid var(--rule);
  border-radius: 14px;
  background: var(--note);
  color: var(--ink);
}
.big-input::placeholder { color: var(--ink-2); opacity: .7; }
.big-input:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 28%, transparent); }
.code-input { font-family: var(--font-display); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.form-err { color: var(--red); font-weight: 700; min-height: 1.5em; }
.form-err:empty { min-height: 0; }
.room-alt { color: var(--ink-2); }
@media (max-width: 430px) {
  .join-form { flex-direction: column; }
}

/* The room-code board: big enough to read from the back of a classroom */
.board {
  background: var(--board-bg);
  color: #fff;
  border-radius: 18px;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 3vw, 32px);
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  container-type: inline-size;
  box-shadow: var(--shadow);
}
.board-label { font-family: var(--font-display); font-size: var(--step--1); font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: var(--board-dim); }
/* Tiles fill the board: --n is the number of characters in the code. */
.tiles { --n: 9; display: flex; justify-content: center; gap: .1em; font-size: 1.75rem; font-size: min(6rem, calc(84cqi / (var(--n) * 1.1))); }
.tile {
  width: 1.05em; height: 1.36em;
  display: grid; place-items: center;
  border-radius: .12em;
  background: linear-gradient(var(--board-tile) 0 calc(50% - 1px), var(--board-bg) calc(50% - 1px) calc(50% + 1px), var(--board-tile) calc(50% + 1px));
  color: var(--board-ink);
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1;
}
.tile.gap { width: .38em; background: none; }
.board-how { color: var(--board-dim); }
.board-how b { color: #fff; }
.board-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn-board { background: transparent; color: var(--board-ink); border-color: color-mix(in srgb, var(--board-ink) 50%, transparent); }
.btn-board:hover { border-color: var(--board-ink); }
.board-steps { list-style: none; margin: 10px 0 0; padding: 18px 0 0; border-top: 1px solid var(--board-tile); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; counter-reset: step; text-align: left; color: var(--board-dim); font-size: var(--step--1); }
.board-steps li { counter-increment: step; display: grid; gap: 4px; align-content: start; }
.board-steps li::before { content: counter(step); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--board-ink); color: var(--board-bg); font-family: var(--font-display); font-weight: 800; }
.board-steps b { color: #fff; }
@media (max-width: 860px) { .board-steps { display: none; } }
.board.mini { padding: 18px 16px; }
.board.mini .tiles { font-size: clamp(1.5rem, 1rem + 2vw, 2.2rem); }

.lobby { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.lobby-side { display: grid; gap: 14px; align-content: start; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.side-head h2, .final-box h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; line-height: 1.1; }
@media (max-width: 860px) { .lobby { grid-template-columns: minmax(0, 1fr); } }

/* Player lists: lobby roster and scores */
.roster, .scores, .trips { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px;
  padding: 7px 10px 7px 12px;
  border-radius: 12px;
  background: var(--note);
  border: 1px solid var(--rule);
}
.row.me { border-color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.row.off { opacity: .55; }
.row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.row.off .dot { background: var(--skip); }
.rank { min-width: 1.4rem; font-family: var(--font-display); font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pname { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { flex: none; font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-2); padding: 2px 7px; border-radius: 999px; border: 1px solid var(--rule); }
.tag.host { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.pstat { flex: none; font-size: var(--step--1); font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.pstat.found { color: var(--green); }
.pstat.found::before { content: "✓ "; }
.pstat.thinking::after { content: "…"; }
.pts { flex: none; min-width: 2ch; text-align: right; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.kick {
  flex: none;
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 999px;
  border: 1.5px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  font-weight: 800; line-height: 1;
  cursor: pointer;
}
.kick:hover { border-color: var(--red); color: var(--red); }
.kick.armed { border-color: var(--red); background: var(--red); color: #fff; font-size: var(--step--1); }

.controls { display: grid; gap: 12px; }
.setup { display: grid; gap: 14px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--rule); }
.setup-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; }
.setup-label { font-weight: 700; color: var(--ink-2); font-size: var(--step--1); }
.setup .btn-lg { width: 100%; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--paper); border: 1.5px solid var(--rule); }
.seg button { min-width: 3.1rem; padding: 7px 12px; border: 0; border-radius: 9px; background: transparent; font-weight: 800; cursor: pointer; font-variant-numeric: tabular-nums; }
.seg button[aria-checked="true"] { background: var(--blue); color: var(--on-blue); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 700; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.check small { display: block; font-weight: 400; color: var(--ink-2); font-size: var(--step--1); }
.waiting { padding: 14px 16px; border-radius: 14px; border: 1.5px dashed var(--rule); color: var(--ink); }
.waiting .muted { display: block; font-size: var(--step--1); margin-top: 2px; }
.leave-btn { justify-self: start; color: var(--ink-2); font-size: var(--step--1); }

/* The game: the hint chat on the left, scores on the right */
.room-game { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.room-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-progress { font-family: var(--font-display); font-weight: 800; font-stretch: 85%; font-size: var(--step-2); line-height: 1.1; }
.chip-btn {
  display: none; align-items: center; gap: 6px;
  font-weight: 700; font-size: var(--step--1);
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--rule); color: var(--ink-2); cursor: pointer;
}
.chip-btn b { color: var(--ink); font-variant-numeric: tabular-nums; }
.room-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.room-body .envelope { min-height: 0; }
.scoreboard { min-height: 0; overflow-y: auto; display: grid; gap: 10px; align-content: start; padding: 2px; }
.watchers { font-size: var(--step--1); color: var(--ink-2); }
@media (max-width: 860px) {
  .room-body { grid-template-columns: minmax(0, 1fr); }
  .scoreboard { display: none; }
  .chip-btn { display: inline-flex; }
}
.dock { position: relative; border-top: 1px solid var(--rule); background: var(--surface); }
.dock .clock { top: -1px; }
.dock .composer { border-top: 0; padding-bottom: 4px; }
.dock-row { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; flex-wrap: wrap; min-height: 34px; padding: 4px 14px 10px; }
.dock .composer[hidden] + .dock-row { padding-top: 14px; }
.others { font-size: var(--step--1); font-weight: 700; color: var(--ink-2); margin-left: auto; font-variant-numeric: tabular-nums; }
.others.flash { color: var(--green); }
.guess-input:disabled { opacity: .55; }
.msg.sys { align-self: center; max-width: 92%; padding: 2px 8px; color: var(--ink-2); font-size: var(--step--1); font-weight: 700; text-align: center; }
.msg.sys.warn { color: var(--amber); }
.reveal { padding: 4px 14px 14px; display: grid; gap: 10px; justify-items: start; }
.reveal-top { display: flex; align-items: center; gap: 12px; }
.reveal-top .flag { font-size: 2.6rem; }
.reveal h2 { font-family: var(--font-display); font-weight: 800; font-size: var(--step-2); line-height: 1.05; }
.reveal-top p { color: var(--ink-2); font-size: var(--step--1); font-weight: 700; }
.finders { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.finders li { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--rule); background: var(--note); font-size: var(--step--1); color: var(--ink-2); }
.finders li b { color: var(--ink); }
.finders li.first { border-color: var(--lit); box-shadow: inset 0 0 0 1px var(--lit); }

/* Running the game on a big screen: bigger text, no guess box */
.room-app.watching .chat .msg { font-size: 1.3rem; max-width: min(92%, 44rem); }
.room-app.watching .chat .msg .label { font-size: .95rem; }
.room-app.watching .dock-row .status, .room-app.watching .others { font-size: var(--step-1); }
.room-app.watching .room-progress { font-size: var(--step-3); }

/* Final scores */
.final { display: grid; gap: 22px; }
.final-head { display: grid; gap: 10px; }
.podium { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; gap: 12px; align-items: flex-end; max-width: 720px; }
.podium li { flex: 0 1 220px; display: grid; justify-items: center; gap: 6px; min-width: 0; padding: 18px 10px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--rule); text-align: center; }
.podium li.p1 { order: 2; padding-block: 30px 20px; border: 2px solid var(--lit); box-shadow: var(--shadow); }
.podium li.p2 { order: 1; }
.podium li.p3 { order: 3; }
.podium .place { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; background: var(--die-bg); color: var(--die-dot); }
.podium .pname { width: 100%; text-align: center; font-family: var(--font-display); font-size: 1.15rem; }
.podium .pts { min-width: 0; font-family: var(--font-body); font-size: var(--step--1); color: var(--ink-2); font-weight: 700; }
.podium li.me .pname { color: var(--blue); }
.final-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.final-box { display: grid; gap: 10px; min-width: 0; }
.trips li { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 7px 12px; border-radius: 12px; background: var(--note); border: 1px solid var(--rule); }
.trips .flag { font-size: 1.4rem; }
@media (max-width: 960px) { .final-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .final-next { grid-column: 1 / -1; } }
@media (max-width: 640px) { .final-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 404 ---------- */
.lost-page { max-width: 640px; margin-inline: auto; padding-block: 18px 40px; display: grid; gap: 28px; }
.lost-page h1 { font-family: var(--font-display); font-weight: 800; font-stretch: 78%; font-size: var(--step-4); line-height: .95; }

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