* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', Arial, sans-serif;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    touch-action: none;
}

canvas { display: block; }

#hud {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Crosshair */
#crosshair {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
.cross-h, .cross-v {
    position: absolute;
    background: rgba(255, 255, 255, 0.85);
}
.cross-h {
    width: 18px; height: 2px;
    top: -1px; left: -9px;
}
.cross-v {
    width: 2px; height: 18px;
    top: -9px; left: -1px;
}
.cross-dot {
    position: absolute;
    width: 4px; height: 4px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    top: -2px; left: -2px;
}
.cross-circle {
    position: absolute;
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.7);
    border-radius: 50%;
    top: -10px; left: -10px;
}

/* Hit marker */
#hit-marker {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.05s;
}
#hit-marker.visible { opacity: 1; }
.hit-line {
    position: absolute;
    width: 12px; height: 2px;
    background: #fff;
}
.hit-1 { transform: translate(-14px, -1px) rotate(45deg); }
.hit-2 { transform: translate(2px, -1px) rotate(-45deg); }
.hit-3 { transform: translate(-14px, 11px) rotate(-45deg); }
.hit-4 { transform: translate(2px, 11px) rotate(45deg); }
#hit-marker.headshot .hit-line { background: #ff3333; }

/* Ammo */
#ammo-display {
    position: absolute;
    bottom: 40px; right: 40px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}
#ammo-current { font-size: 44px; }

#weapon-name {
    position: absolute;
    bottom: 78px; right: 40px;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    letter-spacing: 3px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* Score */
#score {
    position: absolute;
    top: 20px; left: 20px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

/* Kill feed */
#kill-feed {
    position: absolute;
    top: 20px; right: 20px;
    text-align: right;
}
.kill-message {
    color: #ff4444;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    margin-bottom: 4px;
    animation: fadeOut 3s forwards;
}
@keyframes fadeOut {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
}

/* Kill feed entries (multiplayer) */
.kill-entry {
    color: rgba(255,255,255,0.9);
    font-size: 12px;
    margin-bottom: 3px;
    padding: 2px 8px;
    background: rgba(0,0,0,0.45);
    border-radius: 3px;
    animation: fadeOut 5s forwards;
    white-space: nowrap;
}
.kill-entry.headshot { color: #ff4444; }
.kill-weapon { color: rgba(255,255,255,0.45); font-size: 10px; }
.kill-name { font-weight: bold; }

/* Kill streak announcement */
#streak-announce {
    position: absolute;
    top: 32%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 42px;
    font-weight: 900;
    color: #ffdd00;
    text-shadow: 0 0 20px rgba(255,221,0,0.6), 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 4px;
    display: none;
    z-index: 14;
    pointer-events: none;
}
.streak-show { animation: streakPop 0.3s ease-out; }
.streak-fade { animation: streakFade 0.5s forwards; }
@keyframes streakPop {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}
@keyframes streakFade {
    0% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Death screen enhancements */
.death-killer { font-size: 22px; color: #ff6666; margin-top: 12px; }
.death-killer strong { color: #ff4444; }
.death-weapon { font-size: 16px; color: rgba(255,255,255,0.5); margin-top: 4px; }

/* Damage popups */
.damage-popup {
    position: absolute;
    color: #ffdd00;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
    pointer-events: none;
    animation: damageFloat 0.8s forwards;
}
.damage-popup.headshot {
    color: #ff3333;
    font-size: 26px;
}
@keyframes damageFloat {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-50px); }
}

/* Minimap */
#minimap {
    position: absolute;
    bottom: 130px; right: 20px;
    width: 160px; height: 160px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    z-index: 11;
    pointer-events: none;
}

/* Reload bar */
#reload-bar {
    position: absolute;
    bottom: 110px; left: 50%;
    transform: translateX(-50%);
    width: 180px; height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    display: none;
}
#reload-progress {
    height: 100%;
    background: white;
    border-radius: 2px;
    width: 0%;
}

/* ===== CS:GO Style Main Menu ===== */
#main-menu {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #0f0f1a 100%);
    color: white;
    z-index: 20;
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
    animation: menuFadeIn 0.4s ease-out;
}
@keyframes menuFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.menu-left {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 24px;
    background: rgba(0,0,0,0.4);
    border-right: 1px solid rgba(255,80,80,0.15);
}
.menu-logo h1 {
    font-size: 36px;
    font-weight: 900;
    letter-spacing: 6px;
    line-height: 1.1;
    color: #ff4444;
    margin: 0;
    text-shadow: 0 0 20px rgba(255,68,68,0.3);
}
.menu-subtitle {
    font-size: 11px;
    letter-spacing: 4px;
    color: rgba(255,255,255,0.35);
    margin-top: 8px;
}
.menu-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.menu-btn {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.menu-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: rgba(255,255,255,0.3);
}
.menu-btn-play {
    background: linear-gradient(135deg, #cc2222, #aa1111);
    color: white;
    border-color: #ff4444;
    font-size: 18px;
}
.menu-btn-play:hover {
    background: linear-gradient(135deg, #dd3333, #cc2222);
    box-shadow: 0 0 20px rgba(255,68,68,0.3);
}
.menu-bottom {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.menu-sens {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}
.menu-sens input[type="range"] {
    flex: 1;
    accent-color: #ff4444;
}
.menu-sens span {
    min-width: 30px;
    color: #ff4444;
}

/* Center panel */
.menu-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
}
.menu-center canvas {
    width: 100% !important;
    height: 100% !important;
}
#menu-mode-select {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
#menu-mode-select h3 {
    font-size: 22px;
    letter-spacing: 6px;
    color: #ff4444;
    margin-bottom: 10px;
}
.mode-btn {
    padding: 16px 50px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 250px;
    text-align: center;
}
.mode-btn:hover {
    background: rgba(255,68,68,0.2);
    border-color: #ff4444;
    box-shadow: 0 0 15px rgba(255,68,68,0.2);
}
.mode-btn-back {
    margin-top: 10px;
    background: transparent;
    color: rgba(255,255,255,0.5);
    border-color: rgba(255,255,255,0.1);
    font-size: 13px;
}

/* Right panel */
.menu-right {
    flex: 0 0 280px;
    padding: 30px 20px;
    background: rgba(0,0,0,0.3);
    border-left: 1px solid rgba(255,80,80,0.15);
    overflow-y: auto;
}
.menu-section {
    margin-bottom: 24px;
}
.menu-section h3 {
    font-size: 13px;
    letter-spacing: 4px;
    color: rgba(255,255,255,0.4);
    margin: 0 0 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 6px;
}
.char-options {
    display: flex;
    gap: 8px;
}
.char-btn {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    transition: all 0.2s;
}
.char-btn:hover { border-color: rgba(255,255,255,0.4); color: white; }
.char-btn.active {
    border-color: #ff4444;
    background: rgba(255,68,68,0.1);
    color: white;
    box-shadow: 0 0 10px rgba(255,68,68,0.15);
}
.char-icon { width: 48px; height: 48px; display: block; margin: 0 auto 4px; pointer-events: none; }

.loadout-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.loadout-btn {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    background: rgba(255,255,255,0.03);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.loadout-btn:hover { border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.06); }
.loadout-btn.active {
    border-color: #ff4444;
    background: rgba(255,68,68,0.1);
    box-shadow: 0 0 8px rgba(255,68,68,0.1);
}
.loadout-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
}
.loadout-detail {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}
.loadout-btn.active .loadout-detail { color: rgba(255,255,255,0.6); }

/* Custom loadout picker */
#custom-loadout {
    margin-top: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}
.weapon-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.weapon-pick {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
}
.weapon-pick input[type="checkbox"] { accent-color: #ff4444; }
#custom-slots {
    margin-top: 8px;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}

/* Pause overlay */
#pause-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    color: white;
}
#pause-overlay h2 { font-size: 42px; letter-spacing: 8px; color: #ff4444; margin-bottom: 30px; }
.pause-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 24px;
    font-size: 14px;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
}
.pause-stat-val { color: white; font-weight: bold; font-size: 18px; display: block; }
.pause-buttons { display: flex; flex-direction: column; gap: 12px; min-width: 220px; }
.pause-btn {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}
.pause-btn:hover {
    background: rgba(255,255,255,0.12);
    color: white;
    border-color: rgba(255,255,255,0.4);
}
.pause-resume {
    background: rgba(255,68,68,0.15);
    border-color: #ff4444;
    color: #ff4444;
}
.pause-resume:hover {
    background: rgba(255,68,68,0.3);
    color: #ff6666;
}
.pause-quit:hover {
    border-color: #ff4444;
    color: #ff4444;
}

/* Match overlays */
#match-waiting, #match-result {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 25;
    color: white;
    gap: 16px;
}
#match-waiting h2, #match-result h2 {
    font-size: 32px;
    letter-spacing: 4px;
    color: #ff4444;
}
#match-cancel-btn, #match-return-btn {
    padding: 12px 30px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    border: 1px solid #ff4444;
    border-radius: 4px;
    background: rgba(255,68,68,0.15);
    color: white;
    cursor: pointer;
    margin-top: 10px;
}
#match-cancel-btn:hover, #match-return-btn:hover {
    background: rgba(255,68,68,0.3);
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Name prompt */
#name-prompt {
    display: flex;
    gap: 8px;
}
#name-input {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(0,0,0,0.4);
    color: white;
    outline: none;
    width: 140px;
}
#name-input:focus { border-color: #ff4444; }
#name-btn {
    padding: 8px 14px;
    font-size: 14px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
#name-btn:hover { background: #ff6666; }

/* Coffee link */
.coffee-link {
    color: rgba(255,255,255,0.35);
    font-size: 12px;
    text-decoration: none;
    transition: color 0.2s;
}
.coffee-link:hover { color: #ffdd44; }

/* Enhanced HP bar */
#hp-bar {
    position: absolute;
    bottom: 40px; left: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
}
#hp-icon {
    color: #44ff44;
    filter: drop-shadow(0 0 4px rgba(68,255,68,0.4));
    transition: color 0.3s, filter 0.3s;
}
#hp-bar-inner {
    width: 280px; height: 28px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
#hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(180deg, #66ff66 0%, #44dd44 50%, #33bb33 100%);
    transition: width 0.3s ease-out, background 0.3s;
}
.hp-tick {
    position: absolute;
    top: 0; bottom: 0;
    width: 1px;
    background: rgba(0,0,0,0.4);
    z-index: 1;
}
#hp-text {
    font-size: 16px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    min-width: 30px;
}
/* Low HP pulse */
#hp-bar.low-hp #hp-bar-inner {
    animation: hpPulse 0.8s ease-in-out infinite;
    border-color: rgba(255,68,68,0.6);
}
#hp-bar.low-hp #hp-icon {
    color: #ff4444;
    filter: drop-shadow(0 0 8px rgba(255,68,68,0.6));
    animation: hpPulse 0.8s ease-in-out infinite;
}
#hp-bar.critical-hp #hp-bar-inner {
    animation: hpPulseFast 0.4s ease-in-out infinite;
    border-color: rgba(255,0,0,0.8);
}
#hp-bar.critical-hp #hp-icon {
    color: #ff0000;
    filter: drop-shadow(0 0 12px rgba(255,0,0,0.8));
    animation: hpPulseFast 0.4s ease-in-out infinite;
}
@keyframes hpPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}
@keyframes hpPulseFast {
    0%, 100% { opacity: 0.6; box-shadow: 0 0 8px rgba(255,0,0,0.3); }
    50% { opacity: 1; box-shadow: 0 0 16px rgba(255,0,0,0.6); }
}

/* Damage direction indicators */
#damage-indicators {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}
.dmg-indicator {
    position: absolute;
    opacity: 0;
    transition: opacity 0.1s;
}
.dmg-indicator.active { opacity: 1; }
.dmg-top {
    top: 0; left: 50%; transform: translateX(-50%);
    width: 200px; height: 40px;
    background: radial-gradient(ellipse at center bottom, rgba(255,0,0,0.6) 0%, transparent 70%);
}
.dmg-right {
    top: 50%; right: 0; transform: translateY(-50%);
    width: 40px; height: 200px;
    background: radial-gradient(ellipse at left center, rgba(255,0,0,0.6) 0%, transparent 70%);
}
.dmg-bottom {
    bottom: 0; left: 50%; transform: translateX(-50%);
    width: 200px; height: 40px;
    background: radial-gradient(ellipse at center top, rgba(255,0,0,0.6) 0%, transparent 70%);
}
.dmg-left {
    top: 50%; left: 0; transform: translateY(-50%);
    width: 40px; height: 200px;
    background: radial-gradient(ellipse at right center, rgba(255,0,0,0.6) 0%, transparent 70%);
}

/* Grenade counter */
#grenade-display {
    position: absolute;
    bottom: 70px; left: 40px;
    color: rgba(255,255,255,0.8);
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}
.grenade-icon {
    font-size: 18px;
}

/* Network info */
#net-info {
    position: absolute;
    top: 44px; left: 20px;
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    letter-spacing: 1px;
}
#connection-status { color: #ff4444; }

/* Damage overlay (red flash) */
#damage-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(255,0,0,0.6) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}

/* Death screen */
#death-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(80, 0, 0, 0.5);
    z-index: 15;
}
#death-screen h2 {
    color: #ff3333;
    font-size: 48px;
    letter-spacing: 6px;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
}
#death-screen p {
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    margin-top: 12px;
}

/* Scoreboard */
#scoreboard {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.85);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 20px 30px;
    display: none;
    min-width: 400px;
    z-index: 16;
}
#scoreboard h3 {
    color: #ff4444;
    font-size: 18px;
    letter-spacing: 4px;
    text-align: center;
    margin-bottom: 14px;
}
#scoreboard table {
    width: 100%;
    border-collapse: collapse;
    color: white;
    font-size: 14px;
}
#scoreboard th {
    color: rgba(255,255,255,0.5);
    font-size: 11px;
    letter-spacing: 2px;
    text-align: left;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
#scoreboard td {
    padding: 6px 10px;
}

/* Scope overlay (sniper ADS) */
#scope-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    z-index: 12;
    pointer-events: none;
}
#scope-overlay::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: min(90vh, 90vw);
    height: min(90vh, 90vw);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 3px solid rgba(0,0,0,0.9);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.95);
}
.scope-ring {
    position: absolute;
    top: 50%; left: 50%;
    width: min(88vh, 88vw);
    height: min(88vh, 88vw);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.6);
}
.scope-cross-h {
    position: absolute;
    top: 50%;
    left: 0; right: 0;
    height: 1px;
    background: rgba(0,0,0,0.7);
    transform: translateY(-0.5px);
}
.scope-cross-v {
    position: absolute;
    left: 50%;
    top: 0; bottom: 0;
    width: 1px;
    background: rgba(0,0,0,0.7);
    transform: translateX(-0.5px);
}
.scope-mil-dot {
    position: absolute;
    left: 50%;
    width: 4px;
    height: 4px;
    background: rgba(0,0,0,0.8);
    border-radius: 50%;
    transform: translateX(-50%);
}
.scope-md-1 { top: calc(50% + 40px); }
.scope-md-2 { top: calc(50% + 80px); }
.scope-md-3 { top: calc(50% + 120px); }

/* Map select button */
#map-select {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    pointer-events: auto;
}
.map-button {
    padding: 6px 18px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.map-button:hover {
    color: white;
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
}

/* Chat */
#chat-box {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 340px;
    z-index: 13;
    pointer-events: none;
}
#chat-messages {
    max-height: 180px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.chat-msg {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    padding: 2px 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
    animation: chatFade 10s forwards;
}
.chat-msg .chat-name { font-weight: bold; }
.chat-msg.system { color: #ffaa44; font-style: italic; }
@keyframes chatFade {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}
#chat-box.active .chat-msg { animation: none; opacity: 1; }
#chat-box.active #chat-messages { max-height: 200px; overflow-y: auto; }
#chat-input-wrap {
    margin-top: 4px;
    pointer-events: auto;
}
#chat-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    background: rgba(0,0,0,0.7);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: white;
    outline: none;
}
#chat-input:focus {
    border-color: rgba(255,255,255,0.4);
}

/* Map vote panel */
#vote-panel {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 12px 20px;
    z-index: 14;
    text-align: center;
    pointer-events: auto;
}
.vote-title {
    color: #ffaa44;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 8px;
}
.vote-options {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.vote-btn {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: bold;
    color: white;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}
.vote-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
}
.vote-btn.voted {
    background: rgba(255,170,68,0.3);
    border-color: #ffaa44;
    color: #ffaa44;
}
.vote-btn span {
    display: inline-block;
    min-width: 16px;
    padding: 1px 5px;
    margin-left: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    font-size: 12px;
}
.vote-timer {
    color: rgba(255,255,255,0.5);
    font-size: 11px;
    margin-top: 6px;
}

/* Settings panel */
#settings-panel {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.9);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 0;
    z-index: 25;
    min-width: 340px;
    pointer-events: auto;
    color: white;
}
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.settings-header h3 {
    color: #ff4444;
    font-size: 16px;
    letter-spacing: 3px;
    margin: 0;
}
#settings-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
}
#settings-close:hover { color: white; }
.settings-body {
    padding: 16px 20px;
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}
.setting-row label {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    min-width: 90px;
}
#sens-slider {
    flex: 1;
    accent-color: #ff4444;
}
#sens-value {
    font-size: 13px;
    color: #ffaa44;
    min-width: 35px;
    text-align: right;
}
.crosshair-options {
    display: flex;
    gap: 6px;
}
.ch-opt {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ch-opt:hover { background: rgba(255,255,255,0.2); }
.ch-opt.active {
    border-color: #ff4444;
    background: rgba(255,68,68,0.2);
}
.settings-body hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 14px 0;
}
.settings-btn {
    padding: 8px 18px;
    font-size: 13px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    margin-bottom: 8px;
}
.settings-btn:hover { background: rgba(255,255,255,0.2); }
#feedback-form {
    margin-top: 8px;
}
#feedback-name, #feedback-text {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: white;
    outline: none;
    margin-bottom: 6px;
    font-family: inherit;
    resize: vertical;
}
#feedback-status {
    font-size: 12px;
    color: #44ff44;
}

/* (Old skin selection removed — replaced by character select in main menu) */

/* Rank display in HUD */
#rank-display {
    position: absolute;
    top: 20px; left: 160px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    color: #cd7f32;
}
.rank-badge {
    display: inline-block;
    width: 18px; height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: middle;
}
.rank-icon {
    display: inline-block;
    width: 20px; height: 20px;
    line-height: 20px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    border: 1.5px solid;
    border-radius: 4px;
    margin-right: 4px;
}

/* (Old start-settings removed — merged into main menu) */

/* Buy Me a Coffee link */
.coffee-link {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 28px;
    font-size: 15px;
    font-weight: bold;
    color: #1a1a1a;
    background: linear-gradient(135deg, #ffdd00 0%, #ff9900 100%);
    border: none;
    border-radius: 8px;
    text-decoration: none;
    letter-spacing: 1px;
    transition: all 0.25s;
    box-shadow: 0 2px 10px rgba(255,153,0,0.3);
    pointer-events: auto;
}
.coffee-link:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 20px rgba(255,153,0,0.5);
    background: linear-gradient(135deg, #ffee33 0%, #ffaa22 100%);
}

/* ============================================
   TOUCH CONTROLS — Roblox Rivals style
   ============================================ */
#touch-controls {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 11;
    pointer-events: none;
    display: none;
}

/* Look zone — FULL SCREEN background (touch anywhere to look) */
#look-zone {
    position: absolute;
    left: 0; top: 0;
    width: 100%; height: 100%;
    pointer-events: auto;
    touch-action: none;
    z-index: 0;
}

/* Joystick zone — bottom-left quadrant */
#joystick-zone {
    position: absolute;
    left: 0; bottom: 0;
    width: 40%; height: 50%;
    pointer-events: auto;
    touch-action: none;
    z-index: 2;
}

#joystick-base {
    position: absolute;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.25);
    display: none;
    transform: translate(-50%, -50%);
    z-index: 3;
}

#joystick-stick {
    position: absolute;
    top: 50%; left: 50%;
    width: 50px; height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px rgba(255,255,255,0.15);
}

/* ---- Shared button styles ---- */
.touch-btn {
    position: absolute;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.8);
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    z-index: 4;
}

.touch-btn:active {
    background: rgba(255,68,68,0.35);
    border-color: #ff4444;
}

/* ---- Right side: FIRE, JUMP, RELOAD ---- */

/* FIRE — large, bottom-right */
.touch-btn-fire {
    width: 80px; height: 80px;
    right: 20px; bottom: 60px;
    font-size: 15px;
    font-weight: 900;
    background: rgba(255,68,68,0.2);
    border: 3px solid rgba(255,68,68,0.5);
    color: rgba(255,100,100,0.9);
}
.touch-btn-fire:active {
    background: rgba(255,68,68,0.5);
    border-color: #ff4444;
    color: white;
}

/* JUMP — left of fire */
.touch-btn-jump {
    right: 115px; bottom: 45px;
    width: 52px; height: 52px;
    font-size: 10px;
}

/* RELOAD — above fire */
.touch-btn-reload {
    right: 30px; bottom: 160px;
    width: 48px; height: 48px;
    font-size: 13px;
}

/* ---- Left side: SPRINT, CROUCH, GRENADE ---- */

/* SPRINT — right of joystick, bottom area */
.touch-btn-sprint {
    left: 170px; bottom: 40px;
    width: 48px; height: 48px;
    font-size: 9px;
}

/* CROUCH — above-right of joystick */
.touch-btn-crouch {
    left: 160px; bottom: 100px;
    width: 48px; height: 48px;
    font-size: 13px;
}

/* GRENADE — above crouch */
.touch-btn-grenade {
    left: 18px; bottom: 220px;
    width: 48px; height: 48px;
    font-size: 13px;
    background: rgba(255,170,0,0.15);
    border-color: rgba(255,170,0,0.35);
}
.touch-btn-grenade:active {
    background: rgba(255,170,0,0.4);
    border-color: #ffaa00;
}

/* Utility buttons — chat, vote (top-left area) */
.touch-btn-util {
    width: 44px; height: 44px;
    font-size: 9px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
}
.touch-btn-util:active {
    background: rgba(100,180,255,0.3);
    border-color: #66aaff;
}
#touch-chat { left: 10px; top: 80px; }
#touch-vote { left: 60px; top: 80px; }
#touch-inspect { left: 110px; top: 80px; }

/* Weapon bar — top-right */
#touch-weapon-bar {
    position: absolute;
    top: 50px; right: 10px;
    display: flex;
    gap: 5px;
    pointer-events: auto;
    z-index: 4;
}

.touch-weapon {
    width: 36px; height: 36px;
    border-radius: 6px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: bold;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.touch-weapon.active {
    border-color: #ff4444;
    background: rgba(255,68,68,0.3);
    color: white;
}

/* ============================================
   LAYOUT EDITOR
   ============================================ */

/* Edit mode — darken look zone, show drag indicators */
#touch-controls.edit-mode #look-zone {
    background: rgba(0,0,0,0.3);
    pointer-events: none;
}

#touch-controls.edit-mode .touch-btn,
#touch-controls.edit-mode #touch-weapon-bar,
#touch-controls.edit-mode #joystick-zone {
    outline: 2px dashed rgba(255,170,0,0.6);
    outline-offset: 4px;
    box-shadow: 0 0 12px rgba(255,170,0,0.3);
}

/* Actively dragging */
.layout-dragging {
    outline-color: #ff4444 !important;
    box-shadow: 0 0 20px rgba(255,68,68,0.5) !important;
    opacity: 0.85;
    z-index: 100 !important;
}

/* Editor toolbar — top center */
#layout-editor-toolbar {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 200;
    pointer-events: auto;
}

#layout-editor-toolbar button {
    padding: 10px 28px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
    border-radius: 8px;
    border: 2px solid;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    font-family: 'Segoe UI', sans-serif;
}

#layout-done-btn {
    background: rgba(68,255,68,0.2);
    border-color: #44ff44;
    color: #44ff44;
}
#layout-done-btn:active {
    background: rgba(68,255,68,0.4);
}

#layout-reset-btn {
    background: rgba(255,170,0,0.2);
    border-color: #ffaa00;
    color: #ffaa00;
}
#layout-reset-btn:active {
    background: rgba(255,170,0,0.4);
}

/* Resize widget */
#layout-resize-widget {
    position: fixed;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.88);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 8px 14px;
    z-index: 201;
    pointer-events: auto;
}

#layout-resize-widget button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 20px;
    font-weight: bold;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
#layout-resize-widget button:active {
    background: rgba(255,255,255,0.3);
}

#resize-scale {
    color: #ffaa44;
    font-size: 14px;
    font-weight: bold;
    min-width: 38px;
    text-align: center;
    font-family: 'Segoe UI', sans-serif;
}

/* ============================================
   RESPONSIVE: Tablet (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {
    #main-menu {
        flex-direction: column;
        overflow-y: auto;
    }
    .menu-left {
        width: 100%;
        padding: 20px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 16px;
    }
    .menu-logo h1 { font-size: 20px; line-height: 1.1; }
    .menu-center {
        height: 300px;
        min-height: 250px;
    }
    .menu-right {
        width: 100%;
        padding: 20px;
    }
    .loadout-options {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .loadout-btn { flex: 1 1 45%; min-width: 140px; }
}

/* ============================================
   RESPONSIVE: Phone (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    .menu-left { padding: 12px; gap: 10px; }
    .menu-logo h1 { font-size: 16px; }
    .menu-subtitle { font-size: 10px; }
    .menu-btn { padding: 10px 24px; font-size: 14px; }
    .menu-center { height: 200px; min-height: 180px; }
    .menu-right { padding: 12px; }
    .char-btn { padding: 8px; }
    .char-icon { width: 32px; height: 32px; }
    .loadout-btn { padding: 8px 10px; }
    .loadout-name { font-size: 12px; }
    .loadout-detail { font-size: 9px; }
    .mode-btn { padding: 12px 30px; font-size: 14px; }
    #name-input { width: 120px; font-size: 13px; }
}

/* ============================================
   RESPONSIVE: Landscape phone (max-height: 500px)
   ============================================ */
@media (max-height: 500px) {
    #main-menu {
        flex-direction: row;
        overflow-y: auto;
    }
    .menu-left { width: 200px; padding: 10px; }
    .menu-logo h1 { font-size: 14px; }
    .menu-center { min-height: 200px; }
    .menu-right { width: 240px; padding: 10px; overflow-y: auto; }
}

/* ============================================
   RESPONSIVE: HUD on mobile (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    #score {
        top: 8px; left: 8px;
        font-size: 12px;
    }
    #rank-display {
        top: 8px; left: 100px;
        font-size: 11px;
    }
    #net-info {
        top: 28px; left: 8px;
        font-size: 10px;
    }
    #kill-feed { top: 8px; right: 8px; }
    .kill-message { font-size: 11px; }
    .kill-entry { font-size: 10px; }
    #streak-announce { font-size: 28px; }
    #minimap { width: 100px; height: 100px; bottom: 160px; right: 10px; }
    #hp-bar {
        bottom: 80px;
        left: 10px;
    }
    #hp-bar-inner {
        width: 160px;
        height: 20px;
    }
    #hp-text { font-size: 12px; }
    #grenade-display {
        bottom: 110px;
        left: 10px;
        font-size: 13px;
    }
    #ammo-display {
        bottom: 80px;
        right: 80px;
        font-size: 20px;
    }
    #ammo-current { font-size: 32px; }
    #weapon-name {
        bottom: 108px;
        right: 80px;
        font-size: 11px;
    }
    #reload-bar {
        bottom: 140px;
        width: 120px;
    }
    #chat-box {
        bottom: 130px;
        left: 8px;
        width: 200px;
    }
    .chat-msg { font-size: 11px; }
    #scoreboard {
        min-width: 280px;
        padding: 12px 16px;
    }
    #scoreboard table { font-size: 11px; }
    #settings-panel { min-width: 280px; }
}
