:root {
  --ink: #120c14;
  --paper: #fff6e6;
  --gold: #ffd23f;
  --hot: #ff5a3c;
  --ice: #9fe8ff;
  --aurora: #7dffb0;
  --panel: rgba(18, 12, 26, 0.86);
  --line: rgba(255, 210, 63, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #07050c; color: var(--paper); font-family: 'Rubik', system-ui, sans-serif; overflow: hidden; }
#app { width: 100vw; height: 100vh; display: grid; place-items: center; }
#stage { position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; container-type: inline-size; }
canvas { width: 100%; height: 100%; display: block; image-rendering: auto; background: #0b1030; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6cqw; padding: 2cqw; text-align: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 20, 60, 0.55), rgba(5, 3, 10, 0.85)); }
.screen.dim { background: rgba(6, 4, 12, 0.78); }
.screen.scroll { justify-content: flex-start; overflow-y: auto; }
.hidden { display: none !important; }

h2 { font-family: 'Bungee', Impact, sans-serif; font-size: 4cqw; margin: 0; color: var(--gold); text-shadow: 0.3cqw 0.3cqw 0 var(--ink), 0 0 2cqw rgba(255, 90, 60, 0.5); letter-spacing: 0.1em; }
h3 { font-family: 'Bungee', Impact, sans-serif; font-size: 1.5cqw; color: var(--aurora); margin: 1.2cqw 0 0.5cqw; letter-spacing: 0.05em; }

.logo { font-family: 'Bungee', Impact, sans-serif; font-size: 10cqw; line-height: 0.9; display: flex; gap: 1cqw; transform: rotate(-3deg); }
.logo span:first-child { color: var(--gold); text-shadow: 0.5cqw 0.5cqw 0 var(--hot), 1cqw 1cqw 0 var(--ink); }
.logo span:last-child { color: var(--paper); text-shadow: 0.5cqw 0.5cqw 0 #2f7fd8, 1cqw 1cqw 0 var(--ink); }
.tag { margin: 0 0 1cqw; font-size: 1.6cqw; color: var(--aurora); letter-spacing: 0.25em; text-transform: uppercase; }

.menu { display: flex; flex-direction: column; gap: 0.8cqw; width: 36cqw; }
.btn { font-family: 'Bungee', Impact, sans-serif; font-size: 1.7cqw; padding: 0.9cqw 1.6cqw; border: 0.25cqw solid var(--ink); border-radius: 0.6cqw; cursor: pointer;
  background: linear-gradient(180deg, #ffe27a, #f2a51e); color: var(--ink); box-shadow: 0 0.45cqw 0 var(--ink); transition: transform 0.06s, filter 0.1s; }
.btn:hover, .btn:focus-visible { filter: brightness(1.12); outline: 0.3cqw solid var(--paper); outline-offset: 0.2cqw; transform: translateX(0.4cqw); }
.btn:active { transform: translateY(0.3cqw); box-shadow: 0 0.15cqw 0 var(--ink); }
.btn.ghost { background: linear-gradient(180deg, #4b3d6b, #2a2142); color: var(--paper); }
.btn.small { font-size: 1.4cqw; padding: 0.7cqw 1.4cqw; }
.btn:disabled { filter: grayscale(1) brightness(0.6); cursor: default; }
.mute { position: absolute; right: 1.5cqw; bottom: 1.5cqw; font-size: 2.2cqw; background: none; border: 0; cursor: pointer; }

.cards { display: flex; gap: 1.6cqw; }
.card { width: 20cqw; padding: 1cqw; border-radius: 1cqw; background: var(--panel); border: 0.3cqw solid #3b3150; cursor: pointer; position: relative; transition: transform 0.1s; }
.card canvas { width: 100%; height: auto; aspect-ratio: 1; background: radial-gradient(circle at 50% 70%, rgba(255, 255, 255, 0.08), transparent 70%); }
.card .nm { font-family: 'Bungee', Impact, sans-serif; font-size: 2cqw; color: var(--gold); }
.card .tt { font-size: 1.1cqw; color: var(--aurora); text-transform: uppercase; letter-spacing: 0.15em; }
.card .ds { font-size: 1.05cqw; opacity: 0.85; min-height: 2.6em; }
.card .stats { display: grid; grid-template-columns: auto 1fr; gap: 0.2cqw 0.6cqw; font-size: 0.95cqw; text-align: left; margin-top: 0.5cqw; align-items: center; }
.card .bar { height: 0.6cqw; background: #2a2142; border-radius: 1cqw; overflow: hidden; }
.card .bar i { display: block; height: 100%; background: linear-gradient(90deg, #4d7cff, #7dffb0); }
.card.p1 { border-color: var(--gold); transform: translateY(-0.6cqw); }
.card.p2 { border-color: var(--hot); transform: translateY(-0.6cqw); }
.card.p1.p2 { border-image: linear-gradient(90deg, var(--gold), var(--hot)) 1; }
.card .who { position: absolute; top: 0.6cqw; font-family: 'Bungee', Impact, sans-serif; font-size: 1.1cqw; padding: 0.1cqw 0.6cqw; border-radius: 0.4cqw; color: var(--ink); }
.card .who.w1 { left: 0.6cqw; background: var(--gold); }
.card .who.w2 { right: 0.6cqw; background: var(--hot); }
.card .who.ok::after { content: ' ✓'; }
.cards.mini .card { width: 12cqw; padding: 0.6cqw; }
.cards.mini .card .ds, .cards.mini .card .stats, .cards.mini .card .tt { display: none; }
.cards.mini .card .nm { font-size: 1.4cqw; }

.selrow { display: flex; gap: 1cqw; align-items: center; font-size: 1.3cqw; }
.chip { font-family: 'Rubik', sans-serif; font-weight: 800; font-size: 1.2cqw; padding: 0.4cqw 1cqw; border-radius: 2cqw; border: 0.2cqw solid #4b3d6b; background: transparent; color: var(--paper); cursor: pointer; }
.chip.on { background: var(--aurora); color: var(--ink); border-color: var(--aurora); }
.hint { font-size: 1.2cqw; opacity: 0.8; margin: 0; min-height: 1.4em; }

.panel { background: var(--panel); border: 0.25cqw solid #3b3150; border-radius: 1cqw; padding: 1.6cqw; display: flex; flex-direction: column; gap: 1.2cqw; align-items: center; }
.panel label { font-size: 1.3cqw; display: flex; gap: 1cqw; align-items: center; }
input { font-family: 'Bungee', Impact, sans-serif; font-size: 1.5cqw; padding: 0.5cqw 0.9cqw; border-radius: 0.5cqw; border: 0.2cqw solid var(--gold); background: #0d0916; color: var(--paper); text-transform: uppercase; width: 18cqw; }
#onCode { width: 9cqw; text-align: center; letter-spacing: 0.3em; }
.onbtns { display: flex; gap: 1cqw; align-items: center; flex-wrap: wrap; justify-content: center; }
.joinrow { display: flex; gap: 0.5cqw; }
.status { font-size: 1.5cqw; color: var(--ice); min-height: 1.5em; margin: 0; }
.status b { font-family: 'Bungee', Impact, sans-serif; font-size: 3cqw; color: var(--gold); letter-spacing: 0.2em; display: block; }

.toplist { list-style: none; counter-reset: r; padding: 0; margin: 0; width: 48cqw; background: var(--panel); border-radius: 1cqw; border: 0.25cqw solid #3b3150; }
.toplist li { counter-increment: r; display: grid; grid-template-columns: 3cqw 1fr auto auto; gap: 1cqw; align-items: center; padding: 0.55cqw 1.2cqw; font-size: 1.4cqw; border-bottom: 1px solid rgba(255, 255, 255, 0.06); text-align: left; }
.toplist li::before { content: counter(r); font-family: 'Bungee', Impact, sans-serif; color: var(--gold); }
.toplist li:nth-child(1)::before { content: '🥇'; } .toplist li:nth-child(2)::before { content: '🥈'; } .toplist li:nth-child(3)::before { content: '🥉'; }
.toplist li .n { font-family: 'Bungee', Impact, sans-serif; }
.toplist li .s { font-family: 'Bungee', Impact, sans-serif; color: var(--ice); }
.toplist li .m { font-size: 1cqw; opacity: 0.6; }
.toplist li.me { background: rgba(125, 255, 176, 0.18); }
.toplist li.empty { grid-template-columns: 1fr; opacity: 0.6; }
.toplist li.empty::before { content: ''; }
.toplist.compact li { padding: 0.3cqw 1cqw; font-size: 1.15cqw; }

.help { display: flex; gap: 3cqw; text-align: left; max-width: 90cqw; }
.help .col { flex: 1; }
.help table { border-collapse: collapse; font-size: 1.2cqw; width: 100%; }
.help td { padding: 0.35cqw 0.6cqw; border-bottom: 1px solid rgba(255, 255, 255, 0.07); vertical-align: top; }
.help .moves td:last-child { font-family: 'Bungee', Impact, sans-serif; color: var(--gold); white-space: nowrap; }
.small { font-size: 1.1cqw; opacity: 0.85; }
.help ul { padding-left: 1.4cqw; margin: 0; }
.help li { margin: 0.3cqw 0; }
kbd { font-family: 'Bungee', Impact, sans-serif; font-size: 0.95em; background: #2a2142; border: 1px solid #5a4b80; border-bottom-width: 3px; border-radius: 0.3cqw; padding: 0 0.4cqw; margin: 0 0.1cqw; }

.results { display: flex; gap: 2cqw; }
.res { background: var(--panel); border: 0.25cqw solid #3b3150; border-radius: 1cqw; padding: 1cqw 1.6cqw; min-width: 26cqw; }
.res.win { border-color: var(--gold); }
.res .nm { font-family: 'Bungee', Impact, sans-serif; font-size: 1.8cqw; }
.res .sc { font-family: 'Bungee', Impact, sans-serif; font-size: 3cqw; color: var(--ice); }
.res .st { font-size: 1.1cqw; opacity: 0.85; }
.savebox { display: flex; gap: 1cqw; align-items: center; font-size: 1.3cqw; flex-wrap: wrap; justify-content: center; }

.toast { position: absolute; left: 50%; top: 2cqw; transform: translateX(-50%); background: var(--panel); border: 0.2cqw solid var(--gold); padding: 0.8cqw 1.6cqw; border-radius: 0.8cqw; font-size: 1.4cqw; z-index: 10; }

@media (max-aspect-ratio: 4/3) { #stage { width: 100vw; } }
