/* ============================================================
   MEOWBEATS — Smoke's Rhythm Adventure
   CSS Design System
   ============================================================ */

:root {
    --bg-dark:        #07000f;
    --card-bg:        rgba(14, 8, 28, 0.92);
    --border-color:   rgba(255, 255, 255, 0.08);
    --neon-purple:    #9d4edd;
    --neon-pink:      #ff007f;
    --neon-cyan:      #00f3ff;
    --neon-green:     #22ff88;
    --neon-yellow:    #ffdd22;
    --text-color:     #f0f4f8;
    --text-muted:     #7a8294;
    --font-pixel:     'Press Start 2P', monospace;
    --font-sans:      'Outfit', sans-serif;

    /* Lane colors */
    --lane-0: #22ff88;
    --lane-1: #ff4444;
    --lane-2: #ffdd22;
    --lane-3: #4499ff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: radial-gradient(ellipse at center, #110018 0%, #04000a 100%);
    color: var(--text-color);
    font-family: var(--font-sans);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
}

/* ─── GAME CONTAINER ─────────────────────────────────── */
#game-container {
    position: relative;
    width: 95vw;
    height: auto;
    max-height: 84vh;
    max-height: 84dvh;
    aspect-ratio: 16 / 9;
    max-width: min(1080px, calc(84vh * 16 / 9));
    max-width: min(1080px, calc(84dvh * 16 / 9));
    border-radius: 14px;
    overflow: hidden;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.85),
        0 0 40px rgba(157, 78, 221, 0.18),
        0 0 80px rgba(0, 243, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    touch-action: none;
}

#game-container:fullscreen,
#game-container:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    background-color: #07000f;
    touch-action: none;
}

/* ─── GAME CONTROLS HUD ──────────────────────────────── */
#game-controls {
    position: absolute;
    top: 12px;
    right: 14px;
    display: flex;
    gap: 8px;
    z-index: 30;
    pointer-events: auto;
}

#game-controls.hidden { display: none; }

.ctrl-btn {
    background: rgba(10, 5, 20, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 7px 10px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-width: 36px;
    min-height: 36px;
}

.ctrl-btn:hover {
    background: rgba(157, 78, 221, 0.3);
    border-color: var(--neon-purple);
    color: #fff;
}

.ctrl-btn:active { transform: scale(0.93); }

/* ─── MOBILE TOUCH LANES ─────────────────────────────── */
#touch-lanes {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 18%;
    display: flex;
    z-index: 25;
    pointer-events: auto;
}

#touch-lanes.hidden { display: none; }

.touch-lane {
    flex: 1;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.08s;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.touch-lane:active,
.touch-lane.pressed {
    opacity: 1;
}

/* ─── OVERLAYS ───────────────────────────────────────── */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 0, 12, 0.82);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 12px;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ─── CARDS ──────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px 36px;
    width: 92%;
    max-width: 460px;
    text-align: center;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.6),
        0 0 20px rgba(157, 78, 221, 0.08);
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 94%;
    overflow: hidden; /* card itself doesn't scroll */
}

.card-wide {
    max-width: 560px;
}

/* Song select card: header + list + back button layout */
#song-overlay .card {
    padding-bottom: 0; /* footer handles its own padding */
}

#song-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;     /* critical: lets flex child shrink below content size */
    scrollbar-width: thin;
    scrollbar-color: rgba(157,78,221,0.4) transparent;
    padding-right: 4px;
    margin-right: -4px;
}

#song-list::-webkit-scrollbar {
    width: 4px;
}
#song-list::-webkit-scrollbar-track {
    background: transparent;
}
#song-list::-webkit-scrollbar-thumb {
    background: rgba(157,78,221,0.4);
    border-radius: 4px;
}

#btn-back-start {
    flex-shrink: 0;
    width: calc(100% + 72px);   /* bleed to card edges */
    margin-left: -36px;
    margin-right: -36px;
    margin-bottom: 0;
    border-radius: 0 0 18px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 14px 24px;
}


/* ─── TYPOGRAPHY ─────────────────────────────────────── */
.logo {
    font-family: var(--font-pixel);
    font-size: 22px;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 0 14px var(--neon-purple), 0 0 28px rgba(157,78,221,0.4);
    line-height: 1.4;
}

.logo-sm {
    font-family: var(--font-pixel);
    font-size: 13px;
    color: #fff;
    letter-spacing: 1px;
    text-shadow: 0 0 10px var(--neon-purple);
    line-height: 1.6;
}

.tagline {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2.5px;
}

.section-label {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ─── STORY BOX ──────────────────────────────────────── */
.story-box {
    background: rgba(157, 78, 221, 0.07);
    border: 1px solid rgba(157, 78, 221, 0.2);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #dde4f0;
    text-align: center;
}

/* ─── CONTROLS CARD ──────────────────────────────────── */
.controls-card {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-color);
}

.key {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-bottom: 3px solid rgba(0,0,0,0.5);
    border-radius: 5px;
    padding: 2px 7px;
    font-weight: 700;
    font-size: 12px;
    color: #fff;
    display: inline-block;
}

/* ─── BUTTONS ────────────────────────────────────────── */
.btn {
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 15px;
    padding: 13px 24px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s, opacity 0.1s;
    text-decoration: none;
    display: inline-block;
    letter-spacing: 0.5px;
}

.btn:hover  { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--neon-purple) 0%, var(--neon-pink) 100%);
    box-shadow: 0 0 14px rgba(157,78,221,0.4), 0 4px 12px rgba(0,0,0,0.4);
}

.btn-primary:hover {
    box-shadow: 0 0 24px rgba(157,78,221,0.7), 0 6px 20px rgba(0,0,0,0.5);
}

.btn-share {
    background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-purple) 100%);
    box-shadow: 0 0 14px rgba(0,243,255,0.3), 0 4px 12px rgba(0,0,0,0.4);
}

.btn-share:hover {
    box-shadow: 0 0 24px rgba(0,243,255,0.6), 0 6px 20px rgba(0,0,0,0.5);
}

.btn-back {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-color);
    box-shadow: none;
}

.btn-back:hover {
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,255,255,0.25);
    color: #fff;
}

.btn-ghost {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-muted);
    font-size: 13px;
    padding: 10px 20px;
}

.btn-ghost:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

/* ─── SONG SELECT ────────────────────────────────────── */
#song-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.song-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 14px 18px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 14px;
}

.song-card:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(157,78,221,0.4);
    transform: translateX(3px);
}

.song-card:active { transform: translateX(1px); }

.song-emoji {
    font-size: 28px;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

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

.song-name {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: #fff;
    line-height: 1.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

.song-genre {
    display: inline-block;
    margin-top: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    color: var(--text-muted);
}

.song-bpm {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ─── DIFFICULTY GRID ────────────────────────────────── */
.difficulty-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.diff-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    color: var(--text-color);
    font-family: var(--font-sans);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.diff-btn:hover {
    background: rgba(34,255,136,0.08);
    border-color: rgba(34,255,136,0.35);
    transform: translateX(3px);
}

.diff-btn-mid:hover {
    background: rgba(255,221,34,0.08);
    border-color: rgba(255,221,34,0.35);
}

.diff-btn-hard:hover {
    background: rgba(255,68,68,0.08);
    border-color: rgba(255,68,68,0.35);
}

.diff-btn:active { transform: translateX(1px); }

.diff-icon { font-size: 26px; flex-shrink: 0; }

.diff-name {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: #fff;
    display: block;
    margin-bottom: 3px;
}

.diff-desc {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
}

/* ─── RESULTS SCREEN ─────────────────────────────────── */
.results-card { max-width: 480px; }

.gameover-title {
    font-family: var(--font-pixel);
    font-size: 16px;
    color: var(--neon-green);
    text-shadow: 0 0 14px rgba(34,255,136,0.5);
    line-height: 1.5;
}

.gameover-title.failed {
    color: var(--neon-pink);
    text-shadow: 0 0 14px rgba(255,0,127,0.5);
}

.gameover-desc {
    font-size: 13px;
    color: var(--text-muted);
}

.stars-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 4px 0;
}

.star {
    font-size: 28px;
    color: rgba(255,255,255,0.15);
    transition: color 0.3s, text-shadow 0.3s, transform 0.3s;
    display: inline-block;
}

.star.lit {
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255,221,34,0.8), 0 0 20px rgba(255,221,34,0.4);
    transform: scale(1.15);
}

.scores-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.score-card {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.score-card strong {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: #fff;
    display: block;
}

.results-breakdown {
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 12px;
    flex-wrap: wrap;
}

.break-item { display: flex; align-items: center; gap: 4px; }
.perfect-col { color: var(--neon-cyan); }
.good-col    { color: var(--neon-green); }
.miss-col    { color: #ff5555; }

.stats-footer {
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── RESPONSIVE: MOBILE PORTRAIT ───────────────────── */
@media (max-aspect-ratio: 1/1) {
    #game-container {
        width: 100vw;
        height: auto;
        aspect-ratio: 9 / 16;
        max-height: 100vh;
        max-height: 100dvh;
        max-width: min(500px, 100vw);
        border-radius: 0;
    }

    .logo { font-size: 16px; }
    .logo-sm { font-size: 10px; }
    .card { padding: 18px 20px; gap: 10px; }
    .card-wide { max-width: 96vw; }
    .song-card { padding: 10px 14px; }
    .song-name { font-size: 8px; }
    .diff-btn { padding: 11px 14px; }
    .gameover-title { font-size: 13px; }
    .scores-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .score-card strong { font-size: 12px; }
    .btn { font-size: 14px; padding: 11px 20px; }
    .star { font-size: 22px; }
    .results-breakdown { font-size: 11px; gap: 8px; }
}

@media (max-width: 420px) {
    .logo { font-size: 14px; }
    .song-emoji { font-size: 22px; width: 32px; }
    .results-breakdown { flex-direction: column; align-items: center; gap: 4px; }
}
