:root {
  --bg: #fff4e0;
  --ink: #1d2340;
  --card: #ffffff;
  --muted: #6b6f86;
  --orange: #ff6b35;
  --teal: #12b5a5;
  --yellow: #ffd23f;
  --red: #ef3e5c;
  --green: #1fbf6b;
  --line: #1d2340;
  --shadow: 4px 4px 0 var(--line);
  --radius: 16px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% 10%, #ffe1b8 0, transparent 40%),
    radial-gradient(circle at 90% 85%, #d4f5ef 0, transparent 45%),
    var(--bg);
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
.logo {
  font-size: clamp(42px, 12vw, 72px); font-weight: 900; letter-spacing: -2px;
  color: var(--orange); text-shadow: 3px 3px 0 var(--line); transform: rotate(-3deg); margin: 18px 0 4px;
}
.tagline { color: var(--muted); font-size: 18px; max-width: 26em; }
.card {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; width: 100%;
}
button, .btn {
  font: inherit; font-weight: 800; font-size: 18px; color: var(--ink); cursor: pointer;
  background: var(--yellow); border: 3px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 18px; transition: transform .06s, box-shadow .06s; text-decoration: none; display: inline-block;
  touch-action: manipulation; user-select: none;
}
button:active:not(:disabled), .btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--line); }
button:disabled { cursor: default; }
button.primary, .btn.primary { background: var(--orange); color: #fff; }
button.ghost { background: var(--card); }
button.small { font-size: 14px; padding: 8px 12px; box-shadow: 3px 3px 0 var(--line); }
input {
  font: inherit; font-size: 20px; font-weight: 700; width: 100%; padding: 14px; color: var(--ink);
  border: 3px solid var(--line); border-radius: 14px; background: #fff; outline: none;
}
input:focus { box-shadow: 0 0 0 4px #ffd23f99; }
.row { display: flex; gap: 10px; width: 100%; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.small-print { font-size: 13px; color: var(--muted); }

/* lobby */
.code { font-size: 44px; font-weight: 900; letter-spacing: 6px; color: var(--teal); text-shadow: 2px 2px 0 var(--line); }
.players { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 15px;
}
.chip.me { background: #fff0c2; }
.chip.off { opacity: .45; }
.chip.done { background: var(--teal); color: #fff; }
.chip .crown { font-size: 14px; }
.seg { display: flex; gap: 8px; justify-content: center; }
.seg button { flex: 1; background: #fff; }
.seg button.on { background: var(--teal); color: #fff; }

/* question */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.round { font-weight: 900; font-size: 15px; color: var(--muted); white-space: nowrap; }
.title { font-weight: 900; font-size: 20px; text-align: center; margin: 4px 0 10px; min-height: 24px; }
.mult { background: var(--red); color: #fff; padding: 2px 8px; border-radius: 8px; font-size: 13px; margin-left: 6px; }
.timer { height: 14px; border: 3px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; margin-bottom: 12px; }
.timer > div { height: 100%; background: var(--teal); transform-origin: left; }
.timer.hurry > div { background: var(--red); }
.shape {
  aspect-ratio: 1; width: min(100%, 52dvh); margin: 0 auto 14px; display: block;
  background: var(--card); border: 3px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 4%;
}
.shape svg { width: 100%; height: 100%; overflow: visible; }
.shape path { fill: var(--ink); transition: fill .4s; }
.shape.right path { fill: var(--green); }
.shape .spin { transform-origin: 250px 250px; transition: transform 1.1s cubic-bezier(.5, -0.4, .3, 1.4); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.options button { background: #fff; padding: 14px 10px; min-height: 68px; font-size: 17px; line-height: 1.15; }
.options button .flag { display: block; font-size: 20px; margin-bottom: 2px; }
.options button.mine { background: var(--yellow); }
.options button.correct { background: var(--green); color: #fff; }
.options button.wrong { background: var(--red); color: #fff; }
.options button.dim { opacity: .45; }
.options button .who { display: block; font-size: 12px; font-weight: 700; margin-top: 4px; opacity: .9; }
.status { text-align: center; margin-top: 12px; font-weight: 700; color: var(--muted); min-height: 22px; }

/* reveal */
.reveal-top { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.reveal-top .shape.mini { width: 38%; flex: 0 0 38%; margin: 0; border-radius: 16px; }
.reveal-top .map { flex: 1; min-width: 0; margin: 0; }
.options.compact { gap: 8px; }
.options.compact button { min-height: 0; padding: 9px 8px; font-size: 15px; }
.reveal-name { font-size: 28px; font-weight: 900; text-align: center; }
.roast { text-align: center; font-style: italic; color: var(--muted); margin: 4px 0 10px; }
.map { width: 100%; display: block; margin: 6px 0; }
.map path { fill: #d9dbe6; stroke: #fff; stroke-width: .8; }
.map path.hit { fill: var(--orange); stroke: var(--line); stroke-width: 1.2; }
.quips { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.quips li { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; font-weight: 700; }
.board { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.board li { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; font-weight: 700; }
.board li.me { background: #fff0c2; }
.board .pos { width: 28px; font-weight: 900; color: var(--muted); }
.board .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .gain { color: var(--green); font-size: 14px; }
.board .gain.zero { color: var(--red); }
.board .pts { font-weight: 900; min-width: 56px; text-align: right; }
.board .stats { font-size: 12px; color: var(--muted); font-weight: 600; }
.next { text-align: center; color: var(--muted); font-weight: 700; margin-top: 10px; }

/* results */
.podium { font-size: 64px; }
.winner { font-size: 24px; font-weight: 900; }

#conn {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
}
.toast { animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
@keyframes wobble { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.wobble { animation: wobble 2s ease-in-out infinite; display: inline-block; }

/* share sheet (when the browser has no native one) */
#sheet {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: #1d234066; padding: 16px;
}
#sheet .sheet { max-width: 360px; gap: 10px; }
#sheet .qr { border: 3px solid var(--line); border-radius: 12px; width: 220px; height: 220px; background: #fff; }
#sheet input { font-size: 14px; text-align: center; }
#sheet .row .btn { flex: 1; text-align: center; padding: 10px 6px; font-size: 14px; }
