:root {
  --ink: #0b0620;
  --panel: rgba(12, 8, 34, .86);
  --line: rgba(255, 255, 255, .14);
  --green: #4fe36b;
  --cyan: #3affd2;
  --red: #ff4a5a;
  --gold: #ffd23a;
  --text: #fff;
  --muted: rgba(255, 255, 255, .62);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #140b3a; color: var(--text); font-family: "Russo One", system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); overflow-y: auto; z-index: 5; }
.screen.dim { background: rgba(5, 2, 20, .55); backdrop-filter: blur(3px); }

.logo { font-size: clamp(44px, 10vw, 104px); letter-spacing: .02em; line-height: .9; text-align: center; color: #fff; text-shadow: 0 6px 0 #000, 0 0 30px rgba(58, 255, 210, .5); -webkit-text-stroke: 3px #000; paint-order: stroke fill; }
.logo span { display: block; color: var(--gold); font-size: .62em; letter-spacing: .3em; margin-top: .1em; }

button { font-family: inherit; color: #fff; cursor: pointer; border: 3px solid #000; border-radius: 14px; background: linear-gradient(#5a6aff, #3a3ad0); box-shadow: 0 5px 0 #000, inset 0 2px 0 rgba(255, 255, 255, .35); text-shadow: 0 2px 0 #000; transition: transform .08s; }
button:active { transform: translateY(3px); box-shadow: 0 2px 0 #000, inset 0 2px 0 rgba(255, 255, 255, .35); }
button.green { background: linear-gradient(#7dff5a, #2fb84a); }
button.red { background: linear-gradient(#ff7a7a, #d02a3a); }
button.big { font-size: clamp(18px, 3.4vw, 26px); padding: 14px 30px; }
button.small { font-size: 15px; padding: 8px 14px; border-radius: 11px; box-shadow: 0 4px 0 #000, inset 0 2px 0 rgba(255, 255, 255, .3); }

.menuMain { display: flex; align-items: center; gap: clamp(14px, 4vw, 40px); }
button.round { border-radius: 50%; display: grid; place-items: center; padding: 0; }
button.round.play { width: clamp(110px, 20vw, 170px); height: clamp(110px, 20vw, 170px); font-size: clamp(48px, 9vw, 80px); background: radial-gradient(circle at 40% 35%, #a6ff7a, #2fb84a 70%); animation: bob 1.6s ease-in-out infinite; }
button.round.side { width: clamp(76px, 13vw, 110px); height: clamp(76px, 13vw, 110px); font-size: clamp(28px, 5vw, 42px); }
button.round small { display: block; font-size: 12px; margin-top: -6px; }
@keyframes bob { 50% { transform: scale(1.06); } }
.menuRow { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }
.pill { background: var(--panel); border: 2px solid #000; border-radius: 999px; padding: 6px 14px; font-size: 18px; display: inline-flex; align-items: center; gap: 6px; }
.hint { color: var(--muted); font-size: 14px; text-align: center; margin: 0; font-family: system-ui, sans-serif; }

.topbar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar h3 { margin: 0; font-size: clamp(18px, 3vw, 26px); text-shadow: 0 3px 0 #000; }

.carousel { display: flex; align-items: center; gap: 12px; width: min(760px, 100%); }
.arrow { font-size: 28px; width: 56px; height: 72px; flex: none; }
.card { flex: 1; min-width: 0; background: var(--panel); border: 3px solid #000; border-radius: 22px; padding: 18px 20px; box-shadow: 0 8px 0 #000, inset 0 0 0 2px var(--accent, #fff3); cursor: pointer; }
.lcTop { display: flex; align-items: center; gap: 14px; }
.lcTop svg { flex: none; filter: drop-shadow(0 3px 0 #000); }
.lcName { flex: 1; min-width: 0; }
.lcName h2 { margin: 0; font-size: clamp(24px, 5vw, 40px); text-shadow: 0 3px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcDiff { font-size: 16px; }
.done { color: var(--green); }
.bars { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin-top: 16px; font-size: 14px; }
.pbar { position: relative; height: 22px; background: rgba(0, 0, 0, .5); border: 2px solid #000; border-radius: 999px; overflow: hidden; }
.pbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #7dff3a, #3affd2); }
.pbar.p i { background: linear-gradient(90deg, #3aa8ff, #6a5aff); }
.pbar span { position: relative; display: block; text-align: center; font-size: 13px; line-height: 18px; text-shadow: 0 1px 0 #000; }
.lcMeta { margin-top: 12px; font-size: 13px; color: var(--muted); }
.dots { display: flex; gap: 8px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .3); }
.dots i.on { background: #fff; }

.coins { display: flex; gap: 4px; }
.coin { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-style: normal; border: 2px solid #000; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .35); }
.coin.got { background: radial-gradient(circle at 35% 35%, #fff3a0, #ffcf2a 60%, #c48a00); color: #8a5a00; text-shadow: none; }
.coins.big .coin { width: 40px; height: 40px; font-size: 20px; }

.panel { background: var(--panel); border: 3px solid #000; border-radius: 20px; padding: 18px 20px; box-shadow: 0 8px 0 #000; width: min(560px, 100%); }
.panel h3, .panel h2, .panel h1 { margin: 0 0 10px; text-shadow: 0 3px 0 #000; }
.panel.center { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.panel h1 { font-size: clamp(26px, 6vw, 44px); color: var(--gold); }
.panel label { font-size: 14px; color: var(--muted); }
.cstats { display: flex; gap: 22px; justify-content: center; }
.cstats div { display: flex; flex-direction: column; align-items: center; }
.cstats b { font-size: 28px; }
.cstats span { font-size: 12px; color: var(--muted); }
.starsGot { color: var(--gold); font-size: 26px; margin-top: 8px; text-shadow: 0 3px 0 #000; }

.setRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.setRow input[type=range] { flex: 1; max-width: 260px; accent-color: var(--cyan); }
.chk { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: #fff !important; font-size: 15px !important; cursor: pointer; }
.chk input { width: 20px; height: 20px; accent-color: var(--green); }
input, select { font-family: system-ui, sans-serif; font-size: 15px; background: rgba(0, 0, 0, .5); color: #fff; border: 2px solid #000; border-radius: 10px; padding: 8px 10px; user-select: text; -webkit-user-select: text; }
input[type=color] { padding: 2px; width: 52px; height: 34px; }
.statRow { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.help { max-height: 86vh; overflow: auto; font-family: system-ui, sans-serif; font-size: 15px; line-height: 1.45; }
.help h3 { font-family: "Russo One", sans-serif; }
.help ul { padding-left: 20px; }

.list { max-height: 58vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-top: 50px; }
.empty { color: var(--muted); font-family: system-ui; text-align: center; }
.myRow { display: flex; align-items: center; gap: 6px; padding: 8px; background: rgba(255, 255, 255, .05); border-radius: 12px; flex-wrap: wrap; }
.myName { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.myName small { color: var(--muted); font-family: system-ui; font-size: 12px; }
.myRow button.small { padding: 6px 10px; font-size: 13px; }
.importBox { display: flex; gap: 8px; }
.importBox input { flex: 1; min-width: 0; }
.copyRow { display: flex; gap: 8px; margin: 4px 0 12px; }
.copyRow input { flex: 1; min-width: 0; }

#icons { justify-content: flex-start; padding-top: 70px; }
#iconPreview { width: min(700px, 100%); height: auto; }
.iconPanel h4 { margin: 10px 0 8px; }
.faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.face { position: relative; padding: 2px; background: rgba(0, 0, 0, .4); border-radius: 12px; box-shadow: 0 3px 0 #000; }
.face canvas { display: block; width: 100%; height: auto; }
.face.sel { outline: 3px solid var(--cyan); }
.face.locked canvas { opacity: .25; }
.face em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 13px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 32px; height: 32px; border-radius: 8px; padding: 0; box-shadow: 0 3px 0 #000; }
.sw.sel { outline: 3px solid #fff; outline-offset: 1px; }

#hud { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; z-index: 4; }
#practiceBar { position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; z-index: 4; }
.hudBtn { width: 46px; height: 46px; font-size: 16px; padding: 0; border-radius: 12px; opacity: .8; }
.hudBtn.cp { width: 64px; background: linear-gradient(#7dff5a, #2fb84a); }
.hudBtn.cp.del { background: linear-gradient(#ff7a7a, #d02a3a); }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: #000; color: #fff; padding: 10px 18px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 20; font-size: 15px; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* editor */
#editorUI { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
#editorUI > * { pointer-events: auto; }
.edTop { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.edTop input { width: 150px; }
.seg { display: inline-flex; border: 3px solid #000; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 0 #000; }
.seg button { border: 0; border-radius: 0; box-shadow: none; padding: 7px 10px; font-size: 13px; background: rgba(20, 14, 60, .92); border-right: 2px solid #000; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: linear-gradient(#5a6aff, #3a3ad0); }
.edNav { position: absolute; right: 8px; bottom: 150px; display: flex; gap: 6px; }
.edBottom { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 3px solid #000; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.edBottom .seg { align-self: flex-start; max-width: 100%; overflow-x: auto; }
#edItems { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.item { flex: none; width: 74px; padding: 4px; border-radius: 10px; background: rgba(0, 0, 0, .35); box-shadow: 0 3px 0 #000; display: flex; flex-direction: column; align-items: center; }
.item img { width: 48px; height: 48px; }
.item span { font-size: 10px; text-align: center; line-height: 1.1; text-shadow: none; }
.item.on { outline: 3px solid var(--cyan); background: rgba(58, 255, 210, .15); }
#edProps { position: absolute; right: 8px; top: 70px; width: 240px; padding: 12px; font-size: 13px; }
#edProps h4, #edSettingsPanel h4 { margin: 0 0 8px; }
#edProps .row { display: flex; gap: 6px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
#edProps input[type=number] { width: 64px; padding: 4px 6px; }
#edProps .tip { color: var(--muted); font-family: system-ui; margin: 4px 0; }
#edSettingsPanel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(380px, 92vw); }

@media (max-width: 640px) {
  .edTop input { width: 100px; }
  .seg button { padding: 6px 7px; font-size: 12px; }
  .edNav { bottom: 160px; }
  #edProps { top: auto; bottom: 200px; }
  .arrow { width: 40px; }
  .card { padding: 14px; }
}
#edRot, #edUndo, #edRedo, #edSettings, #edShare { font-size: 20px; font-family: system-ui, sans-serif; padding: 4px 10px; min-width: 40px; }
