:root {
  --ink: #2B2250;
  --ink2: #5B4F8F;
  --sky: #BFE3F2;
  --lemon: #FFD23F;
  --pink: #FF5A8A;
  --mint: #3FD3A1;
  --card: #FFFDF7;
  --disp: "Lilita One", "DM Sans", system-ui, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--sky); color: var(--ink); font-family: var(--body); font-weight: 700; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }

/* floating labels */
.plus { position: absolute; left: 0; top: 0; font-family: var(--disp); font-size: 22px; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; white-space: nowrap; will-change: transform; }
.plus.mid { font-size: 30px; color: var(--c, var(--lemon)); }
.plus.big { font-size: 44px; color: var(--c, var(--lemon)); }
.plus.combo { font-size: 24px; color: var(--mint); }
.nametag { position: absolute; left: 0; top: 0; padding: 3px 10px 4px; border-radius: 10px; background: var(--c); color: var(--ink); font-size: 14px; font-weight: 800; border: 2.5px solid var(--ink); white-space: nowrap; }

/* joystick */
.joy { position: fixed; z-index: 4; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; background: rgba(255,255,255,.28); border: 3px solid rgba(43,34,80,.35); pointer-events: none; }
.joy i { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: var(--card); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }

/* hud */
.hud { position: fixed; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.ib { flex: none; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; background: var(--card); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.ib svg { width: 22px; height: 22px; }
.ib:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.ib.small { width: 40px; height: 40px; border-radius: 13px; }
.mute .offi { display: none; } .mute.off .on { display: none; } .mute.off .offi { display: block; }
.mid { flex: 1; min-width: 0; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.timer { display: flex; align-items: center; gap: 7px; padding: 6px 16px 7px 12px; border-radius: 14px; background: var(--card); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font-family: var(--disp); font-size: 24px; line-height: 1; }
.timer svg { width: 20px; height: 20px; }
.timer.low { background: var(--pink); color: #fff; animation: beat 1s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.08); } }
.prog { width: 100%; display: flex; align-items: center; gap: 8px; }
.prog .bar { position: relative; flex: 1; height: 20px; border-radius: 10px; background: rgba(255,255,255,.75); border: 3px solid var(--ink); overflow: visible; }
.prog .bar > i { position: absolute; inset: 0; border-radius: 7px; background: linear-gradient(180deg, #FFE27A, var(--lemon) 60%, #F2B92A); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.prog .mk { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); background: var(--ink); }
.prog .mk::after { content: ""; position: absolute; inset: 4px; clip-path: inherit; background: #fff; }
.prog .mk.on::after { background: var(--lemon); }
.prog .mk.on { animation: pop .4s cubic-bezier(.3,1.7,.5,1); }
.prog span { font-family: var(--disp); font-size: 20px; min-width: 46px; text-align: right; -webkit-text-stroke: 4px var(--card); paint-order: stroke fill; }
.board { list-style: none; margin: 0; padding: 6px 8px; width: min(100%, 250px); border-radius: 14px; background: rgba(255,253,247,.9); border: 3px solid var(--ink); font-size: 14px; }
.board li { display: flex; align-items: center; gap: 7px; padding: 2px 2px; }
.board li i, .rank li i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.board li span { flex: 1; }
.board li.me { font-weight: 800; background: rgba(255,210,63,.35); border-radius: 7px; }
.sizechip { position: fixed; z-index: 5; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; row-gap: 5px; min-width: 210px; padding: 8px 14px 10px; border-radius: 16px; background: rgba(255,253,247,.92); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); pointer-events: none; }
.sizechip b { grid-row: span 2; font-family: var(--disp); font-weight: 400; font-size: 22px; }
.sizechip span { font-size: 14px; color: var(--ink2); }
.sizechip i { display: block; height: 8px; border-radius: 4px; background: #E6E0F2; overflow: hidden; }
.sizechip s { display: block; height: 100%; background: var(--mint); transform-origin: left; transform: scaleX(0); transition: transform .25s; }
.toast { position: fixed; z-index: 6; left: 50%; top: 32%; margin: 0; transform: translateX(-50%); padding: 10px 22px 12px; border-radius: 18px; background: var(--ink); color: #fff; font-family: var(--disp); font-size: clamp(22px, 4.6vw, 32px); white-space: nowrap; pointer-events: none; box-shadow: 0 5px 0 rgba(43,34,80,.35); }
.toast.pop { animation: toast .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes toast { from { transform: translateX(-50%) scale(.5); opacity: 0; } }
.tip { position: fixed; z-index: 5; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 84px); transform: translateX(-50%); margin: 0; padding: 9px 18px; border-radius: 14px; background: var(--lemon); border: 3px solid var(--ink); font-size: 17px; white-space: nowrap; pointer-events: none; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-6px); } }

/* panels */
.panel { position: fixed; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 420px); max-height: 94vh; overflow: auto; padding: 22px 20px 18px; border-radius: 26px; background: var(--card); border: 4px solid var(--ink); box-shadow: 0 8px 0 var(--ink), 0 24px 60px rgba(43,34,80,.25); text-align: center; animation: rise .35s cubic-bezier(.3,1.4,.5,1); }
@keyframes rise { from { transform: translate(-50%, -44%); opacity: 0; } }
.panel h2 { font-family: var(--disp); font-weight: 400; font-size: 38px; margin: 0 0 12px; line-height: 1.05; }
.kicker { margin: 0 0 4px; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin: 0 0 10px; padding: 13px 18px; border-radius: 18px; border: 3px solid var(--ink); background: var(--card); color: var(--ink); font-family: var(--disp); font-size: 22px; box-shadow: 0 5px 0 var(--ink); }
.btn svg { width: 22px; height: 22px; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { background: var(--lemon); font-size: 28px; }
.btn.alt { background: var(--pink); color: #fff; }
.btn:focus-visible, .ib:focus-visible, .lvl:focus-visible, .skin:focus-visible { outline: 3px dashed var(--pink); outline-offset: 3px; }
.row { display: flex; gap: 10px; }
.row .btn { font-size: 19px; margin-bottom: 0; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 2px 0 14px; }
.stars i { width: 54px; height: 54px; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); background: #DCD6EA; }
.stars i.on { background: var(--lemon); animation: pop .5s cubic-bezier(.3,1.7,.5,1) both; animation-delay: var(--d); }
.stars i:nth-child(2) { transform: translateY(-8px) scale(1.12); }
@keyframes pop { from { transform: scale(0) rotate(-40deg); } }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; margin: 0 0 16px; padding: 12px 16px; border-radius: 16px; background: #F1EDF9; text-align: left; font-size: 16px; }
.stats dt { color: var(--ink2); } .stats dd { margin: 0; font-weight: 800; text-align: right; }
.rank { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; font-size: 17px; }
.rank li span { flex: 1; }
.rank li.me { background: rgba(255,210,63,.4); }

/* menu */
.panel.menu { width: min(94vw, 520px); }
.logo { position: relative; margin: 0; font-family: var(--disp); font-weight: 400; font-size: clamp(54px, 13vw, 78px); line-height: .95; color: #fff; -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; letter-spacing: .01em; display: inline-flex; align-items: center; gap: 8px; }
.logo .dot { display: inline-block; width: .62em; height: .34em; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #0B0718 40%, #3B2E6A 72%, var(--lemon) 74%, var(--lemon) 88%, transparent 90%); transform: translateY(.18em); }
.tag { margin: 8px 0 16px; font-size: 17px; color: var(--ink2); }
.cta { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.cta .btn { margin: 0; white-space: nowrap; }
.sect { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px; }
.sect h2 { font-size: 24px; margin: 0; }
.total { display: flex; align-items: center; gap: 5px; font-size: 17px; }
.total svg { color: #F2B92A; width: 20px; height: 20px; }
.wins { font-size: 15px; color: var(--ink2); }
.lgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.lvl { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 7px; border-radius: 16px; border: 3px solid var(--ink); background: #fff; box-shadow: 0 4px 0 var(--ink); min-width: 0; }
.lvl b { font-family: var(--disp); font-weight: 400; font-size: 24px; line-height: 1; }
.lvl span { font-size: 11px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink2); }
.lvl em { display: flex; gap: 1px; }
.lvl em i { width: 13px; height: 13px; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); background: #DCD6EA; }
.lvl em i.on { background: #F2B92A; }
.lvl.next { background: var(--lemon); animation: beat 1.6s ease-in-out infinite; }
.lvl:disabled { opacity: .45; box-shadow: none; cursor: default; }
.lvl:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.skins { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border: 3px solid transparent; border-radius: 14px; background: none; font-size: 11px; color: var(--ink2); min-width: 0; }
.skin i { width: 38px; height: 22px; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #0B0718 45%, var(--c) 50%); border: 3px solid var(--ink); }
.skin span.need { display: inline-flex; align-items: center; gap: 2px; }
.skin span.need::before { content: ""; width: 11px; height: 11px; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); background: #F2B92A; }
.skin span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skin.sel { border-color: var(--ink); background: #fff; color: var(--ink); }
.skin:disabled { opacity: .45; cursor: default; }
.foot { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 0; }
.foot a { color: var(--ink); font-size: 17px; }

/* demo and share image */
.ogmark { display: none; }
body.og .ogmark { display: block; position: fixed; z-index: 8; left: 6%; top: 50%; transform: translateY(-50%); padding: 26px 34px 30px; border-radius: 30px; background: var(--card); border: 5px solid var(--ink); box-shadow: 0 10px 0 var(--ink); }
body.og .ogmark .logo { font-size: 104px; -webkit-text-stroke-width: 14px; }
body.og .ogmark p { margin: 12px 0 0 6px; font-size: 30px; }
body.demo .panel, body.demo .hud, body.demo .sizechip, body.demo .tip, body.demo .toast { display: none !important; }
body.og .nametag { display: none; }

@media (max-width: 520px) {
  .hud { gap: 8px; }
  .timer { font-size: 20px; padding: 5px 12px 6px 10px; }
  .prog span { font-size: 17px; min-width: 40px; }
  .board { font-size: 12px; }
  .panel h2 { font-size: 32px; }
  .btn.big { font-size: 24px; }
  .cta .btn { font-size: 20px; padding: 12px 10px; }
  .cta .btn.big { font-size: 21px; }
  .lvl b { font-size: 21px; }
  .skin i { width: 32px; height: 19px; }
}
@media (prefers-reduced-motion: reduce) { .timer.low, .lvl.next, .tip, .panel, .toast.pop, .stars i.on { animation: none; } }
