:root {
  --bg: #15121f;
  --panel: rgba(28, 22, 40, 0.88);
  --panel2: rgba(48, 38, 66, 0.9);
  --ink: #f4ead6;
  --muted: #b8a98f;
  --gold: #e8c04a;
  --red: #e0564a;
  --blue: #4a8fe8;
  --ok: #6fd18a;
  --line: rgba(232, 192, 74, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }

/* ------------------------------------------------ screens */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 10;
  background: radial-gradient(ellipse at 50% 20%, rgba(90, 60, 130, 0.55), rgba(15, 10, 25, 0.92)); overflow: auto; padding: 16px; }
.screen.active { display: flex; }
.screen.overlay { background: rgba(10, 6, 18, 0.72); }

.menu-card, .lobby, .end-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.menu-card { width: min(440px, 100%); display: flex; flex-direction: column; gap: 14px; }
.logo { font-family: 'Cinzel', serif; font-weight: 800; font-size: 56px; margin: 0; text-align: center; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff3c0, #e8a83a 60%, #b8602a); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 30px rgba(232, 168, 58, 0.25); }
.subtitle { text-align: center; color: var(--muted); margin-top: -8px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select { background: rgba(0,0,0,.35); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; outline: none; }
input:focus, select:focus { border-color: var(--gold); }
.join-row { display: flex; gap: 10px; }
.join-row input { width: 110px; text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; }
.join-row .btn { flex: 1; }
.btn { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 800; cursor: pointer; transition: transform .08s, background .15s; }
.btn:hover { background: #4d3c6a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #e8b84a, #b8782a); color: #2a1a08; border-color: #ffd98a; }
.btn.primary:hover { background: linear-gradient(180deg, #f8c85a, #c8883a); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.tiny { padding: 4px 8px; font-size: 11px; border-radius: 7px; }
.btn.big { padding: 14px 40px; font-size: 20px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.msg { min-height: 20px; color: #ffb3a0; text-align: center; font-size: 14px; }
.help { font-size: 12px; color: var(--muted); line-height: 1.6; text-align: center; }
.note { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------ lobby */
.lobby { width: min(860px, 100%); display: flex; flex-direction: column; gap: 18px; }
.lobby-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-end; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; }
.room-code { font-family: 'Cinzel', serif; font-size: 52px; font-weight: 800; letter-spacing: 10px; color: var(--gold); user-select: all; }
.lobby-settings { display: flex; flex-direction: column; gap: 8px; min-width: 260px; }
.toggle { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.team { border-radius: 14px; padding: 14px; background: rgba(0,0,0,.25); border: 2px solid; display: flex; flex-direction: column; gap: 10px; }
.team.red { border-color: rgba(224, 86, 74, .6); }
.team.blue { border-color: rgba(74, 143, 232, .6); }
.team h2 { margin: 0; font-family: 'Cinzel', serif; font-size: 20px; }
.team.red h2 { color: var(--red); } .team.blue h2 { color: var(--blue); }
.team ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-height: 180px; }
.team li { background: rgba(255,255,255,.05); border-radius: 8px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; }
.team li.me { outline: 1px solid var(--gold); }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: rgba(232,192,74,.2); color: var(--gold); margin-left: 6px; }
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
@media (max-width: 640px) { .teams { grid-template-columns: 1fr; } .room-code { font-size: 40px; } }

/* ------------------------------------------------ draft */
.draft { width: min(1180px, 100%); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.draft-head { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; }
.draft-center { text-align: center; }
.draft-title { font-family: 'Cinzel', serif; font-size: 28px; font-weight: 800; }
.draft-timer { font-size: 44px; font-weight: 800; color: var(--gold); }
.roster { display: flex; flex-direction: column; gap: 6px; }
.roster .slot { padding: 8px 12px; border-radius: 10px; background: rgba(0,0,0,.35); border-left: 4px solid var(--red); display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.roster.right .slot { border-left: none; border-right: 4px solid var(--blue); }
.roster .slot.locked { background: rgba(232,192,74,.15); }
.roster .slot .cls { color: var(--muted); }
.roster .slot.locked .cls { color: var(--gold); font-weight: 800; }
.roster .slot.bot { opacity: .75; font-style: italic; }
.team li.bot { opacity: .6; font-style: italic; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; width: 100%; }
.class-card { background: var(--panel); border: 2px solid transparent; border-radius: 12px; padding: 12px; cursor: pointer; text-align: center; position: relative; transition: transform .1s, border-color .1s; }
.class-card:hover { transform: translateY(-2px); }
.class-card.sel { border-color: var(--gold); box-shadow: 0 0 20px rgba(232,192,74,.35); }
.class-card.taken, .class-card.locked2 { opacity: .4; cursor: not-allowed; }
.class-card .swatch { width: 58px; height: 58px; border-radius: 50%; margin: 0 auto 8px; box-shadow: inset 0 -6px 12px rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.class-card .nm { font-weight: 800; }
.class-card .role { font-size: 12px; color: var(--muted); }
.class-card .badge { position: absolute; top: 6px; right: 6px; font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.5); color: var(--muted); }
.class-detail { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; min-height: 90px; }
.spell-card { background: rgba(0,0,0,.35); border-radius: 10px; padding: 10px; font-size: 13px; }
.spell-card .k { display: inline-block; min-width: 34px; padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,.1); font-weight: 800; margin-right: 6px; text-align: center; }
.spell-card .sn { font-weight: 800; }
.spell-card .sd { color: var(--muted); margin-top: 4px; }
.spell-card .ss { color: #cfc0a0; margin-top: 4px; font-size: 11px; }
@media (max-width: 760px) { .class-detail { grid-template-columns: 1fr 1fr; } .draft-head { grid-template-columns: 1fr; } }

/* ------------------------------------------------ end */
.end-card { width: min(820px, 100%); text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.end-card h1 { font-family: 'Cinzel', serif; font-size: 48px; margin: 0; }
.end-score { font-size: 28px; font-weight: 800; }
.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats th, .stats td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.07); text-align: center; }
.stats th { color: var(--muted); font-weight: 700; }
.stats tr.t0 td:first-child { border-left: 4px solid var(--red); }
.stats tr.t1 td:first-child { border-left: 4px solid var(--blue); }

/* ------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud .btn, #hud input { pointer-events: auto; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.ch-dot { position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; border-radius: 50%; background: #fff; box-shadow: 0 0 3px #000; }
.ch-ring { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55); box-shadow: 0 0 2px rgba(0,0,0,.6); transition: transform .08s; }
.ch-ring.cast { transform: scale(1.5); }
.hitmarker { position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; opacity: 0; transition: opacity .2s;
  background: linear-gradient(45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%), linear-gradient(-45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%); }
.hitmarker.show { opacity: 1; transition: none; }
.hitmarker.kill { filter: drop-shadow(0 0 4px red) hue-rotate(-40deg) saturate(5); }

#topbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 0; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
#topbar .score { min-width: 70px; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 800; padding: 4px 14px; }
#topbar .score.red { background: rgba(200, 60, 50, .85); border-radius: 12px 0 0 12px; }
#topbar .score.blue { background: rgba(50, 110, 200, .85); border-radius: 0 12px 12px 0; }
.mode-info { background: var(--panel); padding: 6px 18px; text-align: center; min-width: 220px; }
#mode-name { font-family: 'Cinzel', serif; font-weight: 800; font-size: 14px; }
#mode-sub { font-size: 12px; color: var(--muted); }
.objective { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); font-size: 14px; font-weight: 800; text-shadow: 0 2px 4px #000; text-align: center; }

#killfeed { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.kf { background: rgba(0,0,0,.55); padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; animation: fadein .2s; }
.kf .r { color: var(--red); } .kf .b { color: var(--blue); }
#toasts { position: absolute; top: 34%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: rgba(0,0,0,.6); padding: 6px 16px; border-radius: 10px; font-weight: 800; font-size: 16px; text-shadow: 0 1px 2px #000; animation: fadein .15s; }
.toast.big { font-size: 26px; font-family: 'Cinzel', serif; padding: 10px 24px; }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

#bottom { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 16px; }
.vitals { display: flex; flex-direction: column; gap: 6px; width: 230px; }
.bar { position: relative; height: 20px; border-radius: 10px; background: rgba(0,0,0,.6); overflow: hidden; border: 1px solid rgba(255,255,255,.15); }
.bar > div { position: absolute; inset: 0; width: 100%; transition: width .12s; }
.bar.hp > div { background: linear-gradient(90deg, #c43a3a, #ef6a5a); }
.bar.mana > div { background: linear-gradient(90deg, #3a5ac4, #6a9aef); }
.bar span { position: relative; z-index: 1; display: block; text-align: center; font-size: 12px; font-weight: 800; line-height: 20px; text-shadow: 0 1px 2px #000; }
.dodges { display: flex; gap: 6px; }
.dodge-pip { position: relative; width: 104px; height: 14px; border-radius: 7px; background: rgba(0,0,0,.6); overflow: hidden; border: 1px solid rgba(255,255,255,.15); }
.dodge-pip > div { height: 100%; background: linear-gradient(90deg, #c8c0a8, #f0e8d0); }
.dodge-pip > span { position: absolute; inset: 0; text-align: center; font-size: 9px; font-weight: 800; line-height: 14px; letter-spacing: .08em; color: #20202a; }
.dodge-pip.nomana { filter: saturate(.2) brightness(.55); }
.dodge-pip.nomana > span { color: #8ab4ff; }
.castbar { position: absolute; left: 50%; top: calc(50% + 120px); transform: translateX(-50%); width: 220px; height: 16px; border-radius: 8px; background: rgba(0,0,0,.65); border: 1px solid rgba(255,255,255,.22); overflow: hidden; pointer-events: none; }
.castbar > #castbar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; opacity: .75; }
.castbar.charging { border-color: #ffd86a; box-shadow: 0 0 10px rgba(255,216,106,.6); }
.castbar.charging > #castbar-fill { background: linear-gradient(90deg, #ffb84a, #fff0a0) !important; opacity: .9; }
.castbar > #castbar-name { position: relative; text-align: center; font-size: 11px; font-weight: 800; line-height: 16px; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.statuses { display: flex; gap: 4px; flex-wrap: wrap; min-height: 18px; }
.status { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: rgba(0,0,0,.6); }
.spellbar { display: flex; gap: 8px; }
.spell { width: 64px; height: 64px; border-radius: 12px; background: rgba(20,14,30,.85); border: 2px solid rgba(255,255,255,.18); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.spell .cdv { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); }
.spell .cdt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; text-shadow: 0 1px 3px #000; }
.spell .key { position: absolute; top: 2px; left: 4px; font-size: 10px; font-weight: 800; color: var(--muted); }
.spell .mc { position: absolute; bottom: 2px; right: 4px; font-size: 10px; font-weight: 800; color: #8ab4ff; }
.spell.nomana { filter: saturate(.2) brightness(.7); }
.spell.flash { border-color: #fff; }
.scroll-slot { width: 110px; height: 64px; border-radius: 12px; background: rgba(20,14,30,.85); border: 2px dashed rgba(255,255,255,.2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; text-align: center; padding: 4px; }
.scroll-slot.has { border-style: solid; border-color: var(--gold); }
.scroll-slot .key { font-weight: 800; color: var(--muted); font-size: 10px; }

#voice-hud { position: absolute; left: 12px; top: 12px; background: rgba(0,0,0,.5); padding: 6px 8px; border-radius: 10px; display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 700; }
#voice-state.live { color: var(--ok); }
.respawn { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); text-align: center; font-family: 'Cinzel', serif; font-size: 22px; text-shadow: 0 2px 6px #000; }
.respawn .big { font-size: 64px; font-weight: 800; color: var(--gold); }
.scoreboard { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: min(760px, 94vw); }
.scoreboard table { width: 100%; border-collapse: collapse; font-size: 14px; }
.scoreboard th, .scoreboard td { padding: 5px 8px; text-align: center; }
.scoreboard th { color: var(--muted); }
.scoreboard tr.t0 td:first-child { border-left: 4px solid var(--red); text-align: left; }
.scoreboard tr.t1 td:first-child { border-left: 4px solid var(--blue); text-align: left; }
.scoreboard tr.me td { background: rgba(232,192,74,.12); }
#chat { position: absolute; left: 12px; bottom: 16px; width: 300px; }
#chat-log { display: flex; flex-direction: column; gap: 2px; font-size: 13px; max-height: 160px; overflow: hidden; justify-content: flex-end; }
#chat-log div { background: rgba(0,0,0,.4); padding: 2px 8px; border-radius: 6px; text-shadow: 0 1px 2px #000; }
#chat-input { width: 100%; margin-top: 4px; font-size: 13px; padding: 6px 8px; }
.click-to-play { position: absolute; top: 58%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 10px 20px; border-radius: 12px; font-weight: 800; }
#net-stats { position: absolute; right: 12px; bottom: 8px; font-size: 11px; color: rgba(255,255,255,.55); font-family: ui-monospace, monospace; }

.blind { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(255,255,250,1) 0%, rgba(255,255,240,.95) 40%, rgba(255,250,220,.85) 100%); opacity: 0; }
/* Shroud Mist: blind in the dark, with slow smoke turning at the edges of sight */
.blind.dark { background: radial-gradient(ellipse at 50% 55%, rgba(16,8,28,.97) 0%, rgba(9,4,16,.99) 50%, rgba(3,1,6,1) 100%); }
.blind.dark::after { content: ''; position: absolute; inset: -10%; background:
  radial-gradient(circle at 30% 40%, rgba(110,60,170,.16), transparent 35%),
  radial-gradient(circle at 70% 60%, rgba(80,40,140,.14), transparent 40%),
  radial-gradient(circle at 50% 85%, rgba(140,70,200,.10), transparent 30%);
  animation: shroud-drift 6s ease-in-out infinite alternate; }
@keyframes shroud-drift { from { transform: rotate(-4deg) scale(1); } to { transform: rotate(5deg) scale(1.08); } }
.dmg-vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px rgba(200, 20, 20, .9); opacity: 0; transition: opacity .25s; }
.mist-overlay { position: absolute; inset: 0; background: radial-gradient(circle, rgba(20,10,35,.86), rgba(8,4,16,.97)); opacity: 0; transition: opacity .3s; }

#loading { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: rgba(15,10,25,.92); font-family: 'Cinzel', serif; font-size: 20px; }
.spinner { width: 50px; height: 50px; border-radius: 50%; border: 4px solid rgba(232,192,74,.2); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  #chat { bottom: 110px; }
}
@media (max-width: 760px) {
  #bottom { transform: translateX(-50%) scale(.75); transform-origin: bottom center; }
  #chat { width: 240px; }
}

/* ------------------------------------------------ pause menu, controller prompts, transport-only bits */
.pause { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: rgba(10, 6, 18, 0.66); }
.pause.hidden { display: none; }
.pause-card { width: min(460px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px 28px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.pause-card h2 { font-family: 'Cinzel', serif; font-weight: 800; font-size: 30px; margin: 0 0 4px; text-align: center; color: var(--gold); }
.pause-card .settings { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.pause-card .help { font-size: 12px; color: var(--muted); line-height: 1.5; }
.pause-card:has(.sbx:not(.hidden)) { width: min(620px, 94vw); max-height: 94vh; overflow-y: auto; }
.sbx { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.22); }
.sbx.hidden { display: none; }
.sbx-title { font-family: 'Cinzel', serif; font-weight: 800; color: var(--gold); letter-spacing: .06em; }
.sbx-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sbx-row .toggle { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.small kbd { font: inherit; font-size: 11px; opacity: .7; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.sbx-cls { display: flex; align-items: center; gap: 6px; }
.sbx-cls.on { border-color: var(--gold); background: #4d3c6a; }
.sbx-cls i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
input[type=range] { padding: 0; accent-color: var(--gold); }
.pad-focus { outline: 3px solid #ffe36b !important; outline-offset: 2px; box-shadow: 0 0 18px rgba(255, 227, 107, .45) !important; }
.padtxt { display: none; }
body.pad .padtxt { display: inline; }
body.pad .kb { display: none; }
body:not(.has-voice) .voice-only { display: none !important; }
body:not(.on-patch) .patch-only { display: none !important; }
