/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a1a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --lane-pink: #ff3366;
    --lane-cyan: #33ccff;
    --lane-green: #66ff33;
    --lane-gold: #ffcc00;
    --diff-easy: #66ff33;
    --diff-medium: #33ccff;
    --diff-hard: #ff3366;
    --diff-expert: #ffcc00;
    --diff-impossible: #ff2222;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    --transition: 0.2s ease;
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(255, 51, 102, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(51, 204, 255, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 100%, rgba(102, 255, 51, 0.04) 0%, transparent 50%),
        var(--bg);
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% {
        background-position: 0% 0%, 100% 0%, 50% 100%;
    }
    50% {
        background-position: 30% 20%, 70% 80%, 50% 0%;
    }
    100% {
        background-position: 0% 0%, 100% 0%, 50% 100%;
    }
}

.hidden {
    display: none !important;
}

/* ===== Menu Screen ===== */
#menu-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    overflow-y: auto;
    padding: 20px;
}

.menu-container {
    width: 100%;
    max-width: 600px;
    text-align: center;
    animation: fadeSlideIn 0.6s ease-out both;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Title ===== */
.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
    animation: titleEntrance 0.8s ease-out both;
    text-shadow: 0 0 30px rgba(255, 51, 102, 0.3);
}

@keyframes titleEntrance {
    0% {
        opacity: 0;
        transform: scale(0.7) translateY(-20px);
        filter: blur(8px);
    }
    60% {
        opacity: 1;
        transform: scale(1.05) translateY(0);
        filter: blur(0);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

.game-title span {
    background: linear-gradient(135deg, var(--lane-pink), var(--lane-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(51, 204, 255, 0.4));
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 32px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 500;
}

/* ===== Song List ===== */
.song-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 32px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.song-list::-webkit-scrollbar {
    width: 4px;
}

.song-list::-webkit-scrollbar-track {
    background: transparent;
}

.song-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.song-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    text-align: left;
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.4s ease-out both;
}

.song-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.song-card[data-diff="Easy"]::before { background: var(--diff-easy); }
.song-card[data-diff="Medium"]::before { background: var(--diff-medium); }
.song-card[data-diff="Hard"]::before { background: var(--diff-hard); }
.song-card[data-diff="Expert"]::before { background: var(--diff-expert); }
.song-card[data-diff="Impossible"]::before { background: var(--diff-impossible); }

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.song-card:nth-child(1) { animation-delay: 0.05s; }
.song-card:nth-child(2) { animation-delay: 0.1s; }
.song-card:nth-child(3) { animation-delay: 0.15s; }
.song-card:nth-child(4) { animation-delay: 0.2s; }
.song-card:nth-child(5) { animation-delay: 0.25s; }
.song-card:nth-child(6) { animation-delay: 0.3s; }
.song-card:nth-child(7) { animation-delay: 0.35s; }
.song-card:nth-child(8) { animation-delay: 0.4s; }

.song-card:hover {
    transform: translateY(-2px);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.song-card[data-diff="Easy"]:hover { box-shadow: 0 8px 32px rgba(102, 255, 51, 0.1); }
.song-card[data-diff="Medium"]:hover { box-shadow: 0 8px 32px rgba(51, 204, 255, 0.1); }
.song-card[data-diff="Hard"]:hover { box-shadow: 0 8px 32px rgba(255, 51, 102, 0.1); }
.song-card[data-diff="Expert"]:hover { box-shadow: 0 8px 32px rgba(255, 204, 0, 0.1); }
.song-card[data-diff="Impossible"]:hover { box-shadow: 0 8px 32px rgba(255, 34, 34, 0.1); }

.song-card:active {
    transform: scale(0.97);
    transition: transform 0.08s ease;
}

.song-difficulty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #000;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 70px;
}

.song-info {
    flex: 1;
    min-width: 0;
}

.song-title {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.song-best {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Controls Help ===== */
.controls-help {
    padding: 18px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.controls-help h3 {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.controls-help p {
    margin: 4px 0;
}

.controls-help strong {
    color: var(--text-primary);
}

/* ===== Canvas ===== */
#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    background: #050510;
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    pointer-events: none;
}

#hud-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: rgba(10, 10, 26, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.song-name-hud {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#score-display {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-align: center;
    flex: 1;
    background: linear-gradient(135deg, var(--lane-pink), var(--lane-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#accuracy-display {
    font-size: 0.95rem;
    font-weight: 700;
    text-align: right;
    flex: 1;
    color: var(--lane-green);
}

/* ===== Pause Overlay ===== */
#pause-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    background: rgba(10, 10, 26, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.pause-container {
    text-align: center;
    animation: fadeSlideIn 0.3s ease-out both;
}

.pause-container h2 {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    margin-bottom: 32px;
    text-shadow: 0 0 30px rgba(51, 204, 255, 0.4);
}

/* ===== Buttons ===== */
.primary-btn, .secondary-btn {
    display: block;
    width: 220px;
    margin: 10px auto;
    padding: 14px 24px;
    border: none;
    border-radius: 50px;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.primary-btn {
    background: linear-gradient(135deg, var(--lane-pink), #cc2255);
    color: white;
    box-shadow: 0 4px 24px rgba(255, 51, 102, 0.35);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 32px rgba(255, 51, 102, 0.5);
}

.primary-btn:active {
    transform: scale(0.96);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.secondary-btn:active {
    transform: scale(0.96);
}

/* ===== Results Screen ===== */
#results-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.results-container {
    text-align: center;
    animation: fadeSlideIn 0.5s ease-out both;
    max-width: 400px;
    width: 90%;
}

.grade {
    font-size: 7rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 8px;
    animation: gradePulse 2s ease-in-out infinite;
}

@keyframes gradePulse {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.06);
        filter: brightness(1.2);
    }
}

.grade-s {
    color: var(--lane-gold);
    text-shadow: 0 0 40px rgba(255, 204, 0, 0.6), 0 0 80px rgba(255, 204, 0, 0.3);
}

.grade-a {
    color: var(--lane-green);
    text-shadow: 0 0 40px rgba(102, 255, 51, 0.6), 0 0 80px rgba(102, 255, 51, 0.3);
}

.grade-b {
    color: var(--lane-cyan);
    text-shadow: 0 0 40px rgba(51, 204, 255, 0.6), 0 0 80px rgba(51, 204, 255, 0.3);
}

.grade-c {
    color: #ffee44;
    text-shadow: 0 0 40px rgba(255, 238, 68, 0.6), 0 0 80px rgba(255, 238, 68, 0.3);
}

.grade-d {
    color: #ff4444;
    text-shadow: 0 0 40px rgba(255, 68, 68, 0.6), 0 0 80px rgba(255, 68, 68, 0.3);
}

.results-container h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.results-stats {
    margin-bottom: 28px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.95rem;
}

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

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

.stat-value {
    font-weight: 700;
}

.stat-value.perfect { color: var(--lane-gold); }
.stat-value.great { color: var(--lane-green); }
.stat-value.good { color: var(--lane-cyan); }
.stat-value.miss { color: var(--lane-pink); }
.stat-value.combo { color: var(--lane-cyan); }
.stat-value.score { color: var(--text-primary); }

/* ===== Touch Zones ===== */
#touch-zones {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30vh;
    z-index: 15;
    display: flex;
    pointer-events: auto;
}

.touch-zone {
    flex: 1;
    position: relative;
    transition: background var(--transition);
}

.touch-zone::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.1s ease;
    pointer-events: none;
}

.touch-zone[data-lane="0"]::after {
    background: radial-gradient(ellipse at center bottom, rgba(255, 51, 102, 0.25) 0%, transparent 70%);
}
.touch-zone[data-lane="1"]::after {
    background: radial-gradient(ellipse at center bottom, rgba(51, 204, 255, 0.25) 0%, transparent 70%);
}
.touch-zone[data-lane="2"]::after {
    background: radial-gradient(ellipse at center bottom, rgba(102, 255, 51, 0.25) 0%, transparent 70%);
}
.touch-zone[data-lane="3"]::after {
    background: radial-gradient(ellipse at center bottom, rgba(255, 204, 0, 0.25) 0%, transparent 70%);
}

.touch-zone.active::after {
    opacity: 1;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 600px) {
    .game-title {
        font-size: 2.4rem;
    }

    .tagline {
        font-size: 0.8rem;
        margin-bottom: 20px;
    }

    .song-card {
        padding: 12px 14px;
        gap: 10px;
    }

    .song-title {
        font-size: 0.9rem;
    }

    .song-difficulty {
        font-size: 0.6rem;
        padding: 3px 8px;
        min-width: 60px;
    }

    .song-meta {
        font-size: 0.7rem;
    }

    .controls-help {
        font-size: 0.78rem;
        padding: 14px 18px;
    }

    #hud-top {
        padding: 8px 14px;
    }

    #score-display {
        font-size: 1.2rem;
    }

    .grade {
        font-size: 5rem;
    }

    .primary-btn, .secondary-btn {
        width: 180px;
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .pause-container h2 {
        font-size: 2rem;
    }

    #touch-zones {
        height: 35vh;
    }
}

@media (max-width: 360px) {
    .game-title {
        font-size: 2rem;
    }

    .song-list {
        max-height: 50vh;
    }
}
