/* Scribble Arena — design tokens (PRD §89) */
:root {
  --ink: #1D1A3F;
  --ink-fixed: #1D1A3F;
  --line: #1D1A3F;
  --bg: #EEEBFF;
  --surface: #FFFFFF;
  --surface-2: #F5F3FF;
  --muted: #625F8C;
  --yellow: #FFCF33;
  --violet: #4B3BE0;
  --teal: #0FAF97;
  --pink: #F0406C;
  --orange: #FF981A;
  --color-primary: var(--yellow);
  --color-secondary: var(--violet);
  --color-success: var(--teal);
  --color-warning: var(--orange);
  --color-danger: var(--pink);
  --dot: rgba(29, 26, 63, .11);
  --r-sm: 12px;
  --r: 16px;
  --r-lg: 24px;
  --bw: 2.5px;
  --font: 'Baloo 2', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Devanagari', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #F1EFFF; --line: #06051A; --bg: #1B1938; --surface: #28254E; --surface-2: #312D5E;
    --muted: #ABA7DB; --dot: rgba(255, 255, 255, .07); color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); font-size: 1rem; line-height: 1.45; color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.3px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.1; margin: 0 0 .4em; }
a { color: var(--violet); }
@media (prefers-color-scheme: dark) { a { color: #B4ABFF; } }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: 0 18px; border: var(--bw) solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 1.05rem; line-height: 1.1;
  text-decoration: none; cursor: pointer; box-shadow: 0 4px 0 var(--line);
  transition: transform .08s ease, box-shadow .08s ease; touch-action: manipulation; user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--yellow); color: var(--ink-fixed); }
.btn-danger { background: var(--pink); color: #fff; }
.btn-xl { min-height: 58px; width: 100%; font-size: 1.3rem; font-weight: 800; }
.btn-ghost { border-color: transparent; box-shadow: none; background: transparent; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.btn-ghost:active:not(:disabled) { transform: none; box-shadow: none; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-pair .btn { padding: 6px 10px; font-size: 1rem; line-height: 1.1; }
.btn-col { display: grid; gap: 12px; }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: var(--bw) solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 1.25rem; font-weight: 800; cursor: pointer;
}
.field { display: grid; gap: 4px; }
.field.grow { flex: 1; min-width: 0; }
label { font-weight: 700; font-size: .95rem; }
label small, .hint { font-weight: 500; color: var(--muted); }
input[type=text], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px; /* 16px stops iOS zoom */
  border: var(--bw) solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; min-height: 96px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--violet); }
.form-error:empty { display: none; }
.form-error { color: var(--pink); font-weight: 700; min-height: 1.2em; margin: 0; white-space: pre-line; }
.notice { background: var(--orange); color: var(--ink-fixed); border: var(--bw) solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 700; margin: 0; }
.pill { display: inline-block; padding: 0 10px; border-radius: 999px; background: var(--surface-2); border: 2px solid var(--line); font-size: .9rem; }

/* ---------- site chrome ---------- */
.site-head { display: flex; align-items: center; justify-content: space-between; padding: 14px clamp(16px, 4vw, 40px); max-width: 1180px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.3rem; }
.logo-mark { width: 38px; height: 38px; }
.site-nav a { color: var(--ink); font-weight: 700; text-decoration: none; padding: 10px 6px; }
.site-nav a:hover { text-decoration: underline; }
.site-foot { max-width: 1180px; margin: 40px auto 0; padding: 24px clamp(16px, 4vw, 40px) calc(24px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-foot a { color: var(--muted); font-weight: 600; padding: 6px 0; }

/* ---------- home ---------- */
.home { max-width: 1180px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 0; display: grid; gap: 28px; }
.hero-title { font-size: clamp(3.1rem, 15vw, 6.6rem); font-weight: 800; letter-spacing: -.02em; line-height: .92; margin: 8px 0 14px; }
.hero-title .ln { position: relative; display: table; }
.hero-title .ln:nth-child(2) { margin-left: .45em; }
.hero-title .ln:nth-child(3) { margin-left: .15em; }
.hero-title .ln > span { position: relative; z-index: 1; }
.scrib { position: absolute; left: -2%; width: 104%; height: .32em; bottom: .02em; z-index: 0; overflow: visible; }
.scrib path { fill: none; stroke-width: 13; stroke-linecap: round; stroke-dasharray: 320; stroke-dashoffset: 320; animation: draw .55s cubic-bezier(.6, 0, .3, 1) forwards; }
.s1 path { stroke: var(--yellow); animation-delay: .15s; }
.s2 path { stroke: var(--teal); animation-delay: .5s; }
.s3 path { stroke: var(--pink); animation-delay: .85s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.hero-sub { font-size: clamp(1.15rem, 3.8vw, 1.45rem); color: var(--muted); font-weight: 600; margin: 0; max-width: 32ch; }

.join-card {
  display: grid; gap: 14px; padding: 18px; background: var(--surface); border: var(--bw) solid var(--line);
  border-radius: var(--r-lg); box-shadow: 0 6px 0 var(--line); max-width: 520px; width: 100%;
}
.invite-note { margin: 0; font-size: 1.1rem; }
.id-row { display: flex; gap: 12px; align-items: end; }
.avatar-big {
  width: 64px; height: 64px; flex: none; font-size: 2.2rem; line-height: 1; border: var(--bw) solid var(--line);
  border-radius: 18px; background: var(--surface-2); cursor: pointer; box-shadow: 0 3px 0 var(--line);
}
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.avatar-grid button { height: 48px; font-size: 1.6rem; border: 2px solid transparent; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.avatar-grid button[aria-checked=true] { border-color: var(--line); background: var(--yellow); }
.code-row { display: flex; gap: 10px; }
.code-row input { text-transform: uppercase; letter-spacing: .2em; font-weight: 800; }
.lang-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lang-row select { width: auto; min-width: 150px; }

.prose { max-width: 68ch; font-size: 1.08rem; }
.prose h2 { margin-top: 1.4em; font-size: 1.5rem; }
.prose li { margin: .4em 0; }
.home-content { padding-top: 8px; }

@media (min-width: 900px) {
  .home { grid-template-columns: 1.15fr 1fr; align-items: center; column-gap: 48px; padding-top: 32px; }
  .home .join-card { justify-self: end; }
  .home > .ad-wrap, .home-content { grid-column: 1 / -1; }
}

/* ---------- content pages ---------- */
.content { max-width: 820px; margin: 0 auto; padding: 16px clamp(16px, 4vw, 40px); }
.content .prose { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 4vw, 36px); box-shadow: 0 6px 0 var(--line); }
.content .prose h1 { font-size: clamp(2rem, 7vw, 3rem); }
.cta-row { margin: 28px 0; max-width: 360px; }

/* ---------- ads ---------- */
.ad-wrap { margin: 8px 0; text-align: center; min-height: 90px; }
.ad-label { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 4px; }

/* ---------- screens ---------- */
.screen { display: none; }
.screen.active { display: block; }
.sheet-page { max-width: 620px; margin: 0 auto; padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
.bar { display: flex; align-items: center; gap: 12px; padding: 6px 0; position: sticky; top: 0; z-index: 2; background: var(--bg); }
.bar h2 { flex: 1; margin: 0; font-size: 1.45rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-form { display: grid; gap: 14px; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: 0 6px 0 var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 359px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- lobby ---------- */
.code-card { background: var(--yellow); color: var(--ink-fixed); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: 0 6px 0 var(--line); display: grid; gap: 10px; text-align: center; }
.code-card .muted { color: var(--ink-fixed); opacity: .75; font-weight: 700; }
.room-code { font-size: clamp(2.4rem, 13vw, 3.4rem); font-weight: 800; letter-spacing: .14em; line-height: 1; }
.code-card .btn { background: var(--surface); color: var(--ink); }
.lobby-players h3 { display: flex; align-items: center; gap: 10px; }
.lobby-status { text-align: center; font-weight: 700; font-size: 1.1rem; margin: 0; }
.lobby-actions { display: grid; gap: 12px; }
.lobby-summary { text-align: center; margin: 0; }

/* ---------- player list ---------- */
.plist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.plist li { min-width: 0; }
.plist li {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; background: var(--surface);
  border: var(--bw) solid var(--line); border-radius: 14px; cursor: pointer;
}
.plist li.me { background: var(--surface-2); }
.plist li.guessed { background: var(--teal); color: #fff; }
.plist li.drawing { background: var(--yellow); color: var(--ink-fixed); }
.plist .av { font-size: 1.6rem; width: 34px; text-align: center; flex: none; position: relative; }
.plist .av::after { content: ''; position: absolute; right: -2px; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--teal); border: 2px solid var(--line); }
.plist li.off .av::after { background: var(--orange); }
.plist .nm { flex: 1; min-width: 0; font-weight: 700; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.plist .nm .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.plist .nm .crown, .plist .nm small { flex: none; }
.plist .nm .crown { margin-left: 2px; }
.plist .sc { flex: none; }
.plist .nm small { font-weight: 600; opacity: .8; }
.plist .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.plist .rk { width: 22px; font-weight: 800; opacity: .7; flex: none; text-align: right; }
.plist.compact li { min-height: 44px; padding: 4px 8px; gap: 8px; border-radius: 12px; }
.plist.compact .av { font-size: 1.35rem; width: 28px; }

/* ---------- game ---------- */
body.in-game { overflow: hidden; overscroll-behavior: none; }
.game.active {
  display: flex; flex-direction: column; position: fixed; left: 0; right: 0; top: var(--vvt, 0px);
  height: var(--vvh, 100dvh); overflow: hidden; background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.g-top { display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-height: 54px; background: var(--surface); border-bottom: var(--bw) solid var(--line); flex: none; }
.g-round { display: grid; line-height: 1.05; flex: none; }
.g-round strong { font-size: .98rem; }
.g-round small { color: var(--muted); font-weight: 600; font-size: .8rem; }
.g-status { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-status b { color: var(--violet); }
@media (prefers-color-scheme: dark) { .g-status b { color: var(--yellow); } }
.g-timer {
  flex: none; min-width: 66px; height: 42px; padding: 0 10px; display: grid; place-items: center; border: var(--bw) solid var(--line);
  border-radius: 999px; background: var(--surface-2); font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums;
}
.g-timer.urgent { background: var(--pink); color: #fff; }
.g-timer.pulse { animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.g-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.g-players { display: none; }
.g-stage { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 0; }
.canvas-wrap { flex: 0 1 auto; aspect-ratio: 10 / 7.1; min-height: 90px; display: flex; align-items: center; justify-content: center; }
.canvas-box { position: relative; background: #fff; border: var(--bw) solid var(--line); border-radius: 14px; overflow: hidden; }
#board { display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.game[data-role=drawer][data-state=DRAWING] #board { cursor: crosshair; }
.g-word { flex: none; min-height: 34px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 3px; font-weight: 800; font-size: 1.25rem; }
.g-word .ch { min-width: .85em; text-align: center; border-bottom: 3px solid var(--ink); line-height: 1.05; padding: 0 1px; }
.g-word .ch.sp { border: 0; min-width: .7em; }
.g-word .ch.sym { border: 0; }
.g-word .len { font-size: .8rem; color: var(--muted); margin-left: 6px; font-weight: 700; }
.g-word .secret { letter-spacing: .08em; background: var(--yellow); color: var(--ink-fixed); border: var(--bw) solid var(--line); border-radius: 10px; padding: 0 12px; }

.toolbar { flex: none; display: grid; gap: 6px; padding-bottom: 4px; }
.tools { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tool, .size {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.2rem;
  border: var(--bw) solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; padding: 0;
}
.tool.active, .size.active { background: var(--yellow); }
.tb-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.sizes { display: flex; gap: 4px; flex: none; }
.tb-row .palette { flex: 1; min-width: 0; }
.size i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); }
.size.active i { background: var(--ink-fixed); }
.palette { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.palette::-webkit-scrollbar, .tools::-webkit-scrollbar { display: none; }
.swatch { flex: none; width: 36px; height: 36px; border-radius: 50%; border: var(--bw) solid var(--line); cursor: pointer; padding: 0; position: relative; }
.swatch::before { content: ''; position: absolute; inset: -6px; } /* 48px touch target */
.swatch.active { outline: 3px solid var(--violet); outline-offset: 2px; }
.swatch.custom { background: conic-gradient(#f0406c, #ff981a, #ffcf33, #0faf97, #4b3be0, #f0406c); overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.g-side { flex: 1 1 auto; min-height: 130px; display: flex; flex-direction: column; gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabs { display: flex; gap: 6px; flex: none; }
.tab { flex: 1; min-height: 38px; border: var(--bw) solid var(--line); border-radius: 10px; background: var(--surface); font-weight: 700; cursor: pointer; }
.tab.active { background: var(--ink); color: var(--bg); }
.panes { flex: 1; min-height: 60px; position: relative; border: var(--bw) solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.chat-log, .pane-players { position: absolute; inset: 0; margin: 0; padding: 8px 10px; overflow-y: auto; overscroll-behavior: contain; list-style: none; }
.pane-players { display: grid; align-content: start; gap: 6px; background: var(--surface-2); }
.chat-log li { padding: 2px 0; word-wrap: break-word; overflow-wrap: anywhere; font-size: .98rem; }
.chat-log li b { font-weight: 800; }
.chat-log .system { color: var(--muted); font-weight: 600; }
.chat-log .join { color: var(--teal); font-weight: 700; }
.chat-log .leave { color: var(--orange); font-weight: 700; }
.chat-log .correct { color: #fff; background: var(--teal); border-radius: 8px; padding: 3px 8px; margin: 3px 0; font-weight: 800; }
.chat-log .close { color: var(--ink-fixed); background: var(--yellow); border-radius: 8px; padding: 3px 8px; margin: 3px 0; font-weight: 800; }
.chat-log .reveal { color: var(--violet); font-weight: 800; }
.chat-log .turn { color: var(--violet); font-weight: 700; }
@media (prefers-color-scheme: dark) { .chat-log .reveal, .chat-log .turn { color: #B4ABFF; } }
.chat-log .warn { color: var(--pink); font-weight: 800; }
.chat-log .insider { color: var(--teal); }
.composer { display: flex; gap: 6px; flex: none; }
.composer input { flex: 1; min-width: 0; }
.composer .btn { padding: 0 16px; }

/* drawer on small screens: canvas gets the space, chat shrinks (PRD §9) */
@media (max-width: 767px) {
  .game[data-role=drawer][data-state=DRAWING] .g-side { min-height: 90px; }
  .game[data-role=drawer][data-state=DRAWING] .composer,
  .game[data-role=drawer][data-state=DRAWING] .tabs { display: none; }
  .game.kb-open .tabs { display: none; }
}
@media (max-width: 380px) { .g-round small { display: none; } .g-timer { min-width: 56px; } .size { width: 40px; } }

/* tablet */
@media (min-width: 768px) {
  .g-main { flex-direction: row; }
  .g-stage { flex: 1 1 auto; padding: 12px; }
  .canvas-wrap { flex: 1 1 auto; aspect-ratio: auto; }
  .g-side { min-height: 0; }
  .g-side { flex: 0 0 320px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)) 0; }
  .toolbar { grid-template-columns: auto 1fr; align-items: center; }
}
/* desktop: players | canvas | chat (PRD §7) */
@media (min-width: 1024px) and (pointer: fine), (min-width: 1100px) {
  .g-top { padding: 8px 16px; min-height: 60px; }
  .g-status { font-size: 1.2rem; }
  .g-players { display: block; flex: 0 0 240px; padding: 12px 6px 12px 12px; overflow-y: auto; overflow-x: hidden; }
  .tabs, .pane-players { display: none !important; }
  .chat-log { display: block !important; }
  .g-side { flex-basis: 330px; }
  .g-word { font-size: 1.5rem; }
}

/* stage overlays */
.stage-overlay {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 14px; text-align: center; overflow-y: auto; color: #fff; background: rgba(29, 26, 63, .86);
}
.stage-overlay h3 { font-size: clamp(1.3rem, 5vw, 2rem); margin: 0; }
.stage-overlay p { margin: 0; font-weight: 600; }
.stage-overlay .big-word { font-size: clamp(1.8rem, 8vw, 3rem); font-weight: 800; color: var(--yellow); line-height: 1; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 560px; }
.choices .btn { min-width: 120px; font-size: 1.15rem; background: var(--surface); color: var(--ink); }
.count { font-size: clamp(4rem, 22vw, 8rem); font-weight: 800; color: var(--yellow); line-height: 1; animation: pop .9s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } 30% { transform: scale(1); opacity: 1; } }
.gains { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; min-width: min(280px, 100%); }
.gains li { display: flex; justify-content: space-between; gap: 16px; font-weight: 700; padding: 2px 10px; border-radius: 8px; background: rgba(255, 255, 255, .1); }
.gains .plus { color: var(--yellow); }

/* final results (PRD §48) */
.final { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(29, 26, 63, .7); overflow-y: auto; }
.final-card { width: min(460px, 100%); display: grid; gap: 12px; text-align: center; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: 0 8px 0 var(--line); margin: auto; }
.trophy { font-size: 3.4rem; line-height: 1; animation: pop .8s ease-out; }
.winner { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.winner small { display: block; font-size: 1rem; color: var(--muted); }
.final-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.final-list li { display: flex; gap: 10px; align-items: center; padding: 6px 12px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; }
.final-list li:first-child { background: var(--yellow); color: var(--ink-fixed); }
.final-list .sc { margin-left: auto; font-variant-numeric: tabular-nums; }

/* misc overlays */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(29, 26, 63, .55); }
.busy-card { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-lg); padding: 22px 28px; text-align: center; box-shadow: 0 6px 0 var(--line); font-weight: 800; font-size: 1.15rem; }
.busy-card p { margin: 8px 0 0; }
.dots { display: flex; gap: 8px; justify-content: center; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--violet); animation: bounce 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; background: var(--teal); }
.dots i:nth-child(3) { animation-delay: .3s; background: var(--pink); }
@keyframes bounce { 50% { transform: translateY(-8px); } }
.net { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 50; background: var(--orange); color: var(--ink-fixed); border: var(--bw) solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 800; white-space: nowrap; }
.toasts { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 45; display: grid; gap: 8px; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 16px; font-weight: 700; text-align: center; animation: toast .25s ease-out; }
@keyframes toast { from { opacity: 0; transform: translateY(-8px); } }

.sheet { border: var(--bw) solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 0; width: 100%; max-width: 520px; margin: auto auto 0; background: var(--surface); color: var(--ink); box-shadow: 0 -4px 0 var(--line); }
.sheet::backdrop { background: rgba(29, 26, 63, .55); }
.sheet-body { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px; max-height: 85vh; overflow-y: auto; }
.sheet-body h3 { margin: 0 0 4px; font-size: 1.3rem; }
.sheet-body .opt { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; }
@media (min-width: 600px) { .sheet { border-radius: var(--r-lg); margin: auto; box-shadow: 0 6px 0 var(--line); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .scrib path { stroke-dashoffset: 0; }
}

/* keep toasts off the canvas while playing */
body.in-game .toasts { top: auto; bottom: calc(110px + env(safe-area-inset-bottom)); }

/* ---------- animated winner crown ---------- */
.crown {
  display: inline-block; margin-left: 6px; font-size: 1.05em; line-height: 1; vertical-align: -1px;
  transform-origin: 50% 100%; animation: crown-bob 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(255, 207, 51, .9));
}
@keyframes crown-bob {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-4px) rotate(10deg); }
}
.plist li.leader { border-color: var(--line); box-shadow: 0 0 0 3px var(--yellow); }
.winner-badge { position: relative; display: inline-grid; place-items: center; width: 110px; height: 110px; margin: 46px auto 4px; border-radius: 50%; background: var(--yellow); border: var(--bw) solid var(--line); box-shadow: 0 5px 0 var(--line); }
.winner-av { font-size: 3.6rem; line-height: 1; animation: pop .7s ease-out; }
.crown-big {
  position: absolute; top: -44px; left: 50%; font-size: 3.2rem; line-height: 1;
  transform-origin: 50% 100%; filter: drop-shadow(0 0 10px rgba(255, 207, 51, .95));
  animation: crown-drop .8s cubic-bezier(.3, 1.5, .5, 1) both, crown-sway 2.2s ease-in-out .8s infinite;
}
@keyframes crown-drop { from { transform: translate(-50%, -60px) rotate(-30deg); opacity: 0; } to { transform: translate(-50%, 0) rotate(0); opacity: 1; } }
@keyframes crown-sway { 0%, 100% { transform: translate(-50%, 0) rotate(-8deg); } 50% { transform: translate(-50%, -6px) rotate(8deg); } }
.winner-badge::before, .winner-badge::after {
  content: '✦'; position: absolute; color: var(--yellow); font-size: 1.3rem; text-shadow: 0 0 6px rgba(255, 207, 51, .9);
  animation: twinkle 1.4s ease-in-out infinite;
}
.winner-badge::before { left: -22px; top: 22px; }
.winner-badge::after { right: -22px; top: 38px; animation-delay: .7s; }
@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.2); } }
.winner-name { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.chat-log .win { color: var(--ink-fixed); background: var(--yellow); border-radius: 8px; padding: 3px 8px; margin: 3px 0; font-weight: 800; }
@media (prefers-reduced-motion: reduce) { .crown, .crown-big { animation: none; } .crown-big { transform: translate(-50%, 0); } }

/* ---------- drawing cursor & bucket ---------- */
.brush-cursor { position: absolute; z-index: 2; pointer-events: none; border-radius: 50%; transform: translate(-50%, -50%); border: 1.5px solid rgba(29, 26, 63, .85); box-shadow: 0 0 0 1px rgba(255, 255, 255, .9); }
.brush-cursor.eraser { background: rgba(255, 255, 255, .6); border-style: dashed; }
.canvas-box[data-tool=b] #board, .canvas-box[data-tool=e] #board { cursor: none; }
.canvas-box[data-tool=f] #board { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M5 13 13 5l9 9-8 8z' fill='%23fff' stroke='%231d1a3f' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M5 13h17' stroke='%231d1a3f' stroke-width='2'/%3E%3Cpath d='M23 16c1.5 2.5 2.5 4 2.5 5.2a2.5 2.5 0 0 1-5 0c0-1.2 1-2.7 2.5-5.2z' fill='%234b3be0' stroke='%231d1a3f' stroke-width='1.5'/%3E%3Ccircle cx='3' cy='25' r='2.2' fill='%231d1a3f'/%3E%3C/svg%3E") 3 25, crosshair; }
.sizes.off { opacity: .35; }
/* wider screens: show every colour (wrap instead of scroll) */
@media (min-width: 768px) {
  .tb-row .palette { flex-wrap: wrap; overflow: visible; gap: 5px; }
  .tb-row .palette .swatch { width: 30px; height: 30px; }
}

/* ---------- phone rotated to landscape: canvas 70 / chat 30 (PRD §124) ---------- */
.game.land .g-top { min-height: 44px; padding: 3px 8px; }
.game.land .g-timer { height: 36px; }
.game.land .g-main { flex-direction: row; }
.game.land .g-players { display: none; }
.game.land .g-stage { flex: 0 0 68%; padding: 6px 6px 6px 8px; }
.game.land .canvas-wrap { flex: 1 1 auto; aspect-ratio: auto; }
.game.land .toolbar { grid-template-columns: auto 1fr; align-items: center; }
.game.land .g-side { flex: 1 1 32%; min-height: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) 0; }
.game.land .tabs { display: flex !important; }
.game.land .composer, .game.land[data-role=drawer][data-state=DRAWING] .composer { display: flex; }

/* ---------- phone keyboard open: canvas shrinks, hint bar + full-width input stay visible ---------- */
.game.kb-open .g-main { flex-direction: column; }
.game.kb-open .g-players, .game.kb-open .tabs, .game.kb-open .toolbar { display: none !important; }
.game.kb-open .g-top { min-height: 42px; padding: 2px 8px; }
.game.kb-open .g-timer { height: 34px; font-size: 1.05rem; }
.game.kb-open .g-round small { display: none; }
.game.kb-open .g-stage { flex: 1 1 auto; min-height: 0; padding: 4px 8px 0; gap: 2px; }
.game.kb-open .canvas-wrap { flex: 1 1 auto; aspect-ratio: auto; min-height: 60px; }
.game.kb-open .g-word { min-height: 30px; font-size: 1.15rem; }
.game.kb-open .g-side { flex: 0 0 auto; min-height: 0; padding: 4px 8px 6px; gap: 4px; }
.game.kb-open .panes { flex: 0 0 auto; height: 86px; min-height: 0; }
.game.kb-open .composer { display: flex !important; }
.game.kb-open .composer input { font-size: 16px; }

/* ---------- like / dislike drawing ---------- */
.votes { position: absolute; right: 8px; bottom: 8px; z-index: 4; display: flex; gap: 6px; }
.vote {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; min-width: 56px; padding: 0 10px;
  border: var(--bw) solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .94); color: var(--ink-fixed);
  font: 800 .95rem/1 var(--font); cursor: pointer; box-shadow: 0 3px 0 var(--line); transition: transform .08s;
}
.vote span { font-size: 1.15rem; }
.vote:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.vote.up.on { background: var(--teal); color: #fff; }
.vote.down.on { background: var(--pink); color: #fff; }
.votes.readonly .vote { cursor: default; opacity: .9; box-shadow: none; }
.float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.fly { position: absolute; bottom: 44px; font-size: 1.9rem; animation: fly 1.5s ease-out forwards; }
@keyframes fly { 0% { transform: translate(0, 0) scale(.6); opacity: 0; } 15% { opacity: 1; transform: translate(0, -10px) scale(1.1); } 100% { transform: translate(var(--dx), -170px) scale(1); opacity: 0; } }
.stage-overlay .vote-sum { font-size: 1.15rem; font-weight: 800; }
.chat-log .like { color: var(--teal); font-weight: 700; }
.chat-log .dislike { color: var(--pink); font-weight: 700; }
@media (max-width: 380px) { .vote { height: 36px; min-width: 50px; padding: 0 8px; } }
.votes.readonly { pointer-events: none; opacity: .92; } /* the drawer can draw underneath */

/* rejoin card on the home screen */
.rejoin { display: grid; gap: 8px; padding: 12px; border: var(--bw) dashed var(--line); border-radius: 16px; background: var(--surface-2); }
.rejoin p { margin: 0; font-weight: 700; }
