/* Idle / end-screen — fit into svh when possible; grow + scroll when content is taller */

.game-idle-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    justify-content: safe center;
    align-items: center;
    min-height: 100%;
    height: auto;
    width: 100%;
    box-sizing: border-box;
    padding:
        max(8px, env(safe-area-inset-top, 0px))
        12px
        max(16px, env(safe-area-inset-bottom, 0px));
}

.game-idle-screen .start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(4px, 1.2svh, 12px);
    min-height: unset;
    max-height: none;
    overflow: visible;
    padding: clamp(14px, 2.5svh, 28px) 18px;
    width: 100%;
    max-width: 420px;
    box-sizing: border-box;
    flex-shrink: 0;
    /* Always a card: text on the bare blue background had poor contrast.
       The celebrate state swaps in a warmer tint (progress.css). */
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(238, 245, 255, 0.97));
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 32px rgba(10, 40, 110, 0.3);
}

.game-idle-screen .start-screen h2 {
    color: var(--color-ink);
}

/* Darker than the default pill blue: these are small, so they need the extra contrast. */
.game-idle-screen .whats-next {
    color: #144f8f;
}

.game-container--idle .hp-mascot {
    width: clamp(64px, 12svh, 120px);
    height: clamp(64px, 12svh, 120px);
    flex-shrink: 0;
}

.game-container--idle .hp-mascot img {
    width: 100%;
    height: 100%;
}

.game-container--idle .start-screen h2 {
    margin: 0;
    font-size: clamp(1.25rem, 4.5svh, 1.75rem);
    line-height: 1.2;
}

.game-container--idle .whats-next {
    margin: 0;
    padding: clamp(6px, 1svh, 10px) 12px;
    font-size: clamp(0.85rem, 2.4svh, 1.05rem);
}

.game-container--idle .challenge-end-streak {
    margin: 0;
}

.game-container--idle .challenge-end-value {
    font-size: clamp(1.5rem, 5svh, 2.25rem);
}

.game-container--idle .stars-display-large {
    margin: 0;
    padding: clamp(8px, 1.5svh, 16px) clamp(12px, 2svh, 20px);
}

.game-container--idle .stars-value {
    font-size: clamp(2rem, 7svh, 3.25rem);
}

.game-container--idle .scoreboard {
    overflow: visible;
    max-height: none;
    padding: 12px;
    margin: 0;
}

.game-container--idle .scoreboard h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.game-container--idle .scoreboard-content {
    gap: 6px;
}

.game-container--idle .scoreboard-item {
    padding: 8px 12px;
    flex-direction: row;
    align-items: center;
}

.game-container--idle .start-screen-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: clamp(6px, 1.5svh, 14px);
    /* Clear the primary button's 3D lip, then secondary row */
    gap: clamp(14px, 2.5svh, 22px);
    width: 100%;
    flex-shrink: 0;
}

.game-container--idle .start-screen-actions .hp-btn-play {
    margin-bottom: 0;
}

.game-container--idle .start-screen-actions__secondary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 10px 12px;
    width: 100%;
}

.game-container--idle .start-screen-actions__secondary .hp-btn-secondary {
    flex: 1 1 auto;
    min-width: 8.5rem;
    max-width: 12rem;
    text-align: center;
}

@media screen and (max-width: 900px) and (orientation: landscape) {
    .game-idle-screen {
        align-items: flex-start;
        padding-top: 4px;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    }

    .game-idle-screen .start-screen {
        padding: 8px 10px;
        gap: 4px;
    }

    .game-container--idle .hp-mascot {
        width: clamp(48px, 18svh, 72px);
        height: clamp(48px, 18svh, 72px);
    }

    .game-container--idle .start-screen h2 {
        font-size: 1.2rem;
    }

    .game-container--idle .whats-next {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .game-container--idle .scoreboard {
        padding: 8px 10px;
    }

    .game-container--idle .scoreboard h3 {
        margin-bottom: 6px;
        font-size: 0.95rem;
    }

    .game-container--idle .scoreboard-item {
        padding: 4px 8px;
    }

    .game-container--idle .scoreboard-label,
    .game-container--idle .scoreboard-value {
        font-size: 0.85rem;
    }

    .game-container--idle .start-screen-actions {
        margin-top: 4px;
        gap: 12px;
    }

    .game-container--idle .start-screen-actions .btn {
        padding: 8px 16px;
    }
}

.whats-next {
    font-size: 1.05rem;
    color: #1b6ec2;
    font-weight: 600;
    margin: 0 0 16px;
    padding: 10px 14px;
    background: #e8f4fd;
    border-radius: 8px;
    line-height: 1.4;
}

/* —— Full-viewport practice scene (kids 6–10) ——
   Use svh (small viewport) so phone address bar is in the budget.
   Playing: lock, no scroll. Idle/end: fit first; overflow-y scroll only if needed. */

.page main .content:has(.game-container--playing),
.page main .content:has(.game-container--idle) {
    padding: 0 !important;
    max-width: none;
    height: 100%;
    width: 100%;
}

html:has(.game-container--playing),
body:has(.game-container--playing),
html:has(.game-container--idle),
body:has(.game-container--idle) {
    height: 100%;
    max-height: 100svh;
    overflow: hidden;
}

#app:has(.game-container--playing),
.page:has(.game-container--playing),
.page main:has(.game-container--playing),
#app:has(.game-container--idle),
.page:has(.game-container--idle),
.page main:has(.game-container--idle) {
    height: 100%;
    max-height: 100svh;
    overflow: hidden;
    width: 100%;
    max-width: none;
}

.game-container--playing,
.game-container--idle {
    display: block;
    width: 100%;
    max-width: none;
    height: 100vh; /* fallback */
    height: 100svh;
    max-height: 100vh;
    max-height: 100svh;
    margin: 0;
    padding: 0 !important;
    box-sizing: border-box;
}

.game-container--playing {
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.7), transparent 42%),
        radial-gradient(circle at 90% 80%, rgba(47, 111, 237, 0.08), transparent 40%),
        linear-gradient(180deg, #e7f3ff 0%, #f4f8fc 55%, #e4eef8 100%);
}

.game-container--idle {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.35), transparent 40%),
        linear-gradient(165deg, #5b9bff 0%, #2f6fed 45%, #1b5fd0 100%);
}

.practice-screen {
    display: grid;
    grid-template-rows: auto 1fr clamp(28dvh, 30dvh, 32dvh);
    height: 100%;
    width: 100%;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    box-sizing: border-box;
}

/* Header ~10–12% of viewport */
.practice-header {
    flex-shrink: 0;
    padding: clamp(4px, 1.2dvh, 10px) clamp(10px, 3vw, 16px) clamp(4px, 0.8dvh, 8px);
    padding-left: max(clamp(10px, 3vw, 16px), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(10px, 3vw, 16px), env(safe-area-inset-right, 0px));
    box-sizing: border-box;
}

.practice-header-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 8px;
    min-height: clamp(36px, 5.5dvh, 44px);
}

.practice-close {
    width: clamp(34px, 9vw, 40px);
    height: clamp(34px, 9vw, 40px);
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: #6b7280;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.practice-close:active {
    transform: scale(0.94);
    background: #eef1f5;
}

.practice-header-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
}

.practice-score-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 999px;
    background: #ffe08a;
    color: #5c3b00;
    box-shadow: 0 2px 0 #e0b84a;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1rem, 4vw, 1.2rem);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.practice-streak-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ff9f43 0%, #ff7a18 100%);
    color: #fff;
    font-weight: 800;
    font-size: clamp(0.85rem, 3.4vw, 1rem);
    box-shadow: 0 2px 0 #e8680a;
    white-space: nowrap;
}

.practice-score-chip,
.practice-timer-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    color: #374151;
    font-weight: 700;
    font-size: clamp(0.75rem, 3vw, 0.9rem);
    white-space: nowrap;
}

.practice-timer-chip {
    color: #c0392b;
}

.practice-count {
    font-size: clamp(0.95rem, 4vw, 1.15rem);
    font-weight: 800;
    color: #1f2937;
    white-space: nowrap;
}

.practice-progress {
    height: 12px;
    margin-top: var(--space-2);
    background: rgba(47, 111, 237, 0.16);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.practice-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #34c759, #5ad66f);
    border-radius: 999px;
    transition: width 0.25s ease;
}

/* Continuous play stage — no card chrome */
.practice-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 clamp(1vw, 2vw, 3vw);
    box-sizing: border-box;
}

.practice-stage-glow {
    position: absolute;
    inset: 6% 6% 12%;
    border-radius: 40%;
    background:
        radial-gradient(circle at 30% 35%, rgba(47, 111, 237, 0.07), transparent 55%),
        radial-gradient(circle at 78% 70%, rgba(255, 159, 67, 0.06), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.practice-ball-space {
    position: absolute;
    top: 6%;
    left: 50%;
    transform: translateX(-50%);
    width: clamp(18px, 5vw, 28px);
    height: clamp(18px, 5vw, 28px);
    border-radius: 50%;
    background: transparent;
    z-index: 1;
    pointer-events: none;
}

.practice-stave-wrap {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding-bottom: clamp(88px, 18vh, 128px);
}

.practice-stave-wrap #music-output {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.practice-stave-wrap #music-output svg {
    width: auto;
    height: 92%;
    max-width: 100%;
    max-height: 100%;
}

.practice-stave-wrap.is-hit #music-output svg {
    animation: hp-glow-pulse 0.55s var(--ease-soft);
}

.practice-feedback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(4rem, 22vw, 6.5rem);
    font-weight: 900;
    line-height: 1;
    pointer-events: none;
    z-index: 5;
    animation: practice-pop 0.28s ease;
}

.practice-feedback--ok {
    color: #22c55e;
    text-shadow: 0 4px 0 rgba(34, 197, 94, 0.25);
}

.practice-feedback--soft {
    /* Miss: no big X — mascot + keyboard flash teach gently */
    opacity: 0;
}

.practice-feedback--no {
    color: #1f2937;
    text-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}

@keyframes practice-pop {
    0% { transform: scale(0.6); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}

.practice-buddy {
    position: absolute;
    left: max(8px, env(safe-area-inset-left, 0px));
    right: auto;
    bottom: 4px;
    z-index: 3;
    width: auto;
    height: auto;
    max-width: 46%;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    pointer-events: none;
    transition: transform 0.2s ease;
}

.practice-buddy .hp-mascot {
    width: clamp(84px, 22vw, 120px);
    height: clamp(84px, 22vw, 120px);
    filter: none;
}

.practice-buddy .hp-mascot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: bottom center;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.12));
}

.practice-buddy--yes {
    animation: buddy-yes 0.45s ease;
}

.practice-buddy--no {
    animation: buddy-no 0.4s ease;
}

@keyframes buddy-yes {
    0%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-10px) scale(1.08); }
}

@keyframes buddy-no {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px) rotate(-6deg); }
    50% { transform: translateX(6px) rotate(6deg); }
    75% { transform: translateX(-4px); }
}

/* Keyboard — ~28–32% height, bottom anchored; keys capped so they don't stretch on wide screens */
.practice-keyboard-dock {
    --white-key-max-width: 4rem; /* 64px — readable, not tablet-stretched */
    position: relative;
    z-index: 4;
    display: flex;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    min-height: 0;
    padding: clamp(6px, 1.2dvh, 10px) 0 calc(4px + env(safe-area-inset-bottom, 0px));
    background: #d5dee8;
    box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.1);
    overflow: hidden;
    box-sizing: border-box;
}

.practice-keyboard-dock .keyboard {
    position: relative;
    margin: 0;
    height: 100%;
    background: transparent;
    border: none;
    /* 7 white keys × 3em = 21em → nearly full viewport width */
    width: 21em;
    max-width: 100%;
    font-size: clamp(12px, calc((100vw - 8px) / 21), 28px);
}

/* Note Challenge: five white keys C–G, black keys as landmarks */
.practice-keyboard-dock .keyboard.keyboard-naturals {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    font-size: unset;
    gap: 0;
}

.practice-keyboard-dock .keyboard-naturals .white-key {
    position: relative;
    display: block;
    flex: 0 1 var(--white-key-max-width);
    width: var(--white-key-max-width);
    max-width: var(--white-key-max-width);
    min-width: 0;
    height: 100%;
    margin: 0;
    border: 1px solid #b7c2cf;
    border-left-width: 0;
    border-bottom: none;
    border-radius: 0 0 6px 6px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.06);
    z-index: 1;
}

.practice-keyboard-dock .keyboard-naturals .white-key:first-child {
    border-left-width: 1px;
}

.practice-keyboard-dock .keyboard-naturals .black-key {
    position: absolute;
    top: 0;
    height: 58%;
    z-index: 3;
    margin: 0;
    border-radius: 0 0 6px 6px;
    background: linear-gradient(180deg, #3a3f4a 0%, #1a1d24 100%);
    box-shadow: 0 3px 0 #0b0d10;
}

.practice-keyboard-dock .keyboard-two-octaves {
    width: 42em;
    font-size: clamp(8px, calc((100vw - 8px) / 42), 16px);
    transform: none;
    margin: 0;
}

.practice-keyboard-dock .white-key {
    height: 100%;
    width: 3em;
    border: 1px solid #b7c2cf;
    border-bottom: none;
    border-radius: 0 0 clamp(10px, 2.5vw, 16px) clamp(10px, 2.5vw, 16px);
    box-shadow: 0 3px 0 #a8b4c2, 0 5px 10px rgba(0, 0, 0, 0.1);
    background: linear-gradient(180deg, #ffffff 0%, #f3f6fa 100%);
    transition: background-color 0.08s ease, transform 0.08s ease, box-shadow 0.08s ease;
}

.practice-keyboard-dock .white-key.key-pressed {
    background: #dfe7f0;
    transform: translateY(4px);
    box-shadow: 0 1px 0 #a8b4c2;
}

.practice-keyboard-dock .white-key.key-correct {
    background: #4CAF50 !important;
}

.practice-keyboard-dock .white-key.key-wrong {
    background: #ffe08a !important;
    box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.55);
}

.practice-keyboard-dock .key-label {
    bottom: clamp(0.35em, 1.5dvh, 0.7em);
    font-size: clamp(0.95em, 4.5vw, 1.25em);
    font-weight: 800;
    color: #111827;
    letter-spacing: 0.02em;
}

.practice-keyboard-dock .white-key.middle-c-key::before {
    display: none;
}

/* Middle C is the landmark everything is read from: ring its letter. */
.practice-keyboard-dock .white-key.middle-c-key .key-label {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    min-width: 1.9em;
    height: 1.9em;
    padding: 0;
    line-height: 1;
    border: 2.5px solid var(--color-play-blue, #2f6fed);
    border-radius: 50%;
    background: #fff;
    bottom: clamp(0.25em, 1dvh, 0.5em);
}

.practice-keyboard-dock .black-key {
    height: 58%;
    width: 1.85em;
    border-radius: 0 0 8px 8px;
    background: linear-gradient(180deg, #3a3f4a 0%, #1a1d24 100%);
    box-shadow: 0 3px 0 #0b0d10;
}

.practice-keyboard-dock .black-key.key-pressed {
    transform: translateY(3px);
    background: #111;
}

/* Short phones — keep everything in 100dvh */
@media screen and (max-height: 700px) {
    .practice-screen {
        grid-template-rows: auto 1fr clamp(26dvh, 28dvh, 30dvh);
    }

    .practice-buddy .hp-mascot {
        width: clamp(64px, 18vw, 88px);
        height: clamp(64px, 18vw, 88px);
    }

    .practice-stave-wrap {
        padding-bottom: 76px;
    }

    .practice-feedback {
        font-size: clamp(3rem, 18vw, 4.5rem);
    }
}

@media screen and (max-width: 900px) and (orientation: landscape) {
    .practice-screen {
        grid-template-rows: auto 1fr clamp(34dvh, 38dvh, 42dvh);
    }

    .practice-header {
        padding-top: 2px;
        padding-bottom: 2px;
    }

    .practice-ball-space {
        display: none;
    }

    .practice-stage {
        padding-inline: 2vw;
    }

    .practice-buddy {
        width: auto;
        max-width: 34%;
        bottom: 2px;
        left: 4px;
        right: auto;
    }

    .practice-buddy .hp-mascot {
        width: clamp(56px, 16vw, 80px);
        height: clamp(56px, 16vw, 80px);
    }

    .practice-stave-wrap {
        width: 100%;
        max-width: 100%;
        height: 100%;
        padding-bottom: 64px;
    }
}

/* Desktop: still fill the viewport — don't shrink to a phone column */
@media (min-width: 901px) {
    .game-container--playing {
        max-width: none;
        margin: 0;
        border: none;
        box-shadow: none;
    }

    .practice-keyboard-dock .keyboard:not(.keyboard-two-octaves) {
        font-size: clamp(14px, calc((100vw - 8px) / 21), 36px);
    }
}

.game-container--playing .audio-banner {
    top: auto;
    bottom: calc(clamp(28dvh, 30dvh, 32dvh) + 8px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    z-index: 20;
}

.practice-progress-readout {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
    justify-self: end;
}

.practice-progress-label {
    font-weight: 700;
    font-size: clamp(0.95rem, 3.4vw, 1.15rem);
    color: var(--color-ink);
    line-height: 1;
}

/* Note Challenge stage selection */
.page main .content:has(.nc-stages-screen) {
    padding: 0 !important;
    max-width: none;
    width: 100%;
}

.nc-stages-screen {
    position: relative;
    min-height: 100dvh;
    min-height: 100svh;
    padding: var(--space-4) var(--space-4) max(var(--space-6), env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: visible;
    box-sizing: border-box;
    background:
        radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.7), transparent 36%),
        linear-gradient(180deg, #dceaff 0%, #f7fbff 38%, #ffffff 100%);
}

.nc-stages-content {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
}

.nc-stages-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.nc-stages-header h1 {
    font-size: clamp(1.35rem, 5vw, 1.7rem);
    margin: 0;
    text-align: center;
    color: var(--color-play-ink);
}

.nc-stages-mascot .hp-mascot {
    width: 72px;
    height: 72px;
}

.nc-stages-profile {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.nc-back-link {
    background: var(--color-neutral-0);
    border: none;
    color: var(--color-play-blue);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-pill);
    box-shadow: 0 3px 0 var(--color-neutral-200);
}

.nc-stages-intro {
    text-align: center;
    color: var(--color-muted);
    margin: 0 0 var(--space-5);
}

.nc-path-section {
    margin-bottom: var(--space-6);
}

.nc-path--treble { --path-accent: var(--color-path-treble); --path-tint: var(--color-path-treble-tint); }
.nc-path--bass { --path-accent: var(--color-path-bass); --path-tint: var(--color-path-bass-tint); }
.nc-path--grand { --path-accent: var(--color-path-grand); --path-tint: var(--color-path-grand-tint); }
.nc-path--master { --path-accent: var(--color-path-master); --path-tint: var(--color-path-master-tint); }

.nc-path-section__title {
    font-size: 1.2rem;
    margin: 0 0 var(--space-3);
    color: var(--path-accent, var(--color-ink));
}

.nc-path-section__stages {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.nc-stage-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-neutral-0);
    box-shadow: 0 2px 8px rgba(22, 58, 122, 0.06);
    border: 2px solid transparent;
    border-left: 6px solid var(--path-accent, var(--color-play-blue));
}

.nc-stage-card--available {
    background: var(--color-neutral-0);
}

.nc-stage-card--completed {
    background: var(--path-tint, var(--color-neutral-50));
}

.nc-stage-card--locked {
    background: var(--color-neutral-100);
    border-style: dashed;
    border-left-style: solid;
    opacity: 0.82;
}

.nc-stage-card__icon {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.nc-stage-card__badge {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}

.nc-stage-card--locked .nc-stage-card__badge {
    filter: grayscale(1) opacity(0.55);
}

.nc-stage-card__lock-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-pill);
    background: var(--color-neutral-700);
    color: var(--color-neutral-0);
    display: grid;
    place-items: center;
}

.nc-stage-card__body {
    flex: 1;
    min-width: 0;
}

.nc-stage-card__name {
    margin: 0;
    font-size: 1.05rem;
    color: var(--color-ink);
}

.nc-stage-card__desc {
    margin: var(--space-1) 0;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.nc-stage-card__stars {
    display: flex;
    gap: var(--space-1);
}

.nc-star {
    color: var(--color-neutral-300);
    font-size: 1rem;
}

.nc-star--earned {
    color: var(--color-star);
}

.nc-stage-card__lock {
    margin: var(--space-1) 0 0;
    font-size: 0.8rem;
    color: var(--color-muted);
}

.nc-stage-card__best {
    margin: var(--space-1) 0 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-ink);
}

/* Play and Sprint sit side by side on every card, the highlighted next-up one included */
.nc-stage-card__actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* —— Speed sprint —— */
.practice-timer-chip--low {
    background: #fde8e6;
    animation: hp-sprint-pulse 1s ease-in-out infinite;
}

@keyframes hp-sprint-pulse {
    50% { transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
    .practice-timer-chip--low { animation: none; }
}

.game-container--idle .sprint-score .challenge-end-value {
    font-size: clamp(2.5rem, 9svh, 4rem);
}

.sprint-score .challenge-end-points {
    margin-top: 4px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #8a5a00;
}

.sprint-score .challenge-end-label {
    margin-top: 2px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-ink);
}

.game-idle-screen .whats-next.sprint-best--new {
    background: #fff4d6;
    color: #8a5a00;
}

.home-screen__continue-label {
    margin: var(--space-2) 0 0;
    font-size: 0.95rem;
    color: var(--color-ink);
}

.home-screen__continue-desc {
    margin: var(--space-1) 0 var(--space-3);
    font-size: 0.85rem;
    color: var(--color-muted);
}

.home-screen__choose-stage {
    display: block;
    margin-top: var(--space-5);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-play-blue);
    text-decoration: none;
}

.practice-timer-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(47, 111, 237, 0.12);
    color: #2f6fed;
    font-weight: 600;
    font-size: 0.9rem;
}

.keyboard-range {
    display: flex;
    position: relative;
    width: fit-content;
    max-width: 100%;
}

.keyboard-range .white-key {
    flex: 0 1 var(--white-key-max-width, 4rem);
    width: var(--white-key-max-width, 4rem);
    max-width: var(--white-key-max-width, 4rem);
    min-width: 0;
}

/* MIDI-range keyboards (stage paths) — capped key width, centered; landmark black keys */
.practice-keyboard-dock .keyboard.keyboard-range {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative;
    width: fit-content;
    max-width: 100%;
    height: 100%;
    margin-inline: auto;
    font-size: unset;
    gap: 0;
}

.practice-keyboard-dock .keyboard-range .white-key {
    position: relative;
    display: block;
    flex: 0 1 var(--white-key-max-width);
    width: var(--white-key-max-width);
    max-width: var(--white-key-max-width);
    min-width: 0;
    height: 100%;
    margin: 0;
    border: 1px solid #b7c2cf;
    border-left-width: 0;
    border-bottom: none;
    border-radius: 0 0 6px 6px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.06);
    z-index: 1;
}

.practice-keyboard-dock .keyboard-range .white-key:first-child {
    border-left-width: 1px;
}

.practice-keyboard-dock .keyboard-range .black-key {
    position: absolute;
    top: 0;
    height: 58%;
    z-index: 3;
    margin: 0;
    border: none;
    border-radius: 0 0 6px 6px;
    background: linear-gradient(180deg, #3a3f4a 0%, #1a1d24 100%);
    box-shadow: 0 3px 0 #0b0d10;
    /* width/left set inline from key index */
}

/* —— Round-end pause: hold on the finished round until OK is tapped or the bar runs out —— */
.round-end-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(18, 44, 110, 0.45);
}

.round-end-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: min(100%, 340px);
    padding: 20px 20px 16px;
    box-sizing: border-box;
    text-align: center;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 248, 220, 0.98), rgba(255, 255, 255, 0.98));
    box-shadow: 0 16px 40px rgba(10, 40, 110, 0.35);
}

.round-end-title {
    margin: 0;
    font-size: clamp(1.7rem, 7vw, 2.3rem);
    line-height: 1.1;
    color: var(--color-ink);
}

.round-end-sub {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 600;
    color: #144f8f;
}

.round-end-countdown {
    width: 100%;
    height: 8px;
    margin-top: 6px;
    border-radius: 999px;
    background: rgba(47, 111, 237, 0.15);
    overflow: hidden;
}

.round-end-countdown__fill {
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: var(--color-play-blue, #2f6fed);
    transform-origin: left center;
    animation-name: round-end-countdown;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

@keyframes round-end-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}


/* —— Stage list: next stage stands out, finished / far-off stages collapse to a row —— */
.nc-stage-card--current {
    border-color: var(--path-accent, var(--color-play-blue));
    box-shadow: 0 6px 20px rgba(47, 111, 237, 0.28);
    scroll-margin-top: 24px;
}

.nc-stage-card__next-up {
    display: inline-block;
    margin-bottom: 2px;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--color-play-orange, #ff8a3d);
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nc-stage-card--compact {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-3);
}

.nc-stage-card--compact .nc-stage-card__icon {
    width: 34px;
    height: 34px;
}

.nc-stage-card--compact .nc-stage-card__lock-badge {
    width: 16px;
    height: 16px;
    right: -5px;
    bottom: -5px;
}

.nc-stage-card--compact .nc-stage-card__name {
    font-size: 0.95rem;
}

.nc-stage-card--compact .nc-stage-card__stars {
    align-items: center;
}

.nc-stage-card--compact .nc-star {
    font-size: 0.85rem;
}

.nc-stage-card__best-inline {
    margin-left: var(--space-2);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-ink);
}

.nc-stage-card--compact .nc-stage-card__actions {
    flex-direction: row;
}

/* Phone: the full-size card puts its buttons on their own row, so the stage name has the whole width */
@media (max-width: 480px) {
    .nc-stage-card:not(.nc-stage-card--compact) {
        flex-wrap: wrap;
    }

    .nc-stage-card:not(.nc-stage-card--compact) .nc-stage-card__body {
        flex: 1 1 0;
        min-width: 0;
    }

    .nc-stage-card:not(.nc-stage-card--compact) .nc-stage-card__actions {
        flex-direction: row;
        flex: 1 1 100%;
    }

    .nc-stage-card:not(.nc-stage-card--compact) .nc-stage-card__actions > * {
        flex: 1;
    }
}

/* ───────── Free play: a two-octave keyboard and the note you played on the stave ───────── */
.free-play__title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1rem, 3.4vw, 1.25rem);
    color: #1b3a6b;
    justify-self: center;
}

.free-play .practice-header-meta {
    justify-content: center;
}

/* No mascot sits under the stave here, so it can use the space */
.free-play .practice-stave-wrap {
    padding-bottom: clamp(30px, 8vh, 56px);
}

.free-play__name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: clamp(2px, 1.2vh, 10px);
    z-index: 3;
    margin: 0;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.1rem, 4.2vw, 1.7rem);
    color: #2f6fed;
    pointer-events: none;
}

/* Two-octave keyboard (Free play). Key sizes are in em, and a <button> uses its own font size unless told otherwise,
   so without this the keys came out 40px wide and 14 of them overflowed the screen. */
.practice-keyboard-dock .keyboard-two-octaves {
    font-size: clamp(8px, calc((100vw - 8px) / 42), 26px);
    margin-inline: auto;
}

.practice-keyboard-dock .keyboard-two-octaves .white-key,
.practice-keyboard-dock .keyboard-two-octaves .black-key {
    font-size: inherit;
}

.practice-keyboard-dock .keyboard-two-octaves .key-label {
    font-size: clamp(10px, 1.45em, 20px);
    bottom: 0.5em;
}

.practice-keyboard-dock .keyboard-two-octaves .white-key.middle-c-key .key-label {
    bottom: 0.3em;
}

/* ───────── Keep playing (continuous mode): no goal, so no progress bar; a clear Done button instead ───────── */
.practice-progress--none {
    display: none;
}

.practice-done {
    border: none;
    border-radius: 999px;
    padding: 6px 16px;
    margin-left: 8px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.95rem;
    color: #fff;
    background: linear-gradient(180deg, #ffa24a 0%, #f2711c 100%);
    box-shadow: 0 3px 0 #c75a12;
    cursor: pointer;
}

.practice-done:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #c75a12;
}
