/* Poppins, Latin letters only, kept with the page so it looks the same offline (licence: fonts/OFL.txt) */
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("fonts/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("fonts/poppins-600.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url("fonts/poppins-700.woff2") format("woff2"); }

/* Colours from the Edreate palette (edreate/static/css/global.css), plus clear red/yellow/green marks */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #0c0c0c;
  --muted: #6b7280;
  --line: #e7e7e7;
  --key: #e7e7e7;
  --heading: #4531cc;
  --accent: #4531cc;
  --in: #16a34a;
  --out: #dc2626;
  --unsure: #facc15;
  --error: #dc2626;
}

/* The advanced helper switches to dark */
body.dark {
  color-scheme: dark;
  --bg: #121212;
  --fg: #f2f2f2;
  --muted: #9ca3af;
  --line: #2e2e30;
  --key: #3a3a3c;
  --heading: #a497ff;
  --error: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 "Poppins", system-ui, -apple-system, sans-serif;
}

main { max-width: 480px; margin: 0 auto; padding: 12px 16px 48px; }

/* Header: logo, mode, New game on one line */
header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }

/* Logo: WORD as a 2×2 block of tiles in the four marking colours; tapping it opens the menu */
.logo { display: grid; grid-template-columns: repeat(2, 20px); gap: 2px; flex: none; margin: 0; padding: 0; border: 0; background: none; }
.logo b {
  display: grid;
  place-items: center;
  height: 20px;
  border-radius: 4px;
  font-size: .7rem;
  line-height: 1;
}
.logo b:not([class]) { background: var(--key); color: var(--fg); }

/* Mode: a soft accent pill with its own chevron */
.mode {
  flex: 0 1 auto;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 26px 8px 12px;
  border: 0;
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg))
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234531cc' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 10px center / 10px;
  color: var(--heading);
  font-size: .85rem;
  font-weight: 600;
  text-overflow: ellipsis;
}
.mode:focus-visible, .new-game:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
body.dark .mode {
  background-color: color-mix(in srgb, var(--heading) 18%, var(--bg));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a497ff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* New game: an outlined pill with a restart arrow, as tall as the mode pill */
.new-game {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 6px 14px 6px 11px;
  border: 2px solid color-mix(in srgb, var(--heading) 30%, var(--bg));
  border-radius: 20px;
  background: var(--bg);
  color: var(--heading);
  font-size: .85rem;
  font-weight: 600;
  transition: background-color .15s;
}
.new-game svg { width: 15px; height: 15px; }
.new-game:active:not(:disabled) { background: color-mix(in srgb, var(--heading) 14%, var(--bg)); }
/* A group game's Deal, while a game is on */
.new-game:disabled { opacity: .4; cursor: default; }
/* On narrow phones it says just "New", so the mode name isn't cut off */
@media (max-width: 420px) { .new-game .wide { display: none; } }
/* Time since your last guess: centred under the header, digits that don't jiggle as they tick */
.timer { margin: -6px 0 10px; text-align: center; font-size: 1.1rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Duel clock: one quiet line once your own clock has run out */
.times-up { margin: -4px 0 10px; text-align: center; font-size: .85rem; font-weight: 600; color: var(--out); }
h2 { margin: 28px 0 8px; font-size: .95rem; }
/* "Your guesses" on the left, the guess count and game time on the right of the same line */
.guesses-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin: 28px 0 8px; }
.guesses-head h2 { margin: 0; }
.game-stats { display: flex; gap: 16px; margin: 0; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.game-stats[hidden] { display: none; }
.game-stats b { color: var(--fg); font-weight: 600; }
/* Past the game's time limit both timers stop, in red */
.timer.over, .game-stats.over #game-time { color: var(--out); }

button, select {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pill {
  padding: 6px 16px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: transparent;
  font-weight: 600;
}

.label { margin: 14px 0 8px; font-size: .9rem; font-weight: 600; text-align: center; }
.progress { margin: 0 0 12px; text-align: center; font-size: .9rem; font-weight: 600; color: var(--heading); }
.msg { min-height: 1.4em; margin: 4px 0; text-align: center; font-size: .9rem; font-weight: 600; color: var(--error); }
.msg.calm { color: var(--muted); }

/* The guess: a slot a letter filled from the page's keyboard, the next one to fill underlined */
.slots { display: flex; justify-content: center; gap: 12px; margin: 0; }
.slots span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 46px;
  border-bottom: 3px solid var(--line);
  font-size: 1.6rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: border-color .15s;
}
.slots span.next { border-color: var(--heading); }

/* Secret word entry */
.secret input {
  flex: 1;
  min-width: 0;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .3em;
}
.secret input:focus { outline: none; border-color: var(--accent); }
.secret input::placeholder { color: var(--muted); font-weight: 600; letter-spacing: normal; text-transform: none; }

.secret { display: flex; gap: 8px; }

/* Score buttons stay dim until the guess has 4 letters */
.counts { display: flex; gap: 8px; }
.counts button {
  flex: 1;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 1.12rem;
  font-weight: 700;
  transition: opacity .15s;
}
.counts[hidden] { display: none; }
.counts:not(.ready) button { opacity: .35; }
/* The group game's Guess button has no label above it, so it keeps its own distance from the slots. It says whose turn
   it is: grey on someone else's, outlined on yours while you type, filled once the guess can go. */
#guess-row { margin-top: 24px; }
#guess-row:not(.ready) button { opacity: 1; background: var(--key); color: var(--muted); }
#guess-row.mine:not(.ready) button { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); color: var(--heading); }
.counts button:active { filter: brightness(.85); }

/* The keyboard types the guess; its keys and the guess list's tiles share the same colours */
.keyboard { user-select: none; -webkit-user-select: none; }
.row { display: flex; gap: 4px; margin-bottom: 6px; }
.row:nth-child(2) { padding: 0 5%; }
.row:nth-child(3) { padding-left: 15%; }

.key, .tile {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--key);
  font-weight: 700;
  text-transform: uppercase;
}
.key { flex: 1 1 0; min-width: 0; height: 56px; font-size: 1.2rem; }
.key:active { filter: brightness(.85); }
.key.back { flex-grow: 1.5; display: grid; place-items: center; }
.key.back svg { width: 24px; height: 24px; }
.tile { width: 40px; height: 40px; font-size: 1.2rem; }

.in { background: var(--in); color: #fff; }
.out { background: var(--out); color: #fff; }
.unsure { background: var(--unsure); color: #0c0c0c; }

/* A helper-settled letter gets a dot: its colour can't be changed, though its key still types */
.locked::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
  margin: 6px 0 0;
  font-size: .8rem;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
/* Clear: undoes your own key colours, dim when there are none */
.clear {
  display: block;
  margin: 12px auto 0;
  padding: 8px 28px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: transparent;
  color: var(--heading);
  font-size: .95rem;
  font-weight: 600;
}
.clear:disabled { opacity: .4; cursor: default; }
.clear:active:not(:disabled) { background: var(--line); }

/* Guess list: newest first, the score in a circle */
.notes { margin: 0; padding: 0; list-style: none; }
.notes li { display: flex; align-items: center; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
/* A 5-letter group game's guesses have narrower tiles, so a row still fits beside the player's name */
.notes li.five .tile { width: 34px; }
.notes .empty { padding: 12px 0; color: var(--muted); font-size: .9rem; }
/* When in the game it was noted: small and quiet, pushed right next to the score */
.notes .at { margin: 0 6px 0 auto; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.notes .at + .score { margin-left: 0; }
.score {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 2px solid var(--heading);
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 700;
}
/* In a group game: who made the guess, your own rows tinted, and a winning guess kept hidden from the others until the
   game is over, then its score in green */
.notes .who { max-width: 7em; margin-left: 8px; overflow: hidden; font-size: .75rem; font-weight: 600; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.notes li.mine { margin: 0 -8px; padding: 6px 8px; background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }
.notes li.mine .who { color: var(--heading); }
.notes li.won .score { border-color: var(--in); background: var(--in); color: #fff; }
.notes .got { display: grid; place-items: center; height: 40px; padding: 0 12px; border-radius: 6px; background: color-mix(in srgb, var(--in) 14%, var(--bg)); color: var(--in); font-size: .85rem; font-weight: 700; }
.delete { width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 1.4rem; }

/* Menu: a drawer from the left, 80% of the screen; tap outside or × to close */
.menu {
  width: 80%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0 24px 24px 0;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 8px 0 40px rgb(0 0 0 / .25);
  overflow-y: auto;
  overscroll-behavior: contain; /* scrolling the drawer doesn't scroll the page behind it */
}
.menu[open] { animation: slide-in .25s cubic-bezier(.2, .8, .2, 1); }
.menu::backdrop, .sheet::backdrop, .ask::backdrop { background: rgb(0 0 0 / .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
@keyframes slide-in { from { transform: translateX(-100%); } }

.menu-body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom)) 20px;
  outline: none;
}
.menu-head { display: flex; align-items: center; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.menu h2 { flex: 1; margin: 0; font-size: 1.1rem; color: var(--heading); }
.close {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--key);
  color: var(--fg);
  font-size: 1.3rem;
  line-height: 1;
}
.close:active { filter: brightness(.9); }

/* Small section labels */
.menu-label, .view-label {
  margin: 22px 0 8px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* "Now playing": the way you play and how it's going, with a button to its sheet when it's online */
.now { display: grid; gap: 2px; margin-top: 16px; padding: 14px; border-radius: 16px; background: color-mix(in srgb, var(--heading) 8%, var(--bg)); }
.now-label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.now-label .dot[hidden] { display: none; }
.now h3 { margin: 4px 0 0; font-size: 1.05rem; }
#now-lines { display: grid; margin: 0; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
#now-open { margin-top: 10px; }
#now-open[hidden] { display: none; }

/* "Switch how you play": one row a way, the chosen one's ring filled. Real radios, hidden but still focusable. */
.play-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.play-row:last-child { border-bottom: 0; }
.play-row input { position: absolute; opacity: 0; pointer-events: none; }
.play-row:has(:focus-visible) { outline: 2px solid var(--heading); outline-offset: 2px; }
.play-row .radio { flex: none; width: 20px; height: 20px; border: 2px solid var(--line); border-radius: 50%; }
.play-row :checked + .radio { border: 6px solid var(--accent); }
.play-row small { margin-left: auto; font-size: .75rem; font-weight: 400; color: var(--muted); }

/* How to play and Learn words: a row each that opens its view */
.menu-links { display: grid; gap: 8px; margin-top: 18px; }
.menu-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--heading) 8%, var(--bg)); color: var(--fg); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.menu-link:active { background: color-mix(in srgb, var(--heading) 14%, var(--bg)); }
.menu-link:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
.menu-link svg { flex: none; width: 20px; height: 20px; color: var(--heading); }
.menu-link span { font-size: .8rem; color: var(--muted); }
.menu-link b { display: block; font-size: .95rem; color: var(--fg); }
.menu-link::after { content: ""; flex: none; width: 7px; height: 7px; margin: 0 4px 0 auto; border-top: 2.5px solid var(--muted); border-right: 2.5px solid var(--muted); transform: rotate(45deg); }

.menu-foot { margin: auto 0 0; padding-top: 24px; text-align: center; font-size: .8rem; color: var(--muted); }
.menu-foot p { margin: 0; }
.menu-foot p + p { margin-top: 6px; }
/* The release version, stamped in on deploy; a local preview shows dev */
.version { display: block; margin-top: 4px; font-size: .7rem; }

/* Duel clock: the clocks in a dock pinned to the bottom, like a real chess clock. The side that's ticking grows
   and fills in, so whose turn it is shows from across the table. Its background spans the screen, its sides stay
   within main's column, and the page gets room underneath so the secret word scrolls clear of it. */
body.docked main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  gap: 6px;
  padding: 8px max(10px, (100% - 480px) / 2) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
  box-shadow: 0 -6px 20px rgb(0 0 0 / .06);
  font-variant-numeric: tabular-nums;
}
.dock[hidden] { display: none; }
.dock .side {
  flex: 1;
  min-width: 0;
  display: grid;
  justify-items: center;
  padding: 6px 4px;
  border-radius: 14px;
  background: var(--key);
  color: var(--muted);
  transition: flex .2s;
}
.dock .side span { max-width: 100%; overflow: hidden; font-size: .7rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dock .side b { font-size: 1.25rem; line-height: 1.2; }
.dock .side.running { flex: 1.6; background: var(--accent); color: #fff; }
.dock .side.running b { font-size: 2rem; }
.dock .side.over { background: color-mix(in srgb, var(--out) 12%, var(--bg)); color: var(--out); }
.dock .side.won { background: var(--in); color: #fff; }
/* Waiting with nobody there: both sides dimmed; in a group game, a player who dropped out */
.dock .side.idle { opacity: .55; }
/* A group game's 3 or 4 sides and the menu button still fit a 360 px phone */
.dock.many .side b { font-size: 1.1rem; }
.dock.many .side.running b { font-size: 1.6rem; }
/* The middle: the clock's settings, with the connection dot under the icon */
.dock .mid { flex: none; display: grid; place-items: center; width: 40px; padding: 0; border: 0; border-radius: 14px; background: none; color: var(--muted); }
/* A group game's dock with no clocks, for a phone that couldn't join: the button keeps its place and its height */
.dock .mid:first-child, .dock .note + .mid { min-height: 48px; margin-left: auto; }
.dock .mid svg { width: 20px; height: 20px; }
.dock .mid .dot { margin-top: -4px; }
.dock .mid:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
/* A small label on the dock's top edge: waiting, joined, dropped out */
.dock .note {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.dock .note[hidden] { display: none; }
.dock .note.warn { border-color: color-mix(in srgb, var(--out) 40%, var(--bg)); color: var(--out); }
/* The connection dot: hollow while waiting (pulsing as it looks), green once the other phone is there */
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border: 2px solid var(--muted); border-radius: 50%; }
.dot.live { border-color: var(--in); background: var(--in); }
@media (prefers-reduced-motion: no-preference) {
  .dot.wait { animation: pulse 1.2s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: .25; } }

/* Duel clock: the sheet that drops from the top, centred and as wide as the page; tap outside or × to close */
.sheet {
  inset: 0 0 auto;
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0 0 24px 24px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 10px 40px rgb(0 0 0 / .25);
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: drop .25s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes drop { from { transform: translateY(-100%); } }
.sheet-body { display: grid; gap: 14px; padding: max(22px, env(safe-area-inset-top)) 18px 18px; outline: none; }
.sheet-body [hidden] { display: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet h2 { flex: 1; margin: 0; font-size: 1.1rem; color: var(--heading); }
.hint { margin: 0; font-size: .78rem; color: var(--muted); }
#duel-room-hint, #group-room-hint { margin-top: -8px; } /* it belongs to the Room field above */
#duel-invite b, #group-invite b { color: var(--heading); }
/* The room joined, under the group sheet's title, so phones can check they're in the same one */
.in-room { margin: -4px 0 0; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.in-room[hidden] { display: none; }
.in-room b { color: var(--heading); }
.hint.foot { text-align: center; }
/* The room's wins: a row a player, most wins first, this phone's player in the accent colour */
.wins { display: grid; gap: 6px; }
.wins > span { font-size: .75rem; font-weight: 600; color: var(--muted); }
.wins > .hint { font-weight: 400; text-align: center; }
.wins ol { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.wins ol:empty { display: none; }
.wins li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--key); font-weight: 600; }
.wins li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wins li b { font-variant-numeric: tabular-nums; color: var(--heading); }
.wins li em { font-size: .75rem; font-style: normal; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wins li.me { box-shadow: inset 0 0 0 2px var(--accent); }
/* The group game's wins fold away under their label */
details.wins { display: block; }
details.wins > * + * { margin-top: 6px; }
.wins > summary { font-size: .75rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.wins > summary:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
/* The group game's players: a dot for whether they're here, the name, and how they're doing on the right */
.players li em { flex: none; font-size: .8rem; font-style: normal; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.players li.turn em { color: var(--heading); }
.players li.out { opacity: .6; }
/* A game's turn order */
.players .seat { flex: none; width: 1.2em; font-size: .8rem; font-weight: 700; color: var(--muted); text-align: center; }
.err { margin: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--out) 9%, var(--bg)); color: var(--error); font-size: .85rem; font-weight: 600; }

/* Fields: a small label over a rounded box */
.field { display: grid; gap: 4px; }
.field > span, .field > label { font-size: .75rem; font-weight: 600; color: var(--muted); }
.field .opt { font-weight: 400; }
.field input { width: 100%; padding: 9px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: inherit; font: inherit; font-weight: 600; }
.field input:focus { outline: none; border-color: var(--accent); }
.field input::placeholder { color: var(--muted); font-weight: 400; }
.field small.hint { display: block; }

/* Minutes each, as chips; the lit one is the clocks' minutes */
.chips { display: flex; gap: 6px; }
.chips button { flex: 1; min-width: 0; height: 40px; padding: 0; border: 2px solid var(--line); border-radius: 20px; background: var(--bg); font-size: .9rem; font-weight: 600; }
.chips button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--heading); }

.primary { width: 100%; padding: 12px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 1rem; font-weight: 700; }
.primary:active:not(:disabled) { filter: brightness(.85); }
.primary:disabled { opacity: .4; cursor: default; }
.primary.danger { background: var(--error); }
.secondary { min-height: 40px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 20px; background: var(--bg); color: var(--heading); font-size: .85rem; font-weight: 600; }
.secondary:active { background: var(--line); }
.secondary.danger { color: var(--error); }
/* Side by side: a field and its button, or two buttons sharing the width */
.row-flex { display: flex; gap: 8px; align-items: center; }
.row-flex > input, .row-flex > .grow { flex: 1; min-width: 0; }
.row-flex .secondary { white-space: nowrap; }
.sheet button:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }

/* Waiting: the room in big letters, to read out across the table */
.wait-box { display: grid; justify-items: center; gap: 8px; padding: 16px; border-radius: 16px; background: color-mix(in srgb, var(--heading) 8%, var(--bg)); text-align: center; }
.wait-box .waiting { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.wait-box .room-big { font-size: 1.4rem; font-weight: 700; color: var(--heading); letter-spacing: .02em; overflow-wrap: anywhere; }

/* Connected: who's there, with the room on the right; red while they're away, grey once they've left */
.live-line { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--in) 10%, var(--bg)); font-size: .9rem; font-weight: 600; }
.live-line .room { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 400; white-space: nowrap; }
.live-line.dropped { background: color-mix(in srgb, var(--out) 9%, var(--bg)); color: var(--error); }
.live-line.left { background: color-mix(in srgb, var(--heading) 8%, var(--bg)); color: var(--muted); }

/* How to play and Learn words: each a view that takes the game's place, dock and all, in the same column */
body.viewing main, body.viewing .dock { display: none; }
.view { display: grid; gap: 12px; max-width: 480px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px 48px; }
.view[hidden], .view [hidden] { display: none; }
.view p { margin: 0; }
.view-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.view-head h2 { margin: 0; font-size: 1.1rem; color: var(--heading); }
.view-head .close { display: grid; place-items: center; }
.view-head .close svg { width: 18px; height: 18px; }
.view-head .close:focus-visible, .view button:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
.view-label { margin: 16px 0 0; }

/* How to play: the rules in numbered circles, the example of a score, and the rest */
.rules { display: grid; gap: 10px; margin: 4px 0 0; padding: 0; list-style: none; counter-reset: rule; }
.rules li { display: flex; gap: 10px; counter-increment: rule; }
.rules li::before {
  content: counter(rule);
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--heading) 14%, var(--bg));
  color: var(--heading);
  font-size: .75rem;
  font-weight: 700;
}
[data-rules] { display: grid; gap: 12px; margin-top: 4px; }
.example { padding: 14px; border-radius: 16px; background: color-mix(in srgb, var(--heading) 8%, var(--bg)); }
.example-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.example-label { width: 46px; font-size: .75rem; font-weight: 600; color: var(--muted); }
.tiles { display: flex; gap: 4px; }
.tiles b, .marks b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: .95rem;
}
.tiles b:not([class]) { background: var(--key); }
.tiles .again { box-shadow: inset 0 0 0 2px var(--line); color: var(--muted); }
.example .score { width: 30px; height: 30px; font-size: .95rem; }
.example p { margin: 4px 0 0; font-size: .85rem; color: var(--muted); }
.marks { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .9rem; }
.marks span { display: flex; align-items: center; gap: 6px; }
.marks b { width: 24px; height: 24px; font-size: .8rem; }
.helpers { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: .95rem; }
.helpers dt { font-weight: 600; color: var(--heading); }
.helpers dd { margin: 0; }
[data-count] { color: var(--heading); }

/* Learn words' look-up: the word as tiles, its meaning, and whether the dictionary knows it */
.lookup { display: grid; gap: 10px; padding: 16px; border-radius: 16px; background: color-mix(in srgb, var(--heading) 8%, var(--bg)); }
.lookup .ask-word { justify-content: flex-start; }
.lookup .ask-word b { background: var(--bg); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--heading) 18%, var(--bg)); }
.verdict { font-size: .8rem; font-weight: 600; color: color-mix(in srgb, var(--in) 70%, var(--fg)); }
.verdict.no { color: var(--error); }
.view .field input { text-transform: uppercase; letter-spacing: .1em; }
.view .field input::placeholder { text-transform: none; letter-spacing: normal; }

/* Learn words' letter search: how many words have the letters, and the words, in a box that scrolls */
.letter-words { display: flex; flex-wrap: wrap; gap: 6px; max-height: 15rem; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.letter-words li { padding: 4px 10px; border-radius: 8px; background: var(--bg); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--heading); }

/* The ten words, each over its meaning; each new ten fades in */
.learn-words { margin: 0; }
.learn-words div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.learn-words div:last-child { border-bottom: 0; }
.learn-words dt { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--heading); }
.learn-words dd { margin: 2px 0 0; font-size: .9rem; }
@media (prefers-reduced-motion: no-preference) {
  .learn-words div { animation: rise .3s cubic-bezier(.2, .8, .2, 1) backwards; }
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.new-words { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 4px; }
.new-words svg { width: 18px; height: 18px; }

/* Questions and notes: a small card in the middle of the screen, in place of the browser's own */
.ask { width: min(340px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 20px; background: var(--bg); color: var(--fg); box-shadow: 0 10px 40px rgb(0 0 0 / .25); }
.ask form { display: grid; gap: 16px; margin: 0; padding: 22px 18px 18px; }
.ask p { margin: 0; text-align: center; font-weight: 600; overflow-wrap: anywhere; }
.ask-word { display: flex; justify-content: center; gap: 6px; }
.ask-word[hidden], .ask [hidden] { display: none; }
.ask-word b {
  display: grid;
  place-items: center;
  width: 40px;
  height: 46px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--heading) 10%, var(--bg));
  color: var(--heading);
  font-size: 1.3rem;
  text-transform: uppercase;
}
.ask .ask-meaning { margin-top: -6px; color: var(--muted); font-weight: 400; font-size: .95rem; }
.ask button { min-height: 44px; border-radius: 14px; }
.ask button:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .ask[open] { animation: pop .15s ease-out; }
}
@keyframes pop { from { opacity: 0; transform: scale(.95); } }
