:root {
  --bg: #12170f; --panel: #1d2618; --panel2: #29361f; --line: #3d5230; --text: #eef3e6; --muted: #a2b394;
  --accent: #f2c744; --good: #7ddc7a; --bad: #ef7b6c; --me: #4fc3f7; --foe: #ff6b5a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding: var(--site-bar, 0px) max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left)); }
body.playing { overflow: hidden; padding: 0; }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px; max-width: 760px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 1.25rem; letter-spacing: .02em; color: var(--accent); white-space: nowrap; }
.top-right { display: flex; align-items: center; gap: 6px; }
.langs { display: inline-flex; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .85rem; cursor: pointer; }
.langs .chip:first-child { border-radius: 999px 0 0 999px; }
.langs .chip:last-child { border-radius: 0 999px 999px 0; border-left: 0; }
.chip.active { background: var(--accent); color: #1a1a10; border-color: var(--accent); font-weight: 700; }
.conn { max-width: 760px; margin: 0 auto 6px; background: #5b3b12; border: 1px solid #a2701f; border-radius: 8px; padding: 6px 10px; font-size: .9rem; }
main { max-width: 760px; margin: 0 auto; padding-bottom: 24px; }
.tagline { color: var(--muted); margin: 4px 2px 6px; }
.pc-only { margin: 0 2px 10px; display: none; }
@media (hover: none) and (pointer: coarse) { .pc-only { display: block; color: var(--accent); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 2px; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .88rem; margin: 2px 0 8px; }
label { display: block; font-size: .88rem; color: var(--muted); margin: 6px 0 4px; }
input[type=text], input[type=password], input[type=email] { width: 100%; background: #0c1109; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row.join { margin-top: 10px; }
.row.join input { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 700; }
.btn { background: var(--accent); color: #1c1a0c; border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 700; cursor: pointer; min-height: 46px; margin-top: 4px; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.codebox { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.codebox span { font-size: 2rem; letter-spacing: .25em; font-weight: 800; color: var(--accent); flex: 1; }
.codebox .btn { flex: 0 0 auto; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 2147483001; display: flex; align-items: flex-end; justify-content: center; overflow-y: auto; padding: 12px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: 100%; max-width: 560px; margin: auto; display: grid; gap: 10px; }
.sheet h2, .sheet h3 { margin: 0; }
.sheet p { margin: 0; }
.sheet .hint { margin: 0; }
.sheet .big { font-size: 1.8rem; font-weight: 800; text-align: center; }
.sheet .big.win { color: var(--good); }
.sheet .big.lose { color: var(--bad); }
.error { color: var(--bad); min-height: 1.2em; font-size: .9rem; }
.sheet p b { color: var(--accent); }
.sheet ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 4px; font-size: .92rem; }
.units { display: grid; gap: 8px; }
.urow { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; background: var(--panel2); border-radius: 10px; padding: 8px 10px; }
.urow canvas { width: 34px; height: 34px; }
.urow b { display: block; }
.urow small { color: var(--muted); display: block; font-size: .8rem; }
.stats { width: 100%; border-collapse: collapse; font-size: .92rem; }
.stats th, .stats td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.stats th:first-child, .stats td:first-child { text-align: left; color: var(--muted); }
.sheet .row .btn { margin-top: 0; }
@media (min-width: 700px) { .overlay { align-items: center; } }

/* ───────── partita ───────── */
#game { position: fixed; inset: 0; z-index: 10; background: #0a0e08; user-select: none; -webkit-user-select: none; overflow: hidden; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: default; touch-action: none; }
#stage.attack { cursor: crosshair; }
#hud-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: 6px 10px 6px 58px; background: linear-gradient(#0a0e08e8, #0a0e0800); pointer-events: none; }
#hud-top > * { pointer-events: auto; }
#hud-top .grow { flex: 1; pointer-events: none; }
.stat { display: inline-flex; align-items: center; gap: 6px; background: #12190fcc; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-variant-numeric: tabular-nums; }
.stat b { font-size: 1.05rem; }
.stat small { color: var(--good); font-size: .75rem; min-width: 3.4em; }
.stat .gem { width: 12px; height: 12px; background: #f2c744; transform: rotate(45deg); border-radius: 2px; box-shadow: 0 0 6px #f2c744aa; }
.stat.warn b { color: var(--bad); }
#toasts { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; z-index: 2; }
.toast { background: #12190fe6; border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; font-size: .95rem; animation: fade 3.2s forwards; }
.toast.bad { border-color: var(--bad); color: var(--bad); }
.toast.alert { border-color: var(--bad); background: #3b1511e6; color: #ffd0c8; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#mode-hint { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); background: #12190fe6; border: 1px solid var(--accent); border-radius: 10px; padding: 6px 14px; pointer-events: none; z-index: 3; }
#hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 182px; display: grid; grid-template-columns: 232px 1fr 340px; gap: 8px; padding: 6px 8px; background: linear-gradient(#0a0e0800, #0a0e08f0 30%); align-items: stretch; z-index: 2; }
#minimap { width: 220px; height: 138px; align-self: end; border: 2px solid var(--line); border-radius: 6px; background: #0a0e08; cursor: pointer; }
#info, #cmds { background: #12190fe6; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; overflow: hidden; font-size: .9rem; align-self: end; height: 166px; }
#info h3 { margin: 0 0 4px; font-size: 1rem; color: var(--accent); }
#info .sel { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
#info .sel span { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: .8rem; }
#info .muted { color: var(--muted); }
.bar { height: 8px; background: #0c1109; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); margin: 3px 0; }
.bar i { display: block; height: 100%; background: var(--good); }
.bar.q i { background: var(--accent); }
#cmds { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: min-content; gap: 6px; align-content: start; }
.cbtn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 5px 2px; cursor: pointer; text-align: center; line-height: 1.15; font-size: .78rem; position: relative; }
.cbtn canvas { width: 28px; height: 28px; display: block; margin: 0 auto 2px; }
.cbtn b { display: block; font-size: .8rem; }
.cbtn small { color: var(--accent); display: block; }
.cbtn kbd { position: absolute; top: 2px; left: 4px; font: 700 .7rem system-ui; color: var(--muted); }
.cbtn:hover:not(:disabled) { border-color: var(--accent); }
.cbtn:disabled { opacity: .45; cursor: default; }
.cbtn.wide2 { grid-column: span 2; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 4px; }
.qrow { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: nowrap; height: 34px; overflow: hidden; }
.qitem { flex: 0 0 36px; }
.qitem { position: relative; width: 36px; height: 34px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; overflow: hidden; }
.qitem canvas { width: 100%; height: 100%; }
.qitem i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
@media (max-width: 1000px) { #hud-bottom { grid-template-columns: 232px 1fr 300px; } }
@media (max-width: 800px) { #hud-bottom { grid-template-columns: 1fr; height: auto; } #info { display: none; } #minimap { display: none; } #cmds { height: auto; } }
#st-vs b { font-size: .9rem; font-weight: 600; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
