:root { --teal-deep: #173A40; --sage: #DCE6DF; --vinyl: #EFE8DC; --safe: #1FB8A6; --alarm: #FF6B57; --ink: #1B2326;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--teal-deep); color: var(--ink);
  font-family: Nunito, system-ui, sans-serif; font-weight: 600; -webkit-tap-highlight-color: transparent; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px; padding: 16px; z-index: 20; }
.screen.show { display: flex; }
.screen.dim { background: rgba(23, 58, 64, 0.72); }
#loading { background: var(--teal-deep); color: var(--vinyl); }
.load-box { text-align: center; }
.load-room { width: 180px; height: 110px; border: 3px solid var(--sage); border-top: 0; position: relative; margin: 0 auto 14px;
  clip-path: polygon(0 0, 50% 22%, 100% 0, 100% 100%, 0 100%); overflow: hidden; }
#loadFill { position: absolute; left: 0; bottom: 0; width: 100%; height: 0; background: var(--safe); transition: height .2s; }
.panel { background: var(--vinyl); border-radius: 18px; padding: 22px 22px 18px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.35); max-height: calc(100vh - 32px); overflow: auto; }
.panel.wide { max-width: 560px; }
h1 { font-weight: 800; font-size: clamp(34px, 8vw, 48px); margin: 0 0 4px; color: var(--teal-deep); letter-spacing: -0.5px; }
h2 { font-weight: 800; margin: 0 0 10px; color: var(--teal-deep); }
.sub { margin: 0 0 12px; color: #3d5a5e; font-size: 17px; }
.how { margin: 0 0 18px; line-height: 1.45; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; background: var(--safe); color: #062b27; font-weight: 800; min-height: 44px; }
.btn.big { width: 100%; font-size: 20px; padding: 14px; margin-bottom: 10px; }
.btn.ghost { background: transparent; color: var(--teal-deep); border: 2px solid #b9c9c6; }
.btn:focus-visible, .vchip:focus-visible, .icon-btn:focus-visible { outline: 3px solid #ffd27a; outline-offset: 2px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.best, .seed { color: #5b6f72; font-size: 14px; margin: 8px 0 0; }
.toggle { display: block; margin: 10px 0; }
/* HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { pointer-events: none; }
.hud button { pointer-events: auto; }
.hud-top { position: absolute; top: calc(10px + var(--sat)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.hud-left { flex-direction: column; align-items: flex-start; }

.chip-dark { white-space: nowrap; background: rgba(23,58,64,.88); color: var(--vinyl); padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 14px; }
.chip-card { background: #fff6d6; color: #5a3b00; border: 0; border-radius: 10px; padding: 6px 10px; font-weight: 800; font-size: 12px; max-width: 46vw; text-align: left; }
.hud-mid { text-align: center; }
.dots { display: flex; gap: 6px; justify-content: center; background: rgba(23,58,64,.88); padding: 7px 10px; border-radius: 999px; color: var(--vinyl); font-weight: 800; font-size: 14px; min-height: 30px; align-items: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--sage); }
.dot.on { background: var(--safe); border-color: var(--safe); }
.score { color: var(--vinyl); font-weight: 800; margin-top: 4px; text-shadow: 0 1px 3px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.timer { position: relative; width: 48px; height: 48px; }
.timer svg { width: 48px; height: 48px; transform: rotate(-90deg); }
.t-track { fill: rgba(23,58,64,.88); stroke: rgba(220,230,223,.3); stroke-width: 4; }
.t-arc { fill: none; stroke: var(--safe); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 119.4; transition: stroke-dashoffset .3s linear; }
.timer.warn .t-arc { stroke: var(--alarm); }
#tNum { position: absolute; inset: 0; display: grid; place-items: center; color: var(--vinyl); font-weight: 800; font-variant-numeric: tabular-nums; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(23,58,64,.88); color: var(--vinyl); font-weight: 800; }
.hud-bottom { position: absolute; left: 10px; right: 10px; bottom: calc(10px + var(--sab)); display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.views { display: flex; gap: 6px; flex-wrap: wrap; }
.vchip { border: 0; border-radius: 999px; background: rgba(23,58,64,.88); color: var(--vinyl); padding: 10px 12px; min-height: 44px; font-weight: 800; font-size: 14px; }
.vchip.on { background: var(--sage); color: var(--teal-deep); }
.vchip.pulse { animation: pulse 0.9s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.12); background: var(--safe); color: #062b27; } }
.btn.leave { min-height: 48px; font-size: 17px; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.toast { position: absolute; left: 50%; bottom: calc(76px + var(--sab)); transform: translate(-50%, 30px); opacity: 0; max-width: min(92vw, 520px);
  background: var(--vinyl); border-left: 6px solid var(--safe); border-radius: 12px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  transition: transform .28s cubic-bezier(.2,1.4,.4,1), opacity .2s; font-size: 16px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.grey { border-left-color: #8a9396; }
.toast.miss { border-left-color: var(--alarm); }
.toast b { display: block; font-weight: 800; }
.coach { position: absolute; top: calc(78px + var(--sat)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--vinyl); padding: 10px 16px;
  border-radius: 12px; font-weight: 800; max-width: 90vw; text-align: center; }
/* stamps + float text */
#stamps { position: fixed; inset: 0; pointer-events: none; z-index: 12; }
.stamp { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; border: 5px solid var(--safe); background: rgba(31,184,166,.18);
  display: grid; place-items: center; color: var(--safe); font-size: 28px; font-weight: 800; animation: stamp .28s cubic-bezier(.3,1.6,.5,1) both, fadeout .4s 1.4s forwards; }
.stamp.miss { border-color: var(--alarm); color: var(--alarm); background: rgba(255,107,87,.18); }
@keyframes stamp { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes fadeout { to { opacity: 0; } }
.float { position: absolute; color: #fff; font-weight: 800; font-size: 20px; text-shadow: 0 2px 4px rgba(0,0,0,.6); animation: floatup 1s ease-out forwards; transform: translate(-50%, -50%); }
.float.bad { color: #ffd0c8; }
@keyframes floatup { to { transform: translate(-50%, -150%); opacity: 0; } }
.hand { position: absolute; font-size: 40px; animation: bob .8s ease-in-out infinite; transform: translate(-10%, 10%); }
@keyframes bob { 50% { margin-top: 10px; } }
.focus-ring { position: fixed; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; border: 3px dashed #ffd27a; pointer-events: none; z-index: 11; }
.door-card { background: var(--vinyl); border-radius: 14px; padding: 18px 22px; max-width: 360px; text-align: center; box-shadow: 0 18px 50px rgba(0,0,0,.4); border-top: 10px solid #f5c518; animation: flip .5s ease-out both; }
.door-card .nm { font-size: 20px; font-weight: 800; } .door-card .pc { font-size: 22px; font-weight: 800; color: #8a1f12; margin: 8px 0; } .door-card .hint { color: #4f6164; font-size: 14px; }
@keyframes flip { from { transform: perspective(600px) rotateY(80deg); opacity: 0; } }
.stars { font-size: 34px; letter-spacing: 6px; color: #f5b70a; margin-bottom: 6px; }
.list { list-style: none; padding: 0; margin: 0 0 12px; text-align: left; }
.list li { padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; background: #fff; line-height: 1.35; font-size: 15px; }
.list li .tag { font-weight: 800; margin-right: 6px; }
.list li.ok .tag { color: #0f7f72; } .list li.miss .tag { color: #c23a26; }
.list li small { display: block; color: #4f6164; }
.score-big { font-size: 22px; font-weight: 800; color: var(--teal-deep); }
.bars { text-align: left; margin-bottom: 10px; }
.bar { margin-bottom: 8px; } .bar span { display: block; font-size: 14px; } .bar i { display: block; height: 12px; border-radius: 6px; background: var(--safe); }
.reel-bar { position: fixed; top: calc(12px + var(--sat)); left: 50%; transform: translateX(-50%); z-index: 15; background: var(--ink); color: var(--vinyl);
  border-radius: 12px; padding: 8px 8px 8px 14px; display: flex; gap: 12px; align-items: center; max-width: 94vw; }
.reel-bar .btn.ghost { color: var(--vinyl); border-color: #4f6164; min-height: 36px; padding: 6px 12px; }
a { color: #0f7f72; }
@media (max-width: 520px) {
  .vchip { padding: 8px 9px; font-size: 13px; }
  .hud-bottom { flex-direction: column; align-items: stretch; }
  .views { justify-content: space-between; flex-wrap: nowrap; } .views .vchip { flex: 1; white-space: nowrap; } .vchip .k { display: none; }
  .btn.leave { width: 100%; }
  .toast { bottom: calc(124px + var(--sab)); }
  .coach { top: calc(128px + var(--sat)); font-size: 14px; }
  .chip-card { max-width: 40vw; }
}
@media (prefers-reduced-motion: reduce) { .stamp, .float, .toast, .door-card { animation-duration: .01s !important; transition: none !important; } }
