:root {
  --bg: #EDF0F3; --surface: #FFFFFF; --ink: #18202B; --muted: #5A6575; --line: #D3D9E0; --chip: #E2E7ED;
  --accent: #C8102E; --warm: #C9771F; --green: #2F5D50; --paper: #FBF8F1; --paper-ink: #2B2A27; --you: #DCEBFF;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root { --bg: #0F1319; --surface: #171D25; --ink: #E8ECF1; --muted: #9AA5B3; --line: #2A333E; --chip: #222A35; --accent: #F2485E; --warm: #F0A54A; --green: #5FA08C; color-scheme: dark; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font-body); overflow: hidden; }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--warm); outline-offset: 2px; }
#app { height: 100%; display: flex; flex-direction: column; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
#stage { position: relative; flex: 1; min-height: 0; background: #26303b; overflow: hidden; touch-action: none; user-select: none; }
#stage canvas { display: block; width: 100%; height: 100%; }

.taskcard { position: absolute; top: 12px; left: 12px; background: rgba(251,248,241,.95); color: #24221F; border-radius: 10px; padding: 9px 13px; font-size: 13px; line-height: 1.5; max-width: min(320px, 62%); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.taskcard .when { font-family: var(--font-mono); font-size: 11px; color: #6b665c; letter-spacing: .04em; }
.taskcard .goal { font-weight: 700; }
.taskcard .goal.done { color: #2F5D50; }
.taskcard .hidden-goals { color: #6b665c; }
.taskcard .hidden-goals b { color: #2F5D50; font-weight: 500; }
.topbar { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; }
.pill { border: 0; background: rgba(16,20,26,.72); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.banner { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font-size: 13.5px; padding: 6px 14px; border-radius: 999px; box-shadow: 0 6px 16px rgba(0,0,0,.25); max-width: calc(100% - 24px); text-align: center; }
.hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: rgba(16,20,26,.78); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 10px; max-width: calc(100% - 24px); text-align: center; }
.toast { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #2F5D50; color: #fff; font-size: 13.5px; padding: 8px 14px; border-radius: 10px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: calc(100% - 24px); }
.toast.on { opacity: 1; }

.bubble { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); background: #fff; color: #1b1b1b; border-radius: 12px; padding: 7px 11px; font-size: 14px; line-height: 1.35; max-width: 240px; width: max-content; box-shadow: 0 4px 14px rgba(0,0,0,.28); opacity: 0; transition: opacity .25s; }
.bubble.on { opacity: 1; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
.bubble b { display: block; font: 500 10.5px var(--font-mono); letter-spacing: .05em; text-transform: uppercase; color: #8a8a8a; }
.bubble.you { background: var(--you); } .bubble.you::after { border-top-color: var(--you); }
.bubble.stranger { background: #FFE7D6; } .bubble.stranger::after { border-top-color: #FFE7D6; }
.bubble.blur .tx { filter: blur(5px); cursor: pointer; }
.bubble .tx { transition: filter .2s; }
.bubble .think { display: inline-flex; gap: 3px; } .bubble .think i { width: 6px; height: 6px; border-radius: 50%; background: #999; animation: dot 1s infinite; } .bubble .think i:nth-child(2) { animation-delay: .15s } .bubble .think i:nth-child(3) { animation-delay: .3s }
@keyframes dot { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }

.whisper { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(420px, calc(100% - 24px)); background: rgba(16,20,26,.92); color: #fff; border-radius: 12px; padding: 12px 36px 12px 14px; display: grid; gap: 8px; font-size: 14px; }
.whisper .w-say { justify-self: start; border: 0; background: var(--you); color: #10223d; border-radius: 999px; padding: 6px 12px; font-weight: 500; }
.whisper .w-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: #fff; font-size: 20px; line-height: 1; }

.talkbar { background: var(--surface); border-top: 1px solid var(--line); padding: 10px max(12px, env(safe-area-inset-left, 0px)) 12px; display: grid; gap: 8px; }
.talkbar .who { font-size: 12.5px; color: var(--muted); }
.talkbar .who b { color: var(--ink); }
.talkbar .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.talkbar input { flex: 1; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 22px; padding: 0 16px; font: 15px var(--font-body); background: var(--bg); color: var(--ink); }
.talkbar input:disabled { opacity: .6; }
.talkbar .send { height: 44px; min-width: 56px; border: 0; border-radius: 22px; background: var(--green); color: #fff; font-weight: 700; }
.talkbar .send:disabled { opacity: .4; cursor: default; }
.talkbar .icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--chip); color: var(--ink); display: grid; place-items: center; }
.talkbar .icon.rec { background: var(--accent); color: #fff; border-color: var(--accent); }
.talkbar .actions button { border-radius: 999px; padding: 6px 14px; font-size: 13.5px; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.ghost:disabled { opacity: .45; cursor: default; }
.pay { border: 0; background: var(--warm); color: #fff; font-weight: 700; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--warm) 30%, transparent); } }

.overlay { position: fixed; inset: 0; background: rgba(10,14,20,.55); display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); z-index: 20; overflow-y: auto; }
.sheet { background: var(--surface); color: var(--ink); border-radius: 16px; padding: 24px; width: min(460px, 100%); display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.sheet h1, .sheet h2 { font-family: var(--font-display); margin: 0; line-height: 1.25; text-wrap: balance; }
.sheet h1 { font-size: 24px; } .sheet h2 { font-size: 20px; }
.sheet p { margin: 0; color: var(--muted); }
.sheet select { height: 44px; border-radius: 10px; border: 1px solid var(--line); padding: 0 12px; font: 15px var(--font-body); background: var(--bg); color: var(--ink); }
.eyebrow { font: 500 12px var(--font-mono); letter-spacing: .08em; color: var(--accent); text-transform: uppercase; }
.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: grid; gap: 4px; }
.primary { height: 46px; border: 0; border-radius: 12px; background: var(--green); color: #fff; font-weight: 700; font-size: 16px; }
.danger { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 10px; padding: 8px 12px; }
.sheet .ghost { border-radius: 10px; padding: 8px 12px; }
.fine { font-size: 12.5px; }
.switch { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.switch input { margin-top: 4px; }

.recap-wrap { display: grid; gap: 16px; justify-items: center; width: min(400px, 100%); }
.receipt { width: 100%; background: var(--paper); color: var(--paper-ink); font: 12.5px/1.55 var(--font-mono); padding: 24px 22px 30px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  -webkit-mask: radial-gradient(circle 6px at 50% 100%, transparent 98%, #000) bottom / 14px 100% repeat-x; mask: radial-gradient(circle 6px at 50% 100%, transparent 98%, #000) bottom / 14px 100% repeat-x; }
.receipt .c { text-align: center; }
.receipt .big { font: 800 22px var(--font-display); letter-spacing: .04em; }
.receipt hr { border: 0; border-top: 1px dashed #a39d90; margin: 12px 0; }
.receipt .row { display: flex; justify-content: space-between; gap: 10px; }
.receipt .said { color: #8a8476; text-decoration: line-through; text-decoration-color: rgba(200,16,46,.6); }
.receipt .better { font-weight: 500; margin-bottom: 8px; cursor: pointer; }
.receipt .better::after { content: " ▸"; color: #8a8476; }
.receipt .l1 { font: 12.5px/1.6 var(--font-body); }
.recap-actions { width: 100%; display: grid; gap: 8px; }
.recap-actions .fine { color: #e8ecf1; text-align: center; }

@media (max-width: 560px) {
  .taskcard { font-size: 12px; max-width: 64%; }
  .banner { top: 92px; font-size: 12.5px; }
  .bubble { font-size: 13px; max-width: 190px; }
}
@media (prefers-reduced-motion: reduce) { .pay { animation: none; } .bubble, .toast { transition: none; } }

/* sign-in */
.account { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.account .acct-apple { background: #000; color: #fff; border: 0; border-radius: 999px; padding: 11px 16px; font: 500 15px/1 -apple-system, system-ui, sans-serif; cursor: pointer; }
.account .acct-google { min-height: 40px; display: flex; justify-content: center; }
.account .acct-note:empty { display: none; }

/* report */
.bubble .flag { border: 0; background: none; color: #9aa3ad; font-size: 13px; padding: 6px 8px; margin: -6px -8px -6px 0; min-width: 28px; min-height: 28px; cursor: pointer; vertical-align: baseline; }
.bubble .flag:hover, .bubble .flag:focus-visible { color: var(--accent); }
.sheet fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.sheet legend { font-weight: 700; font-size: 14px; margin-bottom: 6px; padding: 0; }
.rep-lines label, .rep-reasons label { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.rep-lines label { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.rep-lines label b { font-weight: 600; margin-right: 4px; }
.rep-lines input, .rep-reasons input { margin-top: 3px; flex: none; }

/* Japanese players: Japanese glyph shapes, not the Chinese ones */
html:lang(ja) { --font-body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif; --font-display: "Bricolage Grotesque", "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif; }
