:root {
    --neon: #ff1f3d;
    --glow: var(--neon);
    --panel: #0b0b12;
    --pixel-font: 'Press Start 2P', 'Courier New', monospace;
    /* Cell size follows the screen so the whole cabinet fits without scrolling */
    --cell: clamp(14px, min(28px, calc((100vh - 270px) / 22), calc((100vw - 260px) / 10)), 28px);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 10px 12px 40px;
    font-family: var(--pixel-font);
    color: #fff;
    background:
        radial-gradient(circle at 50% 0%, #4a0a14 0%, transparent 60%),
        linear-gradient(#08080d, #020204);
    background-attachment: fixed;
    user-select: none;
    -webkit-user-select: none;
}

.home {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 10px;
    color: var(--neon);
    text-decoration: none;
    text-shadow: 0 0 8px var(--neon);
}

.home:hover,
.home:focus-visible {
    color: #fff;
}

/* ---------- Cabinet: dark with neon red trim ---------- */
.cabinet {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
}

.cabinet::after {
    content: '';
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: -16px;
    height: 24px;
    background: radial-gradient(ellipse at center, var(--glow) 0%, transparent 70%);
    opacity: 0.5;
    filter: blur(8px);
}

.body {
    position: relative;
    z-index: 1;
    padding: 10px 16px 0;
    border: 4px solid #000;
    border-radius: 18px 18px 4px 4px;
    box-shadow: 0 0 0 3px var(--glow), 0 0 28px rgba(255, 31, 61, 0.45), 0 10px 30px rgba(0, 0, 0, 0.7);
    background:
        repeating-linear-gradient(0deg, transparent 0 22px, rgba(255, 31, 61, 0.09) 22px 23px),
        repeating-linear-gradient(90deg, transparent 0 46px, rgba(255, 31, 61, 0.07) 46px 47px),
        linear-gradient(#14141c, #0c0c12);
}

.marquee {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: #000;
    border-radius: 6px;
    border: 3px solid var(--glow);
    box-shadow: 0 0 16px var(--glow), inset 0 0 12px rgba(255, 31, 61, 0.25);
}

.mq-title {
    font-size: clamp(10px, 3vw, 15px);
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 0 6px var(--neon), 0 0 18px var(--neon), 0 0 34px var(--neon);
}

.mq-bricks svg {
    display: block;
    width: 52px;
    height: 24px;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
}

/* ---------- Play area ---------- */
.bezel {
    margin-top: 10px;
    padding: 10px;
    background: #040408;
    border-radius: 10px;
    border: 3px solid #25252f;
    box-shadow: inset 0 0 14px #000;
}

.play {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    justify-content: center;
}

.well {
    position: relative;
    border: 3px solid var(--neon);
    border-radius: 4px;
    box-shadow: 0 0 14px rgba(255, 31, 61, 0.6), inset 0 0 14px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    background: #05050a;
}

#board {
    display: block;
    width: calc(var(--cell) * 10);
    height: calc(var(--cell) * 22);
}

/* ---------- Side panel ---------- */
.side {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: clamp(104px, 26vw, 132px);
}

.box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 9px 4px;
    background: #0d0d16;
    border: 2px solid #30303f;
    border-radius: 4px;
}

.box .label {
    font-size: 9px;
    color: #9a8a92;
}

.box .value {
    font-size: 17px;
    color: #fff;
    text-shadow: 0 0 6px var(--neon);
}

.next-box canvas {
    width: 64px;
    height: 64px;
}

.keys {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    font-size: 7px;
    line-height: 2;
    color: #8c8294;
}

.keys b {
    color: var(--neon);
    font-weight: 400;
    margin-right: 4px;
}

.keys li:first-child b {
    display: block;
}

/* ---------- Overlay ---------- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px;
    text-align: center;
    background: rgba(2, 2, 6, 0.88);
    /* Never clip the menu: scroll when it doesn't fit, centre when it does */
    justify-content: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.overlay > :first-child {
    margin-top: auto;
}

.overlay > :last-child {
    margin-bottom: auto;
}

.overlay[hidden] {
    display: none;
}

.overlay h2 {
    margin: 0;
    font-size: clamp(11px, 2.6vw, 15px);
    line-height: 1.5;
    font-weight: 400;
    color: #fff;
    text-shadow: 0 0 6px var(--neon), 0 0 16px var(--neon);
}

.overlay-text {
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #d8ccd2;
}

.overlay-text .big {
    display: block;
    margin: 6px 0;
    font-family: var(--pixel-font);
    font-size: 16px;
    color: #fff;
    text-shadow: 0 0 8px var(--neon);
}

.overlay-text .record {
    display: block;
    font-family: var(--pixel-font);
    font-size: 8px;
    color: #39ff14;
    animation: blink 0.7s steps(1) infinite;
}

.difficulty {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 100%;
}

.difficulty[hidden] {
    display: none;
}

.diff-btn {
    --c: #ffd93b;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 6px;
    font-family: var(--pixel-font);
    color: #fff;
    background: #0e0e18;
    border: 2px solid var(--c);
    border-radius: 6px;
    box-shadow: 0 0 10px color-mix(in srgb, var(--c) 40%, transparent);
    cursor: pointer;
    text-align: center;
    touch-action: manipulation;
}

.diff-btn.easy { --c: #39ff14; }
.diff-btn.crazy { --c: #ff1f3d; }

.diff-name {
    font-size: 11px;
    color: var(--c);
    text-shadow: 0 0 6px var(--c);
}

.diff-goal {
    font-size: 7px;
    color: #fff;
}

.diff-desc {
    font-size: 6px;
    color: #a8a0b0;
}

.diff-btn:hover,
.diff-btn:focus-visible {
    background: color-mix(in srgb, var(--c) 18%, #0e0e18);
    outline: none;
}

.ov-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.ov-buttons button.alt {
    background: linear-gradient(#cfcfe0, #8a8aa0);
    border-color: #3a3a50;
    box-shadow: 0 5px 0 #3a3a50;
}

.start-btn {
    padding: 10px 16px;
    font-family: var(--pixel-font);
    font-size: 10px;
    color: #fff;
    background: linear-gradient(#ff4f66, #d6102c);
    border: 3px solid #5c0614;
    border-radius: 8px;
    box-shadow: 0 5px 0 #5c0614, 0 0 14px rgba(255, 31, 61, 0.6);
    cursor: pointer;
    touch-action: manipulation;
}

.start-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #5c0614;
}

.start-btn:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

.overlay-hint {
    font-size: 7px;
    color: #8c8294;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* ---------- Touch controls (touch screens only) ---------- */
.touch {
    display: none;
    margin: 10px -16px 0;
    padding: 12px 16px;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: linear-gradient(#1b1b25, #101018);
    border-top: 4px solid #2c2c3a;
}

@media (pointer: coarse) {
    .touch {
        display: grid;
    }
    .keys {
        display: none;
    }
}

.tbtn {
    height: 52px;
    font-family: var(--pixel-font);
    font-size: 16px;
    color: #fff;
    background: linear-gradient(#2a2a38, #191924);
    border: 2px solid var(--neon);
    border-radius: 10px;
    box-shadow: 0 4px 0 #000, 0 0 10px rgba(255, 31, 61, 0.35);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.tbtn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #000;
    background: #3a1018;
}

.tbtn.drop,
.tbtn.pause {
    font-size: 11px;
}

/* ---------- Kick plate ---------- */
.base {
    height: 14px;
    margin: 10px -16px 0;
    border-radius: 0 0 4px 4px;
    background: repeating-linear-gradient(90deg, #06060a 0 24px, var(--neon) 24px 28px);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.6);
}

/* ---------- Phones (portrait): stats go above a bigger board ---------- */
@media (max-width: 640px) and (orientation: portrait) {
    :root {
        --cell: clamp(14px, min(28px, calc((100vh - 400px) / 22), calc((100vw - 76px) / 10)), 28px);
    }

    body {
        padding-bottom: 16px;
    }

    .play {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .side {
        order: -1;
        flex-direction: row;
        width: 100%;
        gap: 4px;
    }

    .box {
        flex: 1;
        min-width: 0;
        gap: 4px;
        padding: 5px 2px;
        justify-content: center;
    }

    .box .label {
        font-size: 7px;
    }

    .box .value {
        font-size: 11px;
    }

    .next-box canvas {
        width: 36px;
        height: 36px;
    }

    .overlay-text {
        font-size: 11px;
    }
}

/* ---------- Short screens (phones on their side) ---------- */
@media (max-height: 500px) {
    .overlay {
        gap: 6px;
        padding: 8px;
    }

    .overlay-text {
        font-size: 10px;
        line-height: 1.35;
    }

    .diff-desc {
        display: none;
    }

    .difficulty {
        gap: 5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
