* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #151711; color: #f5f1df; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
canvas { display: block; width: 100vw; height: 100vh; cursor: crosshair; }
.hud { position: fixed; z-index: 2; color: #f4f3e8; background: rgba(8,11,9,.52); border: 1px solid rgba(255,255,255,.08); box-shadow: 0 12px 28px rgba(0,0,0,.22); backdrop-filter: blur(6px); }
.hud-left { left: 18px; bottom: 18px; width: min(360px, calc(100vw - 36px)); padding: 0; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
.hud-right { top: 16px; right: 16px; width: 210px; padding: 9px 10px; border-radius: 4px; }
.hud-left, .hud-right, .help { opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity 120ms linear, transform 120ms linear, visibility 120ms linear; pointer-events: none; }
body.tactical-hud-open .hud-left, body.tactical-hud-open .hud-right, body.tactical-hud-open .help { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; }
.brand { font-size: 17px; font-weight: 800; letter-spacing: 0; margin-bottom: 8px; }
.hud-left .brand { display: none; }
#status { display: inline-block; min-height: 0; max-width: 100%; padding: 5px 9px; color: #e8e5d3; background: rgba(8,11,9,.58); border-left: 3px solid #d6f36c; border-radius: 2px; font-size: 11px; line-height: 1.25; text-transform: uppercase; letter-spacing: .04em; }
.bar { width: 210px; margin-top: 7px; }
.bar span, .panel-title { display: block; margin-bottom: 4px; font-size: 9px; color: rgba(244,243,232,.72); text-transform: uppercase; letter-spacing: .12em; }
.bar div { height: 5px; overflow: hidden; background: rgba(255,255,255,.12); border-radius: 999px; }
.bar i { display: block; width: 0%; height: 100%; background: #59c77d; transition: width 120ms linear; }
#reloadBar { background: #e4b044; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(72px, 1fr)); gap: 6px; width: min(360px, calc(100vw - 36px)); margin-top: 8px; font-size: 10px; }
.stats span { min-width: 0; padding: 6px 8px; background: rgba(8,11,9,.55); border: 1px solid rgba(255,255,255,.07); border-radius: 3px; color: rgba(244,243,232,.72); text-transform: uppercase; letter-spacing: .04em; }
.stats b { display: block; margin-bottom: 1px; font-size: 18px; line-height: 1; color: #fffef4; letter-spacing: 0; text-transform: none; }
ol { margin: 7px 0 0; padding-left: 0; list-style: none; font-size: 12px; line-height: 1.45; }
ol li { display: flex; justify-content: space-between; gap: 8px; color: rgba(244,243,232,.8); }
li.player { color: #86e6ff; font-weight: 800; }
.leaderboard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.leaderboard-head .panel-title { margin-bottom: 0; }
.leaderboard-head button { height: 24px; padding: 0 7px; color: #f7f1db; background: rgba(255,255,255,.08); border: 1px solid rgba(245,241,219,.14); border-radius: 3px; font-size: 10px; font-weight: 800; cursor: pointer; }
.hud-right.collapsed { width: auto; }
.hud-right.collapsed ol { display: none; }
.death-cam { position: fixed; z-index: 4; left: 50%; top: 14px; width: min(420px, calc(100vw - 28px)); padding: 10px 12px; transform: translateX(-50%); color: #f4f3e8; background: rgba(8,11,9,.68); border: 1px solid rgba(245,241,219,.14); border-radius: 4px; box-shadow: 0 12px 28px rgba(0,0,0,.24); backdrop-filter: blur(7px); text-align: center; }
.death-cam-kicker { color: #ff745f; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .14em; }
.death-cam-name { margin-top: 1px; overflow: hidden; color: #fffef4; font-size: 18px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.death-cam-stats { display: flex; justify-content: center; gap: 10px; margin-top: 5px; color: rgba(244,243,232,.74); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.death-cam-stats b { color: #fffef4; }
.death-cam-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.death-cam-actions button { min-width: 0; height: 30px; padding: 0 8px; color: #151711; background: #8be0ff; border: 0; border-radius: 4px; font-size: 11px; font-weight: 900; cursor: pointer; }
.death-cam-actions button.secondary { color: #f7f1db; background: rgba(255,255,255,.12); border: 1px solid rgba(245,241,219,.18); }
.challenge-panel { width: min(360px, calc(100vw - 36px)); margin-top: 8px; padding: 7px 9px; background: rgba(8,11,9,.55); border: 1px solid rgba(255,255,255,.07); border-radius: 3px; }
.challenge-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; font-weight: 800; color: #fffef4; }
.challenge-progress { height: 5px; margin-top: 6px; overflow: hidden; background: rgba(255,255,255,.12); border-radius: 999px; }
.challenge-progress i { display: block; width: 0%; height: 100%; background: #8be0ff; transition: width 160ms linear; }
.challenge-meta { margin-top: 4px; color: rgba(244,243,232,.72); font-size: 11px; }
.weapon-hud { right: 18px; bottom: 18px; width: min(260px, calc(100vw - 36px)); padding: 10px 12px; border-radius: 4px; text-align: right; }
.weapon-name { color: rgba(244,243,232,.78); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.weapon-ammo { margin-top: -2px; color: #fffef4; font-size: 44px; line-height: 1; font-weight: 900; letter-spacing: 0; }
.weapon-slots { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.weapon-slots span { padding: 4px 6px; color: rgba(244,243,232,.72); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); border-radius: 3px; font-size: 10px; text-transform: uppercase; }
.weapon-slots span.active { color: #151711; background: #d6f36c; border-color: transparent; }
.weapon-slots span.special { color: #151711; background: #8be0ff; border-color: transparent; }
.weapon-slots span.nuke { color: #151711; background: #ffd166; border-color: transparent; }
.weapon-slots b { margin-right: 5px; }
.weapon-slots small { margin-left: 4px; color: inherit; opacity: .75; }
.leave-button { position: fixed; z-index: 4; top: 14px; left: 14px; height: 30px; padding: 0 14px; color: #f7f1db; background: rgba(8,11,9,.6); border: 1px solid rgba(255,255,255,.14); border-radius: 4px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; }
.leave-button:hover { background: rgba(255,90,70,.28); border-color: rgba(255,90,70,.55); }
.damage-overlay { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: radial-gradient(circle, transparent 42%, rgba(255,75,55,.32)); transition: opacity 90ms linear; }
body.low-health .damage-overlay { box-shadow: inset 0 0 60px rgba(255,75,55,.26); }
.help { left: 50%; bottom: 14px; display: flex; max-width: calc(100vw - 28px); gap: 6px; padding: 5px; transform: translate(-50%, 8px); border-radius: 4px; font-size: 10px; white-space: nowrap; }
body.tactical-hud-open .help { transform: translate(-50%, 0); opacity: .72; }
.help span { padding: 4px 6px; background: rgba(255,255,255,.07); border-radius: 3px; }
.message { position: fixed; z-index: 6; left: 50%; top: 50%; width: min(520px, calc(100vw - 36px)); padding: 18px; transform: translate(-50%, -50%); background: rgba(18,19,16,.94); border: 1px solid rgba(245,241,219,.22); border-radius: 8px; text-align: center; box-shadow: 0 18px 60px rgba(0,0,0,.35); }
.message.match-summary { width: min(780px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; text-align: left; }
.message h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: 0; }
.message p { margin: 0; color: #d8d1b6; line-height: 1.45; }
.winner-hero { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; text-align: left; }
.winner-hero h1 { margin: 0 0 3px; font-size: clamp(28px, 5vw, 46px); line-height: .95; }
.winner-hero p { color: #ffd166; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.trophy { position: relative; flex: 0 0 auto; width: 70px; height: 66px; filter: drop-shadow(0 10px 18px rgba(255,209,102,.24)); }
.trophy::before { content: ""; position: absolute; left: 15px; top: 4px; width: 40px; height: 35px; background: linear-gradient(#ffe08a, #d59b2e); border-radius: 6px 6px 16px 16px; }
.trophy::after { content: ""; position: absolute; left: 23px; top: 39px; width: 24px; height: 10px; background: #d59b2e; box-shadow: 0 10px 0 8px #8a6327; }
.trophy i { position: absolute; inset: 0; }
.trophy i::before, .trophy i::after { content: ""; position: absolute; top: 9px; width: 20px; height: 22px; border: 5px solid #d59b2e; border-radius: 50%; }
.trophy i::before { left: 0; border-right: 0; }
.trophy i::after { right: 0; border-left: 0; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.summary-grid span { min-width: 0; padding: 10px 8px; background: rgba(255,255,255,.07); border-radius: 6px; color: #c6bfa4; font-size: 12px; }
.summary-grid b { display: block; overflow: hidden; color: #fff7df; font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }
.results-board { margin: 12px 0; overflow: hidden; border: 1px solid rgba(245,241,219,.14); border-radius: 6px; background: rgba(255,255,255,.045); }
.results-board-title { padding: 9px 11px; color: #c6bfa4; border-bottom: 1px solid rgba(245,241,219,.12); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.result-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 54px 54px 70px; align-items: center; gap: 8px; padding: 8px 11px; color: rgba(244,243,232,.78); border-bottom: 1px solid rgba(245,241,219,.08); font-size: 12px; }
.result-row:last-child { border-bottom: 0; }
.result-row.winner { color: #fff7df; background: rgba(255,209,102,.12); }
.result-row.player { color: #8be0ff; font-weight: 900; }
.result-rank { color: #ffd166; font-weight: 900; }
.result-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row b { color: #fff7df; }
.summary-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.lobby-return, .summary-actions button { height: 38px; padding: 0 18px; color: #151711; background: #8be0ff; border: 0; border-radius: 6px; font-size: 14px; font-weight: 800; cursor: pointer; }
.summary-actions button.secondary { color: #f7f1db; background: rgba(255,255,255,.12); border: 1px solid rgba(245,241,219,.18); }
.summary-actions button:disabled { cursor: not-allowed; opacity: .58; }
.lobby-return:hover, .summary-actions button:hover:not(:disabled) { background: #a9eaff; }
.hidden { display: none; }
@media (max-width: 720px) { .hud-right { display: none; } .hud-left { left: 12px; bottom: 92px; width: calc(100vw - 24px); } .weapon-hud { left: 12px; right: auto; bottom: 14px; width: calc(100vw - 24px); } .help { display: none; } .stats, .challenge-panel { width: 100%; } .death-cam { top: 48px; } .death-cam-actions { grid-template-columns: repeat(2, 1fr); } }

.touch-controls, .hud-toggle-button { display: none; }
@media (hover: none) and (pointer: coarse) {
  canvas { touch-action: none; }
  .touch-controls, .hud-toggle-button { display: block; }
  /* No physical Tab key to hold, so a tap on hudToggleButton toggles the
     same tactical-hud-open class Tab uses on desktop - HUD stays out of
     the way (and off the joysticks) until asked for. */
  .weapon-hud { opacity: 0; visibility: hidden; transform: none; transition: opacity 120ms linear, visibility 120ms linear; pointer-events: none; top: 14px; right: 12px; bottom: auto; left: auto; width: auto; min-width: 110px; padding: 8px 10px; }
  body.tactical-hud-open .weapon-hud { opacity: 1; visibility: visible; pointer-events: auto; }
  .hud-left { top: 14px; bottom: auto; left: 12px; width: calc(100vw - 24px); }
  .weapon-slots { display: none; }
  .help, .hud-right { display: none !important; }
}
.hud-toggle-button { position: fixed; z-index: 4; top: 14px; right: 14px; width: 30px; height: 30px; padding: 0; color: #f7f1db; background: rgba(8,11,9,.6); border: 1px solid rgba(255,255,255,.14); border-radius: 50%; font-size: 13px; font-weight: 900; font-style: italic; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.touch-stick { position: fixed; z-index: 4; width: 116px; height: 116px; border-radius: 50%; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.16); touch-action: none; }
.touch-move { left: 22px; bottom: 22px; }
.touch-stick-thumb { position: absolute; top: 50%; left: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(255,255,255,.26); }
.touch-buttons { position: fixed; z-index: 4; right: 22px; bottom: 22px; display: grid; grid-template-columns: repeat(2, 44px); gap: 10px; }
.touch-buttons button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2); background: rgba(8,11,9,.6); color: #f7f1db; font-weight: 900; font-size: 13px; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.touch-buttons button:active { background: rgba(139,224,255,.35); }

.lobby { position: fixed; inset: 0; z-index: 5; display: grid; grid-template-rows: auto 1fr; gap: 18px; padding: 24px; overflow: auto; color: #f7f1db; background: #151711; }
.lobby::before { content: ""; position: fixed; inset: 0; z-index: -1; background: linear-gradient(135deg, rgba(139,224,255,.08), transparent 36%), linear-gradient(315deg, rgba(215,255,117,.08), transparent 34%), #151711; }
.lobby-topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.lobby-brand { margin-bottom: 2px; font-size: 24px; }
.lobby-subtitle { color: #c6bfa4; font-size: 13px; }
.lobby-profile, .lobby-actions, .lobby-board { color: #f7f1db; background: rgba(23,25,20,.82); border: 1px solid rgba(245,241,219,.18); box-shadow: 0 10px 30px rgba(0,0,0,.22); backdrop-filter: blur(8px); border-radius: 8px; }
.lobby-profile { width: min(320px, 100%); padding: 12px; }
.profile-name { font-size: 18px; font-weight: 800; color: #fff7df; }
.profile-meta { margin-top: 4px; font-size: 12px; color: #c6bfa4; line-height: 1.35; }
.lobby-main { display: grid; grid-template-columns: minmax(280px, 360px) minmax(440px, 1fr); gap: 18px; align-items: start; }
.lobby-actions { padding: 14px; }
.match-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; font-size: 12px; }
.match-stats span { min-width: 0; padding: 9px; background: rgba(255,255,255,.07); border-radius: 6px; color: #c6bfa4; }
.match-stats b { display: block; color: #fff7df; font-size: 17px; }
.match-stats i { display: block; font-style: normal; }
.mode-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.mode-list button { min-height: 36px; padding: 0 10px; color: #f7f1db; background: rgba(255,255,255,.08); border: 1px solid rgba(245,241,219,.16); border-radius: 6px; font-weight: 800; cursor: pointer; }
.mode-list button.active { color: #151711; background: #d7ff75; border-color: transparent; }
.mode-list button:disabled { cursor: not-allowed; opacity: .54; }
.play-button { width: 100%; height: 46px; color: #151711; background: #8be0ff; border: 0; border-radius: 6px; font-size: 15px; font-weight: 900; cursor: pointer; }
.play-button:hover { background: #a9eaff; }
.lobby-board { max-height: calc(100vh - 132px); overflow: auto; padding: 12px; }
.lobby-board table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lobby-board th, .lobby-board td { padding: 8px 6px; border-bottom: 1px solid rgba(245,241,219,.12); text-align: right; white-space: nowrap; }
.lobby-board th:nth-child(2), .lobby-board td:nth-child(2) { text-align: left; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.lobby-board th { color: #c6bfa4; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; position: sticky; top: 0; background: rgba(23,25,20,.95); }
.empty-board { color: #c6bfa4; text-align: center !important; padding: 18px 8px !important; }
body:not(.lobby-open) .lobby { display: none; }
body.lobby-open canvas, body.lobby-open .game-ui, body.lobby-open #message { visibility: hidden; }
.nickname-modal { z-index: 7; text-align: left; }
.nickname-modal h1 { text-align: center; }
.nickname-modal p { text-align: center; margin-bottom: 14px; }
.nick-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.nick-row input { min-width: 0; height: 38px; padding: 0 10px; color: #fff7df; background: rgba(255,255,255,.08); border: 1px solid rgba(245,241,219,.24); border-radius: 6px; outline: none; }
.nick-row input:focus { border-color: #8be0ff; box-shadow: 0 0 0 3px rgba(139,224,255,.16); }
.nick-row button { height: 38px; padding: 0 12px; color: #151711; background: #8be0ff; border: 0; border-radius: 6px; font-weight: 800; cursor: pointer; }
.nick-row button.secondary { color: #f7f1db; background: rgba(255,255,255,.12); border: 1px solid rgba(245,241,219,.18); }
.form-error { min-height: 18px; margin-top: 9px; color: #ff9f8d; font-size: 12px; text-align: center; }
@media (max-width: 900px) { .lobby-main { grid-template-columns: 1fr; } .lobby-board { max-height: none; } }
@media (max-width: 720px) { .lobby { padding: 14px; } .lobby-topbar { display: grid; } .lobby-profile { width: 100%; } .match-stats, .mode-list, .summary-grid { grid-template-columns: 1fr; } .winner-hero { justify-content: flex-start; } .trophy { width: 54px; transform: scale(.78); transform-origin: left center; } .result-row { grid-template-columns: 34px minmax(0, 1fr) 42px 42px; } .result-row span:last-child { display: none; } .nick-row { grid-template-columns: 1fr; } .nick-row button { width: 100%; } }
