@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');

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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    user-select: none;
    -webkit-user-select: none
}

#gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block
}

/* Loading */
#loading {
    position: fixed;
    inset: 0;
    background: #08080c;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 1s ease
}

#loading.hidden {
    opacity: 0;
    pointer-events: none
}

.ld-title {
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: 0.4em;
    color: rgba(255, 255, 255, 0.7)
}

.ld-bar {
    width: 120px;
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-top: 1.5rem;
    overflow: hidden
}

.ld-fill {
    width: 100%;
    height: 100%;
    background: rgba(212, 165, 116, 0.6);
    animation: ldAnim 1.5s ease-in-out infinite
}

@keyframes ldAnim {
    0% {
        transform: translateX(-100%)
    }

    100% {
        transform: translateX(100%)
    }
}

/* HUD */
#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10
}

#title {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 0.4em;
    color: rgba(255, 255, 255, 0.35);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4)
}

/* Control Bar */
#control-bar {
    position: absolute;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.5rem;
    background: rgba(12, 10, 8, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(212, 165, 116, 0.1);
    pointer-events: auto;
}

.ctrl-group {
    position: relative
}

.ctrl-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.65rem;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ctrl-btn:hover {
    background: rgba(212, 165, 116, 0.12);
    color: rgba(255, 255, 255, 0.9)
}

.ctrl-btn.active {
    background: rgba(212, 165, 116, 0.18);
    color: #d4a574;
    border: 1px solid rgba(212, 165, 116, 0.2)
}

.ctrl-icon {
    font-size: 0.8rem;
    line-height: 1
}

.ctrl-label {
    font-size: 0.65rem;
    letter-spacing: 0.03em
}

.ctrl-sep {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0 0.15rem
}

.ctrl-toggle.active {
    background: rgba(212, 165, 116, 0.2);
    color: #d4a574
}

/* Dropdowns */
.ctrl-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    min-width: 110px;
    padding: 0.4rem;
    background: rgba(12, 10, 8, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 10px;
    border: 1px solid rgba(212, 165, 116, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.ctrl-dropdown.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1)
}

/* Generic popup panel (music, custom-water colors). Same look as dropdowns. */
.ctrl-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    min-width: 180px;
    padding: 0.55rem 0.65rem;
    background: rgba(12, 10, 8, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 10px;
    border: 1px solid rgba(212, 165, 116, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    z-index: 50;
}

.ctrl-popup.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}

.popup-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
}

.popup-lbl {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: 'Outfit', sans-serif;
    min-width: 50px;
}

.popup-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.popup-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #d4a574;
    border-radius: 50%;
    cursor: pointer;
}

.popup-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #d4a574;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.popup-action {
    padding: 0.4rem 0.6rem;
    border: 1px solid rgba(212, 165, 116, 0.25);
    background: rgba(212, 165, 116, 0.08);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 6px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.68rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.popup-action:hover {
    background: rgba(212, 165, 116, 0.18);
}

.popup-song {
    font-size: 0.64rem;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Outfit', sans-serif;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.popup-btn-row {
    display: flex;
    gap: 0.4rem;
}
.popup-btn-row .popup-action {
    flex: 1;
}

.popup-saved-hdr {
    text-align: left;
    margin-top: 0.1rem;
    color: rgba(255, 255, 255, 0.4);
}

/* When the liq dropdown is open, hide the auto-shown custom-water popup so they don't overlap */
.ctrl-group:has(.ctrl-dropdown.open) > #popup-custom-water {
    opacity: 0;
    pointer-events: none;
}

.ctrl-popup input[type="color"] {
    width: 36px;
    height: 22px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
    padding: 1px;
    outline: none;
}

/* Active state for the Retrowave color-mode buttons inside the in-bar popup */
.vibe-color-mode.active {
    background: rgba(212, 165, 116, 0.18);
    border-color: rgba(212, 165, 116, 0.45);
    color: #f3d6a8;
}

/* In Vibe mode: the filter dropdown in br-menu is redundant (retrowave is always on)
   so hide it. This also frees horizontal space so the long Vibe bar doesn't bump into it. */
body.mode-vibe #btn-filter,
body.mode-vibe #btn-filter + .ctrl-dropdown,
body.mode-vibe #br-menu .ctrl-group:has(#btn-filter) { display: none !important; }

/* ── 🎵 Vibe controls bar polish ──
 * Groups of related buttons/sliders sit in pill-shaped cards with a subtle inset shadow.
 * align-items:stretch on the parent + the parent's space-between justify gives us three
 * cards that hug the left edge, center, and right edge of the bar respectively. */
.vibe-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    min-height: 38px; /* keeps the three groups visually balanced even when contents differ */
}
.ctrl-btn.vibe-primary {
    background: rgba(212, 165, 116, 0.12);
    border-color: rgba(212, 165, 116, 0.28);
    color: #f7e3c2;
    font-weight: 500;
    letter-spacing: 0.04em;
}
.ctrl-btn.vibe-primary:hover {
    background: rgba(212, 165, 116, 0.22);
    border-color: rgba(212, 165, 116, 0.55);
    color: #fff;
}
.ctrl-btn.vibe-primary.active {
    background: rgba(255, 130, 130, 0.22);
    border-color: rgba(255, 130, 130, 0.55);
    color: #fff;
}
.vibe-song-name {
    display: none;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 4px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    margin-left: 4px;
}
.wave-ctrl.locked {
    opacity: 0.45;
    cursor: not-allowed;
}
.wave-ctrl.locked input[type="range"] {
    cursor: not-allowed;
    pointer-events: none;
}

/* 🎨 Custom-palette dropdown — wider than other vibe dropdowns so the 2×2 color grid fits */
.vibe-colors-drop {
    min-width: 240px;
    padding: 8px 10px !important;
}
.vibe-colors-modes {
    display: flex;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}
.vibe-mode-radio {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 3px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.vibe-mode-radio:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.vibe-mode-radio input[type="radio"] { cursor: pointer; }
.vibe-colors-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    padding: 4px 2px 2px;
}
.vibe-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.66rem;
    color: rgba(255, 255, 255, 0.7);
    padding: 2px 0;
    cursor: pointer;
}
.vibe-color-row input[type="color"] {
    width: 34px;
    height: 22px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    padding: 1px;
}

.vibe-popup input[type="color"] {
    width: 36px;
    height: 22px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
    padding: 1px;
    outline: none;
}

.drop-opt {
    padding: 0.4rem 0.6rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.68rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.drop-opt:hover {
    background: rgba(212, 165, 116, 0.1);
    color: #fff
}

.drop-opt.active {
    background: rgba(212, 165, 116, 0.15);
    color: #d4a574
}

/* Wave Slider */
.wave-ctrl {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.3rem
}

.wave-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 70px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.wave-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #d4a574;
    border: none;
    cursor: pointer;
}

.wave-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #d4a574;
    border: none;
    cursor: pointer
}

/* Stats */
#stats-bar {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.8rem;
    background: rgba(12, 10, 8, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 0.2rem
}

.stat-v {
    font-size: 0.8rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.02em
}

.stat-u {
    font-size: 0.55rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.3)
}

.stat-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15)
}

/* Hint */
#hint {
    position: absolute;
    bottom: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    font-weight: 300;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.3);
    white-space: nowrap;
    animation: fadeHint 8s ease forwards;
}

@keyframes fadeHint {

    0%,
    50% {
        opacity: 1
    }

    100% {
        opacity: 0;
        pointer-events: none
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.shake {
    animation: shake 0.2s ease-in-out 0s 2;
    border-color: #f00 !important;
}