/* Doodli: everything visual. A sunny playroom: a cream wall with a faint crayon hatch, white paper
   pages pinned on it, crayon-orange for what you press, merle blue for what you read. Three shapes:
   a desk (the corgis on the left, the page in the middle, the guesses on the right; a Duel's two
   pages side by side), a tablet, and a phone (everything in one column, the page full width, and the
   page scrolls). The safe area of an installed iPhone app is padded exactly once, on .game and
   .screen; heights run 100% down from html, never 100vh.

   On an iPhone's home screen the app runs under iOS's own opaque status bar (index.html sets no
   apple-mobile-web-app-status-bar-style, so the default, tinted by theme-color): the page starts below
   it, and nothing ever sits under the clock (the company's rule, rules/policies/installable-web-apps
   in the corpus). The wall is a fixed layer (body::after), because iOS ignores
   background-attachment: fixed; the document never scrolls (#app is a fixed layer that scrolls
   inside itself), and in standalone html is at least a screen tall: both guard against iOS 26's
   launch-window bugs (WebKit 301108, 316008). */

:root {
  --wall: #fbefd6;
  --wall-2: #f6e2b8;
  --paper: #fffdf7;
  --card: #fffaf0;
  --line: #e6d2a6;
  --ink: #2b2420;
  --ink-dim: #7a6a55;
  --orange: #e8772e;
  --orange-2: #f39a4c;
  --orange-ink: #8a3a0c;
  --blue: #2f4f9e;
  --blue-soft: #dfe6f5;
  --green: #3f9b5a;
  --green-soft: #dcf0e0;
  --red: #d2462f;
  --gold: #f2b544;
  --radius: 14px;
  --bar: env(safe-area-inset-top);
  --chrome: 300px; /* what stands above and below a page on a desk, so the page fits the window */
  --sky: repeating-linear-gradient(-35deg, #00000000 0 14px, #e9cf9a1f 14px 16px), radial-gradient(1100px 600px at 10% -10%, #fff7e3 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, #f8dcae 0%, transparent 60%), linear-gradient(var(--wall), var(--wall));
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
html { background: var(--wall); }
@media (display-mode: standalone) {
  html { min-height: min(100lvh, calc(100% + env(safe-area-inset-top))); }
}
body {
  color: var(--ink);
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
#app { position: fixed; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; }
body::after { content: ""; position: fixed; inset: 0 0 auto; height: 100vh; height: 100lvh; z-index: -1; background: var(--sky); pointer-events: none; }
/* an install made before the opaque bar: a strip of the wall behind the status bar (0 tall elsewhere) */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: var(--bar); z-index: 20; background: var(--wall); transform: translateY(var(--pin, 0px)); pointer-events: none; }
html.scrolled:not(.no-strip) body::before { box-shadow: 0 1px 0 var(--line); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
.small { font-size: 0.85rem; color: var(--ink-dim); }
.hint { color: var(--ink-dim); font-size: 0.92rem; margin: 6px 0 0; }
[hidden] { display: none !important; }

/* ——— buttons ——— */
button, .btn, a.primary, a.ghost-btn {
  cursor: pointer;
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}
button:hover:not(:disabled), a.ghost-btn:hover { background: #fff3dc; border-color: #d9bd85; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.primary, a.primary {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  border-color: #c25f1d;
  color: #fff;
  font-weight: 800;
  padding: 11px 22px;
  box-shadow: 0 3px 0 #b5531a;
  text-shadow: 0 1px 0 #0003;
}
.primary:hover:not(:disabled) { background: linear-gradient(180deg, #f6a861, #ec8338); border-color: #c25f1d; }
.primary.danger { background: linear-gradient(180deg, #e86450, var(--red)); border-color: #9b2a19; box-shadow: 0 3px 0 #8f2414; }
.ghost-btn { background: transparent; }
.warn { color: var(--red); }
.link { background: none; border: none; color: var(--blue); text-decoration: underline; padding: 4px; }
.link:hover:not(:disabled) { background: none; }
.icon-btn { padding: 6px 10px; font-size: 1.15rem; background: transparent; border-color: transparent; position: relative; }
.badge { position: absolute; top: -2px; right: -2px; background: var(--red); color: #fff; font-size: 0.7rem; border-radius: 9px; padding: 1px 5px; font-weight: 800; }
input[type="text"], textarea, select { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; }
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px #e8772e33; }

/* ——— the screens before the game ——— */
.screen {
  min-height: 100%;
  padding: max(20px, var(--bar)) max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  justify-content: center;
}
.screen-inner { width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.screen h1 { font-size: clamp(2.2rem, 7vw, 3.4rem); letter-spacing: 0.01em; font-weight: 900; color: var(--orange); text-shadow: 2px 3px 0 #fff, 4px 6px 0 #e6d2a6; transform: rotate(-1.5deg); }
.tag { max-width: 560px; margin: 0; font-size: 1.05rem; }
.welcome, .join-code { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.welcome input { min-width: 200px; }
.join-code input { width: 6.5em; text-transform: uppercase; text-align: center; letter-spacing: 0.15em; }
.join-code label { color: var(--ink-dim); }
.whoami { display: flex; align-items: center; gap: 10px; }
.home-go { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.home-links { display: flex; gap: 14px; justify-content: center; }
.hero { width: min(100%, 560px); margin: 4px 0 0; }
.hero img { width: 100%; aspect-ratio: 960 / 536; object-fit: cover; border-radius: 18px; border: 6px solid #fff; box-shadow: 0 10px 30px #8a5a1a33; transform: rotate(0.8deg); display: block; }
ul.seats { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
ul.seats li { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px 4px 4px; }

/* the portraits */
.avatar {
  --size: 30px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  flex: none;
  display: inline-grid;
  place-items: center;
  background: var(--face, none) center / cover, var(--ground);
  color: #fff;
  font-weight: 800;
  font-size: calc(var(--size) * 0.45);
  box-shadow: 0 0 0 2px #fff, 0 1px 3px #0003;
}
.avatar[data-face] span { visibility: hidden; }

/* ——— the home tabs ——— */
.home-tabs { width: 100%; text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: 0 4px 0 #ead6ab; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tab { padding: 7px 12px; }
.tab[aria-selected="true"], .seg button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 800; }
.tab-count:not(:empty) { background: #0001; border-radius: 8px; padding: 0 6px; font-size: 0.8rem; }
.empty { color: var(--ink-dim); text-align: center; margin: 14px 0; }
.my-tables, .history, .ranks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.my-table { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.my-table.hot { outline: 3px solid var(--orange); }
.my-table-main { flex: 1; color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.my-table-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.my-code { font-family: ui-monospace, monospace; letter-spacing: 0.1em; }
.my-table-top .mode, .my-table-top em { font-size: 0.75rem; background: var(--wall); border-radius: 6px; padding: 1px 6px; font-style: normal; }
.state { color: var(--ink-dim); font-size: 0.9rem; }
.my-table.hot .state { color: var(--orange-ink); font-weight: 800; }
.my-table-corgis { display: flex; gap: 8px; align-items: center; color: var(--ink-dim); font-size: 0.85rem; min-width: 0; }
.my-table-corgis .names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-table-acts { display: flex; gap: 4px; }
.faces { display: inline-flex; }
.faces .avatar { --size: 22px; margin-right: -5px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; display: flex; flex-direction: column; }
.tile b { font-size: 1.5rem; color: var(--orange); }
.tile span { color: var(--ink-dim); font-size: 0.8rem; }
.moments { display: flex; flex-wrap: wrap; gap: 6px; }
.moments span { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; font-size: 0.85rem; }
.home-tabs h3 { margin: 12px 0 8px; font-size: 1rem; }
.past { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.past.won { background: #fff4d6; }
.place { width: 28px; text-align: center; font-size: 1.2rem; }
.past-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.past-meta { color: var(--ink-dim); font-size: 0.8rem; }
.fridge-btn { padding: 4px 8px; }
.board-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-bottom: 8px; }
.ranks li { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.ranks li.you { outline: 3px solid var(--orange); }
.rank { width: 28px; text-align: center; font-weight: 900; }
.rank-name { flex: 1; min-width: 0; }
.rank-name em { margin-left: 6px; font-size: 0.75rem; color: var(--orange-ink); font-style: normal; font-weight: 800; }
.rank-stats { color: var(--ink-dim); font-size: 0.85rem; text-align: right; }
.rank-stats b { color: var(--ink); }

/* ——— the lobby ——— */
.lobby .screen-inner { max-width: 900px; }
.invite { width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.table-code { display: flex; gap: 10px; align-items: baseline; }
.table-code b { font-family: ui-monospace, monospace; font-size: 1.9rem; letter-spacing: 0.2em; color: var(--orange); }
.linkrow { display: flex; gap: 6px; width: 100%; }
.linkrow input { flex: 1; min-width: 0; }
.people-box, .options, .lobby-chat { width: 100%; text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 4px 0 #ead6ab; }
.people { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.person { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 4px 12px 4px 4px; }
.person.away { opacity: 0.55; }
.person-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person em { font-style: normal; font-size: 0.72rem; background: var(--wall); border-radius: 6px; padding: 1px 6px; }
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-cards.read { grid-template-columns: minmax(0, 280px); }
.mode-card { flex-direction: column; align-items: stretch; text-align: left; padding: 8px; gap: 4px; border-radius: 14px; background: #fff; }
.mode-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; }
.mode-card b { font-size: 1.1rem; }
.mode-card small { color: var(--ink-dim); font-weight: 700; }
.mode-card .mode-blurb { font-size: 0.82rem; color: var(--ink-dim); }
.mode-card.on { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange); }
.mode-card.misfit:not(.on) { opacity: 0.6; }
.mode-card:disabled { opacity: 1; cursor: default; }
.opt { display: flex; flex-direction: column; gap: 6px; }
.opt-label { font-weight: 800; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.opt-label small { font-weight: 400; color: var(--ink-dim); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip small { opacity: 0.75; font-size: 0.75rem; }
.custom-words { width: 100%; resize: vertical; font-family: ui-monospace, monospace; }
.custom-acts { display: flex; gap: 10px; align-items: center; }
.opt-read { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.opt-read li { display: flex; justify-content: space-between; gap: 10px; }
.opt-read span { color: var(--ink-dim); }
.lobby-go { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lobby-go .deal { font-size: 1.2rem; padding: 13px 38px; }
.lobby-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ——— the chat ——— */
.chat { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
.chat-lines { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.drawer .chat-lines { max-height: none; flex: 1; }
.chat-lines li { display: flex; gap: 8px; align-items: flex-start; }
.chat-lines li.mine { flex-direction: row-reverse; }
.chat-bubble { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; display: flex; flex-direction: column; max-width: 80%; word-break: break-word; }
.chat-lines li.mine .chat-bubble { background: #fde3c8; border-color: #f2c595; }
.chat-bubble b { font-size: 0.78rem; color: var(--ink-dim); }
.chat-empty { color: var(--ink-dim); font-style: italic; }
.chat-quick { display: flex; gap: 4px; flex-wrap: wrap; }
.chat-quick button { font-size: 0.8rem; padding: 4px 8px; }
.chat-say { display: flex; gap: 6px; }
.chat-say input { flex: 1; min-width: 0; }

/* ——— the game ——— */
.game {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(8px, var(--bar)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  gap: 8px;
}
.topbar { display: flex; align-items: center; gap: 12px; min-height: 48px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--orange); text-decoration: none; font-weight: 900; font-size: 1.2rem; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.round-box { display: flex; align-items: center; gap: 10px; }
.round-no { font-weight: 800; }
.timer { font-variant-numeric: tabular-nums; font-weight: 900; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 3px 10px; min-width: 4.2em; text-align: center; }
.timer.low { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1s infinite; }
.extra { flex: 1; display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1.5px solid var(--line); border-radius: 20px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
.score-pill b { color: var(--orange); font-size: 1.15rem; }
.treats { letter-spacing: -2px; }
.duel-score b { font-size: 1.2rem; padding: 0 4px; }
.top-acts { display: flex; gap: 2px; margin-left: auto; }
.status-line { text-align: center; font-weight: 800; padding: 5px 14px; border-radius: 12px; background: #fff; border: 1.5px solid var(--line); align-self: center; max-width: 100%; }
.game[data-phase="draw"] .status-line { background: #fff4d6; border-color: var(--gold); }
.stage { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(160px, 210px) 1fr minmax(200px, 250px); gap: 12px; align-items: start; }
.game[data-mode="duel"] .stage { grid-template-columns: minmax(150px, 190px) 1fr; }
.game[data-mode="duel"] .stage > .right { display: none; }
.left, .right { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.left h3, .right h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player { display: flex; align-items: center; gap: 8px; position: relative; padding: 4px 6px; border-radius: 10px; }
.player.me { background: #fff4d6; }
.player.drawing { background: #fde3c8; }
.player.found .player-mark { color: var(--green); font-weight: 900; }
.player.away, .player.gone { opacity: 0.5; }
.player.gone .player-name { text-decoration: line-through; }
.player-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-score { font-variant-numeric: tabular-nums; }
.player em { font-style: normal; font-size: 0.72rem; color: var(--ink-dim); }
.bubble { position: absolute; left: 34px; bottom: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px 8px; font-size: 0.8rem; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; z-index: 5; box-shadow: 0 4px 12px #0002; animation: rise 0.25s ease-out; }
.boards { display: grid; gap: 12px; min-width: 0; }
.boards[data-count="2"] { grid-template-columns: 1fr 1fr; }
.board-panel { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; min-height: 40px; flex-wrap: wrap; }
.panel-who { font-weight: 800; color: var(--ink-dim); font-size: 0.9rem; }
.word-bar { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.word-label { color: var(--ink-dim); font-weight: 700; }
.word-word { font-size: 1.5rem; font-weight: 900; letter-spacing: 0.04em; color: var(--orange-ink); }
.tier { color: var(--gold); letter-spacing: -1px; }
.mask { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.mask i { width: 1.1em; height: 1.45em; border-bottom: 3px solid var(--ink); font-style: normal; font-weight: 900; font-size: 1.3rem; text-align: center; line-height: 1.3em; text-transform: lowercase; }
.mask i.shown { color: var(--blue); animation: rise 0.3s ease-out; }
.mask i.gap { border-bottom: none; width: 0.6em; }
.letters { font-size: 0.8rem; color: var(--ink-dim); align-self: flex-end; }
.page-wrap { position: relative; width: 100%; max-width: calc((100dvh - var(--chrome)) * 4 / 3); aspect-ratio: 4 / 3; margin: 0 auto; }
.boards[data-count="2"] .page-wrap { max-width: none; }
.sketch, .sketch-canvas { width: 100%; height: 100%; display: block; }
.sketch-canvas { border-radius: 14px; background: var(--paper); box-shadow: 0 0 0 1.5px var(--line), 0 8px 24px #8a5a1a26; touch-action: none; user-select: none; -webkit-user-select: none; }
.board-panel.mine.live .sketch-canvas { cursor: crosshair; box-shadow: 0 0 0 3px var(--orange), 0 8px 24px #8a5a1a33; }
.page-over { position: absolute; inset: 0; border-radius: 14px; background: #fffdf7ee; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; animation: rise 0.25s ease-out; overflow-y: auto; }
.page-over[data-kind="reveal"] { background: linear-gradient(180deg, #fffdf700 30%, #fffdf7e6 62%); justify-content: flex-end; gap: 4px; padding-bottom: 14px; }
.page-over[data-kind="reveal"] .reveal-word { font-size: clamp(1.5rem, 4vw, 2.3rem); }
.over-art { width: min(30%, 130px); aspect-ratio: 1; border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: 0 4px 12px #0002; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.choice { flex-direction: column; padding: 12px 18px; min-width: 120px; background: #fff; border-width: 2px; }
.choice b { font-size: 1.25rem; }
.choice span { font-size: 0.8rem; color: var(--ink-dim); }
.choice.t-easy { border-color: #9fd3a9; }
.choice.t-medium { border-color: #f2c88b; }
.choice.t-hard { border-color: #f0a090; }
.choice:hover:not(:disabled) { box-shadow: 0 4px 0 var(--line); transform: translateY(-2px); }
.reveal-word { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 900; color: var(--orange-ink); }
.reveal-points { font-weight: 800; font-size: 1.1rem; color: var(--green); margin: 0; }
.reveal-points.miss { color: var(--ink-dim); }
.reveal-round { font-weight: 900; color: var(--blue); margin: 0; }
.reveal-you { color: var(--green); font-weight: 800; margin: 0; }
.reveal-found { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.reveal-found li { display: flex; align-items: center; gap: 6px; }
.reveal-found small { color: var(--ink-dim); }
.under { display: flex; flex-direction: column; gap: 6px; }
.panel-extras { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.panel-extras:empty { display: none; }
.treat-btn, .skip-btn { font-size: 0.88rem; padding: 6px 10px; }
.guess { display: flex; gap: 6px; }
.guess input { flex: 1; min-width: 0; font-size: 1.05rem; }
.guess.off input { background: #f6efe0; }
.guess.off button { display: none; }
.toolbox { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.tool-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; align-items: center; }
.tool, .tool-act { width: 40px; height: 40px; padding: 0; font-size: 1.1rem; }
.tool[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); }
.sizes { display: flex; gap: 3px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 2px; }
.size { width: 34px; height: 34px; padding: 0; border: none; background: transparent; }
.size i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); display: block; }
.size[aria-pressed="true"] { background: var(--blue-soft); }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.swatch { width: 30px; height: 30px; padding: 0; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }
.swatch:hover:not(:disabled) { background: var(--c); transform: scale(1.1); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.12); }
.board-panel:not(.live) .toolbox { opacity: 0.5; pointer-events: none; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: calc(100dvh - 220px); min-height: 60px; }
.board-feed { max-height: 120px; min-height: 0; font-size: 0.9rem; }
.feed li { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; padding: 3px 6px; border-radius: 8px; }
.feed li b { font-size: 0.85rem; }
.f-guess span { color: var(--ink); }
.f-close { background: #fff4d6; }
.f-close em { color: var(--orange-ink); font-style: normal; font-weight: 800; font-size: 0.8rem; }
.f-got { display: block !important; background: var(--green-soft); color: #1d5530; font-weight: 700; }
.f-note { color: var(--ink-dim); font-size: 0.85rem; }
.f-empty { color: var(--ink-dim); font-style: italic; font-size: 0.85rem; }

/* the chat drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100%); background: #fffaf0f5; border-left: 1.5px solid var(--line); padding: max(12px, var(--bar)) 12px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; z-index: 30; box-shadow: -10px 0 40px #8a5a1a33; backdrop-filter: blur(6px); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }

/* the end of a game */
.over { position: fixed; inset: 0; background: #2b242066; display: flex; justify-content: center; align-items: flex-start; z-index: 25; padding: max(16px, var(--bar)) 16px 16px; overflow-y: auto; backdrop-filter: blur(3px); }
.over-card { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 20px; max-width: 640px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; box-shadow: 0 20px 60px #0004; animation: rise 0.35s ease-out; margin: auto 0; }
.over-card > img { width: 100%; max-width: 300px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; border: 5px solid #fff; box-shadow: 0 4px 14px #0002; }
.over-card h2 { font-size: 1.7rem; color: var(--orange-ink); }
.over-card p { margin: 0; }
.over-acts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.over-fridge { width: 100%; }
.duel-final { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; }
.podium { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 360px; }
.podium li { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; }
.podium li > span:not(.medal):not(.avatar) { flex: 1; text-align: left; }
.podium li.gone { opacity: 0.5; }
.medal { width: 1.8em; }

/* the Fridge */
.fridge { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.fridge h3 { font-size: 1rem; }
.fridge-grid { list-style: none; margin: 0; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; background: linear-gradient(180deg, #eef1f4, #dfe4ea); border-radius: 16px; box-shadow: inset 0 0 0 2px #cfd6de; }
.magnet { transform: rotate(var(--tilt)); }
.fridge-pic { flex-direction: column; align-items: stretch; gap: 4px; padding: 6px 6px 8px; background: #fff; border: none; border-radius: 4px; box-shadow: 0 4px 10px #0002; width: 100%; position: relative; }
.fridge-pic::before { content: ""; position: absolute; top: -6px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff9a7a, var(--red)); box-shadow: 0 2px 3px #0004; }
.fridge-pic canvas { width: 100%; aspect-ratio: 4 / 3; display: block; border-radius: 2px; }
.fridge-word { font-weight: 900; }
.fridge-by { font-size: 0.75rem; color: var(--ink-dim); }
.empty-fridge { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-dim); }
.empty-fridge img { width: 120px; border-radius: 50%; }
.drawing-view { display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; }
.drawing-frame { width: 100%; }
.drawing-frame .sketch-canvas { touch-action: auto; }
.big-word { font-size: 1.6rem; color: var(--orange-ink); }
.drawing-view p { margin: 0; }
.drawing-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* toasts, the banner, dialogs */
.toasts { position: fixed; bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 6px; z-index: 50; width: min(92vw, 460px); pointer-events: none; }
.toast { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 14px; text-align: center; box-shadow: 0 8px 24px #0002; transition: opacity 0.4s, transform 0.4s; }
.toast.error { border-color: var(--red); background: #fde7e2; }
.toast.good { border-color: var(--green); background: var(--green-soft); }
.toast.gone { opacity: 0; transform: translateY(8px); }
.banner { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; z-index: 40; animation: banner 1.9s ease-out forwards; }
.banner strong { font-size: clamp(2.4rem, 9vw, 4.6rem); font-weight: 900; color: #fff; -webkit-text-stroke: 2px var(--orange-ink); text-shadow: 0 5px 0 var(--orange), 0 0 30px #fff; transform: rotate(-3deg); }
.banner.good strong { -webkit-text-stroke-color: #1d5530; text-shadow: 0 5px 0 var(--green), 0 0 30px #fff; }
.banner span { font-size: 1.3rem; font-weight: 900; background: #fff; padding: 4px 14px; border-radius: 12px; margin-top: 10px; color: var(--green); }
dialog.panel { background: var(--card); color: var(--ink); border: 2px solid var(--line); border-radius: 18px; padding: 18px; max-width: min(560px, 94vw); width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 30px 80px #0005; }
dialog.drawing-dialog, dialog.fridge-dialog { max-width: min(820px, 96vw); }
dialog.panel::backdrop { background: #2b242080; }
dialog.panel h2 { margin-bottom: 10px; padding-right: 30px; }
dialog .close { position: absolute; top: 10px; right: 10px; padding: 2px 10px; font-size: 1.3rem; }
.ask-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list > button, .menu-list > a { justify-content: flex-start; }
.sound-panel { display: flex; flex-direction: column; gap: 10px; }
.sound-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sound-row button { min-width: 70px; }
.sound-row button[aria-pressed="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }
.rules-body h3 { margin: 14px 0 6px; color: var(--orange-ink); }
.rules-body ul { padding-left: 20px; margin: 6px 0; }
.rules-body li { margin: 4px 0; }
body.offline::after { content: "Reconnecting…"; position: fixed; inset: auto auto 12px 50%; height: auto; transform: translateX(-50%); background: var(--red); color: #fff; padding: 6px 14px; border-radius: 10px; z-index: 60; font-weight: 800; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 50% { opacity: 0.6; } }
@keyframes banner { 0% { opacity: 0; transform: scale(0.85); } 12% { opacity: 1; transform: scale(1.04); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ——— a tablet, or a narrow desk ——— */
@media (max-width: 1100px) {
  .stage { grid-template-columns: minmax(140px, 170px) 1fr minmax(170px, 210px); gap: 8px; }
  .brand span { display: none; }
}

/* ——— a phone, or anything narrow: one column, the page full width, the page scrolls ——— */
@media (max-width: 820px) {
  .game { gap: 6px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .topbar { gap: 6px; min-height: 40px; }
  .brand img { width: 30px; height: 30px; }
  .round-no { font-size: 0.85rem; }
  .extra { order: 5; flex-basis: 100%; gap: 6px; }
  .pill { padding: 2px 8px; font-size: 0.9rem; }
  .status-line { font-size: 0.9rem; padding: 3px 10px; }
  .stage, .game[data-mode="duel"] .stage { display: flex; flex-direction: column; gap: 8px; }
  .boards { order: 1; }
  .boards[data-count="2"] { grid-template-columns: 1fr; }
  .right { order: 2; }
  .left { order: 3; }
  .page-wrap { max-width: none; }
  .feed { max-height: 150px; }
  .players { flex-direction: row; flex-wrap: wrap; gap: 4px 6px; }
  .player { padding: 2px 8px 2px 2px; background: #fff; border: 1px solid var(--line); border-radius: 20px; }
  .player .avatar { --size: 24px; }
  .player-name { max-width: 7em; }
  .mode-cards { grid-template-columns: 1fr; }
  .mode-card { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .mode-card img { width: 84px; }
  .mode-card .mode-blurb { flex-basis: 100%; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .word-word { font-size: 1.25rem; }
  .mask i { font-size: 1.1rem; }
  .tool, .tool-act { width: 38px; height: 38px; }
  .swatches { gap: 3px; }
  .swatch { width: 24px; height: 24px; }
  /* a Duel on a phone: the page you watch a little smaller than the one you draw on */
  .game[data-mode="duel"] .board-panel:not(.mine) .page-wrap { width: 78%; }
  .choice { min-width: 90px; padding: 10px 12px; }
  .page-over[data-kind="reveal"] { background: linear-gradient(180deg, #fffdf700 30%, #fffdf7e6 62%); justify-content: flex-end; gap: 4px; padding-bottom: 14px; }
.page-over[data-kind="reveal"] .reveal-word { font-size: clamp(1.5rem, 4vw, 2.3rem); }
.over-art { width: 70px; }
}
@media (max-width: 380px) {
  .swatches { gap: 2px; }
  .swatch { width: 22px; height: 22px; }
  .size { width: 30px; height: 30px; }
  .tool, .tool-act { width: 34px; height: 34px; font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
