/* ============================================================
   🌈 CLOUD DASHER — 3D Music Rhythm Game
   ============================================================ */

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

html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: #5faee3;
    font-family: 'Rajdhani', 'Segoe UI', sans-serif;
    color: #e0e6f0;
    cursor: default;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Canvas ── */
#main-canvas {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0; display: block;
}

/* ============================================================
   HUD
   ============================================================ */
#hud {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10; pointer-events: none;
    display: flex; flex-direction: column;
    justify-content: space-between;
}

/* ── Top Left: Score / Combo ── */
#hud-top-left {
    pointer-events: none;
    position: fixed; top: 12px; left: 290px;
    display: flex; gap: 20px; z-index: 20;
}

#score-display, #combo-display, #multiplier-display {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(100,180,255,0.4);
    border-radius: 8px;
    padding: 6px 16px;
    min-width: 80px;
    backdrop-filter: blur(6px);
}

.hud-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.65em; font-weight: 400;
    color: #5577aa; letter-spacing: 2px;
}

#score-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.6em; font-weight: 900;
    color: #ffcc00;
    text-shadow: 0 0 12px rgba(255,204,0,0.6);
}

#combo-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.4em; font-weight: 700;
    color: #33ffaa;
    text-shadow: 0 0 10px rgba(51,255,170,0.5);
    transition: transform 0.1s, color 0.2s;
}

#combo-display.combo-flash #combo-value {
    transform: scale(1.5);
    color: #fff;
}

#multiplier-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.3em; font-weight: 700;
    color: #ff66aa;
    text-shadow: 0 0 10px rgba(255,102,170,0.5);
}

/* ── Top Center: Track ── */
#hud-top-center {
    pointer-events: auto;
    position: fixed; top: 0; left: 290px; right: 200px;
    display: flex; flex-direction: column; align-items: stretch;
    z-index: 15;
}

#spectrum-bar {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0; display: block;
    background: rgba(255,255,255,0.2);
    border-bottom: 1px solid rgba(100,180,255,0.3);
    box-shadow: 0 0 15px rgba(100,180,255,0.2);
}

#now-playing {
    position: relative; z-index: 1;
    text-align: center; padding: 8px 20px;
}

#track-title {
    font-family: 'Orbitron', monospace;
    font-size: 1.2em; font-weight: 700;
    letter-spacing: 2px; color: #fff;
    text-shadow: 0 0 14px rgba(255,200,100,0.9), 0 0 35px rgba(255,150,50,0.5);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 0 0 14px rgba(255,200,100,0.9), 0 0 35px rgba(255,150,50,0.5); }
    100% { text-shadow: 0 0 18px rgba(255,120,180,0.9), 0 0 45px rgba(255,120,180,0.5); }
}

#track-folder {
    font-size: 0.8em; color: #bbddff; margin-top: 2px; font-weight: 300;
    text-shadow: 0 0 5px rgba(0,0,0,1);
}

/* ── Top Right: Energy ── */
#hud-top-right {
    pointer-events: none;
    position: fixed; top: 12px; right: 16px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 20; align-items: flex-end;
}

#energy-display, #speed-display {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(100,180,255,0.4);
    border-radius: 8px; padding: 6px 14px;
    backdrop-filter: blur(6px);
}

#energy-bar-wrap {
    width: 120px; height: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px; overflow: hidden;
    border: 1px solid rgba(100,200,255,0.4);
    margin-top: 3px;
}

#energy-bar-fill {
    width: 100%; height: 100%;
    background: linear-gradient(90deg, #66ddff, #44bbee);
    border-radius: 6px;
    transform-origin: left center;
    transition: transform 0.3s;
    box-shadow: 0 0 10px rgba(100,200,255,0.4);
}

#speed-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.2em; font-weight: 700;
    color: #3399bb;
    text-shadow: 0 0 8px rgba(51,153,187,0.5);
}

/* ── Sway Mode Indicator ── */
#sway-display {
    flex-direction: column; align-items: center;
    background: rgba(255,200,240,0.5);
    border: 2px solid rgba(255,120,200,0.6);
    border-radius: 8px; padding: 6px 14px;
    backdrop-filter: blur(6px);
    animation: swayPulse 0.5s ease-in-out infinite alternate;
}

@keyframes swayPulse {
    0% { border-color: rgba(255,120,200,0.6); box-shadow: 0 0 10px rgba(255,120,200,0.3); }
    100% { border-color: rgba(100,220,255,0.6); box-shadow: 0 0 20px rgba(100,220,255,0.4); }
}

#sway-timer {
    font-family: 'Orbitron', monospace;
    font-size: 1.3em; font-weight: 900;
    color: #dd66aa;
    text-shadow: 0 0 10px rgba(221,102,170,0.7);
}

/* ── Input Indicators ── */
#input-indicators {
    pointer-events: none;
    position: fixed; bottom: 140px; left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 16px; z-index: 20;
}

.key-indicator {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 10px; padding: 8px 14px;
    min-width: 60px;
    transition: all 0.1s;
}

.key-indicator.active {
    border-color: #33ccff;
    background: rgba(51,204,255,0.2);
    box-shadow: 0 0 20px rgba(51,204,255,0.4);
    transform: scale(1.15);
}

/* ── Level Indicator ── */
#level-indicator {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,204,0,0.3);
    border-radius: 10px; padding: 6px 16px;
    min-width: 60px;
}

#level-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.6em; color: #aab; margin-bottom: 4px;
}

#level-dots {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}

.level-dot {
    font-size: 0.9em; color: rgba(255,255,255,0.2);
    transition: all 0.2s ease;
    line-height: 1;
}

.level-dot.active {
    color: #44aadd;
    text-shadow: 0 0 10px rgba(68,170,221,0.6);
    transform: scale(1.3);
}

#level-dot-1.active {
    color: #ffbb44;
    text-shadow: 0 0 10px rgba(255,187,68,0.6);
}

#level-dot-2.active {
    color: #ff8866;
    text-shadow: 0 0 10px rgba(255,136,102,0.6);
}

/* ── Difficulty Selector ── */
#difficulty-selector {
    margin: 16px 0;
    padding: 14px 20px;
    background: rgba(200,230,255,0.4);
    border: 1px solid rgba(100,180,255,0.3);
    border-radius: 12px;
}

#diff-buttons {
    display: flex; gap: 10px; justify-content: center;
}

.diff-btn {
    font-family: 'Orbitron', monospace;
    font-size: 0.8em; font-weight: 700;
    padding: 8px 18px; border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.2);
    color: #ccc; cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: all;
}

.diff-btn:hover {
    border-color: rgba(51,204,255,0.5);
    background: rgba(51,204,255,0.1);
    color: #fff;
}

.diff-btn.active {
    border-color: #33ccff;
    background: rgba(51,204,255,0.2);
    color: #33ccff;
    box-shadow: 0 0 15px rgba(51,204,255,0.3);
}

.diff-btn[data-diff="easy"].active {
    border-color: #33ff66;
    background: rgba(51,255,102,0.15);
    color: #33ff66;
    box-shadow: 0 0 15px rgba(51,255,102,0.3);
}

.diff-btn[data-diff="hard"].active {
    border-color: #ff4444;
    background: rgba(255,68,68,0.15);
    color: #ff4444;
    box-shadow: 0 0 15px rgba(255,68,68,0.3);
}

.key-letter {
    font-family: 'Orbitron', monospace;
    font-size: 1.2em; font-weight: 700; color: #fff;
}

.key-hint {
    font-size: 0.65em; color: #8899bb; margin-top: 2px;
}

/* ── Hit Feedback ── */
#hit-feedback {
    pointer-events: none;
    position: fixed; top: 40%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', monospace;
    font-size: 2.5em; font-weight: 900;
    z-index: 25; opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    text-shadow: 0 0 20px currentColor;
}

#hit-feedback.show {
    opacity: 1;
    transform: translate(-50%, -60%);
}

#hit-feedback.perfect { color: #ffbb00; }
#hit-feedback.great { color: #44ccaa; }
#hit-feedback.good { color: #44aadd; }
#hit-feedback.miss { color: #ee5566; }

/* ── Bottom bar ── */
#hud-bottom {
    pointer-events: auto;
    padding: 8px 20px 12px;
    margin-left: 280px;
    background: linear-gradient(0deg, rgba(180,215,240,0.85) 0%, rgba(200,230,255,0.5) 60%, transparent 100%);
    backdrop-filter: blur(6px);
    border-top: 1px solid rgba(100,180,255,0.25);
}

#transport {
    display: flex; justify-content: center;
    gap: 6px; margin-bottom: 6px;
}

#transport button {
    background: rgba(255,255,255,0.35);
    border: 1px solid rgba(100,180,255,0.4);
    color: #3366aa; font-size: 1.3em;
    width: 44px; height: 38px;
    border-radius: 8px; cursor: pointer;
    transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}

#transport button:hover {
    background: rgba(100,180,255,0.3);
    border-color: rgba(100,180,255,0.6);
    color: #224488;
    box-shadow: 0 0 12px rgba(100,180,255,0.3);
}

#transport button:active { transform: scale(0.9); }

.toggle-btn.active {
    background: rgba(100,180,255,0.35) !important;
    border-color: #4499cc !important;
    color: #224488 !important;
    box-shadow: 0 0 10px rgba(100,200,255,0.4);
}

/* Progress bar */
#progress-row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}

#time-current, #time-total {
    font-family: 'Orbitron', monospace;
    font-size: 0.75em; color: #556688; min-width: 40px;
}
#time-total { text-align: right; }

#progress-wrapper {
    flex: 1; height: 6px; position: relative;
    background: rgba(255,255,255,0.25); border-radius: 3px;
    cursor: pointer;
}

#progress-bg { position: absolute; inset: 0; border-radius: 3px; }

#progress-fill {
    position: absolute; top: 0; left: 0;
    height: 100%; width: 100%; border-radius: 3px;
    background: linear-gradient(90deg, #4499cc, #66bbee);
    box-shadow: 0 0 8px rgba(100,180,255,0.5);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 0.1s linear;
}

#progress-bar {
    position: absolute; top: -6px; left: 0;
    width: 100%; height: 18px;
    -webkit-appearance: none; appearance: none;
    background: transparent; cursor: pointer;
    z-index: 2;
}

#progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #4499cc;
    border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(100,180,255,0.5);
}

/* Bottom row */
#bottom-row {
    display: flex; align-items: center; gap: 14px;
    justify-content: space-between;
}

#volume-wrap {
    display: flex; align-items: center; gap: 6px;
}

#volume-slider {
    width: 80px; height: 4px;
    -webkit-appearance: none; appearance: none;
    background: rgba(255,255,255,0.15); border-radius: 2px;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #4499cc;
    border: 1px solid #fff;
}

#gamepad-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.8em; color: #667788;
}

#gamepad-status.connected { color: #44aa88; }
#gamepad-status.connected #gamepad-icon { filter: none; }

#btn-fullscreen {
    background: rgba(255,255,255,0.35);
    border: 1px solid rgba(100,180,255,0.4);
    color: #3366aa; font-size: 1.2em;
    width: 38px; height: 34px;
    border-radius: 8px; cursor: pointer;
    transition: all 0.15s;
}

#btn-fullscreen:hover {
    background: rgba(100,180,255,0.3);
    color: #224488;
}

/* ============================================================
   START SCREEN
   ============================================================ */
#start-screen {
    position: fixed; top: 0; right: 0; bottom: 0; left: 280px;
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(135,206,235,0.92) 0%, rgba(95,175,230,0.96) 100%);
    animation: startFadeIn 0.5s ease-out;
}

@keyframes startFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#start-content {
    text-align: center; max-width: 500px; padding: 40px;
}

#start-title {
    font-family: 'Orbitron', monospace;
    font-size: 3em; font-weight: 900;
    color: #fff; letter-spacing: 6px;
    text-shadow: 0 0 30px rgba(255,200,100,0.8), 0 0 60px rgba(255,120,180,0.5);
    margin-bottom: 16px;
    animation: titlePulse 2s ease-in-out infinite alternate;
}

@keyframes titlePulse {
    0% { text-shadow: 0 0 30px rgba(255,200,100,0.8), 0 0 60px rgba(255,120,180,0.5); transform: scale(1); }
    100% { text-shadow: 0 0 40px rgba(255,120,180,0.8), 0 0 80px rgba(255,200,100,0.5); transform: scale(1.02); }
}

#start-subtitle {
    font-size: 1.1em; color: #334466; line-height: 1.6;
    margin-bottom: 24px;
}

#start-controls {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 24px;
}

.control-row {
    display: flex; align-items: center; justify-content: center; gap: 12px;
}

.ctrl-key {
    font-family: 'Orbitron', monospace;
    background: rgba(255,255,255,0.35);
    border: 1px solid rgba(100,180,255,0.5);
    padding: 4px 12px; border-radius: 6px;
    font-size: 0.85em; color: #3366aa;
    min-width: 100px; text-align: center;
}

.ctrl-desc {
    font-size: 0.9em; color: #445577; min-width: 120px; text-align: left;
}

#start-hint {
    font-size: 0.95em; color: #dd6600;
    animation: hintBlink 1.5s ease-in-out infinite alternate;
}

@keyframes hintBlink {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* ============================================================
   GAME OVER SCREEN
   ============================================================ */
#gameover-screen {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(135,206,235,0.94) 0%, rgba(95,175,230,0.97) 100%);
    animation: startFadeIn 0.5s ease-out;
}

#gameover-content {
    text-align: center; max-width: 450px; padding: 40px;
}

#gameover-title {
    font-family: 'Orbitron', monospace;
    font-size: 2.5em; font-weight: 900;
    color: #ffcc00; letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(255,204,0,0.6);
    margin-bottom: 24px;
}

#gameover-stats {
    display: flex; flex-direction: column; gap: 12px;
    margin-bottom: 28px;
}

.stat-row {
    display: flex; justify-content: space-between;
    padding: 8px 16px;
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(100,180,255,0.3);
    border-radius: 8px;
}

.stat-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.8em; color: #556688; letter-spacing: 2px;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-size: 1.1em; font-weight: 700; color: #2277bb;
}

#gameover-restart {
    font-family: 'Orbitron', monospace;
    font-size: 1em; font-weight: 700;
    background: linear-gradient(135deg, rgba(100,200,255,0.4), rgba(255,150,200,0.4));
    border: 2px solid rgba(100,180,255,0.5);
    color: #fff; padding: 12px 32px;
    border-radius: 10px; cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
    pointer-events: auto;
}

#gameover-restart:hover {
    background: linear-gradient(135deg, rgba(100,200,255,0.6), rgba(255,150,200,0.6));
    border-color: #66bbee;
    box-shadow: 0 0 20px rgba(100,200,255,0.4);
    transform: scale(1.05);
}

/* ============================================================
   PLAYLIST PANEL
   ============================================================ */
#playlist-panel {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; z-index: 150;
    background: linear-gradient(180deg, rgba(180,215,240,0.96) 0%, rgba(160,200,235,0.98) 100%);
    border-right: 1px solid rgba(100,180,255,0.3);
    display: flex; flex-direction: column;
    backdrop-filter: blur(12px);
    box-shadow: 4px 0 30px rgba(100,150,200,0.3);
}

#playlist-header {
    padding: 12px; display: flex; flex-direction: column; gap: 8px;
    border-bottom: 1px solid rgba(100,180,255,0.2);
}

#playlist-title {
    font-family: 'Orbitron', monospace;
    font-size: 1.1em; font-weight: 700; color: #2277bb;
    letter-spacing: 2px;
}

#search-input {
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(100,180,255,0.3);
    color: #334466; padding: 6px 10px;
    border-radius: 6px; font-family: 'Rajdhani', sans-serif;
    font-size: 0.85em; outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: rgba(100,180,255,0.6);
    box-shadow: 0 0 8px rgba(100,180,255,0.3);
}

#search-input::placeholder { color: #8899aa; }

#playlist-list {
    flex: 1; overflow-y: auto; padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(100,180,255,0.3) transparent;
}

#playlist-list::-webkit-scrollbar { width: 5px; }
#playlist-list::-webkit-scrollbar-thumb {
    background: rgba(100,180,255,0.3); border-radius: 3px;
}

.pl-folder {
    padding: 8px 12px; font-size: 0.8em;
    color: #3366aa; font-weight: 600;
    letter-spacing: 1px; text-transform: uppercase;
    border-top: 1px solid rgba(100,180,255,0.12);
}

.pl-item {
    padding: 8px 12px; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: all 0.1s;
    border-left: 3px solid transparent;
}

.pl-item:hover {
    background: rgba(100,180,255,0.15);
    border-left-color: rgba(100,180,255,0.4);
}

.pl-item.active {
    background: rgba(100,180,255,0.2);
    border-left-color: #4499cc;
}

.pl-item.active .pl-name { color: #2277bb; font-weight: 600; }

.pl-badge { font-size: 1.1em; }

.pl-name {
    flex: 1; font-size: 0.85em; color: #334466;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pl-ext {
    font-size: 0.7em; color: #556677;
    font-family: monospace;
}

/* ── Playlist toggle (mobile) ── */
#playlist-toggle {
    display: none;
    position: fixed; top: 10px; left: 10px;
    z-index: 155; font-size: 1.5em;
    background: rgba(200,230,255,0.8);
    border: 1px solid rgba(100,180,255,0.4);
    color: #2277bb; width: 42px; height: 42px;
    border-radius: 8px; cursor: pointer;
    backdrop-filter: blur(6px);
}

#playlist-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(200,230,255,0.4); z-index: 140;
}

#playlist-overlay.visible { display: block; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 768px) {
    #playlist-panel {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    #playlist-panel.open { transform: translateX(0); }
    #playlist-toggle { display: flex; align-items: center; justify-content: center; }
    #start-screen { left: 0; }
    #hud-top-left { left: 60px; }
    #hud-top-center { left: 10px; right: 10px; }
    #hud-bottom { margin-left: 0; }
    #input-indicators { bottom: 160px; }
    .key-indicator { padding: 6px 10px; }
    .key-letter { font-size: 1em; }
    #start-title { font-size: 2em; }
}
