:root {
  --ink: #1d1438;
  --muted: #6b6185;
  --paper: #fffaf0;
  --paper-2: #fff3dc;
  --line: #e6dcc6;
  --sun: #ffd23f;
  --sun-dark: #e8b400;
  --pink: #ff5d8f;
  --teal: #2ec4b6;
  --sky: #4cc9f0;
  --orange: #ff9f1c;
  --violet: #7b6cff;
  --good: #11865a;
  --good-bg: #dcf8ea;
  --warn: #d6284f;
  --warn-bg: #ffe3ea;
  --whatsapp: #25d366;
  --bg-a: #24125f;
  --bg-b: #3a1c8c;
  --bg-c: #6a2bb8;
  --display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --hand: 'Gochi Hand', 'Comic Sans MS', cursive;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 16px;
  --shadow: 0 5px 0 var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
/* While playing, nothing scrolls the page itself, so the keyboard can't push the guess box away. */
body.in-game { overflow: hidden; overscroll-behavior: none; }
body {
  color: var(--ink);
  font: 700 16px/1.4 var(--body);
  background-color: var(--bg-b);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.07' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 40c10-14 18-14 24 0s14 14 24 0'/%3E%3Cpath d='M160 30l5 12 13 1-10 9 3 13-11-7-11 7 3-13-10-9 13-1z'/%3E%3Ccircle cx='60' cy='160' r='14'/%3E%3Cpath d='M150 150l30-30 8 8-30 30h-8z'/%3E%3Cpath d='M100 100c0-8 12-8 12 0s-18 10-18 0 22-14 24 0'/%3E%3Cpath d='M190 200h20M200 190v20'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(1200px 700px at 10% -10%, #8d3fe0 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 110%, #ff5d8f55 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b) 45%, var(--bg-c));
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  /* Taps and drags are gameplay, not text selection. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button, a, select { touch-action: manipulation; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  font-size: 16px; /* stops iOS zoom on focus */
}
input::placeholder { color: #a99fb8; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}
select:disabled { background: #f3eee2; color: var(--muted); border-color: var(--line); opacity: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  background: #fff;
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink);
  font: 600 17px/1 var(--display);
  text-decoration: none;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.btn.ink { background: var(--ink); color: #fff; }
.btn.sun { background: var(--sun); }
.btn.whatsapp { background: var(--whatsapp); }
.btn.whatsapp svg { width: 22px; height: 22px; }
.btn.wide { width: 100%; }
.btn.big { min-height: 56px; font-size: 20px; }
.btn:disabled, .btn.sun:disabled {
  background: #efe9dc;
  border-color: #cfc5b0;
  box-shadow: 0 4px 0 #cfc5b0;
  color: var(--muted);
  cursor: not-allowed;
}

.link {
  display: block;
  margin: 14px auto 0;
  padding: 8px;
  background: none;
  border: 0;
  color: var(--muted);
  font-weight: 800;
  text-decoration: underline wavy var(--pink);
  text-underline-offset: 4px;
  cursor: pointer;
}

/* ---------- shared page shell ---------- */
.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 16px 32px;
}
.card {
  position: relative;
  width: 100%;
  max-width: 660px;
  padding: 26px 24px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 8px 9px 0 rgba(10, 4, 30, .55);
}
.card.narrow { max-width: 420px; }
.center { text-align: center; }
.eyebrow { text-align: center; font: 600 13px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; font-weight: 700; }
.error { margin-top: 12px; padding: 10px 12px; background: var(--warn-bg); color: var(--warn); border: 2px solid var(--warn); border-radius: 12px; }
.note { margin-top: 10px; padding: 10px 12px; background: var(--paper-2); border: 2px dashed var(--sun-dark); border-radius: 12px; font-size: 14px; }

.mini-brand { font: 700 26px/1 var(--display); color: #fff; letter-spacing: -.01em; }
.mini-brand span { color: var(--sun); }

/* ---------- home ---------- */
.home { overflow: hidden; position: relative; }
.hero { position: relative; text-align: center; z-index: 1; }
.wordmark { display: flex; justify-content: center; align-items: center; gap: 6px; font: 700 clamp(32px, 10vw, 84px)/1 var(--display); letter-spacing: -.02em; }
.wordmark .w { display: inline-block; padding: 4px 12px 8px; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 6px 0 var(--ink); }
.wordmark .w1 { background: var(--sky); transform: rotate(-6deg); }
.wordmark .w2 { background: var(--sun); transform: rotate(4deg) translateY(-6px); }
.wordmark .w3 { background: var(--pink); color: #fff; transform: rotate(-3deg); }
.tagline { margin-top: 18px; color: #e9e2ff; font-size: 18px; }
.tagline b { color: var(--sun); }
.home .card { z-index: 1; }

.invite { margin-bottom: 16px; padding: 10px 12px; background: var(--sun); border: 2.5px solid var(--ink); border-radius: 12px; text-align: center; font: 600 17px var(--display); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 6px; font: 600 15px var(--display); }
.field.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field.row span { margin: 0; white-space: nowrap; }
.field.row select { width: 140px; }
.inline { display: flex; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 800; }
.or { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; color: var(--muted); font: 600 14px var(--display); }
.or::before, .or::after { content: ''; flex: 1; border-top: 2.5px dashed var(--line); }

.steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; margin: 4px 0 0; padding: 0; list-style: none; color: #fff; font-size: 15px; z-index: 1; }
.steps li { display: flex; align-items: center; gap: 8px; }
.n { display: grid; place-items: center; width: 28px; height: 28px; border: 2.5px solid var(--ink); border-radius: 50%; color: var(--ink); font: 700 15px var(--display); }
.n1 { background: var(--sky); } .n2 { background: var(--sun); } .n3 { background: var(--pink); }

.doodles .d { position: absolute; width: 64px; height: 64px; animation: bob 6s ease-in-out infinite; }
.d1 { top: 8%; left: 7%; color: var(--sun); }
.d2 { top: 14%; right: 9%; color: var(--pink); width: 54px; animation-delay: -1s; }
.d3 { bottom: 16%; left: 9%; color: var(--sky); animation-delay: -2s; }
.d4 { bottom: 9%; right: 10%; color: var(--teal); width: 80px; animation-delay: -3s; }
.d5 { top: 46%; left: 3%; color: #ffffff55; width: 70px; animation-delay: -4s; }
.d6 { top: 50%; right: 4%; color: var(--orange); width: 50px; animation-delay: -5s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-14px) rotate(6deg); } }

/* ---------- avatars ---------- */
.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  font: 700 16px/1 var(--display);
  text-transform: uppercase;
}
.avatar.sm { width: 26px; height: 26px; font-size: 13px; border-width: 2px; }
.avatar.lg { width: 58px; height: 58px; font-size: 26px; border-width: 3px; }

/* ---------- lobby ---------- */
.ticket {
  margin: -6px -4px 18px;
  padding: 14px 10px 12px;
  background: repeating-linear-gradient(-45deg, #fff6d8 0 12px, #fff0c4 12px 24px);
  border: 2.5px dashed var(--ink);
  border-radius: 18px;
  text-align: center;
}
.code-big {
  display: block;
  margin: 0 auto;
  padding: 0 8px;
  background: none;
  border: 0;
  font: 700 clamp(46px, 12vw, 66px)/1.1 var(--display);
  letter-spacing: .14em;
  cursor: pointer;
}
.share { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.link-text { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.lobby-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; margin: 24px 0; }
.lobby-grid h2 { margin-bottom: 12px; font: 600 24px/1 var(--display); }
.lobby-grid small { font: 700 14px var(--body); color: var(--muted); }
.lobby-players { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.lobby-players li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ink);
  animation: pop .35s cubic-bezier(.3, 1.6, .5, 1);
}
.lobby-players li.empty { background: transparent; border-style: dashed; border-color: #c9bfa8; box-shadow: none; color: var(--muted); animation: none; }
.lobby-players li.empty .avatar { border-style: dashed; border-color: #c9bfa8; color: #c9bfa8; background: transparent; }
.lobby-players .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { margin-left: auto; flex: none; padding: 2px 9px; background: var(--sun); border: 2px solid var(--ink); border-radius: 99px; font: 600 12px var(--display); }
.tag.away { background: var(--line); border-color: #c9bfa8; color: var(--muted); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- game ---------- */
.play {
  height: var(--app-h, 100dvh);
  display: grid;
  grid-template:
    "top top top" auto
    "players stage side" minmax(0, 1fr)
    "players tools side" auto / 210px minmax(0, 1fr) 320px;
  gap: 12px;
  padding: 12px;
  max-width: 1400px;
  margin: 0 auto;
}
.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 12px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.round { padding: 5px 12px; background: var(--sky); border: 2.5px solid var(--ink); border-radius: 99px; font: 600 14px var(--display); white-space: nowrap; }
.word { text-align: center; font: 600 26px/1.15 var(--display); overflow-wrap: anywhere; }
.word .hand { font: 400 32px/1 var(--hand); }
.word .mask { font-family: var(--display); letter-spacing: .16em; white-space: pre-wrap; }
.word small { font: 700 14px var(--body); color: var(--muted); letter-spacing: 0; }
.clock { position: relative; width: 50px; height: 50px; }
.clock svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.clock circle { fill: none; stroke-width: 5; }
.ring-bg { stroke: var(--line); }
.ring-fill { stroke: var(--teal); stroke-linecap: round; stroke-dasharray: 119.38; transition: stroke .3s; }
.ring-fill.urgent { stroke: var(--warn); }
#timerLabel { position: absolute; inset: 0; display: grid; place-items: center; font: 700 18px var(--display); font-variant-numeric: tabular-nums; }
#timerLabel.urgent { color: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.18); } }

.sound-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
}
.sound-toggle svg { width: 22px; height: 22px; }
.sound-toggle.floating { position: fixed; z-index: 15; top: calc(12px + env(safe-area-inset-top)); right: 12px; box-shadow: 0 3px 0 var(--ink); }
body.in-game .sound-toggle.floating { display: none; }

.players { grid-area: players; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; padding: 2px 2px 6px; }
.chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 9px;
  padding: 8px 10px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 15px;
  transition: background .3s;
}
.chip .avatar { grid-row: span 2; }
.chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .score { font: 700 16px var(--display); font-variant-numeric: tabular-nums; }
.chip .status { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
.chip.me { outline: 3px solid var(--sun); outline-offset: 1px; }
.chip.drawing { background: #fff1c1; }
.chip.guessed { background: var(--good-bg); }
.chip.guessed .status, .chip.guessed .score { color: var(--good); }
.chip.away { opacity: .55; }

.stage-wrap { grid-area: stage; display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; }
.stage { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; box-sizing: content-box; }
canvas { display: block; touch-action: none; }
canvas.can-draw { cursor: crosshair; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: rgba(36, 18, 95, .78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: #fff;
  text-align: center;
  overflow-y: auto;
}
.overlay > * { animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) both; }
.overlay h2 { font: 600 clamp(20px, 4.6vw, 32px)/1.15 var(--display); }
.overlay p { color: #d9d0ff; font-size: 14px; }
.overlay .big {
  padding: 4px 22px 10px;
  background: var(--sun);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--ink);
  font: 400 clamp(32px, 8vw, 58px)/1.05 var(--hand);
  transform: rotate(-2deg);
  overflow-wrap: anywhere;
}
.overlay .reason { padding: 4px 12px; background: rgba(255, 255, 255, .14); border-radius: 99px; color: #fff; font: 600 15px var(--display); }
.overlay .who { display: flex; align-items: center; gap: 10px; }
.picks { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 4px; }
.pick { flex-direction: column; gap: 4px; min-width: 120px; padding: 12px 16px; font-size: 20px; }
.pick small { padding: 2px 8px; border: 2px solid var(--ink); border-radius: 99px; font: 600 11px var(--display); text-transform: uppercase; letter-spacing: .08em; background: #fff; }
.pick.easy { background: #b8f2d8; transform: rotate(-2deg); }
.pick.medium { background: #ffe08a; }
.pick.hard { background: #ffb3c9; transform: rotate(2deg); }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.results { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 520px; }
.result { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 99px; font-size: 14px; }
.result b { color: var(--good); }
.result.artist { background: #fff1c1; }

.tools {
  grid-area: tools;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  min-width: 0;
  padding: 7px 10px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* Two groups (colours, then pen/fill/eraser + sizes + undo/clear). They sit side by side when
   there's room and stack into two rows when there isn't; buttons shrink rather than scroll. */
.tool-row { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; max-width: 100%; }
.tool {
  display: grid;
  place-items: center;
  flex: 0 1 auto;
  width: 32px;
  min-width: 20px;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  background: #fff;
  border: 2.5px solid var(--line);
  border-radius: 10px;
  font: 600 13px var(--display);
  cursor: pointer;
  transition: transform .1s;
}
.tool.selected { border-color: var(--ink); transform: translateY(-3px); box-shadow: 0 3px 0 var(--ink); }
.tool svg { width: 62%; height: 62%; }
.tool .paint { fill: var(--current, var(--ink)); stroke: var(--ink); stroke-width: 1; }
.tool.danger { color: var(--warn); }
.tool.swatch { border-radius: 50%; border-color: rgba(0, 0, 0, .2); }
.dot { display: block; max-width: 70%; max-height: 70%; background: var(--current, var(--ink)); border-radius: 50%; }
.mode-fill .size { opacity: .4; }
.tool-sep { flex: none; width: 2px; height: 22px; margin: 0 2px; background: var(--line); border-radius: 2px; }
canvas.can-draw.fill-mode { cursor: cell; }

.side { grid-area: side; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chat {
  flex: 1;
  min-height: 0;
  padding: 8px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.msg { padding: 3px 8px; border-radius: 10px; animation: slide .2s ease-out; }
.msg b { font-weight: 800; }
.msg.system { color: var(--muted); font-size: 13px; }
.msg.correct { margin: 3px 0; background: var(--good-bg); border: 2px solid var(--good); color: var(--good); font: 600 15px var(--display); }
.msg.close { margin: 3px 0; background: #fff1c1; border: 2px dashed var(--sun-dark); }
.msg.insider { background: #e6f6ff; }
@keyframes slide { from { transform: translateY(6px); opacity: 0; } }
.report {
  padding: 7px 10px;
  background: #fff;
  border: 2px solid var(--warn);
  border-radius: 12px;
  color: var(--warn);
  font: 600 13px var(--display);
  cursor: pointer;
}
.report:disabled { border-color: var(--line); color: var(--muted); cursor: default; }
.guess { display: flex; gap: 8px; }
.guess input { box-shadow: 0 4px 0 var(--ink); }

/* ---------- game over ---------- */
.home-btn { margin-top: 12px; }
.winner { margin: 4px 0 12px; font: 700 clamp(30px, 8vw, 46px)/1.1 var(--display); text-align: center; overflow-wrap: anywhere; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 6px 0 18px; }
.place { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 31%; max-width: 150px; min-width: 0; animation: rise .6s cubic-bezier(.3, 1.4, .5, 1) both; }
.place .pname { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 16px var(--display); }
.place .block { display: grid; place-items: center; width: 100%; border: 3px solid var(--ink); border-bottom-width: 0; border-radius: 14px 14px 0 0; font: 700 30px var(--display); }
.place .pts { font-size: 14px; color: var(--muted); }
.place.p1 .block { height: 120px; background: var(--sun); }
.place.p2 .block { height: 88px; background: var(--sky); }
.place.p3 .block { height: 64px; background: var(--pink); }
.place.p1 { animation-delay: .25s; }
.place.p3 { animation-delay: .1s; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.podium-base { height: 6px; }
.standings { display: grid; gap: 7px; margin: 0 0 20px; padding: 0; list-style: none; }
.standings li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; }
.standings .rank { width: 24px; font: 700 18px var(--display); text-align: center; }
.standings .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- overlays, toast, banner ---------- */
.replaced { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(20, 8, 50, .82); }
.replaced h2 { font: 600 26px var(--display); margin-bottom: 8px; }
.replaced p { margin-bottom: 18px; color: var(--muted); }

.rules {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 8px 9px 0 rgba(10, 4, 30, .55);
}
.rules::backdrop { background: rgba(20, 8, 50, .7); }
.rules h2 { font: 700 32px/1 var(--display); }
.rules h3 { margin-top: 16px; font: 600 22px/1 var(--display); }
.rules ol, .rules ul { margin: 10px 0 0; padding-left: 20px; }
.rules li { margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.rules li b { font-weight: 800; }
.rules .close { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; font-size: 24px; line-height: 1; cursor: pointer; }

.banner {
  position: fixed;
  z-index: 25;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--warn);
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 99px;
  font: 600 14px var(--display);
}
.spinner { width: 14px; height: 14px; border: 2.5px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed;
  z-index: 25;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  background: var(--ink);
  color: #fff;
  border: 2.5px solid #fff;
  border-radius: 99px;
  font: 600 15px var(--display);
  animation: pop .25s ease-out;
}

.confetti { position: fixed; z-index: 40; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); } }

/* ---------- desktop tweaks ---------- */
@media (min-width: 821px) {
  .tool { width: 32px; }
}

/* ---------- phones: canvas first, chat below ---------- */
@media (max-width: 820px) {
  /* Pinned to the *visible* area (above the keyboard); app.js keeps --vv-top/--app-h current. */
  .play {
    position: fixed;
    top: var(--vv-top, 0px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
  }
  /* The guess box comes last and never shrinks; the drawing gives up space first. */
  .play > * { flex-shrink: 0; }
  .play .stage-wrap { flex-shrink: 1; }
  .side .guess, .side .report { flex: none; }
  .side .chat { min-height: 36px; }
  body.typing .play { padding-bottom: 7px; }
  body.typing .players, body.typing .report { display: none; }
  body.typing .stage-wrap { min-height: 0; }
  body.typing .side { flex: 1 1 auto; min-height: 0; }
  .topbar { flex: none; gap: 8px; padding: 5px 6px 5px 8px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  .round { padding: 3px 8px; font-size: 12px; }
  .word { font-size: 19px; }
  .word .hand { font-size: 25px; }
  .word small { font-size: 12px; }
  .clock { width: 40px; height: 40px; }
  #timerLabel { font-size: 15px; }
  .sound-toggle.inbar { width: 34px; height: 34px; border-radius: 10px; }
  .sound-toggle.inbar svg { width: 18px; height: 18px; }
  .stage-wrap { flex: 0 1 calc((100vw - 20px) * .75); min-height: 110px; }
  .stage { border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  .players { flex: none; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 1px 1px 4px; scrollbar-width: none; }
  .players::-webkit-scrollbar { display: none; }
  .chip { flex: none; display: flex; align-items: center; gap: 6px; max-width: 160px; padding: 3px 9px 3px 3px; border-width: 2px; border-radius: 99px; box-shadow: 0 2px 0 var(--ink); font-size: 13px; }
  .chip .avatar { width: 24px; height: 24px; font-size: 12px; border-width: 2px; }
  .chip .score { font-size: 13px; }
  .chip .status { display: none; }
  .tools { flex: none; gap: 5px; padding: 5px 6px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  .tool-row { flex: 1 1 100%; justify-content: space-between; gap: 3px; }
  .tool { width: 30px; border-width: 2px; border-radius: 8px; }
  .tool.selected { transform: translateY(-2px); box-shadow: 0 2px 0 var(--ink); }
  .side { flex: 1 1 96px; min-height: 96px; gap: 6px; }
  .chat { padding: 4px; font-size: 14px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
  .guess .btn { min-height: 46px; padding: 8px 14px; }
  .guess input { min-height: 46px; box-shadow: 0 3px 0 var(--ink); }
  .report { padding: 4px 8px; }
}

@media (max-width: 480px) {
  .lobby-grid { grid-template-columns: 1fr; gap: 20px; }
  .share { grid-template-columns: 1fr; }
  .card { padding: 22px 16px; border-radius: 20px; box-shadow: 5px 6px 0 rgba(10, 4, 30, .55); }
  .wordmark { gap: 3px; }
  .wordmark .w { padding: 3px 8px 6px; border-radius: 12px; }
  .doodles .d { opacity: .6; }
  .d5, .d6 { display: none; }
}

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

/* ---------- Google account ---------- */
.account { margin-bottom: 14px; }
.google-btn { display: flex; justify-content: center; min-height: 44px; }
.account .hint { margin-top: 8px; font-size: 13px; }
.account .or { margin-top: 12px; }
.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
}
.profile-pic { flex: none; width: 40px; height: 40px; border: 2.5px solid var(--ink); border-radius: 50%; object-fit: cover; }
.profile-text { flex: 1; min-width: 0; }
.profile-label { display: block; color: var(--muted); font: 600 12px var(--display); letter-spacing: .08em; text-transform: uppercase; }
.profile-text b { display: block; overflow: hidden; font: 600 19px/1.2 var(--display); text-overflow: ellipsis; white-space: nowrap; }
.btn.mini { min-height: 34px; padding: 4px 10px; font-size: 14px; box-shadow: 0 3px 0 var(--ink); }
.name-dialog { width: min(420px, calc(100vw - 32px)); }
.name-dialog h2 { padding-right: 44px; font-size: 28px; }
.name-dialog .hint { margin: 10px 0 14px; }
.name-form { display: flex; gap: 8px; }
.name-form input { flex: 1; min-width: 0; }
@media (max-width: 380px) {
  .profile { flex-wrap: wrap; }
  .profile-text { flex-basis: calc(100% - 60px); }
  .btn.mini { flex: 1; }
}
