:root {
  --bg: #13241c;
  --board: #1d3a2c;
  --panel: rgba(12, 22, 17, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --chalk: #f1f5ee;
  --muted: #a9bdb1;
  --accent: #ffd54f;
  --seven: #ff2d55;
  --ok: #69f0ae;
  --hp: #5cdb5c;
  --armor: #4fa3ff;
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --title: 'Bangers', 'Impact', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--chalk); font-family: var(--font); }
[hidden] { display: none !important; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
body.ingame canvas#game { cursor: none; }
button { font-family: inherit; }
kbd { display: inline-block; min-width: 22px; padding: 2px 6px; border-radius: 5px; background: #2b3f35; border: 1px solid #4b6457; border-bottom-width: 3px; font: 700 12px var(--font); color: #fff; text-align: center; margin-right: 2px; }

/* ---------------- MENU ---------------- */
.screen { position: fixed; inset: 0; overflow-y: auto; z-index: 10;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 213, 79, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(255, 45, 85, 0.08), transparent 50%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 6px),
    var(--board);
}
.menu-wrap { max-width: 1400px; margin: 0 auto; padding: 18px 16px 30px; }
.title { text-align: center; margin: 6px 0 14px; }
.title h1 { font-family: var(--title); font-size: clamp(44px, 8vw, 92px); letter-spacing: 3px; margin: 0; line-height: 0.95;
  color: var(--chalk); text-shadow: 3px 3px 0 #0b1712, 0 0 30px rgba(255,255,255,0.15); }
.title .seven { color: var(--seven); display: inline-block; transform: rotate(-8deg) scale(1.15); text-shadow: 3px 3px 0 #4a0010, 0 0 25px rgba(255,45,85,0.6); }
.title .tag { margin: 6px 0 0; color: var(--muted); font-style: italic; }
.menu-grid { display: grid; grid-template-columns: 300px 1fr 340px; gap: 14px; align-items: start; }
.panel { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.panel h2 { font-family: var(--title); letter-spacing: 1.5px; font-weight: 400; font-size: 28px; margin: 0 0 10px; color: var(--accent); }
.left label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
input[type=text], input:not([type]) { width: 100%; padding: 11px 12px; border-radius: 9px; border: 2px solid #3b5547; background: #0d1813; color: #fff; font: 500 16px var(--font); outline: none; }
input:focus { border-color: var(--accent); }
.btn { cursor: pointer; border: none; border-radius: 10px; padding: 10px 14px; font-weight: 800; color: #1a1a1a; background: var(--accent); box-shadow: 0 4px 0 #b08d1a; transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b08d1a; }
.btn.big { width: 100%; margin-top: 14px; font-family: var(--title); font-size: 30px; letter-spacing: 2px; font-weight: 400; padding: 8px; }
.btn.small { padding: 6px 10px; font-size: 12px; box-shadow: 0 2px 0 #b08d1a; }
.btn.ready { background: var(--ok); box-shadow: 0 4px 0 #2e9c64; }
.err { color: #ff8a80; min-height: 18px; font-size: 13px; }
.lobby-head { display: flex; justify-content: space-between; gap: 8px; }
.lobby-head small { display: block; font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.lobby-head b { font-size: 22px; }
.lobby-head .cd b { color: var(--accent); font-family: var(--title); font-size: 34px; font-weight: 400; }
#lobbyList { list-style: none; margin: 10px 0 0; padding: 0; max-height: 240px; overflow: auto; }
#lobbyList li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,0.04); margin-bottom: 5px; font-size: 14px; }
#lobbyList li canvas { width: 30px; height: 34px; border-radius: 6px; flex: none; }
#lobbyList li .who { flex: 1; min-width: 0; }
#lobbyList li .who small { display: block; color: var(--muted); font-size: 11px; }
#lobbyList li .rd { font-size: 12px; font-weight: 700; color: #777; }
#lobbyList li .rd.on { color: var(--ok); }
.hint { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.linkrow { display: flex; gap: 6px; align-items: center; }
.linkrow code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; background: #0d1813; padding: 6px; border-radius: 6px; }
.settings { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); display: grid; gap: 6px; font-size: 14px; }
.settings .tog { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.settings .vol { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.settings input[type=range] { flex: 1; accent-color: var(--accent); }
#hof { margin-top: 12px; font-size: 13px; }
#hof h3 { margin: 0 0 6px; font-family: var(--title); font-weight: 400; letter-spacing: 1px; color: var(--accent); font-size: 20px; }
#hof div { padding: 3px 0; color: var(--muted); }
#hof b { color: #fff; }

#charGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.card { cursor: pointer; background: #0d1813; border: 2px solid transparent; border-radius: 10px; padding: 4px; text-align: center; transition: transform .1s, border-color .1s; position: relative; }
.card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.25); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,213,79,0.25); }
.card canvas { width: 100%; aspect-ratio: 96/110; border-radius: 7px; display: block; }
.card .nm { font-weight: 800; font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .tt { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .taken { position: absolute; top: 6px; right: 6px; background: var(--seven); color: #fff; font-size: 9px; font-weight: 800; padding: 1px 4px; border-radius: 4px; }

.detail .top { display: flex; gap: 12px; align-items: center; }
.detail canvas { width: 120px; height: 138px; border-radius: 12px; flex: none; }
.detail h3 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 38px; letter-spacing: 1.5px; line-height: 1; }
.detail .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.stat { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-top: 6px; color: var(--muted); }
.stat .sb { flex: 1; height: 7px; background: #0d1813; border-radius: 4px; overflow: hidden; }
.stat .sb i { display: block; height: 100%; background: var(--accent); }
.ab { margin-top: 10px; padding: 9px 10px; border-radius: 9px; background: rgba(255,255,255,0.04); border-left: 4px solid var(--muted); }
.ab.q { border-color: #4fc3f7; } .ab.f { border-color: var(--seven); } .ab.p { border-color: var(--ok); }
.ab .h { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.ab .d { font-size: 13px; color: #d5e2da; margin-top: 3px; line-height: 1.35; }
.quotes { margin-top: 10px; font-size: 12px; color: var(--muted); font-style: italic; line-height: 1.5; }
.controls { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); }
.controls small { color: #6f8a7b; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-size: 14px; }
#hud > * { pointer-events: none; }
#topLeft { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pill { background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; padding: 5px 12px; display: flex; align-items: center; gap: 6px; backdrop-filter: blur(3px); }
.pill b { font-size: 18px; }
.pill small { color: #bbb; }
.pill.zone { font-size: 13px; }
.pill.zone.danger { background: rgba(120, 30, 180, 0.7); animation: pulse 1s infinite; }
@keyframes pulse { 50% { filter: brightness(1.4); } }
#hStatus { display: flex; flex-wrap: wrap; gap: 4px; max-width: 320px; }
#hStatus span { background: rgba(0,0,0,0.6); border-radius: 6px; padding: 3px 7px; font-size: 12px; font-weight: 700; }
#hStatus span.bad { background: rgba(160, 20, 40, 0.75); }
#hStatus span.good { background: rgba(20, 130, 70, 0.75); }
#topRight { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#minimap { width: 200px; height: 200px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.25); background: #2b4a35; box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
#killfeed { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; max-width: 380px; }
#killfeed div { background: rgba(0,0,0,0.6); border-radius: 7px; padding: 4px 9px; font-size: 13px; animation: slidein .2s; text-align: right; }
#killfeed div.me { background: rgba(255,45,85,0.55); }
#killfeed .v { color: #bbb; font-style: italic; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
#announce { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(90vw, 760px); }
#announce div { font-family: var(--title); font-size: clamp(22px, 3vw, 34px); letter-spacing: 1.5px; text-shadow: 2px 2px 0 #000, 0 0 18px rgba(0,0,0,0.8); animation: pop .3s; }
@keyframes pop { from { transform: scale(1.4); opacity: 0; } }
#toasts { position: absolute; bottom: 190px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 4px; align-items: center; }
#toasts div { background: rgba(0,0,0,0.6); padding: 4px 12px; border-radius: 8px; font-weight: 700; font-size: 14px; animation: pop .2s; }
#prompt { position: absolute; bottom: 230px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.7); border: 1px solid rgba(255,255,255,0.2); padding: 7px 14px; border-radius: 10px; font-weight: 700; white-space: nowrap; }
#prompt:empty { display: none; }
#progress { position: absolute; top: 58%; left: 50%; transform: translateX(-50%); width: 220px; height: 22px; background: rgba(0,0,0,0.6); border-radius: 11px; overflow: hidden; border: 1px solid rgba(255,255,255,0.3); }
#progress .fill { height: 100%; background: linear-gradient(90deg, #ffd54f, #ffb300); width: 0; }
#progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; text-shadow: 1px 1px 0 #000; }
#trainHint { position: absolute; bottom: 260px; left: 50%; transform: translateX(-50%); background: rgba(255, 213, 79, 0.95); color: #1a1a1a; padding: 12px 22px; border-radius: 12px; font-size: 20px; animation: pulse 1s infinite; text-align: center; }
#trainHint small { display: block; font-size: 12px; }

#bottom { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 12px; gap: 10px; }
#abil { display: grid; grid-template-columns: 84px 74px 74px; grid-template-rows: auto auto; gap: 6px; align-items: end; }
#myPortrait { width: 84px; height: 96px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.3); grid-row: span 2; }
.abox { position: relative; width: 74px; height: 74px; border-radius: 12px; background: rgba(0,0,0,0.65); border: 2px solid #4fc3f7; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 4px; text-align: center; }
.abox.ult { border-color: var(--seven); }
.abox.ready { box-shadow: 0 0 14px rgba(79,195,247,0.8); }
.abox.ult.ready { box-shadow: 0 0 18px rgba(255,45,85,0.9); animation: pulse 0.8s infinite; }
.abox kbd { position: absolute; top: 4px; left: 4px; }
.abox .nm { font-size: 10px; font-weight: 700; line-height: 1.05; z-index: 2; }
.abox .cdt { position: absolute; top: 22px; left: 0; right: 0; font-size: 20px; font-weight: 900; z-index: 2; text-shadow: 1px 1px 0 #000; }
.abox .cdov { position: absolute; inset: 0; background: rgba(0,0,0,0.6); z-index: 1; }
.passive { grid-column: 2 / span 2; font-size: 11px; color: #cfe; background: rgba(0,0,0,0.55); border-radius: 8px; padding: 4px 6px; max-width: 154px; }
#center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bars { width: min(440px, 46vw); display: flex; flex-direction: column; gap: 3px; }
.bar { position: relative; height: 12px; background: rgba(0,0,0,0.6); border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,0.18); }
.bar.hp { height: 20px; }
.bar .fill { height: 100%; width: 100%; transition: width .15s; }
.bar.hp .fill { background: linear-gradient(180deg, #7ef07e, #2fa82f); }
.bar.hp.low .fill { background: linear-gradient(180deg, #ff6b6b, #c62828); }
.bar.armor .fill { background: linear-gradient(180deg, #7cc1ff, #2a73d9); }
.bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; text-shadow: 1px 1px 0 #000; }
#slots { display: flex; gap: 6px; }
.slot { position: relative; width: 96px; height: 64px; background: rgba(0,0,0,0.6); border: 2px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 3px 5px; display: flex; flex-direction: column; justify-content: space-between; }
.slot.small { width: 64px; }
.slot.sel { border-color: #fff; background: rgba(40,40,40,0.8); transform: translateY(-4px); }
.slot kbd { position: absolute; top: -9px; left: -6px; transform: scale(0.85); }
.slot canvas { width: 86px; height: 28px; align-self: center; }
.slot .wn { font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .am { font-size: 13px; font-weight: 900; text-align: right; }
.slot .ic { font-size: 24px; text-align: center; line-height: 1.2; }
.slot .ct { position: absolute; bottom: 2px; right: 5px; font-weight: 900; }
#inv { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; font-size: 12px; }
#ammoList div { background: rgba(0,0,0,0.55); padding: 2px 8px; border-radius: 6px; margin-top: 2px; display: flex; gap: 8px; justify-content: space-between; min-width: 120px; }
#ammoList i { font-style: normal; font-weight: 900; }
.coins { background: rgba(0,0,0,0.6); padding: 5px 10px; border-radius: 8px; font-size: 15px; }
.coins b { color: var(--accent); }

#chat { position: absolute; left: 12px; bottom: 150px; width: 340px; max-width: 45vw; }
#chatLog { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow: hidden; justify-content: flex-end; }
#chatLog div { font-size: 13px; background: rgba(0,0,0,0.45); padding: 2px 7px; border-radius: 5px; transition: opacity 1s; align-self: flex-start; }
#chatLog div.sys { color: #9fd; font-style: italic; }
#chatLog div.old { opacity: 0; }
#chat.open #chatLog div.old { opacity: 1; }
#chatInput { pointer-events: auto; margin-top: 4px; padding: 7px; font-size: 14px; }

#quiz { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); width: min(92vw, 520px); background: #fffef5; color: #222; border-radius: 12px; padding: 14px 16px; pointer-events: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  background-image: repeating-linear-gradient(0deg, transparent 0 23px, #c5dbf0 23px 24px); border-left: 6px solid #ef9a9a; }
#quiz h3 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 28px; letter-spacing: 1px; color: #c62828; }
#quiz .q { font-weight: 700; margin: 6px 0 10px; font-size: 16px; }
#quiz .ans { display: grid; gap: 6px; }
#quiz button { pointer-events: auto; text-align: left; padding: 8px 10px; border-radius: 8px; border: 2px solid #333; background: #fff; font-weight: 700; cursor: pointer; font-size: 14px; }
#quiz button:hover { background: #ffe082; }
#quiz .tbar { height: 5px; background: #c62828; margin-top: 10px; border-radius: 3px; transition: width .1s linear; }
#quiz small { color: #666; }

#shop { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(94vw, 560px); background: #0e2a5c; border: 4px solid #5e92f3; border-radius: 16px; padding: 14px; pointer-events: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.7); }
#shop h3 { margin: 0 0 4px; font-family: var(--title); font-weight: 400; letter-spacing: 1px; font-size: 30px; }
#shop .sub { font-size: 12px; color: #b3cdf7; margin-bottom: 10px; }
#shop .items { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#shop button.it { pointer-events: auto; display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 9px; border: 2px solid #2d5aa8; background: #133a7c; color: #fff; cursor: pointer; text-align: left; font-size: 13px; }
#shop button.it:hover { background: #1d4fa3; }
#shop button.it.no { opacity: 0.45; }
#shop button.it b { color: var(--accent); white-space: nowrap; }
#shop .close { pointer-events: auto; margin-top: 10px; width: 100%; }

#deathScreen { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); text-align: center; background: rgba(0,0,0,0.75); border: 2px solid var(--seven); border-radius: 16px; padding: 16px 26px; pointer-events: auto; min-width: 300px; }
#deathScreen h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 52px; letter-spacing: 2px; color: var(--seven); }
#deathScreen p { margin: 6px 0; }
#deathScreen .row { display: flex; justify-content: center; gap: 20px; margin: 10px 0; }
#deathScreen .row div b { display: block; font-size: 26px; }
#deathScreen .row div small { color: #aaa; }
#deathScreen button { pointer-events: auto; }
#specBar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.6); padding: 6px 14px; border-radius: 10px; }
#bigmap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); }
#bigmapCanvas { width: min(86vh, 92vw); height: min(86vh, 92vw); border-radius: 14px; border: 3px solid rgba(255,255,255,0.3); }
#bigmap p { margin: 6px; color: #ccc; }
#hurt { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(255,0,0,0.55)); opacity: 0; transition: opacity .25s; }

#endScreen { position: fixed; inset: 0; z-index: 20; background: rgba(8, 15, 11, 0.88); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
#endScreen .box { width: min(760px, 100%); background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 18px; text-align: center; }
#endScreen h2 { font-family: var(--title); font-weight: 400; font-size: clamp(40px, 7vw, 72px); margin: 0; letter-spacing: 3px; color: var(--accent); text-shadow: 3px 3px 0 #000; }
#endScreen .win { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 10px 0; }
#endScreen .win canvas { width: 110px; height: 126px; border-radius: 12px; }
#endScreen .win .nm { font-size: 30px; font-weight: 900; }
#endScreen .line { color: var(--muted); font-style: italic; font-size: 18px; margin-top: 4px; }
#endScreen table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
#endScreen td, #endScreen th { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; }
#endScreen th { color: var(--muted); font-weight: 500; font-size: 12px; }
#endScreen tr.me td { background: rgba(255, 213, 79, 0.15); }
#endScreen .back { margin-top: 10px; color: var(--muted); }
#conn { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 30; background: #b71c1c; padding: 8px 16px; border-radius: 10px; font-weight: 700; }

@media (max-width: 1100px) {
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .menu-grid .left { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .menu-grid { grid-template-columns: 1fr; }
  #charGrid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  #minimap { width: 120px; height: 120px; }
  .slot { width: 66px; } .slot.small { width: 48px; }
  .slot canvas { width: 58px; }
  #abil { grid-template-columns: 60px 56px 56px; }
  #myPortrait { width: 60px; height: 70px; }
  .abox { width: 56px; height: 56px; }
  .passive, #inv, #chat { display: none; }
}
