/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: none;
    /* Firefox */
}

*::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Edge */
}

:fullscreen {
    cursor: none;
}

:root {
    --primary: #00f0ff;
    --primary-glow: rgba(0, 240, 255, 0.4);
    --secondary: #ff00e5;
    --secondary-glow: rgba(255, 0, 229, 0.4);
    --accent: #ffae00;
    --accent-glow: rgba(255, 174, 0, 0.4);
    --bg-dark: #0a0a1a;
    --bg-card: rgba(15, 15, 40, 0.85);
    --text: #e0e6ff;
    --text-dim: rgba(224, 230, 255, 0.5);
    --danger: #ff3366;
    --success: #00ff88;
    --border-glow: rgba(0, 240, 255, 0.15);
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Rajdhani', sans-serif;
    color: var(--text);
}

/* ===== GAME CONTAINER ===== */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height — excludes mobile address bar */
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-dark);
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: transparent;
    image-rendering: pixelated;
    will-change: transform;
}

/* ===== OVERLAYS ===== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 100;
    background: rgba(5, 5, 20, 0.97);
    animation: fadeIn 0.4s ease-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 0;
}

/* CRT scan lines overlay on menus */
.overlay::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.06) 2px,
            rgba(0, 0, 0, 0.06) 4px);
    pointer-events: none;
    z-index: 1000;
}

.hidden,
.overlay.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ===== MENU CONTENT ===== */
.menu-content,
.modal-content {
    text-align: center;
    padding: 3rem;
    max-width: 620px;
    width: 95%;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.menu-content {
    min-height: 100%;
}

.modal-content {
    min-height: auto;
    max-height: 95vh;
    max-height: 95dvh;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(10, 10, 35, 0.95), rgba(5, 5, 25, 0.98));
    border: 2px solid rgba(0, 240, 255, 0.25);
    border-radius: 4px;
    padding: 2rem 1.2rem;
    box-shadow:
        0 0 40px rgba(0, 240, 255, 0.1),
        0 0 80px rgba(0, 240, 255, 0.05),
        inset 0 1px 0 rgba(0, 240, 255, 0.15),
        inset 0 0 60px rgba(0, 240, 255, 0.03);
    position: relative;
}

/* Corner accents on modal */
.modal-content::before,
.modal-content::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--primary);
    border-style: solid;
    border-width: 0;
}

.modal-content::before {
    top: -1px;
    left: -1px;
    border-top-width: 2px;
    border-left-width: 2px;
}

.modal-content::after {
    bottom: -1px;
    right: -1px;
    border-bottom-width: 2px;
    border-right-width: 2px;
}

/* ===== TITLE ===== */
.game-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.title-line {
    display: block;
    font-size: 4.5rem;
    letter-spacing: 0.3em;
    margin-right: -0.3em;
    color: var(--primary);
    text-shadow:
        0 0 10px var(--primary-glow),
        0 0 30px var(--primary-glow),
        0 0 60px var(--primary-glow),
        2px 2px 0 rgba(0, 0, 0, 0.8);
    animation: titlePulse 3s ease-in-out infinite;
    -webkit-text-stroke: 1px rgba(0, 240, 255, 0.3);
}

.title-line.accent {
    font-size: 5.5rem;
    letter-spacing: 0.35em;
    margin-right: -0.35em;
    color: var(--secondary);
    text-shadow:
        0 0 10px var(--secondary-glow),
        0 0 30px var(--secondary-glow),
        0 0 60px var(--secondary-glow),
        0 0 100px var(--secondary-glow),
        2px 2px 0 rgba(0, 0, 0, 0.8);
    animation: titlePulse 3s ease-in-out infinite alternate;
    -webkit-text-stroke: 1px rgba(255, 0, 229, 0.3);
}

@keyframes titlePulse {

    0%,
    100% {
        opacity: 0.85;
    }

    50% {
        opacity: 1;
    }
}

.subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.5em;
    color: var(--text-dim);
    margin-bottom: 3rem;
    text-transform: uppercase;
}

/* ===== BUTTONS ===== */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
    margin: 2rem auto;
    width: 100%;
}

.menu-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    padding: 1rem 2.5rem;
    border: 2px solid rgba(0, 240, 255, 0.2);
    border-radius: 2px;
    background: linear-gradient(180deg, rgba(15, 15, 40, 0.7), rgba(10, 10, 30, 0.9));
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 100%;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
}

.menu-btn .btn-icon {
    position: absolute;
    left: 1rem;
    font-size: 1.2rem;
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.12), transparent);
    transition: left 0.4s;
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
    box-shadow:
        0 0 15px var(--primary-glow),
        inset 0 0 15px rgba(0, 240, 255, 0.05);
    transform: scale(1.03);
}

.menu-btn:active {
    transform: scale(0.97);
    background: rgba(0, 240, 255, 0.1);
}

.menu-btn.primary {
    background: linear-gradient(180deg, rgba(0, 240, 255, 0.12), rgba(255, 0, 229, 0.08));
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
    animation: btnPulse 2s ease-in-out infinite;
}

.menu-btn.primary:hover {
    background: linear-gradient(180deg, rgba(0, 240, 255, 0.25), rgba(255, 0, 229, 0.15));
    box-shadow:
        0 0 25px var(--primary-glow),
        0 0 50px rgba(0, 240, 255, 0.1);
    transform: scale(1.05);
    animation: none;
}

.btn-continue-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.continue-level {
    font-size: 0.7em;
    opacity: 0.6;
    letter-spacing: 0.1em;
}

@keyframes btnPulse {

    0%,
    100% {
        box-shadow: 0 0 15px var(--primary-glow);
    }

    50% {
        box-shadow: 0 0 25px var(--primary-glow), 0 0 40px rgba(0, 240, 255, 0.08);
    }
}

.level-code-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
    justify-content: center;
    width: 100%;
}

.level-code-input {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(0, 240, 255, 0.2);
    color: #00f0ff;
    font-family: 'Orbitron', monospace;
    font-size: 0.75rem;
    padding: 8px 14px;
    border-radius: 2px;
    text-align: center;
    letter-spacing: 3px;
    text-transform: uppercase;
    flex: 1;
    min-width: 0;
    outline: none;
    transition: all 0.3s;
}

.level-code-input::placeholder {
    color: rgba(0, 240, 255, 0.3);
    letter-spacing: 2px;
    font-size: 0.65rem;
}

.level-code-input:focus {
    border-color: #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.level-code-input.invalid {
    border-color: #ff3366;
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.3);
    animation: shake 0.3s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.code-btn {
    background: rgba(0, 240, 255, 0.1);
    border: 2px solid rgba(0, 240, 255, 0.2);
    color: #00f0ff;
    font-size: 1.1rem;
    padding: 7px 12px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.3s;
}

.code-btn:hover {
    background: rgba(0, 240, 255, 0.2);
    border-color: #00f0ff;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

/* ===== SETTINGS ===== */
.settings-section {
    width: 100%;
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.12);
    border-radius: 4px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
}

.settings-section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--primary);
    text-shadow: 0 0 8px var(--primary-glow);
    margin: 0 0 0.5rem;
    text-align: left;
}

.volume-controls {
    margin-bottom: 1.2rem;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
    border: 2px solid rgba(0, 240, 255, 0.15);
    width: 100%;
}

.settings-section .volume-controls {
    margin-bottom: 0;
    border: none;
    background: none;
    padding: 0;
}

.volume-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.volume-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1px;
    width: 90px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.vol-icon {
    display: inline-block;
    width: 22px;
    text-align: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.volume-val {
    font-family: 'Orbitron', monospace;
    font-size: 0.6rem;
    color: #00f0ff;
    min-width: 35px;
    text-align: right;
}

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

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00f0ff;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    cursor: pointer;
    transition: transform 0.15s;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00f0ff;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    border: none;
    cursor: pointer;
}

.btn-icon {
    font-size: 1.2rem;
}

/* ===== SCORING GUIDE ===== */

.scoring-modal h2 {
    padding: 0 0.2rem;
}

.scoring-guide {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    gap: 0.5rem;
    margin: 0.5rem 0;
    max-height: 60vh;
    max-height: 60dvh;
    overflow-y: auto;
    padding: 0 2px 0 0;
}

.scoring-guide::-webkit-scrollbar {
    width: 4px;
}

.scoring-guide::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

.scoring-guide::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.3);
    border-radius: 2px;
}

.scoring-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.12);
    border-radius: 4px;
    padding: 0.6rem 1rem;
}

.scoring-section.scoring-danger {
    background: rgba(255, 51, 102, 0.04);
    border-color: rgba(255, 51, 102, 0.2);
}

.scoring-section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--primary);
    text-shadow: 0 0 8px var(--primary-glow);
    margin: 0 0 0.5rem;
}

.scoring-danger .scoring-section-title {
    color: #ff4477;
    text-shadow: 0 0 8px rgba(255, 51, 102, 0.4);
}

.scoring-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    table-layout: fixed;
}

.scoring-table th:first-child,
.scoring-table td:first-child {
    width: 60%;
}

.scoring-table th:last-child,
.scoring-table td:last-child {
    width: 40%;
}

.scoring-table thead th {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.4);
    text-align: left;
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid rgba(0, 240, 255, 0.1);
}

.scoring-table thead th:last-child {
    text-align: right;
}

.scoring-table td {
    padding: 0.25rem 0.4rem;
    color: rgba(255, 255, 255, 0.75);
    border-bottom: none;
    text-align: left;
    vertical-align: top;
}

.scoring-table td:last-child {
    text-align: right;
}

.scoring-table td.pts {
    text-align: right;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.scoring-table td.pts.penalty {
    color: #ff4477;
}

.pu-icon, .pd-icon {
    display: inline-block;
    width: 22px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    color: #fff;
    vertical-align: middle;
    margin-right: 4px;
}

.pd-icon {
    background: #880022;
    border: 1px solid #ff2244;
    border-radius: 4px;
}

.scoring-note-row td {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    font-style: italic;
    padding-top: 0;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(0, 240, 255, 0.12);
    text-align: left !important;
}

.scoring-formula {
    display: inline-block;
    font-family: 'Orbitron', monospace;
    font-size: 0.6rem;
    font-style: normal;
    color: rgba(0, 240, 255, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 2px;
    margin-top: 2px;
}

.scoring-modal .menu-buttons {
    margin: 0.5rem 0 0;
}

@media (max-aspect-ratio: 1/1) {
    .scoring-guide {
        max-height: 55vh;
        max-height: 55dvh;
        gap: 0.4rem;
    }

    .scoring-table {
        font-size: 0.75rem;
    }

    .scoring-table td.pts {
        font-size: 0.65rem;
    }

    .scoring-section-title {
        font-size: 0.6rem;
    }

    .scoring-section {
        padding: 0.5rem 0.7rem;
    }
}

/* ===== CONTROLS GRID ===== */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin: 1rem 0;
    width: 100%;
}

.control-item {
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid var(--border-glow);
    border-radius: 10px;
    padding: 0.6rem;
    pointer-events: none;
    user-select: none;
}

.control-item .key {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.control-item .desc {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ===== LEVEL COMPLETE / GAME OVER ===== */
.level-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--success), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.5rem;
    animation: levelPulse 1s ease-in-out infinite alternate;
}

@keyframes levelPulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.05);
    }
}

.gameover-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    color: var(--danger);
    text-shadow: 0 0 30px rgba(255, 51, 102, 0.5);
    margin-bottom: 1.5rem;
}

.stats {
    margin: 1rem 0;
    font-size: 1.1rem;
    line-height: 1.6;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.stats::-webkit-scrollbar {
    width: 4px;
}

.stats::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

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

.stats .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.8rem;
    border-bottom: 1px solid var(--border-glow);
}

.stats .stat-label {
    color: var(--text-dim);
    font-weight: 500;
}

.stats .stat-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* ===== HUD ===== */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(180deg, rgba(5, 5, 20, 0.9) 0%, transparent 100%);
    z-index: 50;
    font-family: 'Orbitron', sans-serif;
    pointer-events: none;
}

#hud.hidden {
    display: none;
}

.hud-left,
.hud-right {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    z-index: 1;
}

.hud-song {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    color: var(--primary);
    opacity: 0.4;
    letter-spacing: 0.1em;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

.hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    text-shadow: 0 0 8px var(--primary-glow);
    opacity: 0.85;
}

.hud-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 0 6px var(--primary-glow),
        0 0 20px rgba(0, 240, 255, 0.2);
    letter-spacing: 0.05em;
}

.hud-sublabel {
    font-size: 0.6rem;
    color: var(--accent);
    letter-spacing: 0.15em;
    font-weight: 700;
    text-shadow: 0 0 8px var(--accent-glow);
}

.hud-timer {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.15em;
    font-weight: 400;
    font-family: 'Orbitron', monospace;
    margin-top: 1px;
}

.hud-btn {
    cursor: pointer;
    pointer-events: all;
    font-size: 1.3rem;
    transition: transform 0.2s;
}

.hud-btn:hover {
    transform: scale(1.2);
}

/* ===== MENU FOOTER ===== */
.menu-footer {
    margin-top: 2rem;
}

.menu-footer p {
    font-size: 0.85rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

/* ===== MODAL HEADINGS ===== */
.modal-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== RESPONSIVE ===== */

/* Prevent overscroll/bounce on mobile */
html,
body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    touch-action: none;
}

#game-container {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#gameCanvas {
    touch-action: none;
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-top)) {
    #game-container {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Small screens (phones) */
@media (max-width: 600px) {
    .title-line {
        font-size: 2.5rem;
    }

    .title-line.accent {
        font-size: 3.2rem;
    }

    .subtitle {
        font-size: 0.8rem;
        letter-spacing: 0.3em;
        margin-bottom: 1.5rem;
    }

    .menu-content,
    .modal-content {
        padding: 1.2rem 1rem;
    }

    .menu-btn {
        min-width: 200px;
        padding: 0.7rem 1.2rem;
        font-size: 0.8rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .hud-value {
        font-size: 1rem;
    }

    .hud-label {
        font-size: 0.55rem;
    }

    #hud {
        padding: 0.4rem 0.8rem;
    }

    .hud-left,
    .hud-right {
        gap: 0.8rem;
    }

    .modal-content h2 {
        font-size: 1.5rem;
    }

    .stats {
        font-size: 1rem;
    }

    .menu-footer p {
        font-size: 0.7rem;
    }

    #btn-controls,
    .menu-footer {
        display: none;
    }
}

/* Portrait orientation */
@media (max-aspect-ratio: 1/1) {
    .leaderboard-modal {
        min-width: 0;
    }

    .lb-level-name {
        display: none;
    }

    .title-line {
        font-size: 2rem;
        letter-spacing: 0.2em;
        margin-right: -0.2em;
    }

    .title-line.accent {
        font-size: 2.6rem;
        letter-spacing: 0.25em;
        margin-right: -0.25em;
    }

    .subtitle {
        font-size: 0.7rem;
        letter-spacing: 0.2em;
        margin-bottom: 1rem;
    }

    .menu-content {
        padding: 1rem;
    }

    .menu-btn {
        min-width: 180px;
        padding: 0.65rem 1rem;
        font-size: 0.75rem;
    }

    .menu-buttons {
        gap: 0.7rem;
        margin: 1rem 0;
    }

    .modal-content {
        padding: 0.8rem 0.7rem;
        max-height: 88vh;
        max-height: 88dvh;
        overflow-y: auto;
    }

    .modal-content h2 {
        font-size: 1.3rem;
        letter-spacing: 0.15em;
        margin-bottom: 0.5rem;
    }

    .level-title {
        font-size: 1.2rem;
        margin-bottom: 0.3rem;
    }

    .gameover-title {
        font-size: 1.3rem;
        margin-bottom: 0.3rem;
    }

    .stats {
        margin: 0.3rem 0;
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .stats .stat-row {
        padding: 0.2rem 0.4rem;
    }

    .level-record-submit {
        padding: 0.3rem 0.3rem 0;
    }

    .menu-buttons {
        margin: 0.5rem auto;
    }

    .volume-controls {
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.8rem;
    }

    .volume-row {
        padding: 3px 0;
    }

    .menu-buttons {
        gap: 0.5rem;
        margin: 0.5rem 0;
    }

    .menu-btn {
        padding: 0.5rem 0.8rem;
    }

    .level-code-input {
        width: 130px;
        font-size: 0.65rem;
        padding: 6px 10px;
    }



    #hud {
        padding: 0.3rem 0.5rem;
    }

    .hud-left,
    .hud-right {
        gap: 0.5rem;
    }

    .hud-value {
        font-size: 0.85rem;
    }

    .hud-label {
        font-size: 0.5rem;
        letter-spacing: 0.1em;
    }

    .hud-btn {
        font-size: 1rem;
    }

    .hud-song {
        font-size: 0.5rem;
    }



    .menu-footer {
        margin-top: 1rem;
    }

    .menu-footer p {
        font-size: 0.6rem;
    }

    .volume-controls {
        padding: 0.5rem 0.6rem;
    }

    .volume-label {
        font-size: 0.55rem;
        min-width: 55px;
    }

    .volume-val {
        font-size: 0.5rem;
    }
}

/* ===== COMBO POPUP ===== */
.combo-popup {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 2rem;
    pointer-events: none;
    z-index: 200;
    animation: comboFloat 1s ease-out forwards;
    text-shadow: 0 0 20px currentColor;
    contain: layout style;
}

@keyframes comboFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-80px) scale(1.5);
    }
}

/* ===== SCORE POPUP ===== */
.score-popup {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 190;
    animation: scoreFloat 0.9s ease-out forwards;
    text-shadow: 0 0 10px currentColor;
    white-space: nowrap;
    contain: layout style;
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.8);
    }

    20% {
        transform: translateY(-10px) scale(1.1);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
}

/* ===== HIGH SCORE HUD ===== */
.highscore-val {
    color: var(--accent) !important;
    text-shadow: 0 0 10px var(--accent-glow), 0 0 25px rgba(255, 174, 0, 0.2) !important;
    font-size: 1.5rem !important;
    font-weight: 900 !important;
}

/* ===== BONUS STAT COLORS ===== */
.stat-value.bonus-time {
    color: var(--primary);
}

.stat-value.bonus-lives {
    color: var(--danger);
}

.stat-value.bonus-perfect {
    color: #ffdd00;
    text-shadow: 0 0 10px rgba(255, 221, 0, 0.5);
}

.stat-value.bonus-combo {
    color: var(--secondary);
}

.stat-row.level-code {
    margin-top: 0.5rem;
    border-top: 1px solid rgba(0, 240, 255, 0.2);
    padding-top: 0.5rem;
}

.stat-value.code-value {
    color: #00f0ff;
    font-family: 'Orbitron', monospace;
    letter-spacing: 4px;
    text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
    font-size: 1.1rem;
}

/* Total row */
.stats .stat-row.total {
    border-top: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    background: rgba(0, 240, 255, 0.05);
}

.stats .stat-row.total .stat-label,
.stats .stat-row.total .stat-value {
    font-size: 1.1rem;
    color: var(--text);
}

/* High score row */
.stats .stat-row.highscore {
    border: 1px solid var(--accent);
    border-radius: 8px;
    margin-top: 0.75rem;
    background: rgba(255, 174, 0, 0.1);
    animation: highscorePulse 1.5s ease-in-out infinite alternate;
}

.stats .stat-row.highscore .stat-label {
    color: var(--accent);
    font-weight: 700;
}

.stats .stat-row.highscore .stat-value {
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
}

@keyframes highscorePulse {
    from {
        box-shadow: 0 0 10px rgba(255, 174, 0, 0.1);
    }

    to {
        box-shadow: 0 0 25px rgba(255, 174, 0, 0.3);
    }
}

/* Level record row */
.stats .stat-row.level-record {
    border: 1px solid rgba(180, 130, 255, 0.4);
    border-radius: 8px;
    margin-top: 0.75rem;
    background: rgba(120, 80, 200, 0.1);
}

.stats .stat-row.level-record .stat-label {
    color: #bb99ff;
    font-weight: 700;
    font-size: 0.85em;
}

.stats .stat-row.level-record .stat-value {
    color: #bb99ff;
    text-shadow: 0 0 12px rgba(180, 130, 255, 0.5);
}

/* New level record */
.stats .stat-row.level-record.new-record {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.12);
    animation: levelRecordPulse 1.5s ease-in-out infinite alternate;
}

.stats .stat-row.level-record.new-record .stat-label {
    color: #ffd700;
}

.stats .stat-row.level-record.new-record .stat-value {
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

@keyframes levelRecordPulse {
    from {
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
    }

    to {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    }
}

/* Level record name submit */
.level-record-submit {
    text-align: center;
    padding: 0.5rem 0.5rem 0;
}

.level-record-submit .level-code-row {
    justify-content: center;
}

.level-record-submit .submit-status {
    font-size: 0.6rem;
    margin-top: 0.3rem;
    color: #ffd700;
    min-height: 1em;
}

/* ===== POWER-UP / POWER-DOWN POPUP ===== */
.power-popup {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 0.1em;
    pointer-events: none;
    z-index: 250;
    white-space: nowrap;
    animation: powerFloat 1.2s ease-out forwards;
    contain: layout style;
}

.power-popup.positive {
    color: #00ff88;
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.8), 0 0 30px rgba(0, 255, 136, 0.4);
}

.power-popup.negative {
    color: #ff3344;
    text-shadow: 0 0 15px rgba(255, 0, 0, 0.8), 0 0 30px rgba(255, 0, 0, 0.4);
}

@keyframes powerFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.7);
    }

    15% {
        opacity: 1;
        transform: translateY(-10px) scale(1.15);
    }

    30% {
        transform: translateY(-20px) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-70px) scale(0.9);
    }
}

/* Leaderboard */
.leaderboard-modal {
    min-width: 360px;
}

.leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    margin-bottom: 1rem;
    width: 100%;
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    table-layout: fixed;
}

.lb-table th,
.lb-table td {
    padding: 8px 6px;
    text-align: left;
}

.lb-table th {
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.3);
}

.lb-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
}

.lb-table th:nth-child(1),
.lb-table td:nth-child(1) {
    width: 32px;
}

.lb-table th:nth-child(3),
.lb-table td:nth-child(3) {
    width: 45px;
    text-align: center;
}

.lb-table th:nth-child(4),
.lb-table td:nth-child(4) {
    text-align: right;
}

.lb-table th:nth-child(5),
.lb-table td:nth-child(5) {
    width: 72px;
    text-align: right;
}

.lb-table tr:hover td {
    background: rgba(0, 240, 255, 0.05);
}

.lb-rank {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.65rem;
}

.lb-rank-1 {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.lb-rank-2 {
    color: #c0c0c0;
    text-shadow: 0 0 8px rgba(192, 192, 192, 0.4);
}

.lb-rank-3 {
    color: #cd7f32;
    text-shadow: 0 0 8px rgba(205, 127, 50, 0.4);
}

.lb-name {
    color: #fff;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 80px;
}

.lb-score {
    color: var(--primary);
    text-align: right;
    font-weight: 700;
}

.lb-level {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-size: 0.6rem;
}

.lb-date {
    color: rgba(255, 255, 255, 0.35);
    text-align: right;
    font-size: 0.55rem;
    letter-spacing: 0.5px;
}

.lb-you td {
    background: rgba(0, 240, 255, 0.12) !important;
    border-top: 1px solid rgba(0, 240, 255, 0.3);
    border-bottom: 1px solid rgba(0, 240, 255, 0.3);
}

.lb-you .lb-name {
    color: #00f0ff;
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.lb-separator td {
    text-align: center;
    color: rgba(255, 255, 255, 0.2);
    font-size: 1.2rem;
    padding: 0.1rem 0;
    letter-spacing: 4px;
}

/* Level Leaders */
.lb-levels {
    table-layout: auto;
}

.lb-levels th:nth-child(1),
.lb-levels td:nth-child(1) {
    width: auto;
}

.lb-levels th:nth-child(3),
.lb-levels td:nth-child(3) {
    width: auto;
    text-align: right;
}

.lb-level-num {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.65rem;
    white-space: nowrap;
}

.lb-level-name {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
    font-size: 0.5rem;
    margin-left: 4px;
}

/* Narrow screen: make leaderboard/level-leaders fit */
@media (max-width: 400px) {
    .leaderboard-modal {
        min-width: 0;
    }

    .lb-table {
        font-size: 0.55rem;
    }

    .lb-table th,
    .lb-table td {
        padding: 6px 3px;
    }

    .lb-level-name {
        display: none;
    }

    .lb-level-num {
        font-size: 0.55rem;
    }

    .lb-name {
        max-width: 55px;
    }

    .lb-date {
        font-size: 0.45rem;
    }
}

/* Daily Leaderboard Date List */
.daily-dates-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
}

.daily-date-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Orbitron', sans-serif;
    color: #fff;
}

.daily-date-btn:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.3);
}

.daily-date-btn.today {
    border-color: rgba(255, 215, 0, 0.4);
    background: rgba(255, 215, 0, 0.08);
}

.daily-date-btn.today:hover {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.6);
}

.daily-date-label {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    min-width: 80px;
    text-align: left;
}

.daily-date-btn.today .daily-date-label {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.daily-date-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
}

.daily-date-count {
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.35);
    min-width: 60px;
    text-align: right;
}

.daily-date-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 1px;
    overflow: hidden;
}

.daily-top-name {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.daily-top-score {
    font-size: 0.65rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.3);
}

/* Daily pagination */
.daily-pagination {
    display: flex;
    gap: 8px;
    width: 100%;
}

.daily-nav-btn {
    flex: 1;
    font-size: 0.65rem !important;
    padding: 0.5rem 0.6rem !important;
    min-width: auto !important;
}

.daily-nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

/* Played Levels */
.played-levels-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
}

.played-level-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    gap: 10px;
}

.played-level-btn:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.3);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.15);
}

.played-level-btn:active {
    transform: scale(0.98);
    background: rgba(0, 240, 255, 0.12);
}

.played-level-num {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 32px;
    text-align: center;
}

.played-level-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    overflow: hidden;
}

.played-level-name {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    letter-spacing: 0.5px;
}

.played-level-shape {
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.5px;
}

.played-level-code {
    font-size: 0.55rem;
    color: rgba(0, 240, 255, 0.5);
    letter-spacing: 2px;
    min-width: 60px;
    text-align: right;
}

.played-levels-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: rgba(255, 255, 255, 0.35);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
}

/* Score submit */
.score-submit {
    text-align: center;
    padding: 0.8rem 0;
    margin-bottom: 0.5rem;
    border-top: 1px solid rgba(0, 240, 255, 0.15);
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
}

.submit-label {
    color: #ffd700;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    margin-bottom: 0.6rem;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.submit-status {
    font-size: 0.6rem;
    margin-top: 0.4rem;
    color: #00f0ff;
    min-height: 1em;
}