* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: 140px;
}

h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #f0f0f0;
    margin-top: 12px;
    margin-bottom: 6px;
}

.hud {
    width: 90%;
    max-width: 460px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #aaa;
}

.hud .progress {
    font-weight: 600;
    color: #ccc;
}

.hud .timer {
    font-variant-numeric: tabular-nums;
}

.hud .highscore {
    font-size: 0.75rem;
    color: #777;
}

.reset-hs {
    display: none;
    font-size: 0.7rem;
    color: #555;
    cursor: pointer;
    margin-left: -4px;
}

.reset-hs.visible {
    display: inline;
}

.reset-hs:active {
    color: #e5383b;
}

.staff-container {
    width: 90%;
    max-width: 460px;
    background: #2a2a2a;
    border-radius: 12px;
    padding: 16px 8px;
}

canvas#staff {
    width: 100%;
    display: block;
}

.feedback {
    margin-top: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    min-height: 2.8rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.feedback .result {
    padding: 6px 20px;
    border-radius: 8px;
}

.feedback .result.correct {
    background: #1b4332;
    color: #52b788;
}

.feedback .result.incorrect {
    background: #461220;
    color: #e5383b;
}

.feedback .answer {
    width: 100%;
    font-size: 0.85rem;
    color: #999;
}

.feedback .next-hint {
    font-size: 0.75rem;
    color: #666;
    margin-top: 2px;
}

.start-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.start-panel.visible {
    display: flex;
}

.clef-btns {
    display: flex;
    gap: 0;
}

.clef-btns button {
    padding: 0 14px;
    height: 36px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid #555;
    background: #333;
    color: #aaa;
    cursor: pointer;
}

.clef-btns button:first-child {
    border-radius: 8px 0 0 8px;
}

.clef-btns button:last-child {
    border-radius: 0 8px 8px 0;
}

.clef-btns button + button {
    border-left: none;
}

.clef-btns button.selected {
    background: #2d7a56;
    color: #52b788;
    border-color: #52b788;
}

.clef-btns button.selected + button {
    border-left: none;
}

.option-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.option-group .label {
    font-size: 0.85rem;
    color: #888;
}

.note-count-btns {
    display: flex;
    gap: 0;
}

.note-count-btns button {
    width: 40px;
    height: 36px;
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid #555;
    background: #333;
    color: #aaa;
    cursor: pointer;
}

.note-count-btns button:first-child {
    border-radius: 8px 0 0 8px;
}

.note-count-btns button:last-child {
    border-radius: 0 8px 8px 0;
}

.note-count-btns button + button {
    border-left: none;
}

.note-count-btns button.selected {
    background: #2d7a56;
    color: #52b788;
    border-color: #52b788;
}

.note-count-btns button.selected + button {
    border-left: none;
}

.note-toggle-btns {
    display: flex;
    gap: 0;
}

.note-toggle-btns button {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid #555;
    background: #333;
    color: #555;
    cursor: pointer;
}

.note-toggle-btns button:first-child {
    border-radius: 8px 0 0 8px;
}

.note-toggle-btns button:last-child {
    border-radius: 0 8px 8px 0;
}

.note-toggle-btns button + button {
    border-left: none;
}

.note-toggle-btns button.selected {
    background: #2d7a56;
    color: #52b788;
    border-color: #52b788;
}

.note-toggle-btns button.selected + button {
    border-left: none;
}

.start-btn {
    padding: 14px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    background: #52b788;
    color: #1a1a1a;
    cursor: pointer;
}

.start-btn:active {
    background: #3a9d6e;
}

/* Round summary overlay */
.summary {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
}

.summary.visible {
    display: flex;
}

.summary h2 {
    font-size: 1.5rem;
    color: #f0f0f0;
}

.summary .stat {
    font-size: 1.1rem;
    color: #ccc;
}

.summary .stat strong {
    color: #52b788;
}

.summary .new-best {
    color: #f9c74f;
    font-size: 0.9rem;
    font-weight: 600;
}

.summary button {
    margin-top: 12px;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    background: #52b788;
    color: #1a1a1a;
    cursor: pointer;
}

.summary button:active {
    background: #3a9d6e;
}

.next-btn {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #52b788;
    cursor: pointer;
    user-select: none;
    z-index: 10;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 0.05em;
}

.next-btn:active {
    background: #3a9d6e;
}

.next-btn.wrong {
    background: #e5383b;
}

.next-btn.wrong:active {
    background: #c1292e;
}

.next-btn.visible {
    display: flex;
}

.piano {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    display: flex;
    justify-content: center;
    background: #111;
    padding: 0 2px;
    user-select: none;
}

.keys {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 500px;
    height: 100%;
}

.key {
    position: relative;
    flex: 1;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 6px 6px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    z-index: 1;
    transition: background 0.08s;
}

.key:active, .key.active {
    background: #ddd;
}

.key.black {
    position: absolute;
    top: 0;
    width: 9%;
    height: 65%;
    background: #222;
    border: 1px solid #000;
    border-top: none;
    border-radius: 0 0 4px 4px;
    color: #aaa;
    font-size: 0.6rem;
    z-index: 2;
    padding-bottom: 6px;
}

.key.black:active, .key.black.active {
    background: #444;
}

.key.black[data-note="C#"] { left: calc(100% / 7 * 1 - 4.5%); }
.key.black[data-note="D#"] { left: calc(100% / 7 * 2 - 4.5%); }
.key.black[data-note="F#"] { left: calc(100% / 7 * 4 - 4.5%); }
.key.black[data-note="G#"] { left: calc(100% / 7 * 5 - 4.5%); }
.key.black[data-note="A#"] { left: calc(100% / 7 * 6 - 4.5%); }
