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

body {
    background: #1a1a2e;
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
    touch-action: none;
}

/* Menu Screen */
#menuScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 20px 0;
}

/* Logo styles */
.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    position: relative;
    width: 70px;
    height: 70px;
}

.player-icon {
    position: absolute;
    width: 40px;
    height: 50px;
    background: linear-gradient(180deg, #166534 0%, #14532d 100%);
    border-radius: 8px 8px 5px 5px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px rgba(22, 101, 52, 0.5);
}

.player-icon::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #d4a574;
    border-radius: 50%;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
}

.player-icon::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 6px;
    background: #374151;
    border-radius: 2px;
    top: 15px;
    right: -20px;
}

.crosshair {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px solid rgba(233, 69, 96, 0.6);
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: #e94560;
}

.crosshair::before {
    width: 2px;
    height: 15px;
    left: 50%;
    top: -8px;
    transform: translateX(-50%);
}

.crosshair::after {
    width: 15px;
    height: 2px;
    top: 50%;
    right: -8px;
    transform: translateY(-50%);
}

.logo-text {
    font-size: 72px;
    font-weight: 900;
    color: #e94560;
    text-shadow:
        0 0 20px rgba(233, 69, 96, 0.8),
        0 0 40px rgba(233, 69, 96, 0.4),
        3px 3px 0 #7f1d1d;
    letter-spacing: 5px;
}

.menu-title {
    color: #fff;
    font-size: 48px;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    margin-bottom: 10px;
    letter-spacing: 15px;
}

.menu-subtitle {
    color: #a0a0a0;
    font-size: 18px;
    margin-bottom: 40px;
}

.menu-container {
    background: rgba(255,255,255,0.05);
    padding: 30px;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    width: 90%;
    max-width: 400px;
}

/* Input Groups */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    color: #fff;
    margin-bottom: 8px;
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    font-size: 16px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #e94560;
}

.map-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    font-size: 16px;
    transition: border-color 0.3s;
    cursor: pointer;
}

.map-select:focus {
    outline: none;
    border-color: #e94560;
}

.map-select option {
    background: #1a1a2e;
    color: #fff;
}

/* Buttons */
.menu-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560, #c73e54);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.2);
}

/* Room List */
#roomList {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 20px;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    margin-bottom: 8px;
    color: #fff;
}

.room-item .room-info {
    display: flex;
    flex-direction: column;
}

.room-item .room-id {
    font-weight: bold;
}

.room-item .room-status {
    font-size: 12px;
    color: #a0a0a0;
}

.room-item button {
    padding: 8px 20px;
    border: none;
    border-radius: 5px;
    background: #e94560;
    color: #fff;
    cursor: pointer;
}

.waiting-text {
    color: #4ade80;
    text-align: center;
    margin-top: 20px;
    animation: pulse 1.5s infinite;
}

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

/* Game Container */
#gameContainer {
    display: none;
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
}

/* Match Score Display */
#matchScore {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 6px;
    z-index: 100;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

#scoreTeam1 {
    color: #4ade80;
}

#scoreTeam2 {
    color: #ef4444;
}

#scoreSeparator {
    color: #fff;
}

/* HUD */
#hud {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #fff;
    font-size: 16px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 100;
}

.hud-item {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-bar {
    width: 150px;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    transition: width 0.3s;
}

.armor-bar {
    width: 150px;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
}

.armor-fill {
    height: 100%;
    background: linear-gradient(90deg, #60a5fa, #3b82f6);
    transition: width 0.3s;
}

/* Minimap */
#minimap {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 150px;
    height: 100px;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 5px;
    z-index: 100;
}

/* Win Screen */
#winScreen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

.win-text {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 0 0 20px currentColor;
}

.win-soldier { color: #4ade80; }
.win-terrorist { color: #ef4444; }

/* Mobile Controls */
#mobileControls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    pointer-events: none;
    z-index: 100;
}

.joystick-container {
    position: absolute;
    width: 120px;
    height: 120px;
    pointer-events: auto;
}

#moveJoystickContainer {
    left: 20px;
    bottom: 20px;
}

#aimJoystickContainer {
    right: 20px;
    bottom: 20px;
}

.joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.joystick-stick {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.mobile-btn {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

#reloadBtn { right: 160px; bottom: 100px; }
#bombBtn { right: 160px; bottom: 30px; background: rgba(255,100,0,0.3); }
#crouchBtn { left: 160px; bottom: 30px; }
#switchWeaponBtn { left: 160px; bottom: 100px; background: rgba(100,100,255,0.3); }
#fireBtn {
    right: 160px;
    bottom: 170px;
    background: rgba(255,50,50,0.5);
    width: 80px;
    height: 80px;
    font-size: 16px;
    font-weight: bold;
}

/* Connection Status */
#connectionStatus {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 15px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border-radius: 5px;
    font-size: 14px;
    z-index: 100;
}

.status-connected { border: 1px solid #4ade80; }
.status-waiting { border: 1px solid #fbbf24; }
.status-disconnected { border: 1px solid #ef4444; }

/* Game Menu Button */
.game-menu-btn {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(100px);
    padding: 8px 20px;
    background: rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 150;
    transition: all 0.2s;
}

.game-menu-btn:hover {
    background: rgba(233, 69, 96, 0.8);
    border-color: #e94560;
}

/* Pause Menu */
.pause-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.pause-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 30px 50px;
    border-radius: 15px;
    border: 2px solid rgba(255,255,255,0.1);
    text-align: center;
}

.pause-content h2 {
    color: #fff;
    font-size: 32px;
    margin-bottom: 25px;
}

.pause-content .menu-btn {
    width: 200px;
    margin-bottom: 10px;
}

/* Portrait orientation warning */
body.portrait-warning::after {
    content: 'Поверните устройство горизонтально';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 20px;
    text-align: center;
    z-index: 10000;
    padding: 20px;
}

body.portrait-warning::before {
    content: '📱↔️';
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 60px;
    z-index: 10001;
    animation: rotate-phone 1.5s ease-in-out infinite;
}

@keyframes rotate-phone {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    50% { transform: translate(-50%, -50%) rotate(90deg); }
}

/* Hide controls hint on mobile */
.hud-controls {
    display: block;
}

/* Mobile Media Queries */
@media (max-width: 768px), (max-height: 500px) {
    #mobileControls { display: block; }
    .menu-title { font-size: 32px; letter-spacing: 10px; }
    .hud-controls { display: none; }
    .logo-text { font-size: 48px; }
    .logo-icon { width: 50px; height: 50px; }
    .player-icon { width: 28px; height: 35px; }
    .player-icon::before { width: 14px; height: 14px; top: -8px; }
    .player-icon::after { width: 20px; height: 4px; top: 10px; right: -12px; }
    .crosshair { width: 42px; height: 42px; }

    #menuScreen {
        justify-content: flex-start;
        padding: 15px 0 30px 0;
    }

    .menu-container {
        margin-bottom: 20px;
    }

    .menu-subtitle {
        margin-bottom: 20px;
    }
}

/* Landscape orientation on mobile */
@media (orientation: landscape) and (max-height: 500px) {
    #menuScreen {
        padding: 10px;
    }

    .logo-container { margin-bottom: 5px; }
    .logo { gap: 10px; }
    .logo-text { font-size: 36px; }
    .logo-icon { width: 40px; height: 40px; }
    .player-icon { width: 22px; height: 28px; }
    .player-icon::before { width: 12px; height: 12px; top: -7px; }
    .player-icon::after { width: 16px; height: 3px; top: 8px; right: -10px; }
    .crosshair { width: 34px; height: 34px; border-width: 2px; }
    .menu-title { font-size: 24px; margin-bottom: 5px; letter-spacing: 8px; }
    .menu-subtitle { font-size: 14px; margin-bottom: 15px; }

    .menu-container {
        padding: 15px;
        max-width: 600px;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .input-group {
        flex: 1;
        min-width: 200px;
        margin-bottom: 0;
    }

    .menu-btn {
        padding: 10px;
        font-size: 14px;
    }

    #roomList {
        max-height: 100px;
        width: 100%;
    }

    #hud {
        font-size: 12px;
    }

    .health-bar {
        width: 100px;
        height: 15px;
    }

    #minimap {
        width: 100px;
        height: 70px;
    }

    .joystick-container {
        width: 100px;
        height: 100px;
    }

    .joystick-base {
        width: 100px;
        height: 100px;
    }

    .joystick-stick {
        width: 40px;
        height: 40px;
    }

    #moveJoystickContainer {
        left: 10px;
        bottom: 10px;
    }

    #aimJoystickContainer {
        right: 10px;
        bottom: 10px;
    }

    .mobile-btn {
        width: 50px;
        height: 50px;
        font-size: 10px;
    }

    #reloadBtn { right: 130px; bottom: 70px; }
    #bombBtn { right: 130px; bottom: 15px; }
    #crouchBtn { left: 130px; bottom: 15px; }
    #switchWeaponBtn { left: 130px; bottom: 70px; }
    #fireBtn { right: 130px; bottom: 130px; width: 60px; height: 60px; font-size: 12px; }

    #mobileControls {
        height: auto;
    }

    .win-text { font-size: 32px; }
    #winScreen .menu-btn { width: 150px; }
}

/* ============== STATISTICS PANEL ============== */
#statsPanel {
    background: rgba(0, 0, 0, 0.95);
    border-radius: 15px;
    padding: 25px;
    margin-top: 20px;
    width: 100%;
    max-width: 500px;
    border: 2px solid #4ade80;
}

#statsPanel h2 {
    color: #4ade80;
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
}

#statsPanel h3 {
    color: #fbbf24;
    text-align: center;
    margin-bottom: 15px;
    font-size: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.stat-label {
    display: block;
    color: #9ca3af;
    font-size: 11px;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
}

/* Leaderboard table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table th {
    color: #9ca3af;
    font-size: 12px;
    font-weight: normal;
}

.leaderboard-table td {
    color: #fff;
    font-size: 14px;
}

.leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-table tr.current-player {
    background: rgba(74, 222, 128, 0.2);
}

.leaderboard-table tr.top-1 td:first-child::before { content: '🥇 '; }
.leaderboard-table tr.top-2 td:first-child::before { content: '🥈 '; }
.leaderboard-table tr.top-3 td:first-child::before { content: '🥉 '; }

#closeStatsBtn {
    margin-top: 20px;
    width: 100%;
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #statsPanel {
        padding: 15px;
    }

    .stat-value {
        font-size: 16px;
    }
}
