:root {
  --ink: #1b2236;
  --ink-2: #48506a;
  --ink-3: #6f7790;
  --paper: #fffaf0;
  --paper-2: #f3ecdc;
  --line: #e2d8c2;
  --sky: #4fa8f0;
  --grass: #5cb84a;
  --grass-d: #3c8a2f;
  --gold: #ffc93c;
  --gold-d: #d99a12;
  --coral: #ff6b5e;
  --coral-d: #cf4237;
  --teal: #1fb5a6;
  --teal-d: #138277;
  --violet: #8e7cff;
  --blue: #3f7fe8;
  --blue-d: #2a5bb0;
  --shadow: 0 6px 0 rgba(27, 34, 54, .22), 0 18px 40px rgba(27, 34, 54, .25);
  --r: 18px;
  --sp: 8px;
  --f-display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --f-body: 'Nunito', system-ui, -apple-system, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #4fa8f0; color: var(--ink); font-family: var(--f-body); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px;
  background: #fff; color: var(--ink); font-weight: 900; font-size: 16px; letter-spacing: .2px;
  box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 var(--line);
  transition: transform .08s, box-shadow .08s, background .15s; position: relative; top: 0;
}
.btn:hover { background: #fffdf7; }
.btn:active, .btn.press { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--line), 0 1px 0 var(--line); }
.btn:focus-visible, .mode:focus-visible, .iconbtn:focus-visible, .ccard:focus-visible, .slot:focus-visible, .pcell:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.btn.primary { background: var(--grass); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12), 0 5px 0 var(--grass-d); text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn.primary:hover { background: #66c553; }
.btn.primary:active, .btn.primary.press { box-shadow: inset 0 -3px 0 rgba(0,0,0,.12), 0 1px 0 var(--grass-d); transform: translateY(4px); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 44px; padding: 0 16px; font-size: 15px; }
.btn svg { width: 20px; height: 20px; }
.btn.primary svg { fill: currentColor; stroke: none; }
#pRestart svg, #rAgain svg, .row2 svg, #rHub svg, #rNext svg { fill: none; stroke: currentColor; }
.iconbtn {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255, 250, 240, .92); color: var(--ink); box-shadow: 0 4px 0 rgba(27,34,54,.25);
  transition: transform .08s, box-shadow .08s;
}
.iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(27,34,54,.25); }
.iconbtn.ghost { background: var(--paper-2); box-shadow: 0 3px 0 var(--line); }
#pauseBtn svg rect { fill: currentColor; stroke: none; }

/* ---------- panels / screens ---------- */
.panel { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); position: relative; }
.screen {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  opacity: 0; visibility: hidden; transition: opacity .28s ease, visibility 0s linear .28s;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.screen.show { opacity: 1; visibility: visible; transition: opacity .28s ease; }
.screen > * { transform: translateY(14px) scale(.98); transition: transform .34s cubic-bezier(.2,1.4,.4,1); }
.screen.show > * { transform: none; }
#pause, #courses, #result, #palette { background: rgba(18, 26, 48, .42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#pause, #courses, #palette, #result { touch-action: pan-y; }

/* ---------- title ---------- */
#title { background: linear-gradient(180deg, rgba(20,40,80,0) 30%, rgba(20,40,80,.28)); align-items: center; }
.tgrid { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 320px); gap: 20px; align-items: center; width: 100%; max-width: 800px; margin: auto; }
.tmain { padding: 26px 26px 20px; }
.badge {
  position: absolute; top: -14px; right: 20px; background: var(--violet); color: #fff; font-weight: 900; font-size: 13px;
  letter-spacing: .6px; text-transform: uppercase; padding: 6px 12px; border-radius: 10px; box-shadow: 0 3px 0 #6450d6; transform: rotate(2deg);
}
.logo { margin: 2px 0 6px; display: flex; gap: 4px; font-family: var(--f-display); font-weight: 400; font-size: 46px; line-height: 1; }
.logo span {
  display: grid; place-items: center; width: 1.04em; height: 1.1em; border-radius: 8px; color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.2); box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), inset 0 3px 0 rgba(255,255,255,.25);
  animation: hop 2.6s cubic-bezier(.3,1.6,.5,1) infinite;
}
.logo span:nth-child(1) { background: #5cb84a; animation-delay: 0s; }
.logo span:nth-child(2) { background: #8a5a3a; animation-delay: .08s; }
.logo span:nth-child(3) { background: #8c9099; animation-delay: .16s; }
.logo span:nth-child(4) { background: #c89a5a; animation-delay: .24s; }
.logo span:nth-child(5) { background: #ff6b5e; animation-delay: .32s; }
.logo span:nth-child(6) { background: #1fb5a6; animation-delay: .4s; }
.logo span:nth-child(7) { background: #ffc93c; animation-delay: .48s; color: #6a4a00; text-shadow: none; }
.logo span:nth-child(8) { background: #8e7cff; animation-delay: .56s; }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 70% { transform: translateY(-9px); } 80% { transform: translateY(0); } }
.tag { margin: 6px 0 16px; font-size: 16px; font-weight: 700; color: var(--ink-2); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 12px 12px; min-height: 104px;
  border-radius: 14px; text-align: left; color: #fff; position: relative; overflow: hidden;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.mode:hover { filter: brightness(1.05); }
.mode:active { transform: translateY(4px); }
.mode .mi { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.22); display: grid; place-items: center; margin-bottom: 6px; }
.mode .mt { font-family: var(--f-display); font-size: 18px; line-height: 1.05; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.mode .ms { font-size: 12.5px; font-weight: 800; opacity: .92; }
.m-park { background: linear-gradient(160deg, #ffcf4a, #f5a623); box-shadow: 0 5px 0 #c27c0e; color: #4a3000; }
.m-park .mt { text-shadow: none; }
.m-park:active { box-shadow: 0 1px 0 #c27c0e; }
.m-build { background: linear-gradient(160deg, #5aa2ff, #3f7fe8); box-shadow: 0 5px 0 var(--blue-d); }
.m-build:active { box-shadow: 0 1px 0 var(--blue-d); }
.m-zomb { background: linear-gradient(160deg, #4a5a8a, #2b3358); box-shadow: 0 5px 0 #1a2040; }
.m-zomb:active { box-shadow: 0 1px 0 #1a2040; }
.m-zomb .mi { color: #b6f56a; }
.how { margin: 16px 0 0; font-size: 13.5px; font-weight: 700; color: var(--ink-3); line-height: 1.4; }
.early { margin: 10px 0 0; font-size: 13px; font-weight: 800; color: #6450d6; }
.tside { padding: 18px 20px; }
.sidehd { display: flex; align-items: center; justify-content: space-between; width: 100%; font-family: var(--f-display); font-size: 19px; text-align: left; min-height: 44px; gap: 8px; }
.sidehd svg { transition: transform .2s; display: none; }
.full { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 9px; }
.full li { position: relative; padding-left: 22px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); line-height: 1.35; }
.full li::before { content: ''; position: absolute; left: 0; top: 4px; width: 11px; height: 11px; border-radius: 3px; background: var(--grass); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.full li:nth-child(2n)::before { background: var(--gold); }
.full li:nth-child(3n)::before { background: var(--coral); }
.full b { color: var(--ink); font-weight: 900; }
.missing { margin: 12px 0 0; font-size: 12.5px; font-weight: 700; color: var(--ink-3); border-top: 2px dashed var(--line); padding-top: 10px; }
#soundBtn { position: absolute; right: 14px; bottom: 12px; width: 44px; height: 44px; background: var(--paper-2); box-shadow: 0 3px 0 var(--line); }
.tmain .early { padding-right: 52px; }
#soundBtn.off .wave { display: none; }
#soundBtn.off::after { content: ''; position: absolute; width: 26px; height: 3px; background: var(--coral); transform: rotate(-45deg); border-radius: 2px; }

/* ---------- sheets ---------- */
.sheet { width: 100%; max-width: 720px; padding: 20px 22px 22px; margin: auto; }
.sheet.small { max-width: 420px; }
.shead { display: flex; align-items: center; gap: 12px; }
.shead h2, .rhead h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 28px; flex: 1; line-height: 1.1; }
.ssub { margin: 6px 0 14px; font-size: 14px; font-weight: 700; color: var(--ink-3); }
.medalcount { font-weight: 900; font-size: 14px; background: var(--paper-2); padding: 8px 12px; border-radius: 10px; display: flex; gap: 6px; align-items: center; }
.medalcount::before { content: ''; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2b0, var(--gold) 55%, var(--gold-d)); }
.clist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ccard {
  display: flex; flex-direction: column; text-align: left; border-radius: 16px; overflow: hidden; background: #fff;
  box-shadow: inset 0 0 0 2px var(--line), 0 5px 0 var(--line); transition: transform .08s, box-shadow .08s; min-height: 44px;
}
.ccard:active { transform: translateY(4px); box-shadow: inset 0 0 0 2px var(--line), 0 1px 0 var(--line); }
.ccard .cart { height: 84px; position: relative; display: flex; align-items: flex-end; padding: 10px 12px; }
.ccard .cnum { position: absolute; top: 10px; left: 12px; font-family: var(--f-display); font-size: 14px; color: #fff; background: rgba(0,0,0,.25); border-radius: 8px; padding: 3px 8px; }
.ccard .cart canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.ccard .cbody { padding: 10px 12px 12px; display: grid; gap: 4px; }
.ccard .cname { font-family: var(--f-display); font-size: 19px; }
.ccard .csub { font-size: 12.5px; font-weight: 700; color: var(--ink-3); min-height: 2.6em; }
.ccard .cbest { display: flex; align-items: center; justify-content: space-between; font-weight: 900; font-size: 14px; margin-top: 4px; }
.ccard .ctimes { display: flex; gap: 6px; font-size: 12px; font-weight: 800; color: var(--ink-2); flex-wrap: wrap; }
.ctimes span { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }
.dot.g { background: var(--gold); } .dot.s { background: #c9d3e0; } .dot.b { background: #d98a4e; } .dot.n { background: #e5e0d4; }

/* palette */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.pcell { aspect-ratio: 1; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 2px var(--line), 0 3px 0 var(--line); display: grid; place-items: center; min-height: 52px; }
.pcell img { width: 70%; image-rendering: pixelated; }
.pcell:active { transform: translateY(2px); }
.pcell.cur { box-shadow: inset 0 0 0 3px var(--blue), 0 3px 0 var(--blue-d); }

/* pause */
.modechip { font-weight: 900; font-size: 13px; background: var(--paper-2); padding: 7px 12px; border-radius: 10px; }
.pbtns { display: grid; gap: 12px; margin: 16px 0 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings { margin-top: 16px; border-top: 2px dashed var(--line); padding-top: 12px; display: grid; gap: 10px; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-weight: 800; font-size: 15px; min-height: 44px; }
.srow input[type=range] { flex: 1; max-width: 200px; accent-color: var(--grass); height: 32px; }
.seg { display: flex; background: var(--paper-2); border-radius: 12px; padding: 3px; }
.seg button { min-height: 40px; min-width: 76px; border-radius: 10px; font-weight: 900; font-size: 14px; color: var(--ink-3); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 0 var(--line); }

/* result */
.rhead { text-align: center; }
.rkicker { font-weight: 900; font-size: 13px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--grass-d); margin-bottom: 4px; }
.rkicker.bad { color: var(--coral-d); }
#result .sheet { max-width: 520px; text-align: center; }
.medal { width: 96px; height: 96px; margin: 14px auto 2px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-display); font-size: 15px; color: #fff; position: relative; animation: medalIn .7s cubic-bezier(.2,1.6,.4,1) both; text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.medal::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; border: 3px dashed rgba(255,255,255,.55); }
.medal.gold { background: radial-gradient(circle at 35% 30%, #fff2b0, var(--gold) 45%, var(--gold-d)); box-shadow: 0 6px 0 #a87406; }
.medal.silver { background: radial-gradient(circle at 35% 30%, #ffffff, #c9d3e0 50%, #8d9aae); box-shadow: 0 6px 0 #6c788a; }
.medal.bronze { background: radial-gradient(circle at 35% 30%, #ffd2a8, #d98a4e 50%, #a25a26); box-shadow: 0 6px 0 #7a3f14; }
.medal.none { background: radial-gradient(circle at 35% 30%, #fff, #d8d2c4); color: var(--ink-3); text-shadow: none; box-shadow: 0 6px 0 #b5ae9e; }
@keyframes medalIn { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: none; } }
.rstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0 18px; }
.stat { background: var(--paper-2); border-radius: 14px; padding: 10px 12px; }
.stat .k { font-size: 12px; font-weight: 900; letter-spacing: .8px; text-transform: uppercase; color: var(--ink-3); }
.stat .v { font-family: var(--f-display); font-size: 28px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 15px; color: var(--ink-3); }
.stat.hi { background: #fff4cf; box-shadow: inset 0 0 0 2px #ffe08a; }
.stat .nb { display: inline-block; margin-top: 2px; font-size: 12px; font-weight: 900; background: var(--coral); color: #fff; border-radius: 8px; padding: 2px 8px; }
.rbtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.rbtns .btn { flex: 1 1 0; white-space: nowrap; padding: 0 12px; min-width: 0; }
.judges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.judge { background: #fff; border-radius: 14px; box-shadow: inset 0 0 0 2px var(--line); padding: 10px 8px 12px; opacity: 0; transform: translateY(12px) scale(.9); transition: opacity .3s, transform .4s cubic-bezier(.2,1.6,.4,1); }
.judge.in { opacity: 1; transform: none; }
.judge .jface { width: 44px; height: 44px; margin: 0 auto 6px; border-radius: 10px; image-rendering: pixelated; box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.judge .jn { font-weight: 900; font-size: 13px; }
.judge .jr { font-size: 12px; font-weight: 800; color: var(--ink-3); }
.judge .js { font-family: var(--f-display); font-size: 30px; line-height: 1.1; color: var(--blue); font-variant-numeric: tabular-nums; }
.judge .jc { font-size: 12.5px; font-weight: 700; color: var(--ink-2); line-height: 1.3; min-height: 2.6em; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud button, #hud .card { pointer-events: auto; }
#topbar { position: absolute; top: calc(10px + var(--sat)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(440px, calc(100% - 260px)); min-width: 200px; }
.pill {
  background: rgba(255, 250, 240, .94); border-radius: 16px; box-shadow: 0 4px 0 rgba(27,34,54,.22); padding: 8px 14px;
  display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 15px; white-space: nowrap; max-width: 100%;
}
.pill .big { font-family: var(--f-display); font-size: 26px; font-weight: 400; font-variant-numeric: tabular-nums; line-height: 1; }
.pill .lbl { font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--ink-3); display: block; line-height: 1.1; }
.pill .sep { width: 2px; align-self: stretch; background: var(--line); border-radius: 2px; }
.pill .col { display: flex; flex-direction: column; align-items: flex-start; }
.pill .prompt { font-family: var(--f-display); font-weight: 400; font-size: 18px; white-space: normal; line-height: 1.1; }
.pill .hearts { display: flex; gap: 2px; }
.heart { width: 18px; height: 16px; position: relative; }
.heart svg { width: 18px; height: 16px; stroke: none; }
.pill .donebtn { min-height: 40px; padding: 0 12px; font-size: 14px; }
.pill .tmlow { color: var(--coral-d); }
#tright { position: absolute; top: calc(10px + var(--sat)); right: calc(10px + var(--sar)); display: flex; gap: 8px; }
#toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: var(--ink); color: #fff; font-weight: 900; font-size: 14px; padding: 8px 14px; border-radius: 12px; box-shadow: 0 3px 0 rgba(0,0,0,.25); animation: tin .25s cubic-bezier(.2,1.6,.4,1), tout .3s ease 1.9s forwards; white-space: nowrap; }
.toast.good { background: var(--teal); box-shadow: 0 3px 0 var(--teal-d); }
.toast.warn { background: var(--coral); box-shadow: 0 3px 0 var(--coral-d); }
.toast.gold { background: var(--gold); color: #4a3000; box-shadow: 0 3px 0 var(--gold-d); }
@keyframes tin { from { transform: translateY(-10px) scale(.8); opacity: 0; } }
@keyframes tout { to { transform: translateY(-6px); opacity: 0; } }
#cross { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); }
#cross i { position: absolute; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1.5px rgba(0,0,0,.35); }
#cross i:first-child { left: 10px; top: 2px; width: 2.5px; height: 18px; }
#cross i:last-child { top: 10px; left: 2px; height: 2.5px; width: 18px; }
#banner { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); font-family: var(--f-display); font-size: clamp(30px, 8vw, 56px); color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.28); text-align: center; white-space: nowrap; animation: bin .5s cubic-bezier(.2,1.6,.4,1); }
#banner small { display: block; font-family: var(--f-body); font-weight: 900; font-size: 16px; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
@keyframes bin { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }
#portalCard { position: absolute; left: 50%; bottom: calc(150px + var(--sab)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); min-width: 280px; }
#portalCard .pcicon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
#portalCard .pctext { display: flex; flex-direction: column; flex: 1; }
#portalCard b { font-family: var(--f-display); font-weight: 400; font-size: 20px; }
#portalCard span { font-size: 13px; font-weight: 700; color: var(--ink-3); }
.pop { animation: popin .3s cubic-bezier(.2,1.6,.4,1); }
@keyframes popin { from { transform: translateX(-50%) translateY(12px) scale(.9); opacity: 0; } }
#hotbar { position: absolute; left: 50%; bottom: calc(10px + var(--sab)); transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; border-radius: 16px; background: rgba(27, 34, 54, .55); pointer-events: auto; }
.slot { width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center; position: relative; background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); transition: transform .1s; }
.slot img { width: 34px; height: 34px; image-rendering: pixelated; pointer-events: none; }
.slot.cur { background: rgba(255,255,255,.3); box-shadow: inset 0 0 0 3px #fff; transform: translateY(-3px); }
.slot .n { position: absolute; right: 3px; bottom: 1px; font-weight: 900; font-size: 12px; color: #fff; text-shadow: 0 1px 0 #000; }
.slot .k { position: absolute; left: 4px; top: 1px; font-weight: 900; font-size: 11px; color: rgba(255,255,255,.75); }
.slot.plus { background: var(--blue); box-shadow: 0 3px 0 var(--blue-d); color: #fff; }
.slot.plus svg { width: 22px; height: 22px; }
.slot svg.sword { width: 32px; height: 32px; }
#lockHint { position: absolute; left: 50%; bottom: calc(84px + var(--sab)); transform: translateX(-50%); background: rgba(27,34,54,.8); color: #fff; padding: 12px 18px; border-radius: 14px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
#lockHint b { font-family: var(--f-display); font-weight: 400; font-size: 20px; }
#lockHint span { font-size: 13px; font-weight: 700; opacity: .85; }
#count { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; pointer-events: none; font-family: var(--f-display); font-size: 120px; color: #fff; text-shadow: 0 6px 0 rgba(0,0,0,.25); }
#count.go { color: var(--gold); }
#count span { animation: cnt .9s ease forwards; }
@keyframes cnt { 0% { transform: scale(1.8); opacity: 0; } 20% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }
#hurtv { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 40, 40, .55)); transition: opacity .3s; }
#fade { position: fixed; inset: 0; z-index: 40; background: #4fa8f0; display: grid; place-items: center; opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s linear .25s; }
#fade.on { opacity: 1; visibility: visible; transition: opacity .2s; }
.ldblock { display: flex; gap: 8px; }
.ldblock i { width: 22px; height: 22px; border-radius: 5px; background: #fff; box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); animation: hop 1s cubic-bezier(.3,1.6,.5,1) infinite; }
.ldblock i:nth-child(2) { animation-delay: .1s; background: var(--gold); }
.ldblock i:nth-child(3) { animation-delay: .2s; background: var(--grass); }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
#stickZone { position: absolute; left: 0; bottom: 0; width: 45%; height: 70%; pointer-events: auto; }
#stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 3px rgba(255,255,255,.45); pointer-events: none; }
#stickGhost { position: absolute; left: calc(36px + var(--sal)); bottom: calc(96px + var(--sab)); width: 104px; height: 104px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(255,255,255,.35); background: rgba(255,255,255,.08); pointer-events: none; transition: opacity .2s; }
#stickGhost i { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(255,255,255,.35); }
#stick:not([hidden]) ~ #stickGhost, body.sticking #stickGhost { opacity: 0; }
#knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 3px 0 rgba(0,0,0,.2); }
#tbtns { position: absolute; right: calc(14px + var(--sar)); bottom: calc(76px + var(--sab)); display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 12px; align-items: end; pointer-events: none; }
.tbtn { pointer-events: auto; width: 62px; height: 62px; border-radius: 50%; background: rgba(255, 250, 240, .86); box-shadow: 0 4px 0 rgba(27,34,54,.3); display: grid; place-items: center; align-content: center; color: var(--ink); transition: transform .06s, box-shadow .06s; }
.tbtn span { font-size: 11px; font-weight: 900; line-height: 1; margin-top: 1px; }
.tbtn svg { width: 24px; height: 24px; }
.tbtn img { width: 26px; height: 26px; image-rendering: pixelated; }
.tbtn.big { width: 82px; height: 82px; background: var(--grass); color: #fff; box-shadow: 0 5px 0 var(--grass-d); }
.tbtn.big svg { width: 34px; height: 34px; stroke-width: 3; }
.tbtn.held { transform: translateY(3px); box-shadow: 0 1px 0 rgba(27,34,54,.3); }
.tbtn.big.held { box-shadow: 0 1px 0 var(--grass-d); }
.tbtn.atk { background: var(--coral); color: #fff; box-shadow: 0 4px 0 var(--coral-d); }
#tDown { grid-column: 1; grid-row: 1; }
#tBreak { grid-column: 1; grid-row: 1; }
#tPlace { grid-column: 2; grid-row: 1; }
#tJump { grid-column: 2; grid-row: 2; justify-self: end; }
#tDown:not([hidden]) ~ #tBreak { grid-column: 1; grid-row: 2; }
body.touch #hotbar { bottom: calc(8px + var(--sab)); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  #title { padding-top: calc(72px + var(--sat)); align-items: flex-start; }
  .tgrid { grid-template-columns: 1fr; max-width: 460px; gap: 16px; }
  .tmain { padding: 22px 18px 16px; }
  .logo { font-size: clamp(32px, 10vw, 44px); gap: 3px; }
  .clist { grid-template-columns: 1fr; }
  .ccard { flex-direction: row; }
  .ccard .cart { width: 104px; height: auto; min-height: 104px; flex: none; }
  .ccard .csub { min-height: 0; }
  .sidehd svg { display: block; }
  .tside:not(.open) .full, .tside:not(.open) .missing { display: none; }
  .tside.open .sidehd svg { transform: rotate(180deg); }
  #topbar { top: calc(66px + var(--sat)); width: calc(100% - 24px); }
  #portalCard { bottom: calc(240px + var(--sab)); min-width: 0; width: calc(100% - 40px); max-width: 340px; }
  .pill { padding: 6px 12px; gap: 10px; }
  .pill .big { font-size: 22px; }
}
@media (max-width: 420px) {
  .stat { padding: 8px; }
  .stat .v { font-size: 22px; }
  .stat .k { font-size: 11px; letter-spacing: .4px; }
  .rbtns { gap: 8px; flex-wrap: wrap; }
  .rbtns .btn.primary { flex: 1 1 100%; }
  .rbtns .btn { font-size: 15px; padding: 0 8px; }
}
@media (max-width: 380px) {
  .modes { gap: 8px; }
  .mode { padding: 10px; min-height: 96px; }
  .mode .mt { font-size: 16px; }
  .mode .ms { font-size: 12px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  #title { padding-left: calc(132px + var(--sal)); }
  .tgrid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); max-width: 820px; align-items: start; gap: 14px; }
  .missing { display: none; }
  .sidehd { font-size: 17px; min-height: 30px; }
  .mode .mi { display: none; }
  .mode { min-height: 70px !important; justify-content: center; }
  .logo { margin-bottom: 2px; }
  .how { font-size: 12px !important; margin-top: 8px !important; }
  .early { margin-top: 6px; }
  #stickGhost { bottom: calc(40px + var(--sab)); left: calc(56px + var(--sal)); }
  .tmain { padding: 18px 20px 14px; }
  .logo { font-size: 34px; }
  .tag { margin: 4px 0 10px; font-size: 14px; }
  .btn { min-height: 46px; }
  .modes { margin-top: 10px; }
  .mode { min-height: 84px; padding: 10px; }
  .mode .mi { width: 30px; height: 30px; margin-bottom: 3px; }
  .how { margin-top: 10px; font-size: 12.5px; }
  .tside { padding: 14px 16px; }
  .full { gap: 6px; }
  .full li { font-size: 12.5px; }
  .clist { grid-template-columns: repeat(3, 1fr); }
  .ccard .cart { height: 64px; }
  .sheet { padding: 16px 18px; }
  .rstats { margin: 10px 0 12px; }
  .medal { width: 64px; height: 64px; margin-top: 6px; font-size: 13px; }
  #result .sheet { max-width: 600px; padding: 12px 16px 10px; }
  .shead h2, .rhead h2 { font-size: 23px; }
  .rkicker { margin-bottom: 0; }
  .judges { margin-top: 8px; gap: 8px; }
  .judge { padding: 6px 8px 8px; display: grid; grid-template-columns: 30px 1fr auto; grid-template-areas: 'f n s' 'f r s' 'c c c'; column-gap: 8px; text-align: left; align-items: center; }
  .judge .jface { grid-area: f; width: 30px; height: 30px; margin: 0; }
  .judge .jn { grid-area: n; } .judge .jr { grid-area: r; } .judge .js { grid-area: s; font-size: 26px; }
  .judge .jc { grid-area: c; min-height: 0; margin-top: 4px; }
  .rstats { margin: 8px 0 10px; gap: 8px; }
  .stat { padding: 6px 10px; }
  .stat .v { font-size: 22px; }
  .rbtns .btn { min-height: 44px; }
  #result .early { margin-top: 6px; }
  #pause .sheet { max-width: 640px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; padding: 14px 18px; }
  #pause .shead { grid-column: 1 / -1; }
  #pause .pbtns { margin: 10px 0 0; gap: 10px; }
  #pause .settings { margin-top: 10px; border-top: 0; padding-top: 0; gap: 4px; }
  #portalCard { bottom: calc(80px + var(--sab)); }
  #tbtns { bottom: calc(12px + var(--sab)); }
  .tbtn { width: 56px; height: 56px; }
  .tbtn.big { width: 72px; height: 72px; }
  #topbar { width: calc(100% - 300px); }
}

@media (min-width: 768px) and (min-height: 780px) {
  #tbtns { transform: scale(1.25); transform-origin: bottom right; bottom: calc(100px + var(--sab)); }
  #stickGhost { transform: scale(1.25); transform-origin: bottom left; }
  #portalCard { bottom: calc(200px + var(--sab)); }
  .tgrid { zoom: 1.32; }
  .sheet { zoom: 1.25; }
  #topbar { transform: translateX(-50%) scale(1.22); transform-origin: top center; }
  #tright { transform: scale(1.2); transform-origin: top right; }
  #hotbar { transform: translateX(-50%) scale(1.2); transform-origin: bottom center; }
  #lockHint { transform: translateX(-50%) scale(1.15); transform-origin: bottom center; bottom: 110px; }
}

#loadFail { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 26px; text-align: center; max-width: calc(100% - 40px); }
#loadFail b { font-family: var(--f-display); font-weight: 400; font-size: 24px; }
#loadFail span { font-size: 14px; font-weight: 700; color: var(--ink-3); }
#loadFail .btn { margin-top: 8px; min-width: 160px; }
#fade.failed .ldblock { display: none; }
