/* ═══════════════════════════════════════════════════════════════
   HITOSHIBAI KARAOKE — CINEMATIC DESIGN SYSTEM
   ═══════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
    /* Pitch Obsidian & Steel Slate Palette */
    --clr-bg-obsidian:   #08080a;
    --clr-bg-deep:       #050505;
    --clr-white:         #f5f5f4; /* Bone-white primary */
    --clr-white-soft:    #e7e7e4;
    --clr-white-dim:     #64748b; /* Muted steel/slate */
    --clr-border-raw:    rgba(255, 255, 255, 0.12); /* Delicate raw steel border */
    --clr-accent-solar:  #d81c2f; /* Premium Japanese Crimson Red */
    --clr-glass:         rgba(8, 8, 10, 0.85);
    --clr-glass-border:  #334155;

    /* Typography */
    --ff-display: 'Syne', sans-serif;
    --ff-jp:      'Noto Serif JP', serif;
    --ff-en:      'Space Grotesk', sans-serif;
    --ff-mono:    'Space Mono', monospace;

    /* Spacing */
    --sp-xs: 0.25rem;
    --sp-sm: 0.5rem;
    --sp-md: 1rem;
    --sp-lg: 1.5rem;
    --sp-xl: 2.5rem;
    --sp-2xl: 4rem;

    /* Transitions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 200ms;
    --duration-base: 400ms;
    --duration-slow: 700ms;
    --duration-glacial: 1200ms;

    /* Layout */
    --header-height: 64px;
    --footer-height: 100px;
}

/* ── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--ff-en);
    background: var(--clr-bg-obsidian);
    color: var(--clr-white);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

button {
    font-family: var(--ff-mono);
    border: none;
    background: none;
    color: inherit;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── PARTICLE CANVAS ───────────────────────────────────────── */
#particle-canvas {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.25; /* Dialed down particles for structural clarity */
}

/* ── BACKGROUND LAYERS ─────────────────────────────────────── */
.bg-layer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 0;
    background: var(--clr-bg-obsidian);
    overflow: hidden;
}

/* Grain overlay dynamic shift */
.bg-grain {
    animation: grainShift 0.8s steps(4) infinite;
}

@keyframes grainShift {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-2%, -1%); }
    50% { transform: translate(1%, 2%); }
    75% { transform: translate(-1%, 1%); }
}

/* ── SCREENS ───────────────────────────────────────────────── */
.screen {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-slow) var(--ease-out-expo),
                visibility 0s linear var(--duration-slow);
    pointer-events: none;
}

.screen--active {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--duration-slow) var(--ease-out-expo),
                visibility 0s linear 0s;
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN MENU
   ═══════════════════════════════════════════════════════════════ */
.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-lg);
    padding: var(--sp-xl);
    position: relative;
    z-index: 2;
}

/* Badge */
.menu-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: 6px 18px;
    background: var(--clr-glass);
    border: 1px solid var(--clr-border-raw);
    border-radius: 0px;
    font-family: var(--ff-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--clr-accent-solar);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(20px);
    animation: menuFadeIn 0.8s var(--ease-out-expo) 0.15s forwards;
}

.menu-badge__icon {
    font-size: 0.9rem;
    color: var(--clr-accent-solar);
}

/* Title */
.menu-title {
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    animation: menuFadeIn 0.8s var(--ease-out-expo) 0.25s forwards;
}

.menu-title__jp {
    display: block;
    font-family: var(--ff-jp);
    font-size: clamp(4rem, 10vw, 8rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--clr-white);
    letter-spacing: 0.05em;
}

.menu-title__en {
    display: block;
    font-family: var(--ff-display);
    font-size: clamp(1.2rem, 2.8vw, 2.0rem);
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--clr-white-soft);
    margin-top: var(--sp-sm);
}

/* Artist */
.menu-artist {
    display: flex;
    align-items: center;
    gap: var(--sp-lg);
    opacity: 0;
    transform: translateY(20px);
    animation: menuFadeIn 0.8s var(--ease-out-expo) 0.35s forwards;
}

.menu-artist__line {
    width: 60px;
    height: 1px;
    background: var(--clr-border-raw);
}

.menu-artist__name {
    font-family: var(--ff-jp);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--clr-white);
}

.menu-artist__name-en {
    font-family: var(--ff-mono);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--clr-white-dim);
    margin-left: var(--sp-sm);
}

/* Meta info */
.menu-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-lg);
    padding: var(--sp-md) var(--sp-xl);
    background: var(--clr-glass);
    border: 1px solid var(--clr-border-raw);
    border-radius: 0px;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    opacity: 0;
    transform: translateY(20px);
    animation: menuFadeIn 0.8s var(--ease-out-expo) 0.45s forwards;
}

.menu-meta__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.menu-meta__label {
    font-family: var(--ff-mono);
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--clr-white-dim);
}

.menu-meta__value {
    font-family: var(--ff-en);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--clr-white);
}

.menu-meta__divider {
    width: 1px;
    height: 30px;
    background: var(--clr-border-raw);
}

/* Start button */
.menu-start-btn {
    position: relative;
    margin-top: var(--sp-lg);
    padding: 14px 40px;
    background: var(--clr-glass);
    border: 1px solid var(--clr-border-raw);
    border-radius: 0px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    animation: menuFadeIn 0.8s var(--ease-out-expo) 0.55s forwards;
    transition: border-color 0.2s var(--ease-out-expo), transform 0.2s var(--ease-out-expo), color 0.2s var(--ease-out-expo);
    color: var(--clr-white);
}

.menu-start-btn:active {
    transform: translateY(0);
}

.menu-start-btn__glow {
    display: none;
}

.menu-start-btn__border {
    display: none;
}

.menu-start-btn__content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.menu-start-btn__icon {
    width: 14px;
    height: 14px;
    color: var(--clr-accent-solar);
}

.menu-start-btn__text {
    font-family: var(--ff-mono);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Controls hint */
.menu-controls-hint {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--clr-white-dim);
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(20px);
    animation: menuFadeIn 0.8s var(--ease-out-expo) 0.65s forwards;
}

.menu-controls-hint__dot {
    color: var(--clr-white-dim);
}

/* Decorative corner elements */
.menu-deco {
    position: fixed;
    width: 120px;
    height: 120px;
    color: var(--clr-border-raw);
    opacity: 0.15;
    z-index: 1;
}

.menu-deco--tl {
    top: 30px;
    left: 30px;
}

.menu-deco--br {
    bottom: 30px;
    right: 30px;
}

@keyframes menuFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════
   KARAOKE PLAYER
   ═══════════════════════════════════════════════════════════════ */

/* Header */
.player-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding-top: env(safe-area-inset-top);
    padding-left: max(var(--sp-lg), env(safe-area-inset-left));
    padding-right: max(var(--sp-lg), env(safe-area-inset-right));
    gap: var(--sp-md);
    z-index: 20;
    background: var(--clr-glass);
    border-bottom: 1px solid var(--clr-border-raw);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity var(--duration-slow) var(--ease-out-expo),
                transform var(--duration-slow) var(--ease-out-expo);
}

#karaoke-player.player-ui-visible .player-header {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s;
}

.player-back-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0px;
    background: var(--clr-glass);
    border: 1px solid var(--clr-border-raw);
    color: var(--clr-white-dim);
    transition: border-color var(--duration-fast) var(--ease-out-expo),
                transform var(--duration-fast) var(--ease-out-expo),
                color var(--duration-fast) var(--ease-out-expo);
}

.player-back-btn svg {
    width: 18px;
    height: 18px;
}

.player-header__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-header__title {
    font-family: var(--ff-jp);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--clr-white-soft);
}

.player-header__artist {
    font-family: var(--ff-mono);
    font-size: 0.7rem;
    font-weight: 300;
    color: var(--clr-white-dim);
}

.player-romaji-btn {
    padding: 8px 16px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0px;
    background: var(--clr-glass);
    border: 1px solid var(--clr-border-raw);
    font-family: var(--ff-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--clr-white-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    transition: border-color var(--duration-fast) var(--ease-out-expo),
                transform var(--duration-fast) var(--ease-out-expo),
                color var(--duration-fast) var(--ease-out-expo),
                background-color var(--duration-fast) var(--ease-out-expo);
}

.player-romaji-btn.active {
    background: rgba(216, 28, 47, 0.15);
    border-color: var(--clr-accent-solar);
    color: var(--clr-accent-solar);
}

/* ── LYRICS STAGE (state-based slide-up transitions) ───────── */
.lyrics-stage {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: calc(var(--header-height) + 20px) var(--sp-xl) calc(var(--footer-height) + 20px);
    text-align: center;
    z-index: 10;
    overflow: hidden;
}

/* Disable transitions during seeks/jumps to prevent visual desyncs */
.lyrics-stage.no-transition .lyric-line {
    transition: none !important;
}
.lyrics-stage.no-transition .lyric-line__secondary {
    transition: none !important;
}

/* ── LYRIC LINE (base) ─────────────────────────────────────── */
.lyric-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 85%;
    line-height: 1.4;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    font-size: clamp(1.8rem, 4.5vw, 3.2rem);
    color: var(--clr-white);
    will-change: transform, opacity;

    /* THE KEY: only hardware-accelerated transform & opacity transition slowly and smoothly */
    transition:
        transform 1500ms cubic-bezier(0.16, 1, 0.3, 1),
        opacity 1500ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Primary text (romaji) */
.lyric-line__primary {
    font-family: var(--ff-en);
    font-weight: 700;
}

/* Secondary text (kanji) — sits below the primary */
.lyric-line__secondary {
    font-family: var(--ff-jp);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.8vw, 1.15rem);
    display: none;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 1500ms cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--clr-accent-solar);
}

/* When the Kanji toggle is active, place it in the block layout to reserve height */
.lyric-line__secondary.visible {
    display: block;
}

/* ═══════════════════════════════════════════════════════════════
   STATE DEFINITIONS — Each state defines exact visual properties.
   CSS transitions interpolate smoothly between any two states.
   ═══════════════════════════════════════════════════════════════ */

/* ── HIDDEN (below viewport, waiting to enter) ─────────────── */
.lyric-line[data-state="hidden"] {
    transform: translate(-50%, calc(-50% + 220px)) scale(0.3);
    opacity: 0;
    text-shadow: none;
}

/* ── NEXT-2 (two lines ahead, barely visible) ──────────────── */
.lyric-line[data-state="next2"] {
    transform: translate(-50%, calc(-50% + 160px)) scale(0.4);
    opacity: 0.18;
    text-shadow: none;
}

/* ── NEXT (one line ahead, preview) ────────────────────────── */
.lyric-line[data-state="next"] {
    transform: translate(-50%, calc(-50% + 90px)) scale(0.6);
    opacity: 0.35;
    text-shadow: none;
}

/* ── CURRENT (active lyric, center stage) ──────────────────── */
.lyric-line[data-state="current"] {
    transform: translate(-50%, calc(-50% - 10px)) scale(1.0);
    opacity: 1;
    text-shadow: none;
}
.lyric-line[data-state="current"] .lyric-line__secondary {
    color: var(--clr-accent-solar);
}
.lyric-line[data-state="current"] .lyric-line__secondary.visible {
    opacity: 0.95;
}

/* ── PREVIOUS (just passed, sliding up and fading) ─────────── */
.lyric-line[data-state="prev"] {
    transform: translate(-50%, calc(-50% - 110px)) scale(0.6);
    opacity: 0.3;
    text-shadow: none;
}

/* ── GONE (exited above viewport) ──────────────────────────── */
.lyric-line[data-state="gone"] {
    transform: translate(-50%, calc(-50% - 200px)) scale(0.3);
    opacity: 0;
    text-shadow: none;
}



/* ── INSTRUMENTAL DOTS ─────────────────────────────────────── */
.lyric-line .instrumental-dots {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.lyric-line .instrumental-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--clr-accent-solar);
    opacity: 0.5;
    animation: dotPulse 1.2s ease-in-out infinite;
}

.lyric-line .instrumental-dots span:nth-child(2) { animation-delay: 0.2s; }
.lyric-line .instrumental-dots span:nth-child(3) { animation-delay: 0.4s; }
.lyric-line .instrumental-dots span:nth-child(4) { animation-delay: 0.6s; }
.lyric-line .instrumental-dots span:nth-child(5) { animation-delay: 0.8s; }

@keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.5); opacity: 0.8; }
}

/* ── PLAYER FOOTER ─────────────────────────────────────────── */
.player-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    display: flex;
    flex-direction: column;
    padding: 0 var(--sp-xl) var(--sp-lg);
    padding-bottom: max(var(--sp-lg), env(safe-area-inset-bottom));
    padding-left: max(var(--sp-xl), env(safe-area-inset-left));
    padding-right: max(var(--sp-xl), env(safe-area-inset-right));
    z-index: 20;
    background: var(--clr-glass);
    border-top: 1px solid var(--clr-border-raw);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--duration-slow) var(--ease-out-expo),
                transform var(--duration-slow) var(--ease-out-expo);
}

#karaoke-player.player-ui-visible .player-footer {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.2s;
}

/* Progress bar */
.progress-bar-container {
    padding: 8px 0;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(71, 85, 105, 0.3);
    border-radius: 0px;
    overflow: visible;
    transition: height var(--duration-fast);
}

.progress-bar__fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--clr-accent-solar);
    border-radius: 0px;
    transition: width 0.1s linear;
}

.progress-bar__glow {
    display: none;
}

.progress-bar__thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    background: var(--clr-white);
    border: 1px solid var(--clr-accent-solar);
    border-radius: 0px;
    transform: translate(-50%, -50%) scale(0);
    transition: transform var(--duration-base) var(--ease-spring);
}

/* Time & controls row */
.player-time {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--ff-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--clr-white-dim);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
}

.player-ctrl-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0px;
    background: var(--clr-glass);
    border: 1px solid var(--clr-border-raw);
    color: var(--clr-white-dim);
    transition: border-color var(--duration-fast) var(--ease-out-expo),
                transform var(--duration-fast) var(--ease-out-expo),
                color var(--duration-fast) var(--ease-out-expo);
}

.player-ctrl-btn svg {
    width: 20px;
    height: 20px;
}

.player-ctrl-btn svg text {
    font-family: var(--ff-mono);
    font-weight: 700;
}

.player-ctrl-btn--play {
    width: 52px;
    height: 52px;
    color: var(--clr-accent-solar);
    border-color: var(--clr-accent-solar);
    background: rgba(216, 28, 47, 0.05);
    transition: border-color var(--duration-fast) var(--ease-out-expo),
                transform var(--duration-fast) var(--ease-out-expo),
                color var(--duration-fast) var(--ease-out-expo),
                background-color var(--duration-fast) var(--ease-out-expo);
}

.player-ctrl-btn--play svg {
    width: 22px;
    height: 22px;
}

/* Play/Pause icon toggle */
.player-ctrl-btn--play .icon-pause { display: none; }
.player-ctrl-btn--play.playing .icon-play { display: none; }
.player-ctrl-btn--play.playing .icon-pause { display: block; }

/* Old beat-pulse removed — now handled in .lyric-line section above */



/* ── COUNTDOWN OVERLAY ─────────────────────────────────────── */
.countdown-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 8, 10, 0.7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-base) var(--ease-out-expo),
                visibility var(--duration-base) var(--ease-out-expo);
}

.countdown-overlay.active {
    opacity: 1;
    visibility: visible;
}

.countdown-number {
    font-family: var(--ff-display);
    font-size: 8rem;
    font-weight: 800;
    color: var(--clr-accent-solar);
    animation: countPulse 1.0s var(--ease-out-expo) forwards;
}

@keyframes countPulse {
    0% { transform: scale(1.6); opacity: 0; }
    20% { transform: scale(1); opacity: 1; }
    80% { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(0.7); opacity: 0; }
}


/* ── AUDIO-REACTIVE ENHANCEMENTS ───────────────────────────── */

/* Climax active layout updates (glow text-shadow removed for performance) */

/* Ending state */
.lyric-line .ending-text {
    font-family: var(--ff-jp);
    font-weight: 300;
    font-size: 0.6em;
    opacity: 0.6;
    letter-spacing: 0.3em;
    animation: fadeInSlow 2s var(--ease-out-expo) forwards;
}

@keyframes fadeInSlow {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 0.6; transform: scale(1); }
}

/* Chorus active layout updates (glow text-shadow removed for performance) */

/* ── FOCUS MODE (auto-hide UI during playback) ─────────────── */
.player-header, .player-footer {
    transition: opacity var(--duration-slow) var(--ease-out-expo),
                transform var(--duration-slow) var(--ease-out-expo);
}

/* ── CUSTOM SELECTION ──────────────────────────────────────── */
::selection {
    background: rgba(216, 28, 47, 0.3);
    color: var(--clr-white);
}

/* ── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--clr-border-raw);
    border-radius: 0px;
}

/* ── LOADING STATE ─────────────────────────────────────────── */
.loading-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 8px 20px;
    border-radius: 0px;
    background: var(--clr-glass);
    border: 1px solid var(--clr-border-raw);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    font-family: var(--ff-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--clr-white-dim);
    display: none;
}

.loading-indicator.visible { display: flex; align-items: center; gap: 8px; }

.loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--clr-border-raw);
    border-top-color: var(--clr-accent-solar);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── TRANSITION SCREEN (menu → player) ─────────────────────── */
.transition-wipe {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.transition-wipe__circle {
    width: 10vw;
    height: 10vw;
    min-width: 100px;
    min-height: 100px;
    border-radius: 50%;
    background: var(--clr-bg-deep);
    transform: scale(0);
    will-change: transform;
}

.transition-wipe.animate-in .transition-wipe__circle {
    animation: irisScaleIn 0.8s cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

.transition-wipe.animate-out .transition-wipe__circle {
    animation: irisScaleOut 0.8s cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

@keyframes irisScaleIn {
    0% { transform: scale(0); }
    100% { transform: scale(25); }
}

@keyframes irisScaleOut {
    0% { transform: scale(25); }
    100% { transform: scale(0); }
}

/* ── SPLIT-SCREEN MAIN MENU (Artwork Left, Content Right) ───── */
.menu-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2xl);
    width: 100%;
    max-width: 1200px;
    padding-top: max(var(--sp-xl), env(safe-area-inset-top));
    padding-bottom: max(var(--sp-xl), env(safe-area-inset-bottom));
    padding-left: max(var(--sp-xl), env(safe-area-inset-left));
    padding-right: max(var(--sp-xl), env(safe-area-inset-right));
    z-index: 2;
}

.menu-artwork-panel {
    flex: 1.1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    opacity: 0;
    transform: translateX(-30px);
    animation: menuFadeIn 0.8s var(--ease-out-expo) 0.05s forwards; /* First stagger element */
}

.menu-artwork-frame {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--clr-bg-deep);
    border: 1px solid var(--clr-border-raw);
    border-radius: 12px;
    padding: 10px; /* Elegant outer border spacing margin */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(216, 28, 47, 0.05);
    transition: transform var(--duration-base) var(--ease-out-expo),
                border-color var(--duration-base) var(--ease-out-expo),
                box-shadow var(--duration-base) var(--ease-out-expo);
    will-change: transform, border-color, box-shadow;
}

.menu-artwork-img {
    display: block;
    width: 100%;
    height: auto;
    padding-bottom: 100%; /* Fallback for iOS < 15 */
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px; /* Matching inner rounded corner */
    opacity: 0.94;
    transition: opacity var(--duration-base) var(--ease-out-expo);
}

@supports (aspect-ratio: 1) {
    .menu-artwork-img {
        padding-bottom: 0;
    }
}

.menu-content-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: var(--sp-lg);
}

/* Adjust margins/paddings on inner elements to align nicely */
.menu-content-panel .menu-badge {
    margin-bottom: -4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-content-panel .menu-title {
    text-align: left;
    margin-top: -6px;
    margin-bottom: -4px;
}

.menu-content-panel .menu-artist {
    justify-content: flex-start;
    margin-top: -6px;
}

.menu-content-panel .menu-artist__line {
    display: none; /* Hide line in split layout for cleaner layout */
}

.menu-content-panel .menu-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-lg);
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    margin-top: 4px;
    margin-bottom: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.menu-meta__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.menu-meta__divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.12);
}

/* Start button refined (Frosted Crimson Glass Outline, No Glow) */
.menu-content-panel .menu-start-btn {
    border-radius: 8px;
    border: 1px solid rgba(216, 28, 47, 0.45);
    background: rgba(216, 28, 47, 0.02);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: none;
    margin-top: var(--sp-sm);
    transition: background-color var(--duration-fast) var(--ease-out-expo),
                border-color var(--duration-fast) var(--ease-out-expo),
                transform var(--duration-fast) var(--ease-out-expo);
}

/* Refined player thumbnail styling */
.player-header__thumbnail {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-header__thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── VIEWPORT FRAMING (Cinematic Layout) ─────────────────────── */
.viewport-frame {
    position: fixed;
    top: 24px;
    right: 24px;
    bottom: 24px;
    left: 24px;
    inset: 24px;
    border: 1px solid rgba(255, 255, 255, 0.025);
    pointer-events: none;
    z-index: 999;
}

.viewport-corner {
    position: absolute;
    font-family: var(--ff-mono);
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.12);
    letter-spacing: 0.20em;
    pointer-events: none;
    text-transform: uppercase;
}

.viewport-corner--tl {
    top: -18px;
    left: 16px;
}

.viewport-corner--tr {
    top: -18px;
    right: 16px;
}

.viewport-corner--bl {
    bottom: -18px;
    left: 16px;
}

.viewport-corner--br {
    bottom: -18px;
    right: 16px;
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .viewport-frame {
        display: none; /* Hide framing on mobile for clean vertical alignment */
    }
    
    .menu-container {
        flex-direction: column;
        gap: var(--sp-lg); /* increased spacing gap to fit elements elegantly */
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-left: max(var(--sp-md), env(safe-area-inset-left));
        padding-right: max(var(--sp-md), env(safe-area-inset-right));
        text-align: center;
        margin-top: 10px;
    }

    .menu-artwork-panel {
        justify-content: center;
        transform: translateY(5px);
        animation: menuFadeIn 0.8s var(--ease-out-expo) 0.05s forwards;
    }

    .menu-artwork-frame {
        max-width: 215px; /* compact but present artwork size */
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(216, 28, 47, 0.05);
        padding: 6px; /* Restored mobile frame padding outer border margin */
    }

    .menu-content-panel {
        align-items: center;
        text-align: center;
        gap: 12px; /* increased spacing for breathing room */
    }

    .menu-content-panel .menu-title {
        text-align: center;
    }

    .menu-content-panel .menu-title__jp {
        font-size: clamp(2.4rem, 6.5vw, 3.2rem);
    }

    .menu-content-panel .menu-title__en {
        font-size: 0.95rem;
    }

    .menu-content-panel .menu-artist {
        justify-content: center;
        font-size: 0.9rem;
    }

    .menu-meta {
        flex-direction: row; /* Keep horizontal */
        justify-content: space-between;
        align-items: center;
        gap: 6px;
        padding: 10px 14px;
        width: 100%;
        max-width: 320px;
        box-sizing: border-box;
    }

    .menu-meta__item {
        align-items: center;
        flex: 1;
        min-width: 0; /* allows flex columns to shrink/wrap correctly */
    }

    .menu-meta__label {
        font-size: 0.55rem;
    }

    .menu-meta__value {
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis; /* ensures no overflow leaks */
        width: 100%;
    }

    .menu-meta__divider {
        width: 1px;
        height: 14px;
        background: rgba(255, 255, 255, 0.15);
        flex-shrink: 0; /* prevents vertical lines from compressing to 0px width */
    }

    .lyrics-stage {
        padding-left: var(--sp-md);
        padding-right: var(--sp-md);
    }

    .player-footer {
        padding: 0 var(--sp-md) var(--sp-md);
    }

    /* Mobile Player Header */
    .player-header {
        padding: 0 12px;
        gap: 10px;
    }

    .player-header__thumbnail {
        width: 30px;
        height: 30px;
        border-radius: 4px;
    }

    .player-romaji-btn {
        padding: 6px 10px;
        min-height: 44px;
        font-size: 0.65rem;
        letter-spacing: 0.15em;
    }

    .player-header__info {
        min-width: 0;
    }

    .player-header__title {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .player-header__artist {
        font-size: 0.65rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ── HOVER INTERACTIONS (Pointer Devices only) ─────────────── */
@media (hover: hover) {
    .menu-start-btn:hover {
        border-color: var(--clr-accent-solar);
        transform: translateY(-1px);
    }

    .player-back-btn:hover {
        color: var(--clr-white);
        border-color: var(--clr-accent-solar);
        transform: translateY(-1px);
    }

    .player-romaji-btn:hover {
        border-color: var(--clr-accent-solar);
        color: var(--clr-white);
        transform: translateY(-1px);
    }

    .progress-bar-container:hover .progress-bar {
        height: 6px;
    }

    .progress-bar-container:hover .progress-bar__thumb {
        transform: translate(-50%, -50%) scale(1);
    }

    .player-ctrl-btn:hover {
        color: var(--clr-white);
        border-color: var(--clr-accent-solar);
        transform: translateY(-1px);
    }

    .player-ctrl-btn--play:hover {
        background: rgba(216, 28, 47, 0.15);
        border-color: var(--clr-accent-solar);
        color: var(--clr-white);
        transform: translateY(-1px);
    }

    .menu-artwork-frame:hover {
        transform: translateY(-6px) scale(1.02);
        border-color: var(--clr-accent-solar);
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 45px rgba(216, 28, 47, 0.25);
    }

    .menu-artwork-frame:hover .menu-artwork-img {
        opacity: 1;
    }

    .menu-content-panel .menu-start-btn:hover {
        background: rgba(216, 28, 47, 0.1);
        border-color: rgba(216, 28, 47, 0.75);
        transform: translateY(-2px) scale(1.01);
        box-shadow: none;
    }
}

/* ── POINTER CURSOR STYLING (Fine pointer only) ─────────────── */
@media (pointer: fine) {
    body {
        cursor: default;
    }
    button,
    .progress-bar-container {
        cursor: pointer;
    }
}

/* ── TOUCH DEVICE PROGRESS BAR THUMB BEHAVIOR ─────────────────── */
@media (hover: none) {
    .progress-bar {
        height: 6px;
    }
    .progress-bar__thumb {
        transform: translate(-50%, -50%) scale(1);
    }
}