:root {
  color-scheme: dark;
  --ink: #080d14;
  --panel: #101a27;
  --light: #f1f5f9;
  --text: #dce5ef;
  --dim: #9aaec3;
  --edge: #273b4e;
  --accent: #22d3ee;
  --danger: #fb923c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: #05080c; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .46; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, input { border-radius: 6px; }
button { line-height: 1.25; }
.primary, .secondary, .quiet-button, .icon-button {
  font-weight: 680;
  border: 1px solid transparent;
  min-height: 44px;
  padding: .64rem .92rem;
}
.primary { color: #b6f3fb; background: #14394b; border-color: #3a95ae; }
.primary:hover:not(:disabled) { color: var(--light); background: #205772; border-color: var(--accent); }
.secondary { color: var(--light); background: #142236; border-color: #344f6a; }
.secondary:hover:not(:disabled), .quiet-button:hover, .icon-button:hover { background: #20354c; border-color: #66849d; }
.quiet-button, .icon-button { color: var(--text); background: #101d2a; border-color: var(--edge); }
.icon-button { min-height: 36px; padding: .37rem .65rem; font-size: .875rem; }
.link-button { border: 0; padding: .45rem 0; min-height: 36px; color: var(--accent); background: transparent; font-size: .9rem; }
.link-button:hover { text-decoration: underline; text-underline-offset: .2em; }
label { display: block; font-size: .875rem; color: var(--dim); font-weight: 650; }
input {
  width: 100%; min-width: 0; min-height: 44px; padding: .62rem .82rem;
  border: 1px solid #506478; color: var(--light); background: #101d2a;
}
input::placeholder { color: #a0b4c4; }
.lobby { max-width: 1140px; margin: 0 auto; padding: 0 clamp(.8rem, 3vw, 2rem) 24px; }
.masthead { min-height: 59px; display: flex; align-items: center; justify-content: space-between; gap: .85rem; }
.mast-actions { display: flex; align-items: center; gap: clamp(.55rem, 2vw, 1.35rem); }
.brand { font-weight: 800; display: flex; align-items: center; gap: .65rem; letter-spacing: .14em; color: var(--light); white-space: nowrap; }
.brand-mark { position: relative; width: 20px; height: 20px; border: 2px solid var(--accent); transform: rotate(45deg); }
.brand-mark::after { position: absolute; content: ""; width: 6px; height: 6px; background: var(--accent); top: 5px; left: 5px; }
.net-state { color: var(--dim); font-size: .875rem; display: flex; align-items: center; gap: .45rem; }
.net-state::before { content: ""; width: .48rem; height: .48rem; border-radius: 50%; background: #d4a46d; flex: 0 0 auto; }
.net-state.online::before { background: var(--accent); }
.home-frame, .room-frame { position: relative; isolation: isolate; border: 1px solid var(--edge); border-radius: 15px; background: var(--panel); overflow: hidden; box-shadow: 0 16px 50px #0006; }
.home-frame { display: grid; place-items: center; min-height: clamp(460px, 76vh, 638px); padding: 26px 15px; background: #060b11; }
#lobby-art, .home-shade { position: absolute; width: 100%; height: 100%; inset: 0; z-index: -1; }
.home-shade { background: radial-gradient(ellipse at center, #09111be8 23%, #060b11b0 62%, #04070ae8 100%); }
.home-content {
  width: min(100%, 630px); padding: clamp(24px, 5vw, 46px); text-align: center;
  border: 1px solid #203b51; border-radius: 17px; background: linear-gradient(180deg, #121d2cf4, #0b1017fa);
  box-shadow: 0 24px 65px #0009, inset 0 1px #dce5ef0c;
}
.section-label { color: var(--accent); font-size: .875rem; letter-spacing: .085em; font-weight: 720; margin: 0 0 .65rem; }
.home-content h1 {
  margin: 0; font-size: clamp(1.7rem, 5vw, 3.15rem); letter-spacing: .12em; font-weight: 820; line-height: 1.12;
  color: #8dd8f6; background: linear-gradient(92deg, #22d3ee, #a78bfa 56%, #fb923c);
  background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.home-lead { margin: .7rem 0 1.3rem; line-height: 1.55; font-size: .97rem; color: var(--dim); }
.join-form { display: grid; width: min(100%, 340px); margin: 0 auto; gap: .55rem; text-align: left; }
.code-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; margin-top: .15rem; }
.text-actions { display: flex; gap: 1.15rem; margin-top: .55rem; }
.home-content .text-actions { justify-content: center; margin-top: .82rem; }

.room-frame { max-width: 894px; margin: clamp(4px, 4vh, 34px) auto 0; background: linear-gradient(180deg, #131d2a, #0a1018); }
.room-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.45rem clamp(1rem, 4vw, 2rem) 1.18rem; border-bottom: 1px solid var(--edge); }
.room-header h1 { margin: 0; font-size: clamp(1.45rem, 3.3vw, 2.2rem); color: var(--light); line-height: 1.14; }
.room-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(224px, 1fr); }
.roster-wrap, .invite-rail { padding: 1.25rem clamp(1rem, 4vw, 2rem) 1.4rem; }
.invite-rail { background: #0b1721a9; border-left: 1px solid var(--edge); display: flex; flex-direction: column; gap: .9rem; }
.invite-code { display:block; color: var(--light); width: max-content; font: 780 clamp(1.75rem, 3.3vw, 2.7rem)/1.17 ui-monospace, Menlo, monospace; letter-spacing: .11em; }
.invite-link { font-size: .8125rem; }
.room-directives { border-top: 1px solid var(--edge); padding-top: 1rem; }
.room-directives button { width: 100%; }
.small-note { color: var(--dim); margin: .7rem 0 0; line-height: 1.5; font-size: .875rem; }
.section-heading { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-heading h2 { font-size: 1.12rem; margin: 0; color: var(--light); }
.section-heading span { color: var(--dim); font-size: .875rem; }
.roster { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .66rem; }
.roster li { display:flex; align-items:center; gap:.5rem; min-height: 51px; padding:.5rem .63rem; background:#121e2d; border:1px solid #293e50; border-radius:7px; min-width: 0; }
.roster li.empty { color: var(--dim); border-color:#243243; background: #0d1520; }
.roster li.self { border-color:#2a6880; background:#102431; }
.seat-number { display: none; }
.player-details { display:flex; flex:1; flex-wrap:wrap; gap:.22rem .42rem; min-width:0; }
.seat-name { width:100%; color:var(--light); font-weight:650; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.seat-state { color:var(--dim); font-size:.8125rem; }
.seat-state.ready { color: var(--accent); }
.roster-tools { display: flex; align-items: center; gap: .6rem; }
.roster-tools .link-button { font-size: .8125rem; }
.seat-drop { margin-left: auto; padding: .1rem .42rem; border: 1px solid #35485a; border-radius: 5px; background: #16232f; color: #9fb6c7; font: inherit; font-size: .75rem; cursor: pointer; }
.seat-drop:hover { border-color: #c96f5f; color: #ffd0c7; }
.empty .seat-name { color:var(--dim); font-size:.875rem; font-weight:500; }
.dialog-close { float: right; }
dialog { color: var(--text); background: #111f2c; border:1px solid #648293; border-radius: 12px; width: min(480px, calc(100% - 28px)); padding: 1.45rem; }
dialog::backdrop { background:#03070cc9; }
dialog h2 { color: var(--light); margin:.35rem 0 .8rem; }
dialog p { line-height:1.6; }
.controls-list { margin: 1rem 0 0; }
.controls-list div { display:flex; align-items:center; justify-content:space-between; gap:.5rem; padding:.65rem 0; border-top:1px solid var(--edge); }
.controls-list dt, .controls-list dd { margin:0; font-size:.9rem; }
kbd, .keycap { display:inline-grid; place-items:center; padding:.12rem .34rem; border:1px solid #728b9b; border-radius:4px; color:#f4f9fb; background:#142334; font:650 .77rem/1.18 ui-monospace, Menlo, monospace; min-width:1.35rem; min-height:1.27rem; }
.toast { position: fixed; z-index: 30; left:50%; bottom:26px; transform:translateX(-50%); width: max-content; max-width:calc(100% - 30px); background:#193046; border:1px solid #688899; color:var(--light); padding:.78rem 1rem; border-radius:7px; box-shadow:0 8px 35px #0008; }
body.in-match { overflow:hidden; }
.match { position:fixed; inset:0; display:grid; grid-template-rows:auto minmax(0, 1fr); overflow:hidden; background:#05080c; user-select:none; }
#arena { grid-row:2; grid-column:1; display:block; width:100%; height:100%; min-height:0; cursor:none; }
.match-controls { position:absolute; bottom:14px; right:18px; display:flex; gap:.55rem; align-items:center; }
.combat-hud {
  grid-row:1; grid-column:1; justify-self:center; margin:12px 0 8px; pointer-events:none;
  width:min(1100px, calc(100% - 28px)); display:grid; grid-template-columns:minmax(150px, 1fr) auto minmax(236px, 1fr);
  align-items:center; gap:.85rem; min-height:64px; padding:.43rem .8rem; border:1px solid #25394a;
  border-radius:11px; background:linear-gradient(180deg,#101923f7,#080d15ed);
  box-shadow:0 7px 20px #0003; font-variant-numeric:tabular-nums;
}
.survival { grid-column:2; grid-row:1; display:grid; justify-items:center; gap:.22rem; color:var(--dim); white-space:nowrap; }
.survival strong { color:var(--light); font-size:1.12rem; font-weight:780; }
.survival span { font-size:.8125rem; }
.survival.alert span { color:var(--danger); }
.spectator-label { position:absolute; z-index:1; bottom:14px; left:18px; border:1px solid #33485b; padding:.54rem .7rem; border-radius:7px; background:#0a131ef2; }
.vitals { grid-column:1; grid-row:1; display:grid; grid-template-columns:auto minmax(52px,132px); justify-content:start; align-items:center; gap:.18rem .55rem; color:#c4ebf3; }
.vitals > b { grid-row:span 2; font-weight:780; font-size:1.65rem; line-height:1.03; min-width:2ch; }
.hp-bars { align-self:center; display:grid; gap:3px; }
.hp-bars > span { display:block; width:100%; height:6px; background:#273648; border-radius:3px; overflow:hidden; }
.hp-bars .shield-rail { height:3px; }
.hp-bars > span > span { display:block; height:100%; width:0; background:var(--accent); }
.shield-rail span { background:#8ebeff !important; }
.vital-label { font-size:.78rem; color:#b1c6d4; }
.vital-label output { color:#b4d3ff; }
.loadout { grid-column:3; grid-row:1; justify-self:end; width:min(100%, 300px); }
.utility { display:flex; justify-content:end; gap:.64rem; margin-top:.25rem; color:var(--dim); font-size:.76rem; }
.utility > span { white-space:nowrap; }
.utility .keycap { min-width:1rem; min-height:.95rem; padding:.04rem .19rem; font-size:.68rem; border-color:#40556b; }
.utility strong { color: var(--light); }
.weapon-slots { display:grid; grid-template-columns:1fr; gap:.4rem; }
.weapon-slot { min-width:0; display:flex; align-items:center; gap:.4rem; padding:.26rem .38rem; min-height:31px; border-radius:6px; border:1px solid #263a4d; background:#121e2be8; color:#9cb3c5; }
.weapon-slot.active { border-color:#2b8299; background:#112938; color:#f0f8fb; }
.weapon-slot > span { min-width:0; display:flex; align-items:baseline; gap:.28rem; }
.slot-name { font-size:.83rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.slot-ammo { font:650 .72rem/1.25 ui-monospace, Menlo, monospace; white-space:nowrap; color:#a5bbcd; }
.tab-hint { position:absolute; bottom:16px; left:50%; transform:translateX(-50%); font-size:.79rem; color:#b7c6d7; white-space:nowrap; pointer-events:none; background:#09111bd9; border:1px solid #273b4e; padding:.24rem .55rem; border-radius:999px; }
.pick-prompt { position:absolute; min-width:132px; white-space:nowrap; display:flex; align-items:center; gap:.55rem; pointer-events:none; transform:translate(-50%,-100%); background:#102939fa; border:1px solid #88dde4; color:var(--light); padding:.44rem .64rem; border-radius:6px; box-shadow:0 3px 12px #0008; }
.pick-prompt strong, .pick-prompt small { display:block; }
.pick-prompt strong { font-size:.9rem; }
.pick-prompt small { color:#bee2e9; font-size:.75rem; }
.pick-prompt small:empty { display:none; }
.combat-progress, .combat-note { position:absolute; left:50%; transform:translateX(-50%); top:65%; background:#102130ea; border:1px solid #426577; border-radius:6px; padding:.5rem .75rem; width:min(320px,70vw); font-size:.9rem; pointer-events:none; text-align:center; }
.combat-progress progress { width:100%; height:7px; display:block; margin-top:.4rem; accent-color:var(--accent); }
.combat-note { top:71%; margin:0; color:#ffd0ad; }
.map-layer, .end-layer, .connection-layer { position:absolute; z-index:10; inset:0; display:grid; align-items:center; justify-items:center; background:#03080ccb; }
.map-layer { pointer-events:none; }
.map-card, .end-card, .connection-layer section { background:#0d1c2a; border:1px solid #6f8797; box-shadow:0 18px 60px #000b; border-radius:11px; }
.map-card { width:min(660px, 84vw); padding:1rem; }
#map { width:100%; height:min(48vh, 410px); display:block; background:#08131e; border:1px solid #3d5568; border-radius:6px; }
.death-card { position:absolute; z-index:5; left:22px; top:30%; width:min(280px, calc(100% - 44px)); padding:1rem; background:#111e2cf2; color:var(--text); border:1px solid #5c7385; border-radius:8px; }
.death-card h2, .end-card h2, .connection-layer h2 { color:var(--light); margin:0 0 .65rem; line-height:1.14; }
.death-by { margin:0 0 .2rem; font-size:.86rem; color:#ffd0c7; }
.report-label { margin:.9rem 0 -.35rem; font-size:.78rem; color:#93a9bd; }
.sound-state { margin:.6rem 0 .5rem; font-size:.78rem; line-height:1.5; color:#93a9bd; }
.sound-state b { color:#cfe2f2; font-weight:600; }
.replay { display:block; width:100%; height:auto; margin:.5rem 0 .3rem; border:1px solid #33485b; border-radius:6px; background:#0a131e; }
.kill-feed { position:absolute; top:88px; right:16px; z-index:4; margin:0; padding:0; list-style:none; display:grid; gap:.22rem; justify-items:end; pointer-events:none; }
.kill-feed li { font-size:.78rem; color:#dfeaf3; background:#0b1521d9; border:1px solid #2c4557; border-radius:5px; padding:.2rem .45rem; white-space:nowrap; }
.kill-feed li:first-child { border-color:#5c8fa8; color:#fff; }
.death-card ul, .end-card ul { margin:.8rem 0; padding-left:1.15rem; line-height:1.5; font-size:.9rem; }
.spectator-tools { position:absolute; bottom:58px; left:18px; display:flex; gap:.45rem; }
.end-card, .connection-layer section { width:min(460px,calc(100% - 28px)); padding:1.5rem; }
.end-card h2 { font-size:clamp(1.8rem, 4vw, 2.8rem); overflow-wrap:anywhere; }
.end-card ul:empty, .death-card ul:empty { display:none; }
.end-actions { display:flex; gap:.6rem; flex-wrap:wrap; margin-top:1.1rem; }
.connection-layer { z-index:12; }
@media (max-width: 720px) {
  .masthead { min-height:54px; }
  .brand { font-size:.875rem; }
  .home-frame { min-height:410px; }
  .home-content { padding:1.65rem 1.15rem; }
  .room-header { align-items:center; }
  .room-body { grid-template-columns:1fr; }
  .invite-rail { border-left:0; border-top:1px solid var(--edge); }
  .combat-hud { grid-template-columns:1fr minmax(0, 1.7fr); width:calc(100% - 16px); margin-top:8px; gap:.35rem .55rem; padding:.39rem .48rem; }
  .survival { grid-column:1/-1; display:flex; justify-content:center; gap:.6rem; }
  .vitals { grid-row:2; grid-template-columns:auto minmax(35px,96px); gap:.15rem .35rem; }
  .vitals > b { font-size:1.4rem; }
  .loadout { grid-column:2; grid-row:2; }
  .weapon-slot > span { display:grid; gap:.08rem; }
  .match-controls { right:8px; bottom:10px; }
}
@media (max-width: 430px) {
  .brand-mark { width:16px; height:16px; }
  .brand-mark::after { width:4px; height:4px; top:4px; left:4px; }
  .net-state { font-size:.76rem; }
  .roster { grid-template-columns: 1fr; }
  .tab-hint { bottom:52px; }
}
#arena.observer { cursor: default; }
