:root {
    --mint: #1de9b6;
    --glow: var(--mint);
    --pixel-font: 'Press Start 2P', 'Courier New', monospace;
    /* Canvas width: capped by the screen width and by its height so the whole cabinet fits on a laptop */
    --floor-w: min(720px, calc(100vw - 90px), calc((100vh - 330px) * 720 / 560));
}

* {
    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%, #0f4a40 0%, transparent 62%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 14px, transparent 14px 28px),
        #07120f;
    background-attachment: fixed;
    user-select: none;
    -webkit-user-select: none;
}

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

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

/* ---------- Cabinet: steel with hazard-stripe 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 #04100c;
    border-radius: 18px 18px 4px 4px;
    box-shadow: 0 0 0 3px var(--glow), 0 0 26px rgba(29, 233, 182, 0.4), 0 10px 30px rgba(0, 0, 0, 0.7);
    background:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 6px),
        linear-gradient(#20332f, #121d1a);
}

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

.mq-title {
    font-size: clamp(11px, 3.2vw, 18px);
    letter-spacing: 2px;
    text-shadow: 0 0 6px var(--mint), 0 0 18px var(--mint);
}

.mq-crate {
    width: 28px;
    height: 28px;
}

/* ---------- Screen ---------- */
.bezel {
    margin-top: 10px;
    padding: 8px 10px 10px;
    background: #030a08;
    border-radius: 10px;
    border: 3px solid #2c4a43;
    box-shadow: inset 0 0 14px #000;
}

.hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.hud-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 6px 4px;
    background: #0a1613;
    border: 2px solid #2e4d46;
    border-radius: 4px;
}

.hud-cell .label {
    font-size: 8px;
    color: #8fb5ac;
}

.hud-cell .value {
    font-size: 13px;
    color: #fff;
    text-shadow: 0 0 6px var(--mint);
}

.screen {
    position: relative;
    width: fit-content;
    margin: 0 auto;
    border-radius: 6px;
    overflow: hidden;
    border: 3px solid #1c2c28;
    box-shadow: 0 0 20px rgba(29, 233, 182, 0.25);
}

#floor {
    display: block;
    width: var(--floor-w);
    height: auto;
    aspect-ratio: 720 / 560;
    background: #3a4547;
}

.goal {
    width: var(--floor-w);
    min-height: 2.6em;
    margin: 8px auto 0;
    line-height: 1.6;
    font-size: clamp(7px, 1.8vw, 9px);
    text-align: center;
    color: #ffd93b;
    text-shadow: 0 0 6px #ffd93b;
}

/* ---------- Overlay (level complete / demo complete) ---------- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    text-align: center;
    background: rgba(2, 10, 8, 0.86);
}

.overlay[hidden] {
    display: none;
}

.overlay.clear {
    background: rgba(2, 10, 8, 0.2);
}

.overlay h2 {
    margin: 0;
    font-size: clamp(14px, 3.6vw, 24px);
    font-weight: 400;
    color: var(--mint);
    text-shadow: 0 0 10px var(--mint);
}

.overlay.clear h2 {
    font-size: clamp(24px, 7vw, 56px);
    color: #fff;
    text-shadow: 0 0 14px var(--mint), 0 0 40px var(--mint), 0 5px 0 #0a5a48;
}

.overlay-text {
    margin: 0;
    max-width: 420px;
    font-family: 'Courier New', monospace;
    font-size: clamp(11px, 2.6vw, 14px);
    line-height: 1.5;
    color: #d8f5ee;
}

.ov-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.ov-btn {
    padding: 11px 16px;
    font-family: var(--pixel-font);
    font-size: 10px;
    color: #04100c;
    background: linear-gradient(#7affdf, #17c79c);
    border: 3px solid #0a5a48;
    border-radius: 8px;
    box-shadow: 0 4px 0 #0a5a48, 0 0 12px rgba(29, 233, 182, 0.5);
    cursor: pointer;
    touch-action: manipulation;
}

.ov-btn.alt {
    background: linear-gradient(#dfe9e6, #9bb0aa);
    border-color: #3c524d;
    box-shadow: 0 4px 0 #3c524d;
}

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

/* ---------- Control area ---------- */
.panel {
    margin: 10px -16px 0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: linear-gradient(#233a35, #14231f);
    border-top: 4px solid #3a6359;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.4);
}

.actions {
    display: flex;
    gap: 10px;
}

.act {
    padding: 11px 14px;
    font-family: var(--pixel-font);
    font-size: 9px;
    color: #04100c;
    background: linear-gradient(#7affdf, #17c79c);
    border: 3px solid #0a5a48;
    border-radius: 8px;
    box-shadow: 0 4px 0 #0a5a48;
    cursor: pointer;
    touch-action: manipulation;
}

.act.alt {
    background: linear-gradient(#dfe9e6, #9bb0aa);
    border-color: #3c524d;
    box-shadow: 0 4px 0 #3c524d;
}

.act:active {
    transform: translateY(2px);
}

.act:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.act:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.hint {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 7px;
    text-align: right;
    color: #8fb5ac;
}

/* steering buttons: touch screens only */
.dpad {
    display: none;
    --size: 56px;
    grid-template-columns: repeat(3, var(--size));
    grid-template-rows: repeat(3, var(--size));
    grid-template-areas:
        ". up ."
        "left hub right"
        ". down .";
}

.dir {
    padding: 0;
    color: #04100c;
    font-size: 18px;
    background: linear-gradient(#7affdf, #17c79c);
    border: 3px solid #0a5a48;
    box-shadow: 0 4px 0 #0a5a48;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.dir.up { grid-area: up; border-radius: 12px 12px 0 0; }
.dir.left { grid-area: left; border-radius: 12px 0 0 12px; }
.dir.right { grid-area: right; border-radius: 0 12px 12px 0; }
.dir.down { grid-area: down; border-radius: 0 0 12px 12px; }

.dpad-hub {
    grid-area: hub;
    background: #12a07e;
    border-top: 3px solid #0a5a48;
    border-bottom: 3px solid #0a5a48;
}

.dir:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #0a5a48;
}

@media (pointer: coarse) {
    .dpad { display: grid; }
    .hint { display: none; }
}

@media (max-width: 520px) {
    .panel { flex-wrap: wrap; justify-content: center; }
    .hud-cell .value { font-size: 11px; }
}

/* Touch layout (same as the other games): D-pad on the left, action buttons on the right */
@media (pointer: coarse) {
    .panel { flex-wrap: nowrap; justify-content: space-between; }
    .dpad { order: -1; }
    .actions { flex-direction: column; width: 122px; gap: 12px; }
}

/* the base carries the hazard stripes */
.base {
    height: 16px;
    margin: 10px -16px 0;
    border-radius: 0 0 4px 4px;
    background: repeating-linear-gradient(135deg, #ffd93b 0 14px, #1a1a1a 14px 28px);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.5);
}

/* ---------- Difficulty picker ---------- */
.picker {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: min(360px, 100%);
}

.picker[hidden] {
    display: none;
}

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

.diff-btn.tut { --c: #7fb8ff; }
.diff-btn.hard { --c: #ffd93b; }
.diff-btn.crazy { --c: #ff5d73; }

.diff-key {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 9px;
    color: #04100c;
    background: var(--c);
    border-radius: 4px;
}

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

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

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

/* ---------- Stuck banner + low-moves warning ---------- */
.stuck {
    position: absolute;
    left: 50%;
    top: 8px;
    z-index: 2;
    transform: translateX(-50%);
    padding: 8px 12px;
    font-size: clamp(7px, 1.8vw, 10px);
    white-space: nowrap;
    color: #fff;
    background: #c4192f;
    border: 2px solid #ffd0d6;
    border-radius: 6px;
    box-shadow: 0 0 14px rgba(255, 60, 80, 0.7);
}

.stuck[hidden] {
    display: none;
}

.hud-cell .value.low {
    color: #ff7a7a;
    text-shadow: 0 0 8px #ff3b3b;
}

/* ---------- Board code box ---------- */
.code-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    text-align: left;
}

.code-form label {
    font-size: 7px;
    color: #9fc9bf;
}

.code-row {
    display: flex;
    gap: 8px;
}

.code-row input {
    flex: 1;
    min-width: 0;
    padding: 9px 8px;
    font-family: var(--pixel-font);
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #fff;
    background: #04100c;
    border: 2px solid #2e6d60;
    border-radius: 6px;
}

.code-row input::placeholder {
    font-size: 8px;
    letter-spacing: 0;
    color: #4f7f74;
}

.code-row input:focus {
    outline: none;
    border-color: var(--mint);
    box-shadow: 0 0 10px var(--mint);
}

.code-row .ov-btn {
    padding: 9px 12px;
}

.code-msg {
    min-height: 1.2em;
    font-size: 7px;
    line-height: 1.6;
    color: #ff8f8f;
}

/* the board code in the scoreboard can be tapped to copy it */
.hud-cell.copyable {
    cursor: pointer;
}

.hud-cell.copyable:hover {
    border-color: var(--mint);
}
