/* Chibi Brawlers: Prompt Evolution - Main Styles */

:root {
    --bg-dark: #0a0a12;
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --accent-gold: #f4d03f;
    --accent-orange: #e74c3c;
    --accent-cyan: #00d4ff;
    --accent-magenta: #ff006e;
    --player1-color: #3498db;
    --player1-dark: #2980b9;
    --player2-color: #e74c3c;
    --player2-dark: #c0392b;
    --text-light: #ecf0f1;
    --text-dim: #7f8c8d;
    --panel-bg: rgba(26, 26, 46, 0.95);
    --panel-border: rgba(244, 208, 63, 0.3);
    --glow-cyan: 0 0 20px rgba(0, 212, 255, 0.5);
    --glow-gold: 0 0 20px rgba(244, 208, 63, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow: hidden;
    height: 100%;
}

body {
    font-family: 'Exo 2', sans-serif;
    background: var(--bg-dark);
    background-image: 
        radial-gradient(ellipse at top, var(--bg-gradient-start) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, var(--bg-gradient-end) 0%, transparent 50%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 212, 255, 0.03) 2px,
            rgba(0, 212, 255, 0.03) 4px
        );
    min-height: 100vh;
    height: 100vh;
    color: var(--text-light);
    overflow: hidden;
    touch-action: pan-x pan-y;
    -webkit-user-select: none;
    user-select: none;
    position: fixed;
    width: 100%;
}

/* Prevent scrolling during gameplay */
body.game-active {
    overflow: hidden;
    touch-action: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

body.game-active #game-wrapper {
    overflow: hidden;
    touch-action: none;
}

#game-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    box-sizing: border-box;
    position: relative; /* For absolute positioning of floating button */
}

/* Header */
#game-header {
    text-align: center;
    margin-bottom: 10px;
    position: relative;
    z-index: 100; /* Below floating button but above game */
}

.game-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    line-height: 1;
}

.title-chibi {
    font-family: 'Bangers', cursive;
    font-size: 3.5rem;
    color: var(--accent-cyan);
    text-shadow: 
        3px 3px 0 var(--accent-magenta),
        var(--glow-cyan);
    letter-spacing: 0.15em;
    transform: rotate(-2deg);
}

/* Smaller header during gameplay */
body.game-active .title-chibi {
    font-size: 2rem;
}

body.game-active .title-brawlers {
    font-size: 2.5rem;
    margin-top: -5px;
}

body.game-active .title-subtitle {
    font-size: 0.7rem;
    margin-top: 2px;
}

.title-brawlers {
    font-family: 'Bangers', cursive;
    font-size: 4.5rem;
    color: var(--accent-gold);
    text-shadow: 
        4px 4px 0 var(--accent-orange),
        var(--glow-gold);
    letter-spacing: 0.1em;
    margin-top: -10px;
}

.title-subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
    color: var(--accent-magenta);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    margin-top: 5px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Game Container */
#game-container {
    border: 4px solid var(--accent-gold);
    border-radius: 8px;
    box-shadow: 
        var(--glow-gold),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
    background: #000;
    position: relative;
    touch-action: none;
    margin-top: 10px; /* Add spacing below header */
}

#game-container canvas {
    touch-action: none;
}

/* During gameplay, keep header visible and add spacing */
body.game-active #game-header {
    display: flex !important;
    visibility: visible !important;
}

body.game-active #game-container {
    margin-top: 10px;
}

#game-container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 10px;
    background: linear-gradient(45deg, var(--accent-cyan), var(--accent-magenta), var(--accent-gold));
    z-index: -1;
    opacity: 0.5;
    filter: blur(10px);
}

/* Prompt Panel */
#prompt-panel {
    width: 100%;
    max-width: 960px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

/* Console visible by default in menu */
#prompt-panel {
    display: block;
}

/* Hide console during gameplay (unless in overlay mode) */
body.game-active #prompt-panel:not(.overlay-mode) {
    display: none !important;
}

/* Ensure console is visible in overlay mode */
#prompt-panel.overlay-mode {
    display: block !important;
}

.prompt-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--panel-border);
    position: relative;
}

.close-console-btn {
    background: rgba(231, 76, 60, 0.4);
    border: 2px solid var(--accent-orange);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-light);
    font-weight: bold;
    display: none; /* Hidden by default */
}

.close-console-btn:hover {
    background: rgba(231, 76, 60, 0.7);
    border-color: var(--accent-orange);
    transform: scale(1.1);
}

/* Green checkmark when preset is selected */
.close-console-btn.preset-selected {
    background: rgba(46, 204, 113, 0.4);
    color: #2ecc71;
    border-color: #2ecc71;
}

.close-console-btn.preset-selected:hover {
    background: rgba(46, 204, 113, 0.7);
    border-color: #2ecc71;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.6);
}

/* Show close button only in overlay mode */
#prompt-panel.overlay-mode .close-console-btn {
    display: inline-block;
    margin-right: 10px;
}

/* Ensure prompt buttons are always visible */
.prompt-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.prompt-buttons button {
    display: flex !important;
}

.ai-config-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ai-config-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: var(--accent-cyan);
    transform: rotate(90deg);
}

/* Help button - next to config button */
.help-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-family: 'Exo 2', sans-serif;
    font-weight: 600;
}

.help-btn:hover {
    background: rgba(244, 208, 63, 0.2);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* Fullscreen button */
.fullscreen-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.fullscreen-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Hide fullscreen button when already in fullscreen */
:fullscreen .fullscreen-btn,
:-webkit-full-screen .fullscreen-btn {
    display: none;
}

.prompt-icon {
    font-size: 1.5rem;
    animation: flash 1.5s ease-in-out infinite;
}

@keyframes flash {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.prompt-header h2 {
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.prompt-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.prompt-controls select {
    flex: 1;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-light);
    font-family: 'Exo 2', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.prompt-controls select:hover,
.prompt-controls select:focus {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
    outline: none;
}

#prompt-input {
    width: 100%;
    height: 80px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-light);
    font-family: 'Exo 2', sans-serif;
    font-size: 1rem;
    resize: none;
    transition: all 0.3s ease;
}

#prompt-input:focus {
    border-color: var(--accent-gold);
    box-shadow: var(--glow-gold);
    outline: none;
}

#prompt-input::placeholder {
    color: var(--text-dim);
    font-style: italic;
}

.prompt-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.prompt-buttons button {
    flex: 1;
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-apply {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    color: #000;
    box-shadow: 0 4px 15px rgba(244, 208, 63, 0.4);
}

.btn-apply:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 208, 63, 0.6);
}

.btn-reset {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 2px solid var(--text-dim);
}

.btn-reset:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--text-light);
}

.btn-icon {
    font-size: 1.2rem;
}

/* Mapping Display */
/* Evolution Preview */
/* Evolution Preview - Positioned at top of viewport for visibility */
.evolution-preview {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(10, 20, 40, 0.98) 0%, rgba(30, 30, 60, 0.98) 100%);
    border-radius: 16px;
    border: 3px solid var(--accent-gold);
    display: none;
    text-align: center;
    box-shadow: 0 0 30px rgba(244, 208, 63, 0.4), 0 10px 40px rgba(0, 0, 0, 0.8);
    max-width: 200px;
}

.evolution-preview.active {
    display: block;
    animation: fadeInScale 0.3s ease;
}

.close-preview-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 0, 0, 0.7);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-preview-btn:hover {
    background: rgba(255, 0, 0, 1);
    transform: scale(1.1);
}

.preview-hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 10px;
    font-style: italic;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.preview-header {
    font-family: 'Bangers', cursive;
    font-size: 1.2rem;
    color: var(--accent-gold);
    margin-bottom: 12px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#preview-canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
    padding: 15px;
    background: radial-gradient(ellipse at center, rgba(0, 50, 100, 0.4) 0%, rgba(0, 0, 0, 0.6) 100%);
    border-radius: 10px;
    min-height: 140px;
}

#brawler-preview-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.preview-archetype {
    font-family: 'Exo 2', sans-serif;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.preview-archetype.boxer { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.preview-archetype.tank { background: linear-gradient(135deg, #7f8c8d, #5d6d7e); }
.preview-archetype.speedster { background: linear-gradient(135deg, #00d4ff, #0099cc); }
.preview-archetype.ninja { background: linear-gradient(135deg, #9b59b6, #6c3483); }
.preview-archetype.berserker { background: linear-gradient(135deg, #ff4500, #cc3700); }
.preview-archetype.guardian { background: linear-gradient(135deg, #f4d03f, #d4ac0d); color: #000; }
.preview-archetype.giant { background: linear-gradient(135deg, #8b4513, #5d2e0c); }
.preview-archetype.acrobat { background: linear-gradient(135deg, #e91e63, #ad1457); }
.preview-archetype.balanced { background: linear-gradient(135deg, #2ecc71, #27ae60); }

.mapping-display {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border-left: 4px solid var(--accent-cyan);
    display: none;
}

.mapping-display.active {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.mapping-header {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: var(--accent-cyan);
    margin-bottom: 10px;
}

#mapping-content {
    font-family: 'Exo 2', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-dim);
}

#mapping-content .stat-change {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px;
    background: rgba(0, 212, 255, 0.2);
    border-radius: 4px;
    color: var(--accent-cyan);
}

#mapping-content .stat-change.negative {
    background: rgba(231, 76, 60, 0.2);
    color: var(--accent-orange);
}

#mapping-content .stat-change.ability {
    background: rgba(255, 0, 110, 0.2);
    color: var(--accent-magenta);
}

#mapping-content .stat-change.visual {
    background: rgba(155, 89, 182, 0.2);
    color: #9b59b6;
}

/* Controls Info */
#controls-info {
    display: flex;
    gap: 40px;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 960px;
    padding: 20px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
}

.controls-player {
    text-align: center;
}

.controls-player h3 {
    font-family: 'Bangers', cursive;
    font-size: 1.5rem;
    margin-bottom: 10px;
    letter-spacing: 0.1em;
}

.controls-p1 h3 { color: var(--player1-color); }
.controls-p2 h3 { color: var(--player2-color); }

.controls-vs {
    font-family: 'Bangers', cursive;
    font-size: 2.5rem;
    color: var(--accent-gold);
    text-shadow: 2px 2px 0 var(--accent-orange);
}

.key-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 5px 0;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    background: linear-gradient(180deg, #3a3a4a, #2a2a3a);
    border: 1px solid #4a4a5a;
    border-radius: 5px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: var(--text-light);
    box-shadow: 0 3px 0 #1a1a2a;
}

/* Mode Toggle */
#mode-toggle {
    display: flex;
    gap: 10px;
}

.mode-btn {
    padding: 12px 25px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    border-color: transparent;
    color: #fff;
    box-shadow: var(--glow-cyan);
}

/* Mobile Controls */
#mobile-controls {
    display: none;
}

@media (max-width: 768px) {
    #mobile-controls {
        display: flex !important;
    }
    
    #controls-info {
        display: none;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .title-chibi { font-size: 2.5rem; }
    .title-brawlers { font-size: 3.5rem; }
    
    #controls-info {
        flex-direction: column;
        gap: 20px;
    }
    
    .controls-vs {
        transform: rotate(90deg);
    }
}

@media (max-width: 768px) {
    #game-wrapper { padding: 10px; }
    
    .title-chibi { font-size: 2rem; }
    .title-brawlers { font-size: 2.5rem; }
    .title-subtitle { font-size: 0.7rem; }
    
    .prompt-controls {
        flex-direction: column;
    }
    
    .prompt-buttons {
        flex-direction: column;
    }
    
    #game-container canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    color: var(--accent-gold);
    animation: pulse 1s ease-in-out infinite;
}

/* AI Configuration Modal */
.modal {
    position: fixed;
    z-index: 50000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

/* Hide mobile controls when modals are visible */
body.modal-open #mobile-controls {
    display: none !important;
    pointer-events: none !important;
}

.modal-content {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    margin: 5% auto;
    padding: 30px;
    max-width: 500px;
    max-height: 90vh;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-content h2 {
    color: var(--accent-cyan);
    margin-bottom: 15px;
}

.close {
    color: var(--text-dim);
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: var(--text-light);
}

/* Help Modal Styles */
.help-modal-content {
    max-width: 600px;
}

.help-modal-content h2 {
    text-align: center;
    color: var(--accent-gold);
    font-family: 'Bangers', cursive;
    font-size: 2rem;
    margin-bottom: 20px;
}

.help-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid var(--accent-cyan);
}

.help-section h3 {
    color: var(--accent-cyan);
    font-family: 'Exo 2', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.help-section p {
    color: var(--text-light);
    line-height: 1.5;
    margin: 0;
}

.help-section ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
    color: var(--text-light);
}

.help-section li {
    margin-bottom: 5px;
}

.help-section .controls-grid {
    display: flex;
    gap: 30px;
    margin-top: 10px;
}

.help-section .controls-column {
    flex: 1;
}

.help-section .controls-column h4 {
    color: var(--accent-gold);
    margin-bottom: 8px;
    font-size: 1rem;
}

.help-section .controls-column p {
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.help-section .key {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
}

/* Attack Controls Grid for Help Modal */
.help-intro {
    margin-bottom: 12px !important;
    font-size: 0.95rem;
    opacity: 0.9;
}

.attack-controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

@media (max-width: 500px) {
    .attack-controls-grid {
        grid-template-columns: 1fr;
    }
}

.attack-control-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 10px;
    border-radius: 10px;
    text-align: center;
}

.attack-control-card.light {
    background: rgba(0, 212, 255, 0.12);
    border: 2px solid rgba(0, 212, 255, 0.35);
}

.attack-control-card.heavy {
    background: rgba(255, 107, 53, 0.12);
    border: 2px solid rgba(255, 107, 53, 0.35);
}

.attack-control-card.special {
    background: rgba(244, 208, 63, 0.12);
    border: 2px solid rgba(244, 208, 63, 0.35);
}

.attack-control-card.block {
    background: rgba(155, 89, 182, 0.12);
    border: 2px solid rgba(155, 89, 182, 0.35);
}

.attack-control-card .attack-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.attack-control-card .attack-name {
    font-weight: bold;
    font-size: 0.95rem;
    margin-bottom: 3px;
}

.attack-control-card.light .attack-name { color: #00d4ff; }
.attack-control-card.heavy .attack-name { color: #ff6b35; }
.attack-control-card.special .attack-name { color: #f4d03f; }
.attack-control-card.block .attack-name { color: #9b59b6; }

.attack-control-card .attack-input {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 2px;
}

.attack-control-card .attack-desc {
    font-size: 0.75rem;
    opacity: 0.7;
}

.help-movement {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.help-movement p {
    margin: 0 !important;
    font-size: 0.9rem;
}

.help-tip {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.3);
    padding: 8px 12px !important;
    border-radius: 6px;
    font-size: 0.85rem !important;
}
    font-size: 0.85rem;
    margin-right: 3px;
}

.config-section {
    margin: 20px 0;
}

.config-section label {
    display: block;
    color: var(--accent-gold);
    margin-bottom: 8px;
    font-weight: bold;
}

.config-section input,
.config-section select {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-light);
    font-family: 'Exo 2', sans-serif;
    font-size: 1rem;
}

.config-section input:focus,
.config-section select:focus {
    border-color: var(--accent-cyan);
    outline: none;
}

.config-section small {
    display: block;
    margin-top: 5px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.config-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.config-status {
    margin-top: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#ai-status-indicator {
    font-size: 1.5rem;
    color: #e74c3c;
}

#ai-status-indicator.active {
    color: #2ecc71;
    animation: pulse 2s ease-in-out infinite;
}

/* Audio Controls Styles */
.config-divider {
    border: none;
    border-top: 1px solid var(--panel-border);
    margin: 25px 0 20px;
}

.audio-controls {
    padding: 10px 0;
}

.audio-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.audio-toggle-row label:first-child {
    color: var(--text-light);
    font-weight: normal;
    margin-bottom: 0;
}

.audio-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audio-slider-row input[type="range"] {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;
    border: none;
    padding: 0;
}

.audio-slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-cyan);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.audio-slider-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-cyan);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.audio-slider-row span {
    min-width: 40px;
    text-align: right;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--panel-border);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-dim);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(0, 212, 255, 0.3);
    border-color: var(--accent-cyan);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background-color: var(--accent-cyan);
}

.loading {
    color: var(--accent-cyan);
    font-style: italic;
    padding: 10px;
    text-align: center;
}

.ai-reasoning {
    background: rgba(0, 212, 255, 0.1);
    border-left: 3px solid var(--accent-cyan);
    padding: 10px;
    margin: 10px 0;
    font-size: 0.9rem;
    font-style: italic;
}

.error {
    color: var(--accent-orange);
    background: rgba(231, 76, 60, 0.2);
    padding: 10px;
    border-radius: 5px;
    border-left: 3px solid var(--accent-orange);
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Floating Config Button - always visible, positioned on far right */
.floating-config-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 45px;
    height: 45px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 50%;
    display: flex; /* Always visible */
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    z-index: 500; /* Above game container but below overlay */
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
    .floating-config-btn {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

.floating-config-btn:hover {
    transform: scale(1.1) rotate(90deg);
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.floating-config-btn.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    border-color: transparent;
    transform: rotate(90deg);
    box-shadow: var(--glow-cyan);
}

@media (max-width: 768px) {
    .floating-config-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 12px;
        right: 12px;
    }
}

/* Overlay Mode for Console */
#prompt-panel.overlay-mode {
    display: block !important;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 600px;
    width: 90%;
    z-index: 1000;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    animation: slideInOverlay 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

/* Backdrop when console is open */
#prompt-panel.overlay-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: -1;
    pointer-events: none; /* Don't block clicks to console content */
}

/* Prevent clicks from going through console to game */
#prompt-panel.overlay-mode {
    pointer-events: auto;
}

#prompt-panel.overlay-mode * {
    pointer-events: auto;
}

@keyframes slideInOverlay {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Game active state adjustments */
body.game-active #game-wrapper {
    padding: 20px;
    gap: 10px;
}

/* Mobile controls should stay visible */
@media (max-width: 768px) {
    #mobile-controls {
        display: flex !important;
    }
}

/* Prevent text selection during gameplay */
body.game-active {
    -webkit-user-select: none;
    user-select: none;
}


/* ============================================
   AUTH UI STYLES
   ============================================ */

/* Auth buttons in header */
/* Auth buttons - always on far left, positioned relative to viewport */
.auth-buttons {
    position: fixed;
    top: 10px;
    left: 10px;
    right: auto;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

@media (max-width: 768px) {
    .auth-buttons {
        position: fixed;
        top: 10px;
        left: 5px;
    }
}

.auth-btn {
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-btn {
    background: rgba(52, 152, 219, 0.2);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
}

.login-btn:hover {
    background: rgba(52, 152, 219, 0.4);
    box-shadow: var(--glow-cyan);
}

.signup-btn {
    background: linear-gradient(135deg, var(--accent-gold), #e67e22);
    color: #000;
    border: none;
}

.signup-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--glow-gold);
}

.logout-btn {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid #e74c3c;
    font-size: 0.75rem;
    padding: 6px 12px;
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 0.4);
}

.leaderboard-btn {
    background: rgba(244, 208, 63, 0.2);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    padding: 6px 10px;
    font-size: 1rem;
}

.leaderboard-btn:hover {
    background: rgba(244, 208, 63, 0.4);
    box-shadow: var(--glow-gold);
}

/* User info display - always on far left, positioned relative to viewport */
.user-info {
    position: fixed;
    top: 10px;
    left: 10px;
    right: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
}

@media (max-width: 768px) {
    .user-info {
        position: fixed;
        top: 10px;
        left: 5px;
    }
}

.user-display {
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    padding: 6px 12px;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

/* Pause button - positioned below user info */
.pause-btn {
    position: fixed;
    top: 60px;
    left: 10px;
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    padding: 10px 16px;
    background: rgba(244, 208, 63, 0.2);
    color: var(--accent-gold);
    border: 2px solid var(--accent-gold);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.pause-btn:hover {
    background: rgba(244, 208, 63, 0.4);
    box-shadow: var(--glow-gold);
    transform: scale(1.05);
}

.pause-btn.paused {
    background: rgba(46, 204, 113, 0.2);
    border-color: #2ecc71;
    color: #2ecc71;
}

.pause-btn.paused:hover {
    background: rgba(46, 204, 113, 0.4);
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}

@media (max-width: 768px) {
    .pause-btn {
        position: fixed;
        top: 60px;
        left: 5px;
    }
}

.hidden {
    display: none !important;
}

/* Auth Modal */
.auth-modal-content {
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.auth-tab {
    flex: 1;
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: 'Exo 2', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.auth-tab:hover {
    color: var(--text-light);
}

.auth-tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

.auth-form h2 {
    text-align: center;
    color: var(--accent-gold);
    font-family: 'Bangers', cursive;
    font-size: 1.8rem;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--accent-cyan);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-light);
    font-family: 'Exo 2', sans-serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.form-group input::placeholder {
    color: var(--text-dim);
}

.form-group small {
    display: block;
    margin-top: 5px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.btn-auth-submit {
    width: 100%;
    padding: 14px;
    font-family: 'Bangers', cursive;
    font-size: 1.3rem;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--accent-gold), #e67e22);
    color: #000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.btn-auth-submit:hover {
    transform: scale(1.02);
    box-shadow: var(--glow-gold);
}

.auth-error {
    color: #e74c3c;
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
    min-height: 20px;
}

/* Landscape orientation adjustments for auth modal */
@media (max-height: 600px) and (orientation: landscape) {
    .modal-content {
        margin: 2% auto;
        max-height: 96vh;
        padding: 20px;
    }
    
    .auth-modal-content {
        max-height: 96vh;
        padding: 15px;
    }
    
    .auth-form h2 {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group input {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 4px;
    }
    
    .form-group small {
        font-size: 0.7rem;
        margin-top: 3px;
    }
    
    .btn-auth-submit {
        padding: 12px;
        font-size: 1.1rem;
        margin-top: 8px;
    }
    
    .auth-tabs {
        margin-bottom: 15px;
    }
    
    .auth-tab {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* Leaderboard Modal */
.leaderboard-modal-content {
    max-width: 600px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

.leaderboard-modal-content h2 {
    text-align: center;
    color: var(--accent-gold);
    font-family: 'Bangers', cursive;
    font-size: 2rem;
    margin-bottom: 20px;
}

.leaderboard-loading {
    text-align: center;
    color: var(--text-dim);
    padding: 40px;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 50px 1fr auto auto 100px;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    background: rgba(0, 212, 255, 0.1);
}

.leaderboard-item.is-me {
    border-left-color: var(--accent-gold);
    background: rgba(244, 208, 63, 0.1);
}

.lb-rank {
    font-size: 1.3rem;
    text-align: center;
    font-weight: 700;
}

.lb-info {
    overflow: hidden;
}

.lb-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-username {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.lb-stats {
    text-align: right;
}

.lb-level {
    font-weight: 700;
    color: var(--accent-cyan);
    font-size: 0.9rem;
}

.lb-record {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.lb-archetype {
    font-size: 1.5rem;
    text-align: center;
}

.lb-last-brawl {
    text-align: right;
    font-size: 0.75rem;
}

.lb-last-brawl .won {
    color: #2ecc71;
}

.lb-last-brawl .lost {
    color: #e74c3c;
}

.lb-last-brawl .no-match {
    color: var(--text-dim);
    font-style: italic;
}

.lb-time {
    color: var(--text-dim);
    margin-left: 5px;
}

.no-brawlers, .leaderboard-error {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

/* Auth Notification */
.auth-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.95), rgba(39, 174, 96, 0.95));
    color: #fff;
    padding: 15px 30px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    z-index: 10000;
    box-shadow: 0 5px 30px rgba(46, 204, 113, 0.5);
    transition: transform 0.3s ease;
}

.auth-notification.show {
    transform: translateX(-50%) translateY(0);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .auth-buttons {
        top: 5px;
        left: 10px;
        right: auto;
    }
    
    .auth-btn {
        font-size: 0.75rem;
        padding: 6px 10px;
    }
    
    .user-info {
        left: 10px;
        right: auto;
        top: 5px;
        right: 10px;
    }
    
    .user-display {
        font-size: 0.8rem;
        padding: 4px 8px;
    }
    
    .leaderboard-item {
        grid-template-columns: 40px 1fr auto auto;
    }
    
    .lb-last-brawl {
        display: none;
    }
}

@media (max-width: 480px) {
    .auth-buttons {
        left: 5px;
        right: auto;
    }
    
    .user-info {
        left: 5px;
        right: auto;
        flex-direction: row;
        gap: 5px;
        align-items: center;
    }
}

/* User profile dropdown */
.user-display {
    cursor: pointer;
    background: transparent;
    border: 1px solid rgba(0, 212, 255, 0.3);
    transition: all 0.2s ease;
}

.user-display:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.5);
}

.brawler-preview-section {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 280px;
    touch-action: pan-y;
}

.brawler-preview-loading {
    text-align: center;
    color: var(--text-dim);
    padding: 20px;
}

.brawler-preview-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    touch-action: pan-y;
}

.brawler-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.brawler-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-light);
}

.brawler-level {
    font-size: 0.9rem;
    color: var(--accent-cyan);
    font-weight: 700;
}

.brawler-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0;
}

.brawler-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-light);
}

.brawler-evolution-prompt {
    font-size: 0.85rem;
    color: var(--accent-gold);
    font-style: italic;
    padding: 8px;
    background: rgba(244, 208, 63, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--accent-gold);
    display: none;
}

.brawler-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.evolve-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    background: linear-gradient(135deg, var(--accent-gold), #ffd700);
    border: none;
    border-radius: 6px;
    color: #000;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.evolve-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 208, 63, 0.4);
}

.evolve-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(244, 208, 63, 0.3);
}

.evolve-icon {
    font-size: 1.2rem;
}

.evolve-exp-info {
    font-size: 0.75rem;
    text-align: center;
    padding: 4px;
    border-radius: 4px;
}

.evolve-exp-info.available {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
}

.evolve-exp-info.insufficient {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.user-dropdown {
    position: fixed;
    top: 55px;
    left: 10px;
    right: auto;
    background: rgba(26, 26, 46, 0.98);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    padding: 8px;
    min-width: 280px;
    max-width: min(calc(100vw - 20px), 400px);
    max-height: calc(100vh - 70px);
    max-height: calc(100dvh - 70px);
    overflow-y: auto !important;
    overflow-x: hidden;
    z-index: 200000 !important; /* Must be above game canvas, HUD, and mobile controls */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    /* Ensure dropdown stays within viewport */
    transform: translateX(0);
    /* Mobile scroll support */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y !important;
}

/* Hide mobile controls completely when user dropdown is open */
body.dropdown-open #mobile-controls {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* Ensure dropdown parent doesn't limit z-index */
body.dropdown-open #game-header {
    z-index: 250000 !important;
}

/* Disable game canvas interaction when dropdown is open */
body.dropdown-open #game-container {
    pointer-events: none !important;
}

body.dropdown-open #game-container canvas {
    pointer-events: none !important;
}

.dropdown-item {
    width: 100%;
    padding: 10px 15px;
    background: transparent;
    border: none;
    color: var(--text-light);
    font-family: 'Exo 2', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

/* On mobile, ensure dropdown doesn't go off-screen */
@media (max-width: 768px) {
    .user-dropdown {
        left: 5px;
        right: auto;
        max-width: calc(100vw - 10px);
        min-width: 250px;
        top: 55px;
        z-index: 200000 !important;
    }
}

/* Landscape mode - dropdown must be above game and controls */
@media (max-width: 1024px) and (orientation: landscape) {
    .user-dropdown {
        top: 40px;
        left: 5px;
        z-index: 200000 !important;
        max-height: calc(100vh - 50px);
        max-height: calc(100dvh - 50px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }
}

/* Ensure dropdown scrolls on all mobile */
@media (max-width: 768px) {
    .user-dropdown {
        max-height: calc(100vh - 70px);
        max-height: calc(100dvh - 70px);
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain;
        touch-action: pan-y !important;
    }
}

/* Force scrolling on larger mobile devices like Pixel 9 */
@media (max-width: 500px), (max-height: 900px) and (pointer: coarse) {
    .user-dropdown {
        max-height: calc(100vh - 60px) !important;
        max-height: calc(100dvh - 60px) !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain !important;
        touch-action: pan-y !important;
    }
    
    .user-dropdown * {
        touch-action: pan-y !important;
    }
    
    /* Ensure child elements don't block scrolling */
    .brawler-preview-section,
    .brawler-preview-content,
    .brawler-stats-grid,
    .brawler-actions,
    .daily-limit-info {
        touch-action: pan-y !important;
    }
}

/* Mobile landscape optimization - increased breakpoint for larger phones like Pixel 9 */
@media (max-width: 1024px) and (orientation: landscape) {
    html, body {
        overflow: hidden !important;
        height: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    #game-wrapper {
        padding: 0 !important;
        gap: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        max-width: 100vw !important;
        overflow: hidden !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Compact header bar at top - KEEP VISIBLE for login/settings */
    #game-header {
        position: relative !important;
        flex-shrink: 0 !important;
        height: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
        padding: 2px 8px !important;
        margin: 0 !important;
        background: rgba(10, 10, 30, 0.95) !important;
        z-index: 100 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    
    /* Shrink game title and move to right side near config button */
    #game-header .game-title {
        display: block !important;
        position: absolute !important;
        right: 50px !important; /* Position to left of config button */
        top: 50% !important;
        transform: translateY(-50%) scale(0.35) !important;
        transform-origin: right center !important;
        margin: 0 !important;
        padding: 0 !important;
        white-space: nowrap !important;
    }
    
    .game-title .title-chibi,
    .game-title .title-brawlers,
    .game-title .title-subtitle {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
    }
    
    /* Compact auth/user buttons */
    #game-header .auth-buttons,
    #game-header .user-info {
        transform: scale(0.8);
        transform-origin: left center;
    }
    
    /* Game container takes remaining space below header */
    #game-container {
        position: relative !important;
        flex: 1 !important;
        width: 100% !important;
        height: calc(100vh - 36px) !important;
        height: calc(100dvh - 36px) !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        z-index: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    #game-container::before {
        display: none !important;
    }
    
    /* Canvas sizing - let Phaser handle scaling */
    #game-container canvas {
        max-width: 100% !important;
        max-height: 100% !important;
        display: block !important;
        background: #0a0a12 !important;
    }
    
    /* Hide keyboard controls info on mobile */
    #controls-info {
        display: none !important;
    }
    
    /* Mode toggle - hide on mobile landscape to save space */
    #mode-toggle {
        display: none !important;
    }
    
    /* Prompt panel - keep functional but hidden unless overlay */
    #prompt-panel:not(.overlay-mode) {
        display: none !important;
    }
    
    /* Mobile controls overlaid on game */
    #mobile-controls {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 500 !important;
        pointer-events: none;
    }
    
    /* Make control buttons clickable */
    #mobile-controls > * {
        pointer-events: auto;
    }
}

/* ============================================
   PORTRAIT MODE - LANDSCAPE WARNING
   ============================================ */

/* Force landscape orientation warning - always on top */
#landscape-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 100000; /* Above everything */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Exo 2', sans-serif;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

#landscape-warning .rotate-icon {
    font-size: 80px;
    animation: rotatePhone 2s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-20deg); }
    75% { transform: rotate(90deg); }
}

#landscape-warning h2 {
    font-family: 'Bangers', cursive;
    font-size: 28px;
    color: #f4d03f;
    margin-bottom: 10px;
}

#landscape-warning p {
    font-size: 16px;
    opacity: 0.8;
}

/* Show landscape warning and hide game in portrait mode on mobile */
@media screen and (max-width: 1024px) and (orientation: portrait) {
    #landscape-warning {
        display: flex !important;
    }
    
    /* Hide game container and controls in portrait */
    #game-container {
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    #mobile-controls {
        display: none !important;
    }
    
    /* Keep controls-info hidden too */
    #controls-info {
        display: none !important;
    }
    
    /* Hide mode toggle */
    #mode-toggle {
        display: none !important;
    }
    
    /* Hide prompt panel unless in overlay mode */
    #prompt-panel:not(.overlay-mode) {
        display: none !important;
    }
}

/* =================== */
/* REPLAY STYLES       */
/* =================== */

.view-replays-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 15px;
    margin-top: 10px;
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    border: none;
    border-radius: 8px;
    color: white;
    font-family: 'Exo 2', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.view-replays-btn:hover {
    background: linear-gradient(135deg, #a569bd, #9b59b6);
    transform: translateY(-1px);
}

.view-replays-btn .replay-icon {
    font-size: 18px;
}

/* Replays Modal */
.replays-modal-content {
    max-width: 500px;
    width: 90%;
}

.replays-info {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 20px;
}

.replays-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.replays-loading {
    text-align: center;
    color: var(--text-dim);
    padding: 20px;
}

.no-replays {
    text-align: center;
    padding: 30px;
    color: var(--text-dim);
}

.no-replays .replays-hint {
    font-size: 13px;
    margin-top: 10px;
    opacity: 0.7;
}

/* Individual replay card */
.replay-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.replay-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(244, 208, 63, 0.3);
}

.replay-thumbnail {
    width: 80px;
    height: 45px;
    border-radius: 6px;
    background: #1a1a2e;
    object-fit: cover;
    flex-shrink: 0;
}

.replay-info {
    flex: 1;
    min-width: 0;
}

.replay-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.replay-meta {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}

.replay-finish-type {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.replay-finish-type.special {
    background: #ff6600;
    color: white;
}

.replay-finish-type.heavy {
    background: #e74c3c;
    color: white;
}

.replay-finish-type.light {
    background: #3498db;
    color: white;
}

.replay-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

.replay-play-btn,
.replay-delete-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.replay-play-btn {
    background: #9b59b6;
    color: white;
}

.replay-play-btn:hover {
    background: #a569bd;
}

.replay-delete-btn {
    background: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.replay-delete-btn:hover {
    background: #e74c3c;
    color: white;
}

/* ============================================
   MATCH HISTORY STYLES
   ============================================ */

.view-history-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 15px;
    margin-top: 8px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: none;
    border-radius: 8px;
    color: white;
    font-family: 'Exo 2', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.view-history-btn:hover {
    background: linear-gradient(135deg, #5dade2, #3498db);
    transform: translateY(-1px);
}

.view-history-btn .history-icon {
    font-size: 18px;
}

/* Daily Match Limit Info */
.daily-limit-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    margin-top: 10px;
    background: rgba(52, 152, 219, 0.15);
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 13px;
}

.daily-limit-info .limit-icon {
    font-size: 16px;
}

.daily-limit-info.limit-reached {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

/* History Modal */
.history-modal-content {
    max-width: 550px;
    width: 90%;
}

.history-info {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 20px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.history-loading {
    text-align: center;
    padding: 30px;
    color: var(--text-dim);
}

.no-history {
    text-align: center;
    padding: 30px;
    color: var(--text-dim);
}

.no-history .history-hint {
    font-size: 13px;
    margin-top: 10px;
    opacity: 0.7;
}

/* Individual match history item */
.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 4px solid #7f8c8d;
}

.history-item.victory {
    border-left-color: #2ecc71;
}

.history-item.defeat {
    border-left-color: #e74c3c;
}

.history-result-badge {
    font-size: 24px;
    width: 40px;
    text-align: center;
}

.history-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-opponent {
    font-weight: 600;
    color: white;
    font-size: 14px;
}

.history-opponent .opponent-type {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: normal;
    margin-left: 5px;
}

.history-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-dim);
}

.history-exp {
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-exp.positive {
    color: #2ecc71;
}

.history-exp.negative {
    color: #e74c3c;
}

.history-time {
    font-size: 11px;
    color: var(--text-dim);
    opacity: 0.7;
}
