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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

.screen {
    display: none !important;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex !important;
    justify-content: center;
    align-items: center;
}

/* Ensure only one screen is ever visible */
body > .screen:not(.active) {
    visibility: hidden !important;
    pointer-events: none !important;
}

.container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.container.wide {
    max-width: 800px;
}

h1 {
    text-align: center;
    font-size: 3rem;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(255, 100, 0, 0.8);
    color: #ff6600;
    letter-spacing: 4px;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #fff;
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #aaa;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #aaa;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #fff;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #ff6600;
    box-shadow: 0 0 10px rgba(255, 100, 0, 0.3);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn.primary {
    background: linear-gradient(135deg, #ff6600, #ff9933);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 100, 0, 0.4);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 100, 0, 0.6);
}

.btn.danger {
    background: linear-gradient(135deg, #cc0000, #ff3333);
    color: #fff;
}

.btn.danger:hover {
    transform: translateY(-2px);
}

.btn:not(.primary):not(.danger) {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn:not(.primary):not(.danger):hover {
    background: rgba(255, 255, 255, 0.3);
}

.error {
    color: #ff4444;
    font-size: 0.9rem;
    margin-top: 10px;
    text-align: center;
}

/* Lobby Browser */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.player-info {
    color: #aaa;
    font-size: 0.9rem;
}

.player-info span {
    color: #ff6600;
    font-weight: bold;
}

.lobby-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.lobby-actions input {
    flex: 1;
    min-width: 150px;
}

.lobby-list {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.no-lobbies {
    color: #666;
    text-align: center;
    padding: 50px;
}

.lobby-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.lobby-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.lobby-item:last-child {
    margin-bottom: 0;
}

.lobby-item-info h4 {
    color: #fff;
    margin-bottom: 5px;
}

.lobby-item-info span {
    color: #888;
    font-size: 0.85rem;
}

.lobby-item-info .in-game {
    color: #ff6600;
}

/* Lobby Room */
.lobby-room-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .lobby-room-container {
        grid-template-columns: 1fr;
    }
}

.lobby-info {
    display: flex;
    flex-direction: column;
}

.players-list {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    flex: 1;
    min-height: 150px;
    margin-bottom: 20px;
}

.player-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-bottom: 8px;
}

.player-item:last-child {
    margin-bottom: 0;
}

.player-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
}

.bot-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.bot-buttons .btn {
    flex: 1;
    padding: 8px 16px;
    font-size: 0.9rem;
    background: rgba(100, 100, 255, 0.3);
    border: 1px solid rgba(100, 100, 255, 0.5);
}

.bot-buttons .btn:hover {
    background: rgba(100, 100, 255, 0.5);
}

.lobby-buttons {
    display: flex;
    gap: 10px;
}

.lobby-buttons .btn {
    flex: 1;
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
}

.chat-messages {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    flex: 1;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.chat-messages.small {
    min-height: 100px;
    max-height: 150px;
}

.chat-message {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.chat-message:last-child {
    margin-bottom: 0;
}

.chat-message .name {
    font-weight: bold;
    color: #ff6600;
}

.chat-message .text {
    color: #ddd;
}

.chat-message.system {
    color: #888;
    font-style: italic;
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

.chat-input-container input {
    flex: 1;
}

/* Game Screen */
#game-screen.active {
    padding: 10px;
    align-items: flex-start;
    justify-content: center;
}

.game-layout {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.game-sidebar {
    width: 160px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-player {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 10px;
    border: 2px solid transparent;
}

.sidebar-player.current-player {
    border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-player.dead {
    opacity: 0.4;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.player-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.player-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.stat-row canvas {
    display: block;
}

.game-main {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-header {
    width: 100%;
    margin-bottom: 10px;
    display: flex;
    justify-content: flex-end;
}

.btn.small {
    padding: 6px 12px;
    font-size: 0.75rem;
}

#game-canvas {
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.game-chat {
    width: 100%;
    max-width: 600px;
    margin-top: 10px;
}

.game-chat .chat-messages {
    min-height: 60px;
    max-height: 100px;
}

.game-chat input {
    font-size: 0.9rem;
    padding: 8px 12px;
}

/* Responsive: stack sidebar on small screens */
@media (max-width: 800px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
    }

    .game-sidebar {
        width: 100%;
        max-width: 600px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .sidebar-player {
        flex: 0 0 auto;
        min-width: 140px;
    }
}

/* Overlay */
.overlay {
    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: 1000;
    visibility: visible;
    opacity: 1;
}

.overlay.hidden {
    display: none !important;
    visibility: hidden;
    opacity: 0;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
}

.overlay-content h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #ff6600;
}

.overlay-content p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

/* Modal */
.modal {
    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;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: rgba(30, 30, 50, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 10px;
    color: #ff6600;
}

.modal-content .hint {
    text-align: center;
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.keybind-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.keybind-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.keybind-row span {
    color: #ccc;
}

.keybind-btn {
    padding: 8px 16px;
    min-width: 100px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.keybind-btn.listening {
    border-color: #ff6600;
    background: rgba(255, 100, 0, 0.2);
    animation: pulse 1s infinite;
}

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

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons .btn {
    flex: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 100, 0, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 100, 0, 0.7);
}

/* Controls hint */
.controls-hint {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #888;
}

.controls-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
    margin: 0 2px;
}
