/* ---------------------------------------------------------------- tokens -- */
:root {
    --blue-50: #EFF6FF;
    --blue-100: #DBEAFE;
    --blue-200: #BFDBFE;
    --blue-600: #2563EB;
    --blue-700: #1D4ED8;

    --ink: #0F172A;
    --muted: #64748B;
    --line: #E2E8F0;
    --line-soft: #EEF2F7;
    --surface: #FFFFFF;
    --page: #F1F5F9;
    --panel: #F8FAFC;

    --r-lg: 18px;
    --r-md: 12px;
    --r-sm: 10px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.07);
    --shadow-accent: 0 2px 10px rgba(37, 99, 235, 0.28);

    --ease: background-color 0.15s, border-color 0.15s, color 0.15s,
            box-shadow 0.15s, transform 0.1s;

    /* Clef geometry. The key signature anchors to these (see --sig-anchor) so the sharps
       stay clear of the clef however narrow the stave gets. */
    --clef-treble-left: 4%;
    --clef-treble-width: 38.8px;
    --clef-bass-left: 5%;
    --clef-bass-width: 44.7px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 28px 20px;
    background-color: var(--page);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 26px 28px 30px;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
}

h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ----------------------------------------------------------- config panel -- */
.panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 22px 0 0;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

.settings,
.clef-toggle,
.flavor-toggle,
.inv-toggle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.settings {
    gap: 22px;
}

.setting {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-label,
.row-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.row-label {
    margin-right: 2px;
}

.setting select {
    -webkit-appearance: none;
    appearance: none;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 13px;
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--ease);
}

.setting select:hover {
    border-color: var(--blue-200);
    background-color: var(--blue-50);
}

/* ---------------------------------------------------------- chips/buttons -- */
button {
    font: inherit;
    font-size: 14px;
    padding: 10px 14px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: inherit;
    cursor: pointer;
    transition: var(--ease);
}

button:focus-visible,
.setting select:focus-visible {
    outline: 2px solid var(--blue-200);
    outline-offset: 2px;
}

.clef-btn, .inv-btn, .flavor-btn {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.clef-btn:not(:disabled):hover,
.inv-btn:not(:disabled):hover,
.flavor-btn:not(:disabled):hover {
    background: var(--blue-50);
    border-color: var(--blue-200);
    color: var(--blue-700);
}

.clef-btn.active, .inv-btn.active, .flavor-btn.active {
    background: var(--blue-600);
    border-color: var(--blue-600);
    color: white;
    box-shadow: var(--shadow-accent);
}

/* Inversions that do not apply to the active chord flavors (e.g. 3rd inversion
   while only triads are on) are shown but disabled. */
.inv-btn:disabled {
    background: var(--line-soft);
    border-color: transparent;
    color: #C3CCDA;
    box-shadow: none;
    cursor: not-allowed;
}

/* The always-on base chord set (triads): shown as a chip but not interactive. */
.flavor-base {
    padding: 10px 14px;
    background: var(--blue-600);
    color: white;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: default;
    box-shadow: var(--shadow-accent);
}

/* ------------------------------------------------------------------ staff -- */
.stave {
    width: 100%;
    height: 150px;
    margin: 18px 0 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.staff-lines {
    position: absolute;
    top: 42px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
}

.staff-line {
    height: 1px;
    background-color: black;
    margin-bottom: 15px;
}

/* Notehead: a slanted ellipse, not a circle. Bravura/SMuFL uses ~1.46:1 axes at ~31deg;
   using a gentler ~15deg tilt (up to the right) here. */
.note {
    position: absolute;
    width: 21px;
    height: 14px;
    background-color: black;
    border-radius: 50%;
    left: 50%;
    top: 0;
    transform: translate(-50%, -50%) rotate(-15deg);
}

.ledger-line {
    position: absolute;
    width: 28px;
    height: 1px;
    background-color: black;
    margin-left: -14px;
}

.clef {
    position: absolute;
}

/* Key-signature sharps, drawn just right of the clef. --sig-anchor is the clef's right
   edge; anchoring to it (rather than a bare % of the stave) keeps the sharps clear of the
   clef on narrow screens, where the fixed-width clef outgrows a percentage offset. */
.key-sig {
    position: absolute;
    transform: translate(-50%, -50%);
    --sig-anchor: 13%;
}
body[data-clef="treble"] .key-sig {
    --sig-anchor: calc(var(--clef-treble-left) + var(--clef-treble-width));
}
body[data-clef="bass"] .key-sig {
    --sig-anchor: calc(var(--clef-bass-left) + var(--clef-bass-width));
}

.key-sig svg {
    display: block;
    width: 10.5px;
    height: 34px;
}

.clef-treble {
    left: var(--clef-treble-left);
    top: 22px;
    width: var(--clef-treble-width);
    height: 110px;
}

.clef-bass {
    left: var(--clef-bass-left);
    top: 43px;
    width: var(--clef-bass-width);
    height: 51.7px;
}

body[data-clef="treble"] .clef-bass,
body[data-clef="bass"] .clef-treble {
    display: none;
}

/* --------------------------------------------------------------- answers -- */
.buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
    gap: 6px;
    margin: 18px 0 0;
}

.buttons button {
    padding: 10px 8px;
    background: var(--surface);
    border-color: var(--line);
    border-radius: var(--r-sm);
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.buttons button:hover {
    background: var(--blue-50);
    border-color: var(--blue-600);
    color: var(--blue-700);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
    transform: translateY(-1px);
}

.buttons button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------- feedback -- */
.feedback {
    margin: 16px 0 0;
    padding: 14px;
    min-height: 24px;
    border-radius: var(--r-md);
    text-align: center;
    font-weight: 600;
}

.feedback.correct {
    background: #ECFDF5;
    color: #047857;
}

.feedback.incorrect {
    background: #FEF2F2;
    color: #B91C1C;
}

/* ---------------------------------------------------------- game chooser -- */
.games {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 22px 0 0;
}

.game {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: var(--ease);
}

.game:hover {
    background: var(--blue-50);
    border-color: var(--blue-600);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
    transform: translateY(-1px);
}

.game:focus-visible {
    outline: 2px solid var(--blue-200);
    outline-offset: 2px;
}

.game-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--r-sm);
    background: var(--blue-100);
    color: var(--blue-600);
}

.game-icon svg {
    width: 26px;
    height: 26px;
}

.game-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.game-title {
    font-size: 16px;
    font-weight: 600;
}

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

.game-chevron {
    display: grid;
    place-items: center;
    margin-left: auto;
    color: var(--muted);
    transition: var(--ease);
}

.game:hover .game-chevron {
    color: var(--blue-600);
}

@media (max-width: 560px) {
    body {
        padding: 16px 12px;
    }
    .container {
        padding: 20px 16px 24px;
    }
}
