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

body {
    background: #0a0a0a;
    color: #ccc;
    font-family: 'Segoe UI', 'SF Pro Display', -apple-system, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

#maze-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-direction: column;
}

#mazeCanvas {
    display: block;
}

#sidebar {
    width: 320px;
    background: #0e0e0e;
    border-left: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

#header {
    padding: 16px 20px;
    border-bottom: 1px solid #1a1a1a;
}

#header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #eee;
    letter-spacing: 0.5px;
}

#header .subtitle {
    font-size: 11px;
    color: #555;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#stats {
    padding: 12px 20px;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #eee;
}

.stat-label {
    font-size: 10px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#phase-display {
    padding: 8px 20px;
    border-bottom: 1px solid #1a1a1a;
}

#phase-text {
    font-size: 12px;
    color: #4ecdc4;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

#controls {
    padding: 12px 20px;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

#controls button {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #aaa;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

#controls button:hover {
    background: #222;
    color: #eee;
    border-color: #444;
}

#controls button.active {
    background: #4ecdc4;
    color: #0a0a0a;
    border-color: #4ecdc4;
}

#speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

#speed-control label {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

#speed-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #2a2a2a;
    border-radius: 2px;
    outline: none;
}

#speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4ecdc4;
    cursor: pointer;
}

#speed-value {
    font-size: 12px;
    color: #888;
    min-width: 36px;
    text-align: right;
}

#event-log {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

#event-log::-webkit-scrollbar {
    width: 4px;
}

#event-log::-webkit-scrollbar-track {
    background: transparent;
}

#event-log::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border-radius: 2px;
}

.event-item {
    padding: 4px 20px;
    font-size: 11px;
    color: #888;
    line-height: 1.5;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    transition: opacity 0.5s;
}

.event-item.old {
    color: #444;
}

.event-item.highlight {
    color: #ffd700;
    font-weight: 600;
}

#legend {
    padding: 12px 20px;
    border-top: 1px solid #1a1a1a;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #666;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Celebration overlay */
#celebration {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(255,215,0,0.1) 0%, transparent 70%);
    animation: celebrationPulse 2s ease-in-out infinite;
}

#celebration.active {
    display: block;
}

@keyframes celebrationPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Keyboard hints */
#hints {
    padding: 8px 20px;
    border-top: 1px solid #1a1a1a;
    font-size: 10px;
    color: #333;
}

#hints kbd {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
    color: #555;
    font-family: inherit;
}

/* Endgame text overlay */
#endgame-text {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 50;
    pointer-events: none;
    font-family: 'Segoe UI', 'SF Pro Display', -apple-system, sans-serif;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.8s ease;
    /* Offset to account for sidebar */
    margin-left: -160px;
}

#endgame-text.visible {
    opacity: 1;
}

#endgame-text .main-text {
    font-size: 28px;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
    margin-bottom: 8px;
}

#endgame-text .sub-text {
    font-size: 16px;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
    letter-spacing: 5px;
}

#endgame-text .final-text {
    font-size: 36px;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.4), 0 0 90px rgba(255, 215, 0, 0.2);
}

/* Charge meter */
#charge-meter {
    display: none;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    z-index: 50;
    pointer-events: none;
    /* Offset to account for sidebar */
    margin-left: -160px;
}

#charge-meter.visible {
    display: block;
}

#charge-meter.complete {
    /* gold gradient for MISSION COMPLETE */
}

#charge-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 4px;
    text-align: center;
    font-weight: 600;
    transition: color 0.5s;
}

#charge-label.gold {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    font-size: 14px;
    letter-spacing: 4px;
}

#charge-bar-bg {
    width: 100%;
    height: 8px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    overflow: hidden;
}

#charge-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4, #45b7aa);
    border-radius: 4px;
    transition: width 0.3s ease, background 0.5s;
}

#charge-bar-fill.gold {
    background: linear-gradient(90deg, #ffd700, #ffaa00, #ffd700);
}

#charge-value {
    font-size: 12px;
    color: #888;
    text-align: center;
    margin-top: 4px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    transition: color 0.5s;
}

#charge-value.gold {
    color: #ffd700;
}

/* Screen shake animation */
@keyframes screenShake {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-2px, 1px); }
    20% { transform: translate(2px, -1px); }
    30% { transform: translate(-1px, 2px); }
    40% { transform: translate(1px, -2px); }
    50% { transform: translate(-2px, -1px); }
    60% { transform: translate(2px, 1px); }
    70% { transform: translate(-1px, -2px); }
    80% { transform: translate(1px, 2px); }
    90% { transform: translate(-2px, 1px); }
    100% { transform: translate(0, 0); }
}

#mazeCanvas.shake {
    animation: screenShake 0.15s ease-in-out 6;
}

/* Flash effect */
@keyframes bgFlash {
    0% { background-color: #0a0a0a; }
    30% { background-color: #1a1812; }
    100% { background-color: #0a0a0a; }
}

#maze-container.flash {
    animation: bgFlash 1s ease-out;
}
