:root {
  --bg: #0a0e17;
  --panel: rgba(18, 25, 40, .88);
  --line: rgba(120, 160, 220, .18);
  --text: #e8eefc;
  --muted: #8493b3;
  --accent: #35e0ff;
  --accent2: #ff9a4a;
  --blue: #3aa0ff;
  --red: #ff4d5e;
  --good: #47e08a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 15px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; user-select: none; -webkit-user-select: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
kbd { background: #1d2740; border: 1px solid #33425f; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font: 12px monospace; color: #cfe0ff; }

#game { position: fixed; inset: 0; z-index: 0; touch-action: none; }
#game canvas { display: block; width: 100%; height: 100%; touch-action: none; }
body.playing #game { cursor: none; }

/* ----------------------------------------------------- screens / lobby */
.screen { position: fixed; inset: 0; z-index: 20; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(1200px 700px at 20% -10%, #17314f 0%, transparent 60%), radial-gradient(900px 600px at 100% 100%, #3a1730 0%, transparent 55%), var(--bg); }
.lobby-wrap { max-width: 1280px; margin: 0 auto; padding: 18px 20px 40px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.logo { font-weight: 900; font-size: 34px; letter-spacing: 6px; color: #fff; text-shadow: 0 0 22px rgba(53, 224, 255, .55); }
.logo span { color: var(--accent); margin-left: 8px; }
.invite { text-align: right; }
.invite-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.invite-url { font: 700 18px monospace; color: var(--accent); user-select: text; -webkit-user-select: text; }
.cols { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; backdrop-filter: blur(6px); }
.panel h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); }
.field { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.field input { display: block; width: 100%; margin-top: 4px; background: #0e1626; border: 1px solid #2b3a5a; border-radius: 8px; color: #fff; padding: 9px 11px; font-size: 16px; outline: none; user-select: text; -webkit-user-select: text; }
.field input:focus { border-color: var(--accent); }

.team-pick { display: flex; gap: 8px; margin: 12px 0 0; }
.team-btn { flex: 1; padding: 9px; font-weight: 800; letter-spacing: 2px; border-radius: 8px; border: 2px solid transparent; color: #fff; cursor: pointer; opacity: .55; }
.team-btn[data-team="0"] { background: #17436e; border-color: var(--blue); }
.team-btn[data-team="1"] { background: #6e1a28; border-color: var(--red); }
.team-btn.on { opacity: 1; box-shadow: 0 0 16px currentColor; }

.hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 10px; }
.hero-card { background: #0e1626; border: 2px solid #26344f; border-radius: 10px; padding: 8px 4px 6px; text-align: center; cursor: pointer; transition: transform .1s, border-color .1s; }
.hero-card:hover { transform: translateY(-2px); border-color: #3f5a8a; }
.hero-card.sel { border-color: var(--accent); box-shadow: 0 0 14px rgba(53, 224, 255, .35); background: #12203a; }
.hero-card canvas { width: 54px; height: 54px; display: block; margin: 0 auto 3px; }
.hero-card b { display: block; font-size: 12px; }
.hero-card small { color: var(--muted); font-size: 10.5px; }
.hero-detail { background: #0e1626; border: 1px solid #26344f; border-radius: 10px; padding: 12px; min-height: 160px; }
.hero-detail h3 { margin: 0 0 2px; font-size: 18px; }
.hero-detail .role { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 3px 0; }
.stat div { height: 7px; background: #1a2540; border-radius: 4px; overflow: hidden; }
.stat i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7a8cff); }
.hero-detail p { margin: 8px 0 0; font-size: 13px; }
.hero-detail p b { color: var(--accent2); }

.roster { display: flex; flex-direction: column; gap: 6px; max-height: 330px; overflow-y: auto; }
.r-row { display: flex; align-items: center; gap: 10px; background: #0e1626; border: 1px solid #26344f; border-left-width: 5px; border-radius: 8px; padding: 7px 10px; }
.r-row.me { background: #12203a; }
.r-row canvas { width: 30px; height: 30px; }
.r-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-tag { font-size: 10px; letter-spacing: 1px; padding: 2px 6px; border-radius: 4px; background: #26344f; color: #b9c8e8; }
.how { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: #b5c2dd; }
.how b { color: var(--accent); text-transform: uppercase; letter-spacing: 2px; font-size: 12px; }
.how div { margin-top: 5px; }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.set-row > span { color: #b5c2dd; }
.set-hint { font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
select { background: #0e1626; color: #fff; border: 1px solid #2b3a5a; border-radius: 8px; padding: 7px 9px; font-size: 14px; min-width: 120px; }
.seg { display: flex; border: 1px solid #2b3a5a; border-radius: 8px; overflow: hidden; }
.seg button { background: #0e1626; color: #b5c2dd; border: 0; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--accent); color: #02131a; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid #2b3a5a; background: #0e1626; color: #fff; font-size: 18px; cursor: pointer; }
.stepper b { min-width: 22px; text-align: center; font-size: 17px; }
.switch { position: relative; width: 46px; height: 26px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #26344f; border-radius: 13px; transition: .15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.panel.locked .seg button, .panel.locked select, .panel.locked .stepper button, .panel.locked .switch i { pointer-events: none; opacity: .65; }
.big-btn { width: 100%; margin-top: 14px; padding: 15px; font-size: 18px; font-weight: 900; letter-spacing: 3px; border: 0; border-radius: 12px; cursor: pointer;
  color: #02131a; background: linear-gradient(135deg, var(--accent), #6dffb8); box-shadow: 0 6px 26px rgba(53, 224, 255, .35); }
.big-btn:disabled { filter: grayscale(.9) brightness(.55); cursor: default; box-shadow: none; }
.lobby-note { margin-top: 10px; font-size: 13px; color: var(--accent2); min-height: 18px; text-align: center; }

/* ----------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px 40px rgba(255, 30, 50, 0); transition: box-shadow .35s; }
#vignette.hurt { box-shadow: inset 0 0 160px 50px rgba(255, 30, 50, .55); transition: none; }
#vignette.storm { box-shadow: inset 0 0 180px 50px rgba(255, 60, 90, .35); }

#topbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 8px; }
#tc-center { background: rgba(8, 12, 22, .8); border: 1px solid var(--line); border-radius: 10px; padding: 4px 18px; text-align: center; min-width: 110px; }
#tc-timer { font: 800 22px/1.1 monospace; }
#tc-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.tc-score { background: rgba(8, 12, 22, .8); border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; font: 800 24px/1.4 monospace; min-width: 60px; text-align: center; }
.tc-score.blue { color: var(--blue); border-color: var(--blue); }
.tc-score.red { color: var(--red); border-color: var(--red); }
.tc-score small { display: block; font: 600 10px/1 "Segoe UI", sans-serif; letter-spacing: 1px; margin-top: -4px; opacity: .8; }

#killfeed { position: absolute; top: 12px; left: 14px; display: flex; flex-direction: column; gap: 4px; max-width: 34vw; }
#killfeed div { background: rgba(8, 12, 22, .72); border-radius: 6px; padding: 3px 9px; font-size: 13px; animation: kf 6s forwards; white-space: nowrap; }
@keyframes kf { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
#killfeed i { font-style: normal; color: var(--muted); margin: 0 5px; }

#minimap { position: absolute; top: 10px; right: 10px; width: 200px; height: 134px; border: 1px solid var(--line); border-radius: 8px; background: rgba(6, 9, 16, .75); opacity: .92; }
#ping-box { position: absolute; top: 150px; right: 12px; font-size: 11px; color: var(--muted); }

#vitals { position: absolute; left: 16px; bottom: 16px; width: min(320px, 40vw); }
#hero-name { font-weight: 800; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; text-shadow: 0 2px 6px #000; }
.bar { position: relative; height: 24px; background: rgba(8, 12, 22, .8); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#hp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(90deg, #26c76b, #6dffb8); transition: width .12s; }
#armor-fill { position: absolute; left: 0; top: 0; height: 5px; width: 0; background: #5cb8ff; z-index: 2; transition: width .12s; }
#hp-text { position: absolute; inset: 0; text-align: center; font: 700 14px/24px monospace; text-shadow: 0 1px 3px #000; z-index: 3; }

#weapon-box { position: absolute; right: 16px; bottom: 100px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.wslot { position: relative; min-width: 210px; background: rgba(8, 12, 22, .78); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 14px; overflow: hidden; opacity: .6; }
.wslot.active { opacity: 1; border-color: var(--accent); }
.wslot span { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.wslot b { font: 800 24px monospace; }
#w-reload { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--accent2); }
#w-slot2.empty { display: none; }
#ability-btn { position: absolute; right: 16px; bottom: 16px; width: 210px; height: 66px; background: rgba(8, 12, 22, .82); border: 2px solid var(--accent2); border-radius: 12px; display: flex; align-items: center; gap: 12px; padding: 0 12px; overflow: hidden; }
#ability-btn #ab-key { width: 34px; height: 34px; border-radius: 8px; background: var(--accent2); color: #1a0d00; font: 900 18px/34px monospace; text-align: center; flex: none; }
#ab-name { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; z-index: 2; }
#ab-cd { position: absolute; inset: 0; background: rgba(0, 0, 0, .62); transform-origin: left; z-index: 1; display: none; }
#ability-btn.cool { border-color: #444c5e; }
#ability-btn.cool #ab-key { background: #444c5e; color: #aab; }
#ab-cd.on { display: block; }

#banner { position: absolute; top: 24%; left: 0; right: 0; text-align: center; font: 900 clamp(36px, 8vw, 84px)/1 "Segoe UI", sans-serif; letter-spacing: 6px; text-shadow: 0 4px 30px rgba(0, 0, 0, .8), 0 0 40px rgba(53, 224, 255, .4); }
#banner-sub { position: absolute; top: calc(24% + 90px); left: 0; right: 0; text-align: center; font-size: clamp(14px, 2.2vw, 22px); color: #cfe0ff; text-shadow: 0 2px 8px #000; letter-spacing: 2px; text-transform: uppercase; }
#spec { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); background: rgba(8, 12, 22, .8); border: 1px solid var(--line); border-radius: 10px; padding: 8px 18px; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }

#scoreboard { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: min(560px, 92vw); max-height: 80vh; overflow: auto; background: rgba(8, 12, 22, .92); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; }
table.sb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.sb th { text-align: left; font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; padding: 4px 8px; }
table.sb td { padding: 5px 8px; border-top: 1px solid rgba(120, 160, 220, .1); }
table.sb td.n, table.sb th.n { text-align: right; font-family: monospace; }
table.sb tr.me td { background: rgba(53, 224, 255, .08); }
table.sb tr.dead td { opacity: .5; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

#hitmark { position: fixed; left: 0; top: 0; transform: translate(-50%, -50%); font: 900 26px/1 sans-serif; color: #fff; text-shadow: 0 0 8px #000; z-index: 15; }
#hitmark.kill { color: #ff4d5e; font-size: 38px; }
#crosshair { position: fixed; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 2px solid rgba(255, 255, 255, .85); border-radius: 50%; z-index: 14;
  box-shadow: 0 0 6px rgba(0, 0, 0, .7), inset 0 0 6px rgba(0, 0, 0, .5); transition: width .1s, height .1s, margin .1s, border-color .1s; }
#crosshair::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: #fff; border-radius: 50%; }
#crosshair.reload { border-color: var(--accent2); border-style: dashed; }
body.touch #crosshair { display: none; }

/* touch controls */
#touch { position: absolute; inset: 0; pointer-events: none; }
.stick { position: absolute; bottom: 24px; width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, .06); border: 2px solid rgba(255, 255, 255, .2); pointer-events: auto; touch-action: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px; border-radius: 50%; background: rgba(255, 255, 255, .28); border: 2px solid rgba(255, 255, 255, .5); }
#stick-l { left: 24px; }
#stick-r { right: 24px; }
#touch button { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(10, 16, 30, .65); color: #fff; font: 700 10px sans-serif; width: 64px; height: 64px; letter-spacing: .5px; }
#btn-ab { right: 190px; bottom: 150px; width: 76px; height: 76px; border-color: var(--accent2); }
#btn-rl { right: 200px; bottom: 56px; }
#btn-sw { right: 120px; bottom: 190px; }
#btn-tab { left: 24px; top: 176px; width: 50px; height: 50px; }
body.touch #weapon-box { bottom: 290px; right: 16px; }
body.touch #ability-btn { display: none; }
body.touch #minimap { width: 150px; height: 100px; }
body.touch #vitals { bottom: 190px; }

/* end / connection overlays */
.end-card { margin: 8vh auto; max-width: 720px; padding: 26px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
#end { z-index: 30; background: rgba(5, 8, 14, .8); }
#end-title { font: 900 clamp(28px, 6vw, 54px)/1.1 sans-serif; letter-spacing: 4px; margin-bottom: 16px; }
#conn { z-index: 40; }
#conn-text { font-size: 22px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; background: #1a2540; border: 1px solid var(--accent); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }

#end-board { text-align: left; }
#end-board table.sb td, #end-board table.sb th { text-align: left; }
#end-board table.sb td.n, #end-board table.sb th.n { text-align: right; }
