:root {
  --pink: #ff5fa2; --orange: #ff9f1c; --yellow: #ffd54f; --mint: #06d6a0; --blue: #30b8e6; --purple: #b56cff;
  --ink: #15112b; --ink-2: #26204a; --paper: #fff8ee; --muted: #8e88a8;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: #fff; font-family: var(--font); -webkit-text-size-adjust: 100%; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; }

/* ---------- buttons ---------- */
.btn { border: 0; border-radius: 999px; padding: 12px 22px; font-size: 16px; font-weight: 700; color: #fff; transition: transform .08s ease, filter .15s ease; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--pink), var(--orange)); box-shadow: 0 6px 18px rgba(255, 95, 162, .35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--blue); color: #0b2a3a; }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- title ---------- */
#screen-title { display: grid; place-items: center; overflow: auto; }
.title-sky { position: absolute; inset: 0; background: radial-gradient(1200px 600px at 50% 110%, #5a2a7a 0%, #2b1d5a 45%, #15112b 100%); }
.title-sky::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(#fff 1px, transparent 1.5px), radial-gradient(#fff 1px, transparent 1.5px); background-size: 120px 120px, 70px 70px; background-position: 0 0, 35px 35px; opacity: .35; }
.title-card { position: relative; text-align: center; padding: 28px 24px calc(28px + var(--safe-bottom)); max-width: 520px; width: 100%; }
.title-logo { font-size: 72px; line-height: 1; filter: drop-shadow(0 8px 20px rgba(0,0,0,.4)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.title-card h1 { font-size: 56px; margin: 6px 0 0; letter-spacing: 2px; color: var(--yellow); text-shadow: 0 4px 0 #b3443f, 0 10px 30px rgba(0,0,0,.5); }
.subtitle { margin: 4px 0 18px; color: #d8d2f0; font-size: 17px; }
.title-areas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 22px; }
.title-areas span { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 22%, transparent); border: 1px solid var(--c); color: #fff; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.recover { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.recover input { font: 700 20px/1 monospace; letter-spacing: 4px; text-transform: uppercase; width: 150px; padding: 10px 12px; border-radius: 10px; border: 2px solid rgba(255,255,255,.25); background: rgba(0,0,0,.3); color: #fff; text-align: center; }
.recover-msg { width: 100%; font-size: 13px; color: #ffb3c6; min-height: 18px; }
.lang-toggle { position: absolute; top: calc(12px + var(--safe-top)); right: 12px; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; font-weight: 700; }

/* ---------- creator ---------- */
#screen-creator { background: radial-gradient(900px 500px at 20% 0%, #3a2270 0%, #1b1140 55%, #15112b 100%); overflow: auto; -webkit-overflow-scrolling: touch; }
.creator { display: grid; grid-template-columns: 340px 1fr; gap: 20px; padding: 20px; max-width: 1100px; margin: 0 auto; min-height: 100%; align-items: start; }
.creator-preview { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 12px; }
.creator-preview canvas { width: 100%; max-width: 320px; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.4); background: #2b1d5a; margin: 0 auto; display: block; }
.creator-name { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #cfc8ea; }
.creator-name input { font: 700 18px var(--font); padding: 10px 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: #fff; }
.creator-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.creator-actions .btn-primary { flex: 1; min-width: 150px; }
.creator-options h2 { margin: 4px 0 10px; font-size: 24px; }
.creator-group { margin-bottom: 12px; }
.creator-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #bdb6dc; margin-bottom: 6px; }
.creator-row { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { border: 2px solid rgba(255,255,255,.15); background: rgba(255,255,255,.07); color: #fff; border-radius: 12px; padding: 7px 11px; font-size: 14px; font-weight: 700; position: relative; min-height: 36px; }
.opt.color { width: 36px; height: 36px; padding: 0; border-radius: 50%; border-color: rgba(255,255,255,.35); }
.opt.print { width: 44px; height: 44px; padding: 0; overflow: hidden; }
.opt.print canvas { width: 100%; height: 100%; display: block; border-radius: 9px; }
.opt.selected { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,213,79,.35); }
.opt.locked { opacity: .55; }
.opt .price { position: absolute; right: -4px; bottom: -6px; background: var(--ink); color: var(--yellow); font-size: 10px; padding: 1px 5px; border-radius: 999px; border: 1px solid var(--yellow); }
.creator-hint { min-height: 20px; font-size: 13px; color: var(--yellow); opacity: 0; transition: opacity .2s; }
.creator-hint.show { opacity: 1; }
@media (max-width: 760px) {
  .creator { grid-template-columns: 1fr; padding: 12px 12px calc(20px + var(--safe-bottom)); }
  .creator-preview { position: static; }
  .creator-preview canvas { max-width: 220px; }
}

/* ---------- park ---------- */
#screen-park { background: #1a2a3a; }
#park { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: calc(8px + var(--safe-top)); left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.hud-left, .hud-right { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hud-right { justify-content: flex-end; }
.pill { background: rgba(21,17,43,.78); backdrop-filter: blur(8px); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 700; border: 1px solid rgba(255,255,255,.12); white-space: nowrap; }
.pill-tickets { color: var(--yellow); font-size: 16px; }
.pill-area { color: #fff; }
.pill-online { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #d8d2f0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #888; display: inline-block; }
.dot.live { background: #2ecc71; box-shadow: 0 0 8px #2ecc71; }
.dot.polling { background: var(--yellow); }
.dot.reconnecting { background: var(--orange); animation: blink 1s infinite; }
.dot.offline { background: #e74c3c; }
@keyframes blink { 50% { opacity: .3; } }
.hud-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(21,17,43,.78); backdrop-filter: blur(8px); color: #fff; font-size: 18px; display: grid; place-items: center; padding: 0; }
.hud-btn.hud-lang { font-size: 12px; font-weight: 800; width: auto; padding: 0 10px; }
.area-banner { position: absolute; top: 22%; left: 50%; transform: translate(-50%, -10px); font-size: clamp(22px, 5vw, 40px); font-weight: 900; letter-spacing: 1px; color: #fff; text-shadow: 0 4px 16px rgba(0,0,0,.6), 0 0 2px #000; opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none !important; text-align: center; padding: 0 12px; }
.area-banner small { display: block; font-size: .45em; font-weight: 600; color: #ffe9a8; margin-top: 2px; }
.area-banner.show { opacity: 1; transform: translate(-50%, 0); }
.booth-panel { position: absolute; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%); background: rgba(21,17,43,.9); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.14); border-radius: 18px; padding: 12px 14px; min-width: 260px; max-width: min(92vw, 420px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.booth-panel h3 { margin: 0 0 4px; font-size: 18px; }
.booth-panel .howto { font-size: 12px; color: #cfc8ea; margin-bottom: 8px; }
.booth-panel .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.booth-panel .btn { padding: 9px 16px; font-size: 14px; }
.booth-panel .hint { font-size: 11px; color: var(--muted); }
.booth-panel .others { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; max-height: 120px; overflow: auto; }
.booth-panel .other { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; background: rgba(255,255,255,.06); border-radius: 10px; padding: 4px 6px 4px 10px; }
.booth-panel .other .btn { padding: 5px 10px; font-size: 12px; }
.booth-panel .nobody { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hud-bottom { position: absolute; left: 12px; right: 12px; bottom: calc(14px + var(--safe-bottom)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
.emotes { display: flex; gap: 6px; }
.emotes button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); background: rgba(21,17,43,.7); font-size: 20px; padding: 0; }
.action-btn { width: 74px; height: 74px; border-radius: 50%; border: 3px solid rgba(255,255,255,.5); background: linear-gradient(135deg, var(--pink), var(--orange)); color: #fff; font-size: 24px; font-weight: 900; box-shadow: 0 8px 20px rgba(0,0,0,.4); }
.joystick { position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.35); transform: translate(-50%, -50%); pointer-events: none !important; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.75); transform: translate(-50%, -50%); box-shadow: 0 4px 12px rgba(0,0,0,.35); }
body.touch .emotes { position: absolute; left: 0; bottom: 92px; flex-direction: column; }
@media (max-width: 700px) { .pill-online span:last-child { display: none; } .hud-btn.hud-lang { display: none; } }

/* ---------- modals & toasts ---------- */
#modals:empty { display: none; }
#modals { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,8,25,.6); backdrop-filter: blur(4px); z-index: 20; padding: 12px; }
.modal { background: var(--ink-2); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; width: min(94vw, 560px); max-height: min(90vh, 720px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-close { background: rgba(255,255,255,.1); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-body h3 { margin: 10px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: #bdb6dc; }
.lb-row { display: flex; justify-content: space-between; padding: 6px 8px; border-radius: 8px; font-size: 14px; }
.lb-row:nth-child(odd) { background: rgba(255,255,255,.05); }
.lb-row.me { outline: 1px solid var(--yellow); }
.lb-row .rank { width: 28px; color: var(--muted); }
.lb-row .name { flex: 1; }
.lb-empty { color: var(--muted); font-size: 13px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.shop-item { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; }
.shop-item canvas { width: 56px; height: 56px; border-radius: 10px; }
.shop-item .icon { font-size: 34px; }
.shop-item .nm { font-size: 13px; font-weight: 700; }
.shop-item .btn { padding: 6px 12px; font-size: 13px; }
.shop-item.owned { opacity: .7; }
.minimap-wrap { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.minimap-wrap canvas { width: min(84vw, 420px); height: min(84vw, 420px); border-radius: 12px; background: #1a2a3a; image-rendering: pixelated; }
.minimap-legend { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.minimap-legend span { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 25%, transparent); }
.code-box { font: 700 26px/1 monospace; letter-spacing: 6px; background: rgba(0,0,0,.35); padding: 12px; border-radius: 12px; text-align: center; color: var(--yellow); margin: 8px 0; user-select: all; }
#toasts { position: absolute; top: calc(60px + var(--safe-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 30; pointer-events: none; width: min(92vw, 420px); }
.toast { pointer-events: auto; background: rgba(21,17,43,.94); border: 1px solid rgba(255,255,255,.16); border-radius: 14px; padding: 10px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toast-in .25s ease; }
.toast.good { border-color: var(--mint); }
.toast.bad { border-color: #e74c3c; }
.toast .acts { display: flex; gap: 8px; margin-top: 8px; }
.toast .acts .btn { padding: 6px 12px; font-size: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- minigame layer ---------- */
#gamelayer { position: absolute; inset: 0; z-index: 15; background: #0f0c22; display: flex; flex-direction: column; }
.game-hud { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(8px + var(--safe-top)) 12px 8px; background: rgba(21,17,43,.9); border-bottom: 1px solid rgba(255,255,255,.1); }
.game-hud .title { font-weight: 800; font-size: 16px; }
.game-hud .stat { font-size: 14px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.08); }
.game-hud .stat.time { color: var(--yellow); min-width: 64px; text-align: center; }
.game-hud .stat.opp { color: var(--blue); }
.game-hud .btn { padding: 6px 12px; font-size: 13px; }
.game-stage { flex: 1; position: relative; display: grid; place-items: center; touch-action: none; }
.game-stage canvas { display: block; background: #1b1838; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.5); touch-action: none; }
.game-overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.game-overlay .big { font-size: clamp(48px, 14vw, 120px); font-weight: 900; color: var(--yellow); text-shadow: 0 6px 30px rgba(0,0,0,.6); animation: pop .5s ease; }
.game-overlay .howto { max-width: 480px; font-size: 15px; color: #e8e2ff; background: rgba(21,17,43,.8); padding: 10px 14px; border-radius: 12px; margin-top: 8px; }
.game-overlay .result { background: rgba(21,17,43,.92); border: 1px solid rgba(255,255,255,.15); padding: 18px 26px; border-radius: 18px; }
.game-overlay .result .score { font-size: 48px; font-weight: 900; color: var(--yellow); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
