* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}
body {
    overflow: hidden;
    background: #090d14;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
}
#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    image-rendering: pixelated;
}

/* === SCREEN OVERLAYS === */
#underwater-overlay {
    position: fixed; inset: 0;
    background: rgba(16, 76, 178, 0.45);
    backdrop-filter: blur(1.5px);
    pointer-events: none; z-index: 8; display: none;
}
#damage-vignette {
    position: fixed; inset: 0;
    background: radial-gradient(circle, transparent 48%, rgba(220, 20, 20, 0.68) 100%);
    pointer-events: none; z-index: 9; opacity: 0;
    transition: opacity 0.16s ease-out;
}
#supersonic-vignette {
    position: fixed; inset: 0;
    box-shadow: inset 0 0 65px rgba(255, 255, 255, 0.45);
    pointer-events: none; z-index: 9; opacity: 0;
    transition: opacity 0.14s ease-out;
}
#spawn-shield-vignette {
    position: fixed; inset: 0;
    box-shadow: inset 0 0 85px rgba(250, 204, 21, 0.55), inset 0 0 30px rgba(56, 189, 248, 0.45);
    pointer-events: none; z-index: 9; opacity: 0;
    transition: opacity 0.15s ease-out;
}
#spawn-shield-hud {
    position: fixed; top: calc(50% - 76px); left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.88);
    border: 1.5px solid #facc15;
    border-radius: 6px; padding: 5px 12px;
    z-index: 15; pointer-events: none; display: none;
    text-align: center; box-shadow: 0 0 16px rgba(250, 204, 21, 0.4);
}
#spawn-shield-text {
    font-size: 12px; font-weight: 800; color: #fef08a;
    text-shadow: 1px 1px 0 #000; margin-bottom: 4px;
}
#spawn-shield-bar-bg {
    width: 210px; height: 5px; background: #1e293b;
    border-radius: 3px; overflow: hidden; margin: 0 auto;
}
#spawn-shield-bar-fill {
    width: 100%; height: 100%;
    background: linear-gradient(90deg, #38bdf8, #facc15);
}

/* === AWP 8X MIL-DOT SNIPER SCOPE === */
#sniper-scope {
    position: fixed; inset: 0;
    pointer-events: none; z-index: 11; display: none;
    background: radial-gradient(circle at center, transparent 33%, rgba(0,0,0,0.97) 35.5%);
}
#sniper-scope::before, #sniper-scope::after {
    content: ''; position: absolute; background: rgba(0, 0, 0, 0.88);
}
#sniper-scope::before { top: 50%; left: 0; width: 100%; height: 1.5px; transform: translateY(-50%); }
#sniper-scope::after  { left: 50%; top: 0; width: 1.5px; height: 100%; transform: translateX(-50%); }
.scope-ring {
    position: absolute; top: 50%; left: 50%; width: 67vmin; height: 67vmin;
    border: 3px solid #111; border-radius: 50%; transform: translate(-50%, -50%);
    box-shadow: inset 0 0 24px rgba(0,0,0,0.8);
}
.scope-dot {
    position: absolute; top: 50%; left: 50%; width: 5px; height: 5px;
    background: #ff2222; border-radius: 50%; transform: translate(-50%, -50%);
    box-shadow: 0 0 6px #ff2222;
}
.mil-dot {
    position: absolute; left: 50%; width: 8px; height: 2px;
    background: #000; transform: translateX(-50%);
}
.mil-dot-h {
    position: absolute; top: 50%; width: 2px; height: 8px;
    background: #000; transform: translateY(-50%);
}
.scope-range-label {
    position: absolute; top: calc(50% + 14vmin); left: calc(50% + 4vmin);
    font-family: 'Courier New', monospace; font-size: 11px; color: rgba(255, 60, 60, 0.85);
    font-weight: bold; text-shadow: 1px 1px 0 #000;
}

/* === DYNAMIC 4-LINE FPS CROSSHAIR & HITMARKER === */
#crosshair-wrap {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none; z-index: 12; display: none;
}
.ch-line {
    position: absolute; background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 0 2px #000;
}
#ch-top    { width: 2px; height: 10px; left: -1px; bottom: 5px; }
#ch-bottom { width: 2px; height: 10px; left: -1px; top: 5px; }
#ch-left   { width: 10px; height: 2px; top: -1px; right: 5px; }
#ch-right  { width: 10px; height: 2px; top: -1px; left: 5px; }
#ch-dot    { width: 2px; height: 2px; left: -1px; top: -1px; background: #4ade80; }

#hitmarker {
    position: fixed; top: 50%; left: 50%; width: 28px; height: 28px;
    transform: translate(-50%, -50%); pointer-events: none; z-index: 13;
    opacity: 0; transition: opacity 0.11s ease-out;
}
#hitmarker::before, #hitmarker::after {
    content: ''; position: absolute; top: 50%; left: 0; width: 28px; height: 2.5px;
    background: currentColor; box-shadow: 0 0 4px #000;
}
#hitmarker::before { transform: translateY(-50%) rotate(45deg); }
#hitmarker::after  { transform: translateY(-50%) rotate(-45deg); }

/* === FLOATING DAMAGE NUMBERS === */
#damage-popups {
    position: fixed; inset: 0; pointer-events: none; z-index: 14; overflow: hidden;
}
.dmg-float {
    position: absolute; font-weight: 900; font-family: 'Courier New', monospace;
    font-size: 16px; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
    transform: translate(-50%, -50%);
    animation: dmgRise 0.75s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.dmg-float.hs {
    font-size: 20px; color: #facc15;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.95), 2px 2px 0 #000;
}
@keyframes dmgRise {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -140%) scale(0.9); }
}

#action-progress-wrap {
    position: fixed; top: calc(50% + 28px); left: 50%; transform: translateX(-50%);
    width: 110px; height: 8px; background: rgba(0,0,0,0.78); border: 1px solid #fff;
    display: none; z-index: 13; pointer-events: none; border-radius: 2px;
}
#action-progress-fill { width: 0%; height: 100%; background: #4ade80; }
#action-progress-label {
    position: fixed; top: calc(50% + 39px); left: 50%; transform: translateX(-50%);
    font-size: 11px; font-weight: bold; color: #facc15; text-shadow: 1px 1px 0 #000;
    display: none; z-index: 13; pointer-events: none;
}

/* === KILL STREAK BANNER === */
#streak-banner {
    position: fixed; top: 17%; left: 50%; transform: translate(-50%, -50%) scale(0.8);
    font-size: 28px; font-weight: 900; letter-spacing: 2px;
    color: #ffdd33; text-shadow: 0 0 14px rgba(255, 80, 0, 0.95), 3px 3px 0 #000;
    pointer-events: none; z-index: 25; opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
}

/* === TOP LEFT: MINI INFO & F3 DEBUG === */
#mini-info {
    position: fixed; top: 10px; left: 10px;
    background: rgba(10, 14, 20, 0.82); border-left: 3px solid #4ade80;
    padding: 7px 12px; font-size: 12.5px; font-weight: 600;
    font-family: 'Courier New', monospace;
    z-index: 25; border-radius: 4px; text-shadow: 1px 1px 0 #000;
    pointer-events: none; box-shadow: 0 2px 10px rgba(0,0,0,0.45);
}
#fps-badge {
    color: #4ade80;
    font-weight: 900;
}
#debug-overlay {
    position: fixed; top: 58px; left: 10px;
    background: rgba(0, 0, 0, 0.76); border-left: 3px solid #38bdf8;
    padding: 8px 12px; font-size: 11.5px; font-family: 'Courier New', monospace;
    line-height: 1.48; z-index: 20; display: none; pointer-events: none;
    white-space: pre-line; text-shadow: 1px 1px 0 #000; border-radius: 4px;
}

/* === TOP RIGHT: RADAR MINIMAP, LEADERBOARD & KILL FEED === */
#top-right-hud {
    position: fixed; top: 10px; right: 10px;
    display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
    z-index: 16; pointer-events: none;
}
#minimap-wrap {
    background: rgba(10, 14, 20, 0.85); border: 2px solid #4a5568;
    padding: 4px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.65);
    display: flex; flex-direction: column; align-items: center;
}
#minimap-canvas {
    width: 140px; height: 140px; image-rendering: pixelated;
    border: 1px solid #222; border-radius: 3px;
}
#minimap-label {
    font-size: 10px; color: #cbd5e0; margin-top: 3px; font-weight: bold;
}
#ffa-leaderboard {
    background: rgba(10, 14, 20, 0.84); border: 1.5px solid #334155;
    border-radius: 6px; padding: 6px 9px; width: 225px;
    font-size: 11.5px; box-shadow: 0 4px 12px rgba(0,0,0,0.55);
}
.lb-title {
    font-weight: 800; color: #facc15; font-size: 11px;
    border-bottom: 1px solid #334155; padding-bottom: 3px; margin-bottom: 4px;
    display: flex; justify-content: space-between;
}
.lb-row {
    display: flex; justify-content: space-between; padding: 2px 3px;
    border-radius: 3px; color: #e2e8f0;
}
.lb-row.me {
    background: rgba(74, 222, 128, 0.22); color: #4ade80; font-weight: bold;
}
#kill-feed {
    display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
    width: 330px;
}
.kf-item {
    background: rgba(12, 16, 24, 0.86); border-right: 3px solid #ef4444;
    padding: 4px 9px; font-size: 12px; border-radius: 3px;
    text-shadow: 1px 1px 0 #000; animation: kfIn 0.2s ease-out;
}
.kf-item.hs { border-right-color: #facc15; color: #fef08a; }
.kf-item.me-kill { border-right-color: #4ade80; }
@keyframes kfIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }

/* === TAB SCOREBOARD MODAL === */
#scoreboard-modal {
    position: fixed; inset: 0; background: rgba(6, 10, 18, 0.72);
    backdrop-filter: blur(3px); display: none;
    align-items: center; justify-content: center; z-index: 45; pointer-events: none;
}
.sb-card {
    background: rgba(15, 23, 42, 0.96); border: 2px solid #facc15;
    border-radius: 8px; padding: 16px 20px; width: 540px; max-width: 94vw;
    box-shadow: 0 12px 36px rgba(0,0,0,0.85);
}
.sb-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.sb-table th {
    text-align: left; color: #94a3b8; border-bottom: 1px solid #334155;
    padding: 6px 8px; font-size: 11.5px;
}
.sb-table td { padding: 6px 8px; border-bottom: 1px solid rgba(51, 65, 85, 0.45); }
.sb-table tr.me-row { background: rgba(74, 222, 128, 0.18); color: #4ade80; font-weight: bold; }

/* === BOTTOM LEFT: HP & ARMOR === */
#hud-vitals {
    position: fixed; bottom: 16px; left: 16px;
    background: rgba(12, 16, 24, 0.82); border: 2px solid #334155;
    padding: 10px 14px; border-radius: 8px; z-index: 15;
    width: 235px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,0.55);
}
.vital-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.vital-row:last-child { margin-bottom: 0; }
.vital-icon { font-size: 15px; width: 20px; text-align: center; }
.vital-bar-bg {
    flex: 1; height: 12px; background: #1e293b; border-radius: 3px;
    overflow: hidden; border: 1px solid #475569;
}
.vital-bar-fill { height: 100%; transition: width 0.15s ease; }
#hp-fill { background: linear-gradient(90deg, #dc2626, #22c55e); width: 100%; }
#armor-fill { background: linear-gradient(90deg, #0284c7, #38bdf8); width: 100%; }
.vital-num { font-size: 13px; font-weight: bold; width: 32px; text-align: right; font-family: monospace; }

/* === BOTTOM CENTER: 9-SLOT HOTBAR === */
#hud-bottom {
    position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; z-index: 15;
    pointer-events: none;
}
#item-toast {
    font-size: 13px; font-weight: bold; color: #fff;
    background: rgba(0, 0, 0, 0.72); padding: 3px 12px; border-radius: 4px;
    margin-bottom: 6px; opacity: 0; transition: opacity 0.25s;
    text-shadow: 1px 1px 0 #000;
}
#hotbar {
    display: flex; background: rgba(15, 20, 28, 0.88);
    border: 2px solid #475569; border-radius: 6px; padding: 3px; gap: 3px;
    pointer-events: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.7);
}
.hotbar-slot {
    width: 50px; height: 50px; border: 2px solid #334155;
    background: rgba(51, 65, 85, 0.45); border-radius: 4px;
    position: relative; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.08s;
}
.hotbar-slot.gun-slot { border-color: #475569; background: rgba(30, 58, 138, 0.38); }
.hotbar-slot.active {
    border-color: #facc15; background: rgba(250, 204, 21, 0.24);
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.55); transform: translateY(-2px);
}
.hotbar-slot canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.slot-num {
    position: absolute; top: 1px; left: 4px; font-size: 10px;
    font-weight: bold; color: #e2e8f0; text-shadow: 1px 1px 0 #000;
}
.slot-badge {
    position: absolute; bottom: 1px; right: 3px; font-size: 10px;
    font-weight: bold; color: #facc15; text-shadow: 1px 1px 0 #000;
}

/* === BOTTOM RIGHT: WEAPON & BALLISTICS HUD === */
#hud-weapon {
    position: fixed; bottom: 16px; right: 16px;
    background: rgba(12, 16, 24, 0.82); border: 2px solid #334155;
    padding: 10px 14px; border-radius: 8px; z-index: 15;
    min-width: 235px; text-align: right; pointer-events: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.55);
}
.weapon-header-row {
    display: flex; justify-content: flex-end; align-items: center; gap: 6px;
}
#weapon-name { font-size: 13px; font-weight: bold; color: #38bdf8; letter-spacing: 0.5px; }
#fire-mode-badge {
    font-size: 10px; font-weight: 800; background: #1e293b; color: #facc15;
    border: 1px solid #475569; padding: 1px 5px; border-radius: 3px;
}
#ammo-display {
    font-size: 28px; font-weight: 900; font-family: 'Courier New', monospace;
    color: #fff; line-height: 1.1; margin: 2px 0;
}
#ammo-reserve { font-size: 15px; color: #94a3b8; }
#combat-sub { font-size: 11.5px; color: #cbd5e0; margin-top: 4px; }

/* === TOAST MESSAGE === */
#toast-msg {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.94); border: 2px solid #22c55e;
    color: #fff; padding: 7px 16px; font-size: 13px; font-weight: bold;
    z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.25s;
    border-radius: 6px; text-shadow: 1px 1px 0 #000;
}

/* === BUTTONS & INPUTS === */
.btn {
    background: #334155; color: #fff; border: 2px solid #0f172a;
    box-shadow: inset 1px 1px 0 #64748b, inset -2px -2px 0 #1e293b;
    padding: 9px 14px; font-family: inherit; font-size: 13.5px; font-weight: bold;
    cursor: pointer; border-radius: 5px; transition: background 0.12s;
}
.btn:hover { background: #475569; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #16a34a; box-shadow: inset 1px 1px 0 #4ade80, inset -2px -2px 0 #14532d; }
.btn.primary:hover { background: #22c55e; }
.btn.accent { background: #7c3aed; box-shadow: inset 1px 1px 0 #a78bfa, inset -2px -2px 0 #4c1d95; }
.mc-input {
    background: #0f172a; color: #fff; border: 2px solid #475569;
    padding: 7px 10px; border-radius: 4px; font-family: inherit; font-size: 13px; width: 100%;
}

/* === START / PAUSE MENU === */
#pause-menu {
    position: fixed; inset: 0; background: rgba(8, 12, 20, 0.85);
    backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center;
    z-index: 50; padding: 14px; overflow-y: auto;
}
.menu-card {
    background: rgba(15, 23, 42, 0.96); border: 3px solid #334155;
    border-radius: 10px; padding: 22px 26px; max-width: 780px; width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.85);
}
.game-title {
    font-size: 30px; font-weight: 900; text-align: center;
    background: linear-gradient(90deg, #4ade80, #38bdf8, #facc15);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: 1.5px;
}
.game-sub {
    text-align: center; color: #94a3b8; font-size: 12.5px; margin: 4px 0 16px;
}
.menu-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px;
}
.menu-full { grid-column: 1 / -1; }
.setting-row {
    background: rgba(30, 41, 59, 0.65); border: 1px solid #334155;
    padding: 8px 10px; border-radius: 5px; display: flex; align-items: center; gap: 8px;
    font-size: 12.5px;
}
.controls-box {
    background: rgba(2, 6, 23, 0.68); border: 1px solid #334155;
    border-radius: 6px; padding: 10px 14px; font-size: 11.5px; line-height: 1.55;
    display: grid; grid-template-columns: 1fr 1fr; gap: 3px 16px; color: #cbd5e0;
}
.controls-box b { color: #facc15; }

/* === LAN MULTIPLAYER PANEL === */
.lan-panel {
    background: rgba(15, 23, 42, 0.92);
    border: 1.5px solid #38bdf8;
    border-radius: 6px;
    padding: 9px 11px;
}
.lan-header {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12.5px; color: #38bdf8; margin-bottom: 7px; flex-wrap: wrap; gap: 6px;
}
.lan-controls {
    display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.lan-rooms-list {
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px;
}
.lan-room-chip {
    background: #1e293b; border: 1px solid #475569; border-radius: 4px;
    padding: 4px 8px; font-size: 11.5px; color: #e2e8f0; cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
.lan-room-chip:hover { border-color: #4ade80; background: #334155; }

/* === DEATH / RESPAWN OVERLAY === */
#death-screen {
    position: fixed; inset: 0; background: rgba(120, 10, 10, 0.78);
    backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center;
    z-index: 70;
}
.death-card {
    background: rgba(15, 23, 42, 0.95); border: 3px solid #ef4444;
    padding: 28px 36px; border-radius: 10px; text-align: center; max-width: 420px; width: 92%;
}
.death-title { font-size: 30px; font-weight: 900; color: #ef4444; margin-bottom: 10px; }
.death-stats {
    background: rgba(30, 41, 59, 0.8); padding: 12px; border-radius: 6px;
    margin: 14px 0 18px; font-size: 14px; line-height: 1.8;
}

/* === INVENTORY MODAL (E) === */
#inventory-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.78);
    display: none; align-items: center; justify-content: center; z-index: 60;
}
.inv-panel {
    background: #1e293b; border: 3px solid #475569; border-radius: 8px;
    padding: 16px; width: 620px; max-width: 96vw; max-height: 88vh;
    display: flex; flex-direction: column; gap: 10px;
}
.inv-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 6px; overflow-y: auto; max-height: 360px; padding: 8px;
    background: #0f172a; border-radius: 6px; border: 1px solid #334155;
}
.inv-item {
    width: 56px; height: 56px; background: #1e293b; border: 2px solid #334155;
    border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.inv-item:hover { border-color: #facc15; background: #334155; }
.inv-item canvas { width: 38px; height: 38px; image-rendering: pixelated; }

/* === BLOCKBENCH STUDIO MODAL (B) === */
#bb-modal {
    position: fixed; inset: 0; background: rgba(8, 12, 20, 0.9);
    display: none; align-items: center; justify-content: center; z-index: 65; padding: 12px;
}
.bb-panel {
    background: #1e293b; border: 3px solid #475569; border-radius: 8px;
    width: 920px; max-width: 98vw; max-height: 92vh;
    display: flex; flex-direction: column; overflow: hidden;
}
.bb-header {
    background: #0f172a; padding: 10px 16px; display: flex;
    justify-content: space-between; align-items: center; border-bottom: 2px solid #334155;
}
.bb-body {
    display: grid; grid-template-columns: 320px 1fr; gap: 14px; padding: 14px; overflow-y: auto;
}
@media (max-width: 760px) { .bb-body { grid-template-columns: 1fr; } }
.bb-preview-box {
    background: #0f172a; border: 2px solid #334155; border-radius: 6px;
    height: 280px; position: relative; overflow: hidden; cursor: grab;
}
#bb-json-input {
    width: 100%; height: 215px; background: #020617; color: #4ade80;
    border: 2px solid #334155; border-radius: 4px; padding: 8px;
    font-family: 'Courier New', monospace; font-size: 12px; resize: vertical;
}
