:root {
    --bg-color: #020205;
    --panel-bg: rgba(10, 10, 15, 0.95);
    --panel-border: rgba(255, 255, 255, 0.08);
    --accent-color: #00f3ff;
    --accent-secondary: #ff0055;
    --text-color: #ffffff;
    --text-muted: #888888;
    --header-height: 80px;
    --grid-size: 20;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: rgba(5, 5, 10, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    z-index: 100;
    position: relative;
}

.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 6px;
    text-shadow: 0 0 10px #fff, 0 0 20px var(--accent-color);
    color: var(--accent-color);
}

.header-right {
    display: flex;
    gap: 12px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    transition: 0.3s;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.3s;
    border: none;
    font-family: 'Orbitron', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, #00f3ff, #0066ff);
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
}

.btn-large {
    padding: 16px 48px;
    font-size: 14px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 11px;
}

/* Main Container */
.app-container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Active Effect Display - Above Canvas */
.active-effect-display {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: linear-gradient(135deg, rgba(0, 243, 255, 0.2), rgba(0, 243, 255, 0.08));
    border: 3px solid var(--accent-color);
    border-radius: 16px;
    padding: 24px 50px;
    box-shadow: 0 0 40px rgba(0, 243, 255, 0.9), inset 0 0 25px rgba(0, 243, 255, 0.5);
    backdrop-filter: blur(15px);
    animation: effectPulse 2s ease-in-out infinite;
    text-align: center;
    min-width: 350px;
    max-width: 500px;
}

.active-effect-display.hidden {
    display: none;
}

.effect-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 36px;
    font-weight: 900;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 5px;
    text-shadow: 0 0 25px currentColor, 0 0 50px currentColor, 0 0 75px currentColor;
    margin-bottom: 10px;
    line-height: 1.2;
}

.effect-timer {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
    opacity: 0.95;
    margin-top: 4px;
}

@keyframes effectPulse {
    0%, 100% { 
        opacity: 1; 
        transform: translateX(-50%) scale(1);
        box-shadow: 0 0 50px rgba(0, 243, 255, 1), 0 0 80px rgba(0, 243, 255, 0.6), inset 0 0 30px rgba(0, 243, 255, 0.5);
    }
    50% { 
        opacity: 0.95; 
        transform: translateX(-50%) scale(1.03);
        box-shadow: 0 0 60px rgba(0, 243, 255, 1.2), 0 0 100px rgba(0, 243, 255, 0.8), inset 0 0 35px rgba(0, 243, 255, 0.6);
    }
}

.arena-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(0, 243, 255, 0.05) 0%, var(--bg-color) 100%);
    overflow: hidden;
    min-height: 0;
}

#game-canvas {
    display: block;
    background: var(--bg-color);
    border: 2px solid rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.1), inset 0 0 50px rgba(0, 243, 255, 0.05);
    max-width: 100vw;
    max-height: calc(100vh - 80px);
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

#score-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
}

#score-panel span {
    color: #fff;
}

#mode-display {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    background: rgba(0, 243, 255, 0.1);
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

.mode-badge, .power-up-badge, .combo-badge {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.power-up-badge {
    position: absolute;
    top: 70px;
    right: 20px;
    padding: 8px 16px;
    background: rgba(255, 0, 85, 0.2);
    border: 2px solid var(--accent-secondary);
    border-radius: 8px;
    font-size: 11px;
    color: var(--accent-secondary);
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.8);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.3);
    animation: pulse 1.5s ease-in-out infinite;
}

.combo-badge {
    position: absolute;
    top: 120px;
    right: 20px;
    padding: 8px 16px;
    background: rgba(255, 215, 0, 0.2);
    border: 2px solid #ffd700;
    border-radius: 8px;
    font-size: 11px;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    animation: scale-pulse 0.5s ease-in-out;
}

.combo-badge.hidden {
    display: none;
}

.power-up-badge.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

@keyframes scale-pulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

#announcer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 56px;
    font-weight: 900;
    color: var(--accent-color);
    text-shadow: 0 0 25px rgba(0, 243, 255, 1), 0 0 50px rgba(0, 243, 255, 0.9), 0 0 80px rgba(0, 243, 255, 0.7);
    letter-spacing: 10px;
    text-align: center;
    pointer-events: none;
    z-index: 300;
    opacity: 0;
    display: block;
}

#sub-announcer {
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-secondary);
    text-shadow: 0 0 20px rgba(255, 0, 85, 1), 0 0 40px rgba(255, 0, 85, 0.9);
    letter-spacing: 4px;
    text-align: center;
    pointer-events: none;
    z-index: 300;
    opacity: 0;
    display: block;
}

@keyframes announcePop {
    0% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

.controls-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    letter-spacing: 2px;
}

/* Food Ledger */
.food-ledger {
    position: absolute;
    bottom: 60px;
    right: 20px;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid rgba(0, 243, 255, 0.3);
    border-radius: 8px;
    padding: 12px;
    min-width: 200px;
    max-width: 220px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    z-index: 15;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
    backdrop-filter: blur(10px);
}

.ledger-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 243, 255, 0.2);
    letter-spacing: 1px;
}

.ledger-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.ledger-items::-webkit-scrollbar {
    width: 4px;
}

.ledger-items::-webkit-scrollbar-thumb {
    background: rgba(0, 243, 255, 0.3);
    border-radius: 2px;
}

.ledger-item {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    position: relative;
    padding-left: 11px;
    transition: background 0.2s;
}

.ledger-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ledger-name {
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 2px;
    text-shadow: 0 0 8px currentColor;
}

.ledger-desc {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2px;
}

.ledger-points {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.ledger-count {
    position: absolute;
    top: 6px;
    right: 8px;
    background: var(--accent-color);
    color: #000;
    font-weight: 900;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-family: 'Orbitron', sans-serif;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
    min-width: 20px;
    text-align: center;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 2, 5, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fade-in 0.3s ease-in-out;
}

.overlay.hidden {
    display: none;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-content {
    text-align: center;
    padding: 40px;
    max-width: 600px;
}

.title-main {
    font-family: 'Orbitron', sans-serif;
    font-size: 64px;
    font-weight: 900;
    color: var(--accent-color);
    text-shadow: 0 0 20px rgba(0, 243, 255, 1), 0 0 40px rgba(0, 243, 255, 0.8);
    letter-spacing: 12px;
    margin-bottom: 30px;
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { text-shadow: 0 0 20px rgba(0, 243, 255, 1), 0 0 40px rgba(0, 243, 255, 0.8); }
    50% { text-shadow: 0 0 30px rgba(0, 243, 255, 1), 0 0 60px rgba(0, 243, 255, 1); }
}

#last-score-info {
    margin-bottom: 30px;
}

#last-score-info .label {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

#last-score-info #last-run-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
}

/* Mode Selection */
.mode-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 30px 0;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
}

.mode-btn.active {
    background: rgba(0, 243, 255, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.4);
}

.mode-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.mode-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
    margin-bottom: 4px;
    letter-spacing: 2px;
}

.mode-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.mode-best {
    font-size: 10px;
    color: var(--text-muted);
}

.mode-best-value {
    color: var(--accent-color);
    font-weight: 700;
}

.description {
    font-size: 14px;
    color: var(--text-muted);
    margin: 30px 0;
    line-height: 1.6;
}

.button-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 30px;
}

/* Game Over Screen */
#final-score-display {
    margin: 30px 0;
}

#final-score-display .label {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 12px;
}

#final-score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 56px;
    font-weight: 900;
    color: var(--accent-color);
    text-shadow: 0 0 20px rgba(0, 243, 255, 1);
}

#final-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    font-family: 'Orbitron', sans-serif;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.stat-item span:last-child {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
}

.new-record {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 2px;
    margin: 20px 0;
    animation: record-pulse 1s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

.new-record.hidden {
    display: none;
}

@keyframes record-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Settings Panel */
.controls-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--panel-border);
    z-index: 200;
    transition: right 0.3s ease-in-out;
    overflow-y: auto;
}

.controls-panel.open {
    right: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px;
    border-bottom: 1px solid var(--panel-border);
}

.panel-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 32px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

.panel-content {
    padding: 30px;
}

.panel-content section {
    margin-bottom: 40px;
}

.panel-content h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

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

.control-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.control-group input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 8px;
}

.control-group input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.control-group select {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    cursor: pointer;
}

.control-group select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.stats-display {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--panel-border);
    font-size: 12px;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: var(--text-muted);
}

.stat-row span:last-child {
    color: var(--accent-color);
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
}

/* Responsive */
@media (max-width: 768px) {
    .top-header {
        padding: 0 20px;
    }

    .logo-text {
        font-size: 18px;
        letter-spacing: 3px;
    }

    .mode-selection {
        grid-template-columns: 1fr;
    }

    .title-main {
        font-size: 36px;
        letter-spacing: 6px;
    }

    #announcer {
        font-size: 32px;
    }

    .controls-panel {
        width: 100%;
        right: -100%;
    }

    #score-panel {
        font-size: 12px;
        top: 10px;
        left: 10px;
    }

    #mode-display {
        top: 10px;
        right: 10px;
        font-size: 10px;
        padding: 6px 12px;
    }
}

