/* ==========================================================================
   Slotronome — pixel-art slot machine metronome
   Visual system: warm oak cabinet, brass trim, amber CRT reels, forest scene
   ========================================================================== */

/* --------------------------------------------------------------------------
   Fonts — self-hosted so the pixel-art identity survives offline and behind
   network blockers. Latin + latin-ext subsets only (~60KB total).
   Press Start 2P and Silkscreen are both SIL OFL 1.1; see fonts/*-OFL.txt.
   -------------------------------------------------------------------------- */

@font-face {
    font-family: 'Press Start 2P';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/press-start-2p-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
        U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Press Start 2P';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/press-start-2p-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
        U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
        U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
        U+A720-A7FF;
}

@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/silkscreen-400-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
        U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/silkscreen-400-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
        U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
        U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
        U+A720-A7FF;
}

@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/silkscreen-700-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
        U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 700;
    src: url('../fonts/silkscreen-700-latin-ext.woff2') format('woff2');
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
        U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
        U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
        U+A720-A7FF;
}

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

:root {
    /* --- Scene ------------------------------------------------------- */
    --scene-deep: #16210f;
    --scene-mid: #2f4526;
    --scene-lit: #4e7040;

    /* --- Cabinet (oak) ------------------------------------------------ */
    --wood-hi: #b8834a;
    --wood: #94663a;
    --wood-mid: #7c542d;
    --wood-low: #5d3d1f;
    --wood-edge: #402813;
    --wood-shadow: #2b1a0b;

    /* --- Brass / gold trim -------------------------------------------- */
    --brass-hi: #ffe9a8;
    --brass: #f0bc45;
    --brass-mid: #c98d1f;
    --brass-low: #8a5d10;

    /* --- Display glass ------------------------------------------------- */
    --glass-deep: #0b0704;
    --glass: #17100a;
    --glass-rim: #3a2812;

    /* --- Signal colours -------------------------------------------------- */
    --amber: #ffcf4d;
    --amber-glow: rgba(255, 164, 28, 0.75);
    --red: #e14b38;
    --red-deep: #8e2418;
    --blue: #5aa4ec;
    --blue-deep: #2a5f9e;

    /* --- Legacy aliases (kept so nothing downstream breaks) ------------- */
    --main-bg-color: var(--scene-mid);
    --slot-machine-color: var(--wood);
    --slot-display-color: #2d1e0f;
    --accent-color: var(--amber);
    --text-color: #f6ecd6;
    --button-color: var(--brass);
    --button-hover: #ffd66a;
    --button-active: var(--brass-mid);
    --accent-beat: var(--red);
    --normal-beat: var(--blue);

    /* --- Type ------------------------------------------------------------ */
    --font-display: 'Press Start 2P', 'Courier New', ui-monospace, monospace;
    --font-ui: 'Silkscreen', 'Press Start 2P', 'Courier New', ui-monospace, monospace;

    /* --- Pixel cursors (declared once, reused everywhere) ---------------- */
    --cur-pointer: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAA7klEQVRYhe2XsQ7CIBCGf9PRwTeA+gYdk70iJg4O+gAuDi4OugHvoGMnE98AHqETPsBdwpQQoJSWUif+ySUEuPv4jyvQGB2wA0ZpuQIPzbldCTLhwqRlA66qlHPCqt9aa3Wm3AEjIK3I52iOiYTUPoGSAekHz4T2k1tnKQY6YG8h3/JeW+sMDFzAJEL5n3hvrXPgBIytynfih3HJt13sgLnS4qxcJ1TBJDGoirQx8XrgM3SIF5O4HhhJaYv0wBpYVp4DJSL9hAsG9prhr+Poq9//BZ4EJqfdaIg0nWsYQtNS7FexXcdB/tpKfVNDnQs+bPdYqFN5RDIAAAAASUVORK5CYII='), pointer;
    --cur-grab: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAA20lEQVRYhe2XsQ6DMAxFnyNlKDdA5QYwM5YJiYEhfAALAwsDzIC5fAA3YO5SboA6MSBWLEqQIlVVGJL+JZNtOdfPdm4cAwNQAZ00X4D7HrtSC2PCmqZkk6csS9xCPeccJ3tZMQMVkCX8J+uZCHNjTsBiQHzGNUF70lrHYmAECgfyldYqFgMXoLcq74mP2pJrv1gDUyaLk/KeEBem2EN5pI1OFnBrXeIX5Gz6GhhJ6Yo0wBGovQZaXBCoj0DsIw3fJyTYF2x44xgkVuwzDsge0O7B0q2Rh9gwTdQ2+AbY/2izr+k+gQAAAABJRU5ErkJggg=='), grab;
    --cur-grabbing: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAA3ElEQVRYhe2XwQrCMBBEX4peegs0t9KznjXQgwd/wIMe9OBBBc/1B/QHPPcL/IF68qJeRReChjQbtFQCeTCQTTKb2QnJZgKsgNrrz8Bp6NyFIRIu9DYbUOoq5xGn/lBKmU65BDogTsjnaM5EWBoTQcqA64NnQvnerbOUAC2wtZDv+C+sdQEGDmBkVb4Rb601AR7AzKp8J74aS77tYgvMlRZn5TqhCiaRQXmkjUZW8Bs6xIspWQNj19qeGngZ+J88B76Q6CfGD/4cVkSa7lsYituy2K9i+x0H/msL7qeuR3XBoTWnXdnw7kIAAAAASUVORK5CYII='), grabbing;
    --cur-tempo: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsSAAALEgHS3X78AAAA9UlEQVRYhe2XMQ6DMAxFn1MxlHID1HKDduYKlRgYygGyMLAwlBtwA7gBEwviBhyBCTFgVSlDUiSk/CWTLTs/+SuK7RjFBQPQAAY6+wCvO+eKEHKBTc9mYJMDOSBt8c85L511FcxAA+SJfI/2nIwiaZ8DiYHowDNBF611VmJgBGoP5VprreUGKuBkVL4Tq6y1zsABGC3lO/HZWPJtFztgKrQ4Kc8JCZhEDlWRNiZZwCt0SBaTrAZWXNpyDQxLw8pzYMa/CRcMPGWGv4ljKH7/F4xcMEW6fwTiWMYmxIUF5Lz9GtLdUjE7sI04oIr0t8H3POACfADBJHyxBnqITQAAAABJRU5ErkJggg=='), auto;
}

/* ==========================================================================
   Scene
   ========================================================================== */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-ui);
    color: var(--text-color);
    min-height: 100vh;
    padding: 48px 24px 64px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: var(--scene-deep);
    background-image:
        /* pixel weave */
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.13) 0 2px, transparent 2px 4px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.028) 0 2px, transparent 2px 4px),
        /* horizon light */
        radial-gradient(120% 78% at 50% -6%, var(--scene-lit) 0%, var(--scene-mid) 42%, var(--scene-deep) 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: none;
    text-rendering: geometricPrecision;
    -webkit-tap-highlight-color: transparent;
    /* Nearly every control here is drag-adjustable — stop drags from
       smearing a text selection across the cabinet. */
    user-select: none;
    -webkit-user-select: none;
}

input,
textarea {
    user-select: text;
    -webkit-user-select: text;
}

::selection {
    background: var(--amber);
    color: #2a1a09;
}

/* Warm spotlight pooled behind the cabinet + corner vignette */
.scene-glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(46% 34% at 50% 34%, rgba(255, 198, 92, 0.16), transparent 70%),
        radial-gradient(140% 110% at 50% 45%, transparent 46%, rgba(0, 0, 0, 0.55) 100%);
}

.container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    width: 100%;
}

/* ==========================================================================
   Marquee (title sign)
   ========================================================================== */

.marquee {
    position: relative;
    text-align: center;
    margin: 0 auto 38px;
    padding: 26px 34px 20px;
    max-width: 620px;
    border-radius: 14px;
    background:
        repeating-linear-gradient(93deg, rgba(0, 0, 0, 0.10) 0 2px, transparent 2px 9px),
        linear-gradient(180deg, var(--wood-hi) 0%, var(--wood) 45%, var(--wood-mid) 100%);
    border: 4px solid var(--wood-edge);
    box-shadow:
        inset 0 3px 0 rgba(255, 226, 176, 0.35),
        inset 0 -5px 0 rgba(0, 0, 0, 0.32),
        0 10px 0 var(--wood-shadow),
        0 18px 34px rgba(0, 0, 0, 0.5);
}

/* Brass inner frame */
.marquee::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 3px solid var(--brass-low);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(255, 233, 168, 0.28);
    pointer-events: none;
    opacity: 0.85;
}

/* Chasing bulb strip along the top of the sign */
.marquee-bulbs {
    position: absolute;
    top: -9px;
    left: 26px;
    right: 26px;
    height: 16px;
    border-radius: 8px;
    background-image:
        radial-gradient(circle at 8px 8px, #fff6cf 0 3px, var(--brass) 3px 5px, transparent 5.5px),
        radial-gradient(circle at 24px 8px, #6b4a12 0 3px, var(--brass-low) 3px 5px, transparent 5.5px);
    background-size: 32px 16px;
    background-repeat: repeat-x;
    filter: drop-shadow(0 0 6px rgba(255, 200, 90, 0.55));
    animation: bulbChase 1.1s steps(1) infinite;
    pointer-events: none;
}

@keyframes bulbChase {
    0%, 100% { background-position: 0 0, 0 0; }
    50% { background-position: 16px 0, 16px 0; }
}

.title {
    position: relative;
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 5.4vw, 2.6rem);
    line-height: 1.15;
    letter-spacing: 2px;
    color: transparent;
    /* Base layer paints only the chunky pixel outline + extrude. Text-shadow
       renders for transparent glyphs, and sits above any background — so the
       gradient fill has to ride on top in ::after rather than underneath. */
    text-shadow:
        -3px 0 0 var(--wood-edge), 3px 0 0 var(--wood-edge),
        0 -3px 0 var(--wood-edge), 0 3px 0 var(--wood-edge),
        -3px -3px 0 var(--wood-edge), 3px -3px 0 var(--wood-edge),
        -3px 3px 0 var(--wood-edge), 3px 3px 0 var(--wood-edge),
        0 6px 0 var(--wood-shadow),
        0 9px 0 rgba(0, 0, 0, 0.45),
        0 14px 18px rgba(0, 0, 0, 0.45);
}

/* Gradient fill, clipped to the glyphs, layered over the outline */
.title::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    background: linear-gradient(180deg, #fff6d0 0%, #ffd85c 42%, #f2a41d 58%, #c87c0e 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* text-shadow is inherited — it would bury this fill the same way */
    text-shadow: none;
}

.tagline {
    margin-top: 14px;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 233, 190, 0.72);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   Cabinet
   ========================================================================== */

.slot-machine {
    position: relative;
    padding: 34px 34px 30px;
    border-radius: 18px;
    border: 5px solid var(--wood-edge);
    background:
        repeating-linear-gradient(91deg, rgba(0, 0, 0, 0.09) 0 2px, transparent 2px 8px),
        repeating-linear-gradient(89deg, rgba(255, 240, 210, 0.035) 0 1px, transparent 1px 13px),
        linear-gradient(180deg, var(--wood-hi) 0%, var(--wood) 22%, var(--wood-mid) 72%, var(--wood-low) 100%);
    box-shadow:
        inset 0 4px 0 rgba(255, 231, 186, 0.34),
        inset 0 -8px 0 rgba(0, 0, 0, 0.34),
        inset 6px 0 14px rgba(0, 0, 0, 0.18),
        inset -6px 0 14px rgba(0, 0, 0, 0.18),
        0 14px 0 var(--wood-shadow),
        0 26px 46px rgba(0, 0, 0, 0.55);
}

/* Brass inner frame line */
.slot-machine::before {
    content: '';
    position: absolute;
    inset: 10px;
    border: 3px solid var(--brass-low);
    border-radius: 10px;
    box-shadow:
        inset 0 0 0 1px rgba(255, 233, 168, 0.22),
        0 0 0 1px rgba(0, 0, 0, 0.35);
    opacity: 0.7;
    pointer-events: none;
}

/* Soft top gloss across the cabinet face */
.slot-machine::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 244, 214, 0.16), transparent 26%);
    pointer-events: none;
}

/* Four brass rivets in the cabinet corners */
.cabinet-rivets {
    position: absolute;
    inset: 18px;
    pointer-events: none;
    z-index: 2;
    background-image:
        radial-gradient(circle at 4px 4px, var(--brass-hi) 0 1.5px, var(--brass) 1.5px 4px, var(--brass-low) 4px 5px, transparent 5.5px),
        radial-gradient(circle at calc(100% - 4px) 4px, var(--brass-hi) 0 1.5px, var(--brass) 1.5px 4px, var(--brass-low) 4px 5px, transparent 5.5px),
        radial-gradient(circle at 4px calc(100% - 4px), var(--brass-hi) 0 1.5px, var(--brass) 1.5px 4px, var(--brass-low) 4px 5px, transparent 5.5px),
        radial-gradient(circle at calc(100% - 4px) calc(100% - 4px), var(--brass-hi) 0 1.5px, var(--brass) 1.5px 4px, var(--brass-low) 4px 5px, transparent 5.5px);
    background-repeat: no-repeat;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

/* Maker's plate at the foot of the cabinet */
.cabinet-plate {
    margin: 26px auto 0;
    width: max-content;
    padding: 6px 16px;
    font-size: 9px;
    letter-spacing: 3px;
    color: rgba(255, 226, 170, 0.55);
    border-radius: 4px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.12));
    box-shadow:
        inset 0 1px 0 rgba(0, 0, 0, 0.5),
        inset 0 -1px 0 rgba(255, 226, 170, 0.14);
}

/* ==========================================================================
   Display (the glass)
   ========================================================================== */

.slot-display {
    position: relative;
    padding: 22px 18px;
    margin-bottom: 30px;
    border-radius: 12px;
    border: 5px solid var(--glass-rim);
    background:
        radial-gradient(110% 130% at 50% 0%, #241708 0%, var(--glass) 46%, var(--glass-deep) 100%);
    box-shadow:
        inset 0 0 34px rgba(0, 0, 0, 0.9),
        inset 0 2px 0 rgba(0, 0, 0, 0.8),
        0 0 0 3px var(--brass-low),
        0 0 0 4px rgba(0, 0, 0, 0.4),
        0 8px 20px rgba(0, 0, 0, 0.55),
        0 0 44px rgba(255, 168, 40, 0.10);
}

/* CRT scanlines + corner vignette */
.slot-display::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    z-index: 6;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.24) 0 1px, transparent 1px 3px),
        radial-gradient(120% 120% at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.55) 100%);
    opacity: 0.55;
}

/* Glass glare sweeping the top-left */
.slot-display::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    z-index: 7;
    pointer-events: none;
    background: linear-gradient(122deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.03) 26%, transparent 46%);
}

.tempo-display {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
    border-radius: 8px;
    cursor: var(--cur-tempo);
    transition: filter 0.2s ease;
}

.tempo-display:hover {
    filter: brightness(1.06);
}

.tempo-display.dragging {
    filter: brightness(1.12);
}

/* "BPM" etched next to the reels — zero-width so the reels stay centred */
.bpm-tag {
    width: 0;
    overflow: visible;
    white-space: nowrap;
    margin-left: 14px;
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 2px;
    color: rgba(255, 207, 77, 0.6);
    text-shadow: 0 0 10px rgba(255, 164, 28, 0.45);
    user-select: none;
}

/* ==========================================================================
   Reels
   ========================================================================== */

.digit-container {
    position: relative;
    width: 62px;
    height: 80px;
    margin: 0 4px;
    overflow: hidden;
    border-radius: 7px;
    background: linear-gradient(180deg, #050403 0%, #16100a 50%, #050403 100%);
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass-low),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 3px 8px rgba(0, 0, 0, 0.6);
    cursor: var(--cur-pointer);
    transition: box-shadow 0.2s ease, transform 0.18s ease, filter 0.2s ease;
}

.tempo-display:hover .digit-container {
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass-mid),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 0 12px var(--amber-glow);
}

.digit-container:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 0 18px var(--amber-glow);
    cursor: var(--cur-pointer);
}

.digit-container.digit-selected {
    transform: translateY(-2px) scale(1.08);
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass-hi),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 0 24px var(--amber-glow);
}

/* Cylinder shading + centre window — sits above the digits, below indicators */
.reel-glass {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    border-radius: 7px;
    background:
        linear-gradient(180deg,
            rgba(0, 0, 0, 0.92) 0%,
            rgba(0, 0, 0, 0.45) 16%,
            rgba(0, 0, 0, 0) 34%,
            rgba(255, 236, 190, 0.07) 50%,
            rgba(0, 0, 0, 0) 66%,
            rgba(0, 0, 0, 0.45) 84%,
            rgba(0, 0, 0, 0.92) 100%),
        linear-gradient(96deg, rgba(255, 255, 255, 0.07) 0%, transparent 34%);
}

.digit-roller {
    position: absolute;
    z-index: 1;
    width: 100%;
    transition: transform 0.5s cubic-bezier(0.3, 1, 0.3, 1);
    will-change: transform;
}

/* During a spin the position is driven per frame from script, so the CSS
   transition has to get out of the way — otherwise every frame starts a fresh
   500ms tween and the reel wobbles instead of turning. */
.digit-roller.spinning {
    transition: none;
}

.digit {
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-display);
    font-size: 34px;
    color: var(--amber);
    text-shadow:
        0 0 4px rgba(255, 207, 77, 0.9),
        0 0 14px var(--amber-glow),
        0 0 30px rgba(255, 132, 0, 0.45),
        0 2px 0 rgba(120, 52, 0, 0.8);
    user-select: none;
}

.digit-container.at-limit {
    animation: flash 0.5s ease-in-out 3;
}

@keyframes flash {
    0%, 100% {
        box-shadow:
            inset 0 0 14px rgba(0, 0, 0, 0.95),
            0 0 0 2px var(--brass-low),
            0 0 0 3px rgba(0, 0, 0, 0.6);
    }
    50% {
        box-shadow:
            inset 0 0 22px var(--amber-glow),
            0 0 0 2px var(--red),
            0 0 0 3px rgba(0, 0, 0, 0.6),
            0 0 22px var(--red);
    }
}

/* Scroll feedback ------------------------------------------------------- */

@keyframes scrollPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

.tempo-display.scrolling .digit-container,
.digit-container.scrolling {
    animation: scrollPulse 0.3s ease-in-out;
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 0 20px var(--amber-glow);
}

.tempo-display.scroll-up .digit-container::before,
.digit-container.scroll-up::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: linear-gradient(to bottom, var(--amber), transparent);
    border-radius: 7px 7px 0 0;
    opacity: 0.85;
    z-index: 4;
}

.tempo-display.scroll-down .digit-container::after,
.digit-container.scroll-down::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: linear-gradient(to top, var(--amber), transparent);
    border-radius: 0 0 7px 7px;
    opacity: 0.85;
    z-index: 4;
}

/* ==========================================================================
   Time signature plate
   ========================================================================== */

.time-sig-display {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    padding: 12px 14px;
    min-width: 62px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1;
    color: var(--amber);
    text-shadow: 0 0 4px rgba(255, 207, 77, 0.9), 0 0 14px var(--amber-glow);
    border-radius: 7px;
    background: linear-gradient(180deg, #050403 0%, #16100a 52%, #050403 100%);
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass-low),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 3px 8px rgba(0, 0, 0, 0.6);
    cursor: var(--cur-pointer);
    transition: box-shadow 0.2s ease, transform 0.18s ease;
    user-select: none;
}

.time-sig-display:hover {
    transform: translateY(-50%) scale(1.06);
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 0 18px var(--amber-glow);
}

.time-sig-display.scrolling {
    animation: scrollPulse 0.3s ease-in-out;
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 0 20px var(--amber-glow);
}

.time-sig-display.scroll-up::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 7px;
    background: linear-gradient(to bottom, var(--amber), transparent);
    border-radius: 7px 7px 0 0;
    opacity: 0.85;
    z-index: 2;
}

.time-sig-display.scroll-down::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 7px;
    background: linear-gradient(to top, var(--amber), transparent);
    border-radius: 0 0 7px 7px;
    opacity: 0.85;
    z-index: 2;
}

.time-sig-display.dragging {
    cursor: var(--cur-grabbing) !important;
    transform: translateY(-50%) scale(1.06);
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 2px var(--brass-hi),
        0 0 0 3px rgba(0, 0, 0, 0.6),
        0 0 20px var(--amber-glow);
}

/* ==========================================================================
   Tempo gear (brass cogwheel)
   ========================================================================== */

.tempo-gear-container {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 104px;
    height: 104px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.65));
}

.tempo-gear {
    position: relative;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 34% 28%, var(--brass-hi) 0%, var(--brass) 26%, var(--brass-mid) 58%, var(--brass-low) 100%);
    box-shadow:
        inset 0 0 0 3px rgba(0, 0, 0, 0.28),
        inset 0 -6px 12px rgba(0, 0, 0, 0.4),
        inset 0 6px 10px rgba(255, 245, 210, 0.3);
    cursor: var(--cur-grab);
    transition: filter 0.18s ease;
}

/* Recessed ring */
.tempo-gear::before {
    content: '';
    position: absolute;
    inset: 15px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 32%, rgba(255, 245, 210, 0.22), transparent 62%);
    box-shadow:
        inset 0 0 0 2px rgba(0, 0, 0, 0.3),
        inset 0 3px 8px rgba(0, 0, 0, 0.45);
}

/* Three spoke holes */
.tempo-gear::after {
    content: '';
    position: absolute;
    inset: 15px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 22%, rgba(0, 0, 0, 0.55) 0 5px, transparent 6px),
        radial-gradient(circle at 22% 72%, rgba(0, 0, 0, 0.55) 0 5px, transparent 6px),
        radial-gradient(circle at 78% 72%, rgba(0, 0, 0, 0.55) 0 5px, transparent 6px);
}

.tempo-gear:hover {
    filter: brightness(1.12) saturate(1.08);
}

.tempo-gear.active {
    filter: brightness(1.2) saturate(1.12);
    cursor: var(--cur-grabbing);
}

.gear-tooth {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 16px;
    margin: -8px 0 0 -7.5px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 34%, var(--brass-mid) 100%);
    box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.35);
    clip-path: polygon(24% 0, 76% 0, 100% 100%, 0 100%);
}

.gear-tooth:nth-child(1)  { transform: rotate(0deg)     translateY(-46px); }
.gear-tooth:nth-child(2)  { transform: rotate(22.5deg)  translateY(-46px); }
.gear-tooth:nth-child(3)  { transform: rotate(45deg)    translateY(-46px); }
.gear-tooth:nth-child(4)  { transform: rotate(67.5deg)  translateY(-46px); }
.gear-tooth:nth-child(5)  { transform: rotate(90deg)    translateY(-46px); }
.gear-tooth:nth-child(6)  { transform: rotate(112.5deg) translateY(-46px); }
.gear-tooth:nth-child(7)  { transform: rotate(135deg)   translateY(-46px); }
.gear-tooth:nth-child(8)  { transform: rotate(157.5deg) translateY(-46px); }
.gear-tooth:nth-child(9)  { transform: rotate(180deg)   translateY(-46px); }
.gear-tooth:nth-child(10) { transform: rotate(202.5deg) translateY(-46px); }
.gear-tooth:nth-child(11) { transform: rotate(225deg)   translateY(-46px); }
.gear-tooth:nth-child(12) { transform: rotate(247.5deg) translateY(-46px); }
.gear-tooth:nth-child(13) { transform: rotate(270deg)   translateY(-46px); }
.gear-tooth:nth-child(14) { transform: rotate(292.5deg) translateY(-46px); }
.gear-tooth:nth-child(15) { transform: rotate(315deg)   translateY(-46px); }
.gear-tooth:nth-child(16) { transform: rotate(337.5deg) translateY(-46px); }

.gear-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at 36% 30%, #6a4a1c 0%, #3a2610 62%, #1c1207 100%);
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.8),
        0 0 0 2px rgba(255, 233, 168, 0.22);
    z-index: 2;
}

/* ==========================================================================
   Slot handle
   ========================================================================== */

.slot-handle-container {
    position: absolute;
    right: -34px;
    top: 46px;
    height: 210px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 3;
}

/* Brass bracket at the lever pivot, bolting it to the cabinet side */
.handle-mount {
    position: absolute;
    top: 138px;
    left: 50%;
    width: 74px;
    height: 52px;
    transform: translateX(-62%);
    border-radius: 10px;
    background: linear-gradient(180deg, var(--brass) 0%, var(--brass-mid) 55%, var(--brass-low) 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 245, 210, 0.5),
        inset 0 -2px 0 rgba(0, 0, 0, 0.35),
        0 3px 6px rgba(0, 0, 0, 0.55);
}

.handle-mount::after {
    content: '';
    position: absolute;
    inset: 7px;
    border-radius: 4px;
    background:
        radial-gradient(circle at 4px 4px, rgba(0, 0, 0, 0.5) 0 2px, transparent 2.5px),
        radial-gradient(circle at calc(100% - 4px) 4px, rgba(0, 0, 0, 0.5) 0 2px, transparent 2.5px),
        radial-gradient(circle at 4px calc(100% - 4px), rgba(0, 0, 0, 0.5) 0 2px, transparent 2.5px),
        radial-gradient(circle at calc(100% - 4px) calc(100% - 4px), rgba(0, 0, 0, 0.5) 0 2px, transparent 2.5px);
}

.slot-handle {
    position: relative;
    width: 44px;
    height: 200px;
    transform-origin: 50% 82%;
    cursor: var(--cur-pointer);
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
}

.handle-knob {
    position: absolute;
    top: 0;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle at 34% 28%, #ff8f7d 0%, #e5432f 40%, #a82013 78%, #5d1108 100%);
    box-shadow:
        inset 0 -6px 10px rgba(0, 0, 0, 0.5),
        0 0 0 3px rgba(0, 0, 0, 0.32),
        0 6px 12px rgba(0, 0, 0, 0.5);
}

/* Specular pop on the ball */
.handle-knob::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 10px;
    width: 13px;
    height: 9px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.75);
    filter: blur(1px);
}

/* Brass collar under the ball */
.handle-knob::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    width: 22px;
    height: 12px;
    transform: translateX(-50%);
    border-radius: 4px;
    background: linear-gradient(180deg, var(--brass-hi), var(--brass-mid) 60%, var(--brass-low));
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
}

.handle-arm {
    position: absolute;
    top: 26px;
    left: 50%;
    width: 16px;
    height: 180px;
    transform: translateX(-50%);
    border-radius: 8px;
    background: linear-gradient(90deg,
        #4c4c52 0%,
        #9aa0a8 22%,
        #e8ecf1 44%,
        #aab0b8 62%,
        #63656b 84%,
        #34363a 100%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Machined rings down the shaft */
.handle-arm::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: repeating-linear-gradient(180deg,
        transparent 0 22px,
        rgba(0, 0, 0, 0.22) 22px 24px);
}

/* Soft cast shadow travelling with the lever */
.slot-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 6px;
    width: 12px;
    height: 186px;
    transform: translateX(-118%);
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.42), transparent);
    pointer-events: none;
    opacity: 0.55;
}

.slot-handle.pulled {
    transform: rotate(42deg);
    transition: transform 0.2s cubic-bezier(0.17, 0.67, 0.83, 0.67);
}

.slot-handle.releasing {
    transform: rotate(0);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slot-handle.bounce {
    animation: handleBounce 0.5s ease-out;
}

@keyframes handleBounce {
    0%   { transform: rotate(0); }
    20%  { transform: rotate(-5deg); }
    40%  { transform: rotate(3deg); }
    60%  { transform: rotate(-2deg); }
    80%  { transform: rotate(1deg); }
    100% { transform: rotate(0); }
}

/* ==========================================================================
   Control panel
   ========================================================================== */

.controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 18px;
    margin: 24px 0 28px;
}

.control-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 16px 14px;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.26) 0%, rgba(0, 0, 0, 0.13) 100%);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.45),
        inset 0 -1px 0 rgba(255, 232, 190, 0.13),
        0 1px 0 rgba(255, 232, 190, 0.08);
}

.control-group label {
    font-family: var(--font-ui);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 236, 200, 0.82);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.control-group label.stacked {
    margin-top: 14px;
}

.control-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 14px;
    align-items: start;
}

/* JS flips this to display:block, so it must read well as a block too */
#increment-container {
    align-self: stretch;
}

#increment-container > label {
    display: block;
    margin-bottom: 8px;
}

.bars-label {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 236, 200, 0.55);
}

/* Steppers ---------------------------------------------------------------- */

.number-input {
    display: flex;
    align-items: center;
    width: max-content;
    border-radius: 7px;
    box-shadow:
        0 3px 0 rgba(0, 0, 0, 0.45),
        0 0 0 2px rgba(0, 0, 0, 0.4);
}

.number-input button {
    width: 32px;
    height: 32px;
    border: none;
    font-family: var(--font-display);
    font-size: 12px;
    line-height: 1;
    color: #3a2410;
    background: linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 40%, var(--brass-mid) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.22);
    cursor: var(--cur-pointer);
    transition: filter 0.12s ease, transform 0.06s ease;
}

.number-input button.minus { border-radius: 7px 0 0 7px; }
.number-input button.plus  { border-radius: 0 7px 7px 0; }

.number-input button:hover { filter: brightness(1.1); }

.number-input button:active {
    filter: brightness(0.9);
    transform: translateY(1px);
}

.number-input input,
select {
    width: 74px;
    height: 32px;
    border: none;
    text-align: center;
    font-family: var(--font-display);
    font-size: 13px;
    color: #2a1a09;
    background: linear-gradient(180deg, #fff9e8 0%, #efe1c2 100%);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.22);
    -moz-appearance: textfield;
}

.number-input input::-webkit-outer-spin-button,
.number-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.number-input input.dragging {
    background: linear-gradient(180deg, var(--button-hover) 0%, var(--brass) 100%);
    color: #2a1a09;
}

#min-tempo,
#max-tempo {
    cursor: ns-resize;
}

#min-tempo:hover,
#max-tempo:hover {
    filter: brightness(1.04);
}

/* Selects ------------------------------------------------------------------ */

select {
    width: 100%;
    padding: 0 10px;
    border-radius: 6px;
    cursor: pointer;
}

.pixel-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 34px;
    padding: 0 30px 0 12px;
    border: none;
    border-radius: 7px;
    font-family: var(--font-display);
    font-size: 10px;
    color: #3a2410;
    background:
        /* chevron */
        linear-gradient(45deg, transparent 46%, #3a2410 46% 56%, transparent 56%) no-repeat right 16px top 12px / 8px 8px,
        linear-gradient(-45deg, transparent 46%, #3a2410 46% 56%, transparent 56%) no-repeat right 10px top 12px / 8px 8px,
        linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 40%, var(--brass-mid) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -2px 0 rgba(0, 0, 0, 0.22),
        0 3px 0 rgba(0, 0, 0, 0.45);
    cursor: var(--cur-pointer);
}

.pixel-select:hover { filter: brightness(1.08); }

.pixel-select:focus-visible {
    outline: none;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 0 0 3px var(--amber);
}

/* Lives inside the popup panel, so it sizes to its own content */
#time-signature {
    width: auto;
    min-width: 170px;
    height: 46px;
    font-size: 14px;
    text-align: center;
    text-align-last: center;
}

/* Limit checkbox ------------------------------------------------------------ */

.limit-checkbox {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 7px;
    margin-top: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    background: linear-gradient(180deg, var(--brass) 0%, var(--brass-mid) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        0 3px 0 rgba(0, 0, 0, 0.4);
    transition: filter 0.12s ease, transform 0.06s ease;
}

.limit-checkbox:hover { filter: brightness(1.1); }

.limit-checkbox:active {
    filter: brightness(0.92);
    transform: translateY(1px);
}

/* Flashed when the tempo leaves the min/max range and Limit releases itself */
.limit-checkbox.limit-released {
    animation: limitReleased 0.9s ease-out;
}

@keyframes limitReleased {
    0% {
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 3px 0 rgba(0, 0, 0, 0.4);
    }
    18%, 62% {
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.45),
            0 3px 0 rgba(0, 0, 0, 0.4),
            0 0 0 3px #fff6d0,
            0 0 20px var(--amber);
    }
    100% {
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 3px 0 rgba(0, 0, 0, 0.4);
    }
}

.limit-checkbox input[type="checkbox"] {
    position: relative;
    width: 15px;
    height: 15px;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid rgba(0, 0, 0, 0.45);
    border-radius: 3px;
    background: #2a1a09;
    accent-color: var(--amber);
    cursor: var(--cur-pointer);
}

.limit-checkbox input[type="checkbox"]:checked {
    background: var(--amber);
    box-shadow: 0 0 8px var(--amber-glow);
}

.limit-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3.5px;
    top: 0.5px;
    width: 4px;
    height: 8px;
    border: solid #2a1a09;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.limit-checkbox input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 207, 77, 0.6);
}

.limit-checkbox label {
    font-family: var(--font-display);
    font-size: 9px;
    letter-spacing: 1px;
    color: #3a2410;
    text-shadow: none;
    cursor: var(--cur-pointer);
}

/* ==========================================================================
   Accent beats (quarter-note keys)
   ========================================================================== */

.accent-controls {
    margin-bottom: 28px;
    padding: 16px 14px 18px;
    border-radius: 10px;
    text-align: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.26) 0%, rgba(0, 0, 0, 0.13) 100%);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.45),
        inset 0 -1px 0 rgba(255, 232, 190, 0.13);
}

.panel-caption {
    display: block;
    margin-bottom: 12px;
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255, 236, 200, 0.55);
}

#accent-buttons,
.quarter-notes-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.accent-button {
    position: relative;
    width: 60px;
    height: 84px;
    padding: 0;
    border: none;
    font: inherit;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 10px;
    background: linear-gradient(180deg, #7fbcf5 0%, var(--blue) 42%, var(--blue-deep) 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.45),
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 5px 0 rgba(0, 0, 0, 0.4),
        0 8px 14px rgba(0, 0, 0, 0.35);
    cursor: var(--cur-pointer);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.2s ease, filter 0.16s ease;
    filter: saturate(0.82) brightness(0.92);
}

.accent-button:hover {
    transform: translateY(-3px);
    filter: saturate(1) brightness(1.04);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.45),
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 8px 0 rgba(0, 0, 0, 0.4),
        0 12px 18px rgba(0, 0, 0, 0.4);
}

.accent-button:active {
    transform: translateY(3px);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -2px 0 rgba(0, 0, 0, 0.28),
        0 2px 0 rgba(0, 0, 0, 0.4);
}

/* Quarter note — stem */
.accent-button::before {
    content: '';
    position: absolute;
    left: 35px;
    top: 17px;
    width: 5px;
    height: 43px;
    border-radius: 2px;
    background: #fdfdff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Quarter note — head */
.accent-button::after {
    content: '';
    position: absolute;
    left: 13px;
    top: 50px;
    width: 27px;
    height: 19px;
    border-radius: 50%;
    background: #fdfdff;
    transform: rotate(-20deg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Quantity query: 9+ beats (7/8, 9/8, 12/8…) shrink so a bar stays on one row */
.accent-button:nth-child(1):nth-last-child(n + 9),
.accent-button:nth-child(1):nth-last-child(n + 9) ~ .accent-button {
    width: 46px;
    height: 68px;
}

.accent-button:nth-child(1):nth-last-child(n + 9)::before,
.accent-button:nth-child(1):nth-last-child(n + 9) ~ .accent-button::before {
    left: 26px;
    top: 12px;
    width: 4px;
    height: 34px;
}

.accent-button:nth-child(1):nth-last-child(n + 9)::after,
.accent-button:nth-child(1):nth-last-child(n + 9) ~ .accent-button::after {
    left: 9px;
    top: 40px;
    width: 21px;
    height: 15px;
}

.accent-button:nth-child(1):nth-last-child(n + 9) .accent-dot,
.accent-button:nth-child(1):nth-last-child(n + 9) ~ .accent-button .accent-dot {
    top: 5px;
    width: 11px;
    height: 11px;
}

/* Accent marker — brass gem at the top of the key */
.accent-button .accent-dot {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 14px;
    height: 14px;
    border-radius: 2px;
    transform: translateX(-50%) rotate(45deg) scale(0.35);
    background: linear-gradient(135deg, var(--brass-hi), var(--brass) 55%, var(--brass-mid));
    box-shadow: 0 0 10px rgba(255, 207, 77, 0.95), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.accent-button.accent {
    background: linear-gradient(180deg, #f4917f 0%, #c93a29 44%, var(--red-deep) 100%);
}

.accent-button.accent .accent-dot {
    opacity: 1;
    transform: translateX(-50%) rotate(45deg) scale(1);
}

/* Currently sounding beat */
.accent-button.active {
    filter: saturate(1.15) brightness(1.15);
    transform: translateY(-3px) scale(1.06);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        0 8px 0 rgba(0, 0, 0, 0.4),
        0 0 22px var(--blue),
        0 0 44px rgba(90, 164, 236, 0.45);
}

.accent-button.active.accent {
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        0 8px 0 rgba(0, 0, 0, 0.4),
        0 0 24px var(--red),
        0 0 48px rgba(225, 75, 56, 0.5);
}

.accent-button.active::before,
.accent-button.active.accent::before {
    animation: pulseLight 0.5s ease-in-out;
}

@keyframes pulseLight {
    0%   { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
    35%  { box-shadow: 0 0 18px rgba(255, 255, 255, 0.95), 0 0 34px rgba(255, 255, 255, 0.6); }
    100% { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
}

/* ==========================================================================
   Transport
   ========================================================================== */

.playback-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 22px;
}

/* --- Sound-effects toggle -------------------------------------------------
   Silences the cabinet noises only — the metronome click is never muted. */

.sfx-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 10px;
    letter-spacing: 1px;
    color: #33200c;
    background: linear-gradient(180deg, #ffe9a8 0%, var(--brass) 38%, var(--brass-mid) 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.55),
        inset 0 -3px 0 rgba(0, 0, 0, 0.22),
        0 5px 0 #7a5210,
        0 8px 14px rgba(0, 0, 0, 0.4);
    cursor: var(--cur-pointer);
    transition: filter 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease, background 0.2s ease;
}

.sfx-toggle:hover { filter: brightness(1.07); }

.sfx-toggle:active {
    transform: translateY(3px);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 2px 0 #7a5210;
}

/* Off reads as a switch thrown down: recessed, desaturated, dimmed label */
.sfx-toggle.muted {
    color: rgba(246, 236, 212, 0.62);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.16) 100%);
    box-shadow:
        inset 0 2px 5px rgba(0, 0, 0, 0.55),
        inset 0 -1px 0 rgba(255, 232, 190, 0.12),
        0 1px 0 rgba(255, 232, 190, 0.08);
}

.sfx-toggle:focus-visible {
    outline: none;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        0 5px 0 #7a5210,
        0 0 0 3px var(--amber),
        0 0 18px var(--amber-glow);
}

.sfx-icon {
    position: relative;
    width: 20px;
    height: 16px;
    color: currentColor;
    flex: none;
}

/* Speaker body and cone as one clipped block */
.sfx-icon::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 12px;
    height: 100%;
    background: currentColor;
    clip-path: polygon(0 32%, 34% 32%, 100% 0, 100% 100%, 34% 68%, 0 68%);
}

/* Sound waves when on */
.sfx-icon::after {
    content: '';
    position: absolute;
    right: 1px;
    top: 50%;
    width: 9px;
    height: 9px;
    transform: translateY(-50%) rotate(-45deg);
    border: 2px solid currentColor;
    border-left-color: transparent;
    border-bottom-color: transparent;
    border-radius: 50%;
}

/* …swapped for a slash when off */
.sfx-toggle.muted .sfx-icon::after {
    width: 15px;
    height: 2px;
    right: -1px;
    border: none;
    border-radius: 1px;
    background: currentColor;
    transform: translateY(-50%) rotate(-40deg);
}

#start-stop-btn {
    position: relative;
    top: 0;
    padding: 17px 46px;
    border: none;
    border-radius: 12px;
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 2px;
    color: #33200c;
    background: linear-gradient(180deg, #ffe9a8 0%, var(--brass) 38%, var(--brass-mid) 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.6),
        inset 0 -4px 0 rgba(0, 0, 0, 0.24),
        0 7px 0 #7a5210,
        0 12px 20px rgba(0, 0, 0, 0.45),
        0 0 26px rgba(255, 190, 70, 0.28);
    cursor: var(--cur-pointer);
    transition: filter 0.12s ease, box-shadow 0.12s ease, top 0.08s ease, background 0.2s ease;
    overflow: hidden;
}

/* Glossy sweep across the cap */
#start-stop-btn::before {
    content: '';
    position: absolute;
    inset: 0 0 50% 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent);
    pointer-events: none;
}

#start-stop-btn:hover { filter: brightness(1.07); }

#start-stop-btn:active {
    top: 5px;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        0 2px 0 #7a5210,
        0 5px 10px rgba(0, 0, 0, 0.4);
}

#start-stop-btn.stop {
    top: 4px;
    color: #fff2ee;
    background: linear-gradient(180deg, #f4917f 0%, var(--red) 40%, #b12f20 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -4px 0 rgba(0, 0, 0, 0.24),
        0 3px 0 #79190f,
        0 8px 16px rgba(0, 0, 0, 0.45),
        0 0 30px rgba(225, 75, 56, 0.5);
}

#start-stop-btn:focus-visible {
    outline: none;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.6),
        0 7px 0 #7a5210,
        0 0 0 4px var(--amber);
}

/* ==========================================================================
   Overlays
   ========================================================================== */

.tempo-input-overlay,
.time-signature-popup {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(8, 12, 6, 0.74);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.tempo-input-overlay.active,
.time-signature-popup.active {
    opacity: 1;
    visibility: visible;
}

.tempo-input-overlay .input-container {
    position: relative;
    width: 100%;
    max-width: 330px;
    padding: 30px 26px 26px;
    text-align: center;
    border-radius: 16px;
    border: 5px solid var(--wood-edge);
    background:
        repeating-linear-gradient(91deg, rgba(0, 0, 0, 0.09) 0 2px, transparent 2px 8px),
        linear-gradient(180deg, var(--wood-hi) 0%, var(--wood) 30%, var(--wood-mid) 100%);
    box-shadow:
        inset 0 3px 0 rgba(255, 231, 186, 0.32),
        inset 0 -6px 0 rgba(0, 0, 0, 0.32),
        0 12px 0 var(--wood-shadow),
        0 24px 44px rgba(0, 0, 0, 0.6);
    transform: translateY(14px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tempo-input-overlay.active .input-container {
    transform: translateY(0) scale(1);
}

.tempo-input-overlay .input-container::before {
    content: '';
    position: absolute;
    inset: 7px;
    border: 3px solid var(--brass-low);
    border-radius: 9px;
    box-shadow: inset 0 0 0 1px rgba(255, 233, 168, 0.22);
    opacity: 0.75;
    pointer-events: none;
}

.tempo-input-overlay h3 {
    margin-bottom: 22px;
    font-family: var(--font-display);
    font-size: 1.15rem;
    letter-spacing: 2px;
    color: var(--amber);
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 16px var(--amber-glow);
}

.number-input-large {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}

.number-input-large button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    font-family: var(--font-display);
    font-size: 16px;
    color: #3a2410;
    background: linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 40%, var(--brass-mid) 100%);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.24);
    cursor: var(--cur-pointer);
    transition: filter 0.12s ease;
}

.number-input-large button.minus { border-radius: 8px 0 0 8px; }
.number-input-large button.plus  { border-radius: 0 8px 8px 0; }
.number-input-large button:hover { filter: brightness(1.1); }
.number-input-large button:active { filter: brightness(0.9); }

.number-input-large input {
    width: 118px;
    height: 44px;
    border: none;
    text-align: center;
    font-family: var(--font-display);
    font-size: 19px;
    color: var(--amber);
    background: linear-gradient(180deg, #0a0705 0%, #191008 100%);
    box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.9);
    text-shadow: 0 0 10px var(--amber-glow);
    -moz-appearance: textfield;
}

.number-input-large input::-webkit-outer-spin-button,
.number-input-large input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-help {
    margin-bottom: 22px;
    padding: 10px;
    font-size: 10px;
    line-height: 1.7;
    letter-spacing: 1px;
    color: var(--amber);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 233, 168, 0.16);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.overlay-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.pixel-button {
    position: relative;
    top: 0;
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 1px;
    color: #33200c;
    background: linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 40%, var(--brass-mid) 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        0 5px 0 #7a5210,
        0 8px 14px rgba(0, 0, 0, 0.4);
    cursor: var(--cur-pointer);
    transition: filter 0.12s ease, top 0.08s ease, box-shadow 0.12s ease;
}

.pixel-button:hover { filter: brightness(1.08); }

.pixel-button:active {
    top: 3px;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 2px 0 #7a5210;
}

#cancel-tempo-btn {
    color: #fff2ee;
    background: linear-gradient(180deg, #f4917f 0%, var(--red) 40%, #b12f20 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        0 5px 0 #79190f,
        0 8px 14px rgba(0, 0, 0, 0.4);
}

#cancel-tempo-btn:active {
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), 0 2px 0 #79190f;
}

/* Wooden panel holding the meter picker */
.ts-panel {
    position: relative;
    padding: 26px 30px 22px;
    text-align: center;
    border-radius: 16px;
    border: 5px solid var(--wood-edge);
    background:
        repeating-linear-gradient(91deg, rgba(0, 0, 0, 0.09) 0 2px, transparent 2px 8px),
        linear-gradient(180deg, var(--wood-hi) 0%, var(--wood) 30%, var(--wood-mid) 100%);
    box-shadow:
        inset 0 3px 0 rgba(255, 231, 186, 0.32),
        inset 0 -6px 0 rgba(0, 0, 0, 0.32),
        0 12px 0 var(--wood-shadow),
        0 24px 44px rgba(0, 0, 0, 0.6);
    transform: translateY(14px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.time-signature-popup.active .ts-panel {
    transform: translateY(0) scale(1);
}

.ts-panel::before {
    content: '';
    position: absolute;
    inset: 7px;
    border: 3px solid var(--brass-low);
    border-radius: 9px;
    box-shadow: inset 0 0 0 1px rgba(255, 233, 168, 0.22);
    opacity: 0.75;
    pointer-events: none;
}

.ts-panel h3 {
    margin-bottom: 18px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: var(--amber);
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 16px var(--amber-glow);
}

.ts-hint {
    margin-top: 16px;
    font-size: 10px;
    letter-spacing: 1px;
    color: rgba(255, 236, 200, 0.6);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Below the desktop width the lever moves inside the cabinet, into a reserved
   right-hand gutter — it stays a usable control rather than being hidden. */
@media (max-width: 820px) {
    body { padding: 32px 16px 56px; }

    .slot-machine { padding: 28px 70px 24px 22px; }

    .slot-handle-container {
        right: 6px;
        top: 40px;
        height: 180px;
        transform: scale(0.82);
        transform-origin: top center;
    }

    /* Scale the cog from its container — JS owns .tempo-gear's own transform */
    .tempo-gear-container {
        right: 0;
        transform: translateY(-50%) scale(0.76);
        transform-origin: right center;
    }

    .controls { grid-template-columns: minmax(0, 1fr); }
    .bpm-tag { display: none; }
}

@media (max-width: 620px) {
    .marquee { padding: 20px 22px 16px; }
    .tagline { font-size: 9px; }

    .slot-machine { padding: 24px 56px 20px 14px; }
    .slot-display { padding: 18px 10px; }

    .digit-container { width: 50px; margin: 0 3px; }
    .digit { font-size: 26px; }

    .time-sig-display {
        left: 0;
        min-width: 46px;
        padding: 10px 6px;
        font-size: 13px;
    }

    .tempo-gear-container {
        right: -8px;
        transform: translateY(-50%) scale(0.52);
    }

    .slot-handle-container {
        right: 2px;
        top: 30px;
        transform: scale(0.62);
    }

    .accent-button { width: 50px; height: 72px; }
    .accent-button::before { left: 29px; top: 14px; height: 36px; }
    .accent-button::after { left: 11px; top: 42px; width: 23px; height: 16px; }

    #start-stop-btn { padding: 15px 34px; font-size: 14px; }
}

/* Phone widths: the display has to fit plate + three reels + cog side by side */
@media (max-width: 460px) {
    .slot-machine { padding: 22px 50px 18px 10px; }
    .slot-display { padding: 16px 6px; }

    .digit-container { width: 44px; margin: 0 3px; }
    .digit { font-size: 23px; }

    .time-sig-display {
        min-width: 42px;
        padding: 8px 4px;
        font-size: 12px;
    }

    .tempo-gear-container {
        right: -10px;
        transform: translateY(-50%) scale(0.44);
    }

    .accent-button { width: 46px; height: 66px; }
    .accent-button::before { left: 26px; top: 12px; height: 33px; }
    .accent-button::after { left: 9px; top: 39px; width: 21px; height: 15px; }
}

/* Smallest phones (320px): the display row has ~206px to seat plate, reels
   and cog without collisions, so everything steps down one more notch. */
@media (max-width: 360px) {
    body { padding: 24px 10px 44px; }

    .slot-machine { padding: 20px 44px 16px 8px; }
    .slot-display { padding: 14px 4px; }

    .digit-container { width: 36px; margin: 0 3px; }
    .digit { font-size: 18px; }

    .time-sig-display {
        min-width: 32px;
        padding: 7px 3px;
        font-size: 10px;
    }

    .tempo-gear-container {
        right: -14px;
        transform: translateY(-50%) scale(0.36);
    }

    .slot-handle-container {
        right: 0;
        transform: scale(0.52);
    }

    .accent-button { width: 40px; height: 58px; }
    .accent-button::before { left: 23px; top: 10px; height: 29px; }
    .accent-button::after { left: 8px; top: 34px; width: 18px; height: 13px; }
    .accent-button .accent-dot { top: 4px; width: 9px; height: 9px; }

    #start-stop-btn { padding: 13px 26px; font-size: 12px; }
}

/* ==========================================================================
   Motion / accessibility preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Keyboard affordances
   ========================================================================== */

:focus-visible {
    outline: 3px solid var(--amber);
    outline-offset: 3px;
    border-radius: 4px;
}

/* The reels clip their contents, so an outline would be cut off — ring them
   with a shadow instead, matching the hover treatment. */
.digit-container:focus-visible,
.time-sig-display:focus-visible {
    outline: none;
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.95),
        0 0 0 3px var(--amber),
        0 0 20px var(--amber-glow);
}

.tempo-gear:focus-visible {
    outline: none;
    filter: brightness(1.15) drop-shadow(0 0 6px var(--amber)) drop-shadow(0 0 14px var(--amber-glow));
}

.slot-handle:focus-visible {
    outline: none;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 8px var(--amber));
}

.accent-button:focus-visible {
    outline: none;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.45),
        0 5px 0 rgba(0, 0, 0, 0.4),
        0 0 0 3px var(--amber),
        0 0 20px var(--amber-glow);
}

/* Shortcut hint strip */
.shortcuts {
    margin: 18px auto 0;
    width: max-content;
    max-width: 100%;
    text-align: center;
    font-size: 10px;
    line-height: 2;
    letter-spacing: 1px;
    color: rgba(255, 236, 200, 0.5);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.shortcuts kbd {
    display: inline-block;
    min-width: 20px;
    margin: 0 2px;
    padding: 3px 6px;
    font-family: var(--font-display);
    font-size: 8px;
    color: #f6e6c4;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.2));
    border-radius: 4px;
    box-shadow:
        inset 0 1px 0 rgba(255, 232, 190, 0.22),
        0 2px 0 rgba(0, 0, 0, 0.4);
}

/* Screen-reader-only live region */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Reel symbols, modifiers and the collection plate
   ========================================================================== */

/* A symbol face on a reel strip. Sized to sit inside the 80px slot. */
.digit-symbol {
    color: var(--amber);
    filter: drop-shadow(0 0 4px rgba(255, 207, 77, 0.9))
            drop-shadow(0 0 14px var(--amber-glow));
}

.digit-symbol svg {
    width: 40px;
    height: 40px;
    display: block;
}

/* The BAR and 7/8 faces are wider than they are tall */
.digit-symbol[data-symbol="bar"] svg { width: 48px; height: 29px; }
.digit-symbol[data-symbol="seven"] svg { width: 30px; height: 38px; }

/* The reel that caught a symbol, while it holds before the nudge */
.digit-container.symbol-hit {
    animation: symbolHit 0.6s ease-out 2;
    z-index: 6;
}

@keyframes symbolHit {
    0%, 100% {
        box-shadow:
            inset 0 0 14px rgba(0, 0, 0, 0.95),
            0 0 0 2px var(--brass-low),
            0 0 0 3px rgba(0, 0, 0, 0.6);
    }
    45% {
        box-shadow:
            inset 0 0 14px rgba(0, 0, 0, 0.6),
            0 0 0 2px var(--brass-hi),
            0 0 0 3px rgba(0, 0, 0, 0.6),
            0 0 26px var(--amber),
            0 0 52px var(--amber-glow);
    }
}

/* Banner announcing what just landed */
.modifier-banner {
    position: absolute;
    left: 50%;
    top: calc(100% + 14px);
    z-index: 8;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    white-space: nowrap;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(20, 12, 4, 0.96), rgba(8, 5, 2, 0.96));
    box-shadow:
        0 0 0 2px var(--brass),
        0 0 0 3px rgba(0, 0, 0, 0.7),
        0 8px 24px rgba(0, 0, 0, 0.7),
        0 0 34px rgba(255, 168, 40, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -8px) scale(0.92);
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.25s;
    pointer-events: none;
}

.modifier-banner.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0) scale(1);
}

.modifier-mark {
    display: block;
    width: 30px;
    height: 30px;
    color: var(--amber);
    flex: none;
}

.modifier-mark svg { width: 100%; height: 100%; display: block; }

.modifier-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 10px;
    letter-spacing: 1px;
    color: rgba(255, 236, 200, 0.78);
}

.modifier-text strong {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--amber);
    text-shadow: 0 0 10px var(--amber-glow);
}

/* While a blackout modifier runs, the glass dims — you can see the machine is
   deliberately withholding rather than broken. */
body.modifier-blackout .slot-display {
    box-shadow:
        inset 0 0 34px rgba(0, 0, 0, 0.9),
        inset 0 2px 0 rgba(0, 0, 0, 0.8),
        0 0 0 3px var(--brass-low),
        0 0 0 4px rgba(0, 0, 0, 0.4),
        0 8px 20px rgba(0, 0, 0, 0.55);
}

body.modifier-blackout .digit,
body.modifier-blackout .time-sig-display {
    filter: brightness(0.45) saturate(0.7);
    transition: filter 0.3s ease;
}

/* --- LUCK toggle (shares the SFX button's chrome) ------------------------- */

.luck-icon {
    position: relative;
    width: 18px;
    height: 18px;
    flex: none;
}

.luck-icon::before {
    content: '';
    position: absolute;
    inset: 1px;
    background: currentColor;
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.luck-toggle.muted .luck-icon::before {
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%, 50% 0, 50% 14%, 14% 50%, 50% 86%, 86% 50%, 50% 14%);
}

/* --- Maker's plate, now carrying the collection --------------------------- */

.cabinet-plate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.plate-name {
    font-size: 9px;
    letter-spacing: 3px;
}

.collection-strip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

/* Unfound symbols are etched but unlit — you can see what is still out there */
.collection-slot {
    display: block;
    width: 15px;
    height: 15px;
    color: rgba(255, 226, 170, 0.16);
    transition: color 0.4s ease, filter 0.4s ease, transform 0.3s ease;
}

.collection-slot svg { width: 100%; height: 100%; display: block; }

.collection-slot.found {
    color: var(--brass);
    filter: drop-shadow(0 0 5px rgba(255, 200, 90, 0.55));
}

.collection-slot.just-found {
    animation: symbolFound 0.7s ease-out 3;
}

@keyframes symbolFound {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255, 200, 90, 0.55)); }
    45% { transform: scale(1.45); filter: drop-shadow(0 0 12px var(--amber)) drop-shadow(0 0 22px var(--amber-glow)); }
}

@media (max-width: 460px) {
    .digit-symbol svg { width: 30px; height: 30px; }
    .digit-symbol[data-symbol="bar"] svg { width: 36px; height: 22px; }
    .digit-symbol[data-symbol="seven"] svg { width: 22px; height: 28px; }
    .modifier-banner { padding: 8px 12px; gap: 8px; }
    .modifier-text { font-size: 9px; }
}

/* ==========================================================================
   Tap-along timing
   ========================================================================== */

.timing-panel {
    margin-bottom: 22px;
    padding: 14px 14px 16px;
    border-radius: 10px;
    text-align: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.26) 0%, rgba(0, 0, 0, 0.13) 100%);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.45),
        inset 0 -1px 0 rgba(255, 232, 190, 0.13);
}

.timing-readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
}

.tap-verdict {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 1px;
    color: rgba(255, 236, 200, 0.55);
    transition: color 0.15s ease, text-shadow 0.15s ease;
}

.tap-verdict.idle { color: rgba(255, 236, 200, 0.4); }

.tap-verdict.perfect {
    color: #8ce06a;
    text-shadow: 0 0 10px rgba(140, 224, 106, 0.7);
}

.tap-verdict.good {
    color: var(--amber);
    text-shadow: 0 0 10px var(--amber-glow);
}

.tap-verdict.off {
    color: #f08a72;
    text-shadow: 0 0 10px rgba(225, 75, 56, 0.6);
}

/* Early on the left, late on the right, dead centre is on the beat */
.tap-meter {
    position: relative;
    display: block;
    width: min(280px, 80%);
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg,
        rgba(240, 138, 114, 0.35) 0%,
        rgba(255, 207, 77, 0.3) 30%,
        rgba(140, 224, 106, 0.45) 50%,
        rgba(255, 207, 77, 0.3) 70%,
        rgba(240, 138, 114, 0.35) 100%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Centre tick */
.tap-meter::after {
    content: '';
    position: absolute;
    left: 50%;
    top: -3px;
    bottom: -3px;
    width: 2px;
    margin-left: -1px;
    background: rgba(255, 236, 200, 0.5);
}

.tap-needle {
    position: absolute;
    left: 50%;
    top: -4px;
    width: 6px;
    height: 16px;
    border-radius: 2px;
    background: rgba(255, 236, 200, 0.25);
    transform: translateX(-50%);
    transition: left 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease;
}

.tap-needle.live {
    background: #fff6d0;
    box-shadow: 0 0 8px var(--amber), 0 0 16px var(--amber-glow);
}

.tap-stats {
    min-height: 12px;
    font-size: 10px;
    letter-spacing: 1px;
    color: rgba(255, 236, 200, 0.5);
}

/* The pad itself */
.tap-pad {
    padding: 12px 22px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 2px;
    color: #f6ecd4;
    background: linear-gradient(180deg, #6f8f5f 0%, #4e7040 45%, #38512e 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.32),
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 5px 0 #26361f,
        0 8px 14px rgba(0, 0, 0, 0.4);
    cursor: var(--cur-pointer);
    transition: filter 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
    touch-action: manipulation;
}

.tap-pad:hover { filter: brightness(1.1); }

.tap-pad.hit,
.tap-pad:active {
    transform: translateY(3px);
    filter: brightness(1.25);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        0 2px 0 #26361f,
        0 0 18px rgba(140, 224, 106, 0.55);
}

.tap-pad:focus-visible {
    outline: none;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.32),
        0 5px 0 #26361f,
        0 0 0 3px var(--amber);
}

@media (max-width: 460px) {
    .tap-verdict { font-size: 11px; }
    .tap-pad { padding: 11px 16px; font-size: 10px; }
}
