:root {
    --ink: #17212b;
    --paper: #fff9ea;
    --paper-deep: #f4ead0;
    --sky: #8ed4e8;
    --reed: #2f7b6b;
    --coral: #f36f53;
    --sun: #ffc857;
    --mist: #e8f6f7;
    --key-label: #1268d6;
    --shadow: 0 20px 44px rgba(33, 40, 47, 0.18);
}

* {
    box-sizing: border-box;
}

html,
body,
#app {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        linear-gradient(135deg, rgba(142, 212, 232, 0.45), rgba(255, 200, 87, 0.26)),
        repeating-linear-gradient(90deg, rgba(23, 33, 43, 0.04) 0 1px, transparent 1px 32px),
        var(--paper);
}

button,
a {
    font: inherit;
}

button {
    border: 0;
}

h1,
h2,
p {
    margin: 0;
}

h1:focus {
    outline: none;
}

.app-shell {
    min-height: 100vh;
}

.app-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 1rem clamp(1rem, 4vw, 3rem);
}

.brand-mark {
    align-items: center;
    color: var(--ink);
    display: inline-flex;
    font-size: clamp(1.1rem, 3vw, 1.45rem);
    font-weight: 800;
    gap: 0.55rem;
    text-decoration: none;
}

.brand-icon {
    align-items: center;
    background: var(--coral);
    border: 3px solid var(--ink);
    border-radius: 50%;
    color: white;
    display: inline-flex;
    height: 2.25rem;
    justify-content: center;
    line-height: 1;
    width: 2.25rem;
}

.app-nav {
    display: flex;
}

.nav-pill {
    background: rgba(255, 255, 255, 0.58);
    border: 2px solid rgba(23, 33, 43, 0.16);
    border-radius: 999px;
    color: var(--ink);
    font-weight: 700;
    padding: 0.55rem 0.9rem;
    text-decoration: none;
}

.nav-pill.active {
    background: var(--ink);
    color: white;
}

.app-main {
    padding: 0 clamp(1rem, 4vw, 3rem) 2rem;
}

.practice-stage {
    display: grid;
    gap: clamp(1rem, 3vw, 2rem);
    grid-template-columns: minmax(16rem, 0.75fr) minmax(20rem, 1.25fr);
    margin: 0 auto;
    max-width: 1180px;
}

.lesson-panel,
.exercise-board {
    border: 3px solid var(--ink);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.lesson-panel {
    align-self: start;
    background: linear-gradient(180deg, #ffffff 0%, var(--mist) 100%);
    min-height: 24rem;
    padding: clamp(1rem, 4vw, 2rem);
}

.lesson-kicker {
    color: var(--reed);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.08rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.lesson-panel h1 {
    font-size: clamp(1rem, 4vw, 2.75rem);
    font-weight: 900;
    line-height: 0.95;
    max-width: 20ch;
}

.mode-switch {
    background: white;
    border: 2px solid var(--ink);
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 2rem;
    overflow: hidden;
}

.mode-button {
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font-weight: 900;
    min-height: 3.15rem;
}

.mode-button + .mode-button {
    border-left: 2px solid var(--ink);
}

.mode-button.is-active {
    background: var(--sun);
}

.score-strip {
    display: grid;
    gap: 0.65rem;
    margin-top: 1.35rem;
}

.score-strip span {
    background: rgba(255, 255, 255, 0.72);
    border: 2px solid rgba(23, 33, 43, 0.18);
    border-radius: 8px;
    font-weight: 800;
    padding: 0.7rem 0.8rem;
}

.exercise-board {
    background: rgba(255, 249, 234, 0.92);
    padding: clamp(1rem, 4vw, 1.5rem);
}

.prompt-row {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.prompt-label {
    color: var(--reed);
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.05rem;
    text-transform: uppercase;
}

.prompt-row h2 {
    font-size: clamp(1.4rem, 4vw, 2.25rem);
    font-weight: 900;
    line-height: 1.05;
}

.next-button {
    background: var(--ink);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-weight: 900;
    min-height: 3rem;
    padding: 0 1rem;
}

.music-staff {
    display: block;
    height: auto;
    max-height: 22rem;
    width: 100%;
}

.staff-paper {
    fill: #fffefa;
}

.staff-line {
    stroke: var(--ink);
    stroke-linecap: round;
    stroke-width: 3;
}

.staff-barline {
    stroke: var(--ink);
    stroke-linecap: butt;
    stroke-width: 3;
}

.treble-clef {
    fill: var(--ink);
    pointer-events: none;
    stroke: var(--ink);
    stroke-width: 1.6;
}

.note-head {
    fill: var(--coral);
    stroke: var(--ink);
    stroke-width: 3;
}

.ledger-line {
    stroke: var(--ink);
    stroke-linecap: round;
    stroke-width: 3;
}

.ledger-line.is-target {
    opacity: 0.34;
}

.note-stem {
    stroke: var(--ink);
    stroke-linecap: round;
    stroke-width: 4;
}

.staff-hit-button {
    cursor: pointer;
}

.staff-target {
    fill: rgba(47, 123, 107, 0.15);
    stroke: rgba(47, 123, 107, 0.5);
    stroke-dasharray: 3 4;
    stroke-width: 2;
}

.staff-hit-button:hover .staff-target,
.staff-target.is-selected {
    fill: var(--sun);
    stroke: var(--ink);
    stroke-dasharray: none;
}

.piano-keyboard {
    --black-key-width: min(2.25rem, 5.7vw);
    background: var(--ink);
    border: 3px solid var(--ink);
    border-radius: 8px;
    margin-top: 1rem;
    min-height: 8.5rem;
    overflow: hidden;
    position: relative;
}

.white-key-row {
    display: grid;
    grid-template-columns: repeat(14, minmax(0, 1fr));
    height: 8.5rem;
}

.piano-white-key {
    align-items: end;
    background: linear-gradient(180deg, #fffefa 0%, #f4ead0 100%);
    border-right: 1px solid rgba(23, 33, 43, 0.42);
    color: var(--ink);
    cursor: pointer;
    display: grid;
    font-weight: 900;
    gap: 0.15rem;
    justify-items: center;
    min-width: 0;
    padding: 0 0.2rem 0.65rem;
    position: relative;
    transition: background 120ms ease, transform 120ms ease;
}

.piano-white-key:last-child {
    border-right: 0;
}

.piano-white-key:hover,
.piano-white-key:focus-visible {
    background: linear-gradient(180deg, #fffefa 0%, var(--sun) 100%);
    transform: translateY(3px);
}

.piano-white-key.is-highlighted {
    background: linear-gradient(180deg, #fffefa 0%, #86e68f 100%);
    box-shadow: inset 0 -5px 0 #2f9a44;
}

.piano-white-key span {
    color: var(--key-label);
    font-size: clamp(0.76rem, 1.6vw, 1.1rem);
    line-height: 1;
    position: relative;
    text-shadow: 0 1px 0 white, 0 0 6px white;
    z-index: 3;
}

.piano-white-key small {
    color: var(--key-label);
    font-size: clamp(0.58rem, 1.25vw, 0.78rem);
    font-weight: 900;
    line-height: 1;
    position: relative;
    text-shadow: 0 1px 0 white, 0 0 6px white;
    z-index: 3;
}

.black-key-row {
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

.piano-black-key {
    background: linear-gradient(180deg, #202833 0%, #050607 100%);
    border: 2px solid #050607;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.55);
    height: 4.9rem;
    position: absolute;
    top: 0;
    width: var(--black-key-width);
}

.key-label-row {
    align-items: end;
    bottom: 0.65rem;
    display: grid;
    grid-template-columns: repeat(14, minmax(0, 1fr));
    left: 0;
    pointer-events: none;
    position: absolute;
    right: 0;
    z-index: 4;
}

.key-label {
    color: var(--key-label);
    display: grid;
    font-weight: 900;
    gap: 0.15rem;
    justify-items: center;
    min-width: 0;
    padding: 0 0.2rem;
    text-shadow: 0 1px 0 white, 0 0 6px white, 0 0 10px white;
}

.key-label span {
    font-size: clamp(0.76rem, 1.6vw, 1.1rem);
    line-height: 1;
}

.key-label small {
    font-size: clamp(0.58rem, 1.25vw, 0.78rem);
    font-weight: 900;
    line-height: 1;
}

.feedback {
    background: white;
    border: 2px solid rgba(23, 33, 43, 0.16);
    border-radius: 8px;
    font-weight: 900;
    margin-top: 1rem;
    min-height: 3.25rem;
    padding: 0.9rem 1rem;
}

.feedback.is-correct {
    background: #dff7df;
    border-color: #4f9f4f;
}

.feedback.is-missed {
    background: #ffe5df;
    border-color: var(--coral);
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    color: var(--ink);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    display: block;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
    position: absolute;
    width: 8rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--paper-deep);
    stroke-width: 0.6rem;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: var(--coral);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    font-weight: 900;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    position: absolute;
    text-align: center;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 820px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .practice-stage {
        grid-template-columns: 1fr;
    }

    .lesson-panel {
        min-height: 0;
    }

    .lesson-panel h1 {
        max-width: none;
    }

    .piano-keyboard {
        --black-key-width: min(1.85rem, 6vw);
        min-height: 7.3rem;
    }

    .white-key-row {
        height: 7.3rem;
    }
}

@media (max-width: 480px) {
    .prompt-row {
        align-items: stretch;
        flex-direction: column;
    }

    .next-button {
        width: 100%;
    }

    .piano-keyboard {
        --black-key-width: 1.25rem;
        min-height: 6.4rem;
    }

    .white-key-row {
        height: 6.4rem;
    }

    .piano-white-key {
        padding-bottom: 0.45rem;
    }

    .piano-white-key span {
        font-size: 0.62rem;
    }

    .piano-white-key small {
        font-size: 0.52rem;
    }

    .piano-black-key {
        height: 3.9rem;
    }
}
