:root {
    color-scheme: dark;
    --bg: #1f1f1f;
    --panel: #2a2a2a;
    --border: #3a3a3a;
    --accent: #e8e8e8;
    --accent-soft: #cfcfcf;
    --primary: #7dd3fc;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Special Elite', 'Courier New', Courier, monospace;
    background: radial-gradient(circle at 20% 20%, #27202a, transparent 55%),
        radial-gradient(circle at 80% 0%, #222c30, transparent 60%),
        radial-gradient(circle at 50% 80%, #1f222c, transparent 60%),
        var(--bg);
    color: var(--accent);
    min-height: 100vh;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3.5rem 2rem;
}

.header h1 {
    font-weight: 400;
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
}

.header .tagline {
    margin: 0 0 2rem;
    color: var(--accent-soft);
}

h2 {
    font-weight: 400;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.keyboard-section,
.controls,
.preview {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.75rem;
    margin-bottom: 2rem;
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.25);
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.controls-header h2 {
    margin: 0;
}

.preset-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.preset-selector label {
    font-size: 0.95rem;
    color: var(--accent-soft);
}

.preset-selector select,
.preset-selector button {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.preset-selector select:hover,
.preset-selector button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.preset-selector button {
    background: var(--primary);
    color: #0b1120;
    border-color: var(--primary);
    font-weight: 600;
}

.preset-selector button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(125, 211, 252, 0.3);
}

.hint {
    font-size: 0.875rem;
    color: var(--accent-soft);
    margin-top: 1rem;
}

.keyboard {
    position: relative;
    display: flex;
    height: 200px;
    gap: 2px;
    justify-content: center;
    padding: 0 1rem;
}

.keyboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.keyboard-header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.song-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.song-button {
    appearance: none;
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 8px;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.song-button:hover {
    background: var(--border);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.song-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.song-button.playing {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(125, 211, 252, 0.4);
    animation: pulse-glow 1s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(125, 211, 252, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(125, 211, 252, 0.6);
    }
}

.octave-control {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.octave-button {
    appearance: none;
    background: var(--primary);
    color: #0b1120;
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(125, 211, 252, 0.25);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.octave-button:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(125, 211, 252, 0.3);
}

.octave-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.octave-display {
    font-size: 0.9rem;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.key {
    position: relative;
    border: none;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.05s ease, box-shadow 0.08s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 1rem;
}

.key-white {
    background: linear-gradient(180deg, #f7f7f7, #e0e0e0);
    color: #111;
    border-radius: 0 0 8px 8px;
    flex: 1;
    min-width: 50px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), inset 0 -4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.key-white:active,
.key-white.is-active {
    background: linear-gradient(180deg, #e0e0e0, #c8c8c8);
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 -2px 6px rgba(0, 0, 0, 0.15);
}

.key-black {
    background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
    color: #f0f0f0;
    border-radius: 0 0 6px 6px;
    width: 40px;
    height: 130px;
    position: absolute;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5), inset 0 -3px 6px rgba(255, 255, 255, 0.1);
    z-index: 2;
    padding-bottom: 0.75rem;
}

.key-black:active,
.key-black.is-active {
    background: linear-gradient(180deg, #1a1a1a, #0a0a0a);
    transform: translateY(2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), inset 0 -2px 4px rgba(255, 255, 255, 0.15);
}

/* Position black keys between white keys */
/* Each white key takes up 1/8 of the width. Black keys centered between them. */
.key-black[data-key="w"] { left: calc((100% / 8) * 1 - 20px); }   /* C# - between C(0) and D(1) */
.key-black[data-key="e"] { left: calc((100% / 8) * 2 - 20px); }   /* D# - between D(1) and E(2) */
.key-black[data-key="t"] { left: calc((100% / 8) * 4 - 20px); }   /* F# - between F(3) and G(4) */
.key-black[data-key="y"] { left: calc((100% / 8) * 5 - 20px); }   /* G# - between G(4) and A(5) */
.key-black[data-key="u"] { left: calc((100% / 8) * 6 - 20px); }   /* A# - between A(5) and B(6) */

.key .label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
}

.key .binding {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.7rem;
}

.key-white .binding {
    color: #666;
}

.key-black .label {
    font-size: 0.75rem;
}

.key-black .binding {
    color: #aaa;
    font-size: 0.65rem;
}

.group {
    margin-bottom: 2rem;
}

.group-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.group-title span {
    color: var(--accent-soft);
    font-size: 0.95rem;
}

.control {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr 60px;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.35rem;
}

.control label {
    font-size: 0.95rem;
    color: var(--accent);
}

.control input[type="range"] {
    width: 100%;
}

.control select,
.control input[type="range"] {
    accent-color: var(--primary);
}

.control input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-control {
    grid-template-columns: minmax(200px, 260px) auto 60px;
}

.checkbox-control input[type="checkbox"] {
    justify-self: start;
}

.value {
    font-size: 0.9rem;
    text-align: right;
    color: var(--accent-soft);
}

.preview pre {
    background: rgba(17, 17, 17, 0.65);
    border-radius: 12px;
    padding: 1.5rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    font-size: 0.9rem;
    line-height: 1.45;
}

code {
    color: #cde9ff;
}

@media (max-width: 720px) {
    .keyboard {
        height: 150px;
        padding: 0 0.5rem;
    }

    .key-white {
        min-width: 35px;
    }

    .key-black {
        width: 28px;
        height: 100px;
    }

    .key .label {
        font-size: 0.7rem;
    }

    .key .binding {
        font-size: 0.6rem;
    }

    .keyboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .control {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .value {
        text-align: left;
    }
}
