:root {
  --bg: #1b1d3a;
  --ink: #1d2140;
  --panel: rgba(255, 255, 255, 0.95);
  --muted: #5d6385;
  --chip: rgba(255, 255, 255, 0.9);
  --accent: #ff5a5f;
  --accent2: #3d7eff;
  --gold: #ffcf3f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; cursor: pointer; }

#top { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 6px;
  align-items: center; flex-wrap: wrap; pointer-events: none; z-index: 5; }
.logo { background: var(--chip); padding: 4px 10px; border-radius: 10px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.pill { background: var(--chip); padding: 3px 10px; border-radius: 99px; font-size: 13px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.pill[data-ready='1'] { background: #3ddc97; color: #fff; }
.pill.timer { font-variant-numeric: tabular-nums; font-weight: 800; background: var(--gold); }
.pill.btn { pointer-events: auto; border: 0; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 10;
  background: rgba(20, 22, 50, 0.55); backdrop-filter: blur(3px); }
.panel { width: min(440px, 100%); background: var(--panel); border-radius: 18px; padding: 20px;
  box-shadow: 0 6px 0 rgba(0,0,0,.3), 0 20px 40px rgba(0,0,0,.3); }
.panel h1 { margin: 0 0 4px; font-size: 26px; }
.sub { color: var(--muted); margin: 0 0 14px; }
.field { display: grid; gap: 6px; font-weight: 600; }
.field input { padding: 10px 12px; border-radius: 10px; border: 2px solid #d9dcef; font: inherit; }
.colors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 14px 0; }
.colors button { aspect-ratio: 1; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #d9dcef; }
.colors button[aria-checked='true'] { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.08); }
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; padding: 12px; border-radius: 12px; border: 0; background: #e9ebf7; font-weight: 700; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.actions .primary { background: var(--accent); color: #fff; }
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.stats { position: fixed; top: calc(46px + env(safe-area-inset-top)); left: 10px; display: flex; gap: 6px; }
.stats span { background: var(--chip); border-radius: 10px; padding: 3px 10px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.stats b { font-variant-numeric: tabular-nums; }
.stats .combo { background: var(--gold); font-weight: 800; animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(1.4); } to { transform: scale(1); } }
.joy { position: fixed; left: calc(22px + env(safe-area-inset-left)); bottom: calc(26px + env(safe-area-inset-bottom));
  width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.14); border: 3px solid rgba(255,255,255,.5);
  pointer-events: auto; touch-action: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.buttons { position: fixed; right: calc(18px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom));
  display: flex; gap: 14px; align-items: flex-end; }
.act { pointer-events: auto; touch-action: none; border: 0; border-radius: 50%; color: #fff; font-size: 28px; line-height: 1;
  display: grid; place-items: center; box-shadow: 0 5px 0 rgba(0,0,0,.35); user-select: none; -webkit-user-select: none; }
.act small { font-size: 11px; font-weight: 700; margin-top: -4px; }
.act:active, .act.on { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.act:disabled { opacity: .45; }
.boost { width: 92px; height: 92px; background: var(--accent); }
.horn { width: 66px; height: 66px; background: #6c5ce7; }
@media (hover: hover) and (pointer: fine) { .joy, .buttons { opacity: .55; } }

.result { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8; background: var(--panel);
  border-radius: 18px; padding: 18px 24px; min-width: 260px; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.3); }
.result h2 { margin: 0 0 8px; }
.result ol { text-align: left; margin: 0 0 8px; padding-left: 24px; font-size: 18px; }
.result li b { float: right; margin-left: 16px; }

#side { position: fixed; right: 12px; top: 56px; bottom: 12px; width: 250px; background: var(--panel); border-radius: 16px;
  padding: 12px 14px; overflow: auto; z-index: 4; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
#side h2 { font-size: 15px; margin: 6px 0; }
.joinbox { text-align: center; padding: 4px 0 10px; border-bottom: 1px solid #e3e5f3; }
.joinbox img { width: 100%; max-width: 190px; height: auto; aspect-ratio: 1; display: block; margin: 0 auto 6px; border-radius: 10px; }
.joinbox p { margin: 0; font-size: 13px; font-weight: 600; }
.joinbox code { font-size: 15px; color: var(--accent); }
#rank { margin: 0 0 8px; padding-left: 22px; }
#rank li { padding: 2px 0; display: flex; gap: 6px; align-items: center; }
#rank .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
#rank .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rank b { font-variant-numeric: tabular-nums; }
#feed { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#feed li { padding: 3px 0; border-top: 1px solid #e3e5f3; }
@media (max-width: 760px) { #side { display: none; } }
