:root {
    --lime: #9dff3a;
    --glow: var(--lime);
    --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 */
    --scene-w: min(960px, calc(100vw - 90px), calc((100vh - 305px) * 16 / 9));
}

* {
    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%, #1f4a12 0%, transparent 62%),
        repeating-linear-gradient(100deg, transparent 0 60px, rgba(157, 255, 58, 0.05) 60px 64px),
        #06100a;
    background-attachment: fixed;
    user-select: none;
    -webkit-user-select: none;
}

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

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

/* ---------- Cabinet: dark with neon lime speed stripes ---------- */
.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 #020a04;
    border-radius: 18px 18px 4px 4px;
    box-shadow: 0 0 0 3px var(--glow), 0 0 26px rgba(157, 255, 58, 0.4), 0 10px 30px rgba(0, 0, 0, 0.7);
    background:
        repeating-linear-gradient(100deg, transparent 0 34px, rgba(157, 255, 58, 0.12) 34px 38px),
        linear-gradient(#16221a, #0c140f);
}

.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(157, 255, 58, 0.25);
}

.mq-title {
    font-size: clamp(12px, 3.4vw, 20px);
    letter-spacing: 3px;
    text-shadow: 0 0 6px var(--lime), 0 0 18px var(--lime), 0 0 34px var(--lime);
}

.mq-hills {
    width: 56px;
    height: 28px;
    filter: drop-shadow(0 0 4px rgba(157, 255, 58, 0.6));
}

.mq-hills.flip {
    transform: scaleX(-1);
}

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

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

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

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

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

.hud-cell .value.ok {
    color: var(--lime);
}

.screen {
    position: relative;
    width: fit-content;
    margin: 0 auto;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #1c2c21;
    box-shadow: 0 0 20px rgba(157, 255, 58, 0.3);
}

#scene {
    display: block;
    width: var(--scene-w);
    height: auto;
    aspect-ratio: 16 / 9;
    touch-action: none; /* dragging steers the glider instead of scrolling the page */
    cursor: crosshair;
}

/* ---------- Control area ---------- */
.panel {
    margin: 10px -16px 0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(#1d2d22, #121c15);
    border-top: 4px solid #3a5c45;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.4);
}

.time-btn {
    padding: 11px 14px;
    font-family: var(--pixel-font);
    font-size: 9px;
    color: #06100a;
    background: linear-gradient(#c8ff7a, #7ad61f);
    border: 3px solid #2a5a0c;
    border-radius: 8px;
    box-shadow: 0 4px 0 #2a5a0c, 0 0 12px rgba(157, 255, 58, 0.5);
    cursor: pointer;
    touch-action: manipulation;
}

.time-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #2a5a0c;
}

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

.hint {
    font-size: 7px;
    line-height: 2;
    text-align: right;
    color: #8fb59a;
}

.hint .touch {
    display: none;
}

.lift {
    display: none;
}

@media (pointer: coarse) {
    .hint .desk { display: none; }
    .hint .touch { display: inline; }
    #scene { touch-action: manipulation; cursor: default; }

    /* D-pad side on the left, action buttons on the right */
    .panel { flex-wrap: nowrap; justify-content: space-between; }
    .lift { display: flex; flex-direction: column; gap: 8px; order: -1; }
    .hint { display: none; }
}

.base {
    height: 14px;
    margin: 10px -16px 0;
    border-radius: 0 0 4px 4px;
    background: repeating-linear-gradient(100deg, #050d08 0 22px, var(--lime) 22px 26px);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.6);
}

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

@media (pointer: coarse) {
    .panel { flex-wrap: nowrap; justify-content: space-between; }
}

/* ---------- Touch lift buttons ---------- */
.lift-btn {
    width: 84px;
    height: 56px;
    padding: 0;
    font-size: 22px;
    color: #06100a;
    background: linear-gradient(#c8ff7a, #7ad61f);
    border: 3px solid #2a5a0c;
    border-radius: 10px;
    box-shadow: 0 4px 0 #2a5a0c, 0 0 12px rgba(157, 255, 58, 0.5);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.lift-btn:active,
.lift-btn.held {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #2a5a0c;
    background: linear-gradient(#7ad61f, #c8ff7a);
}

/* ---------- Overlays: difficulty select, pause, win and loss ---------- */
.btns {
    display: flex;
    gap: 10px;
}

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

.time-btn.alt {
    background: linear-gradient(#d9e5dc, #98b3a0);
    border-color: #3a5c45;
    box-shadow: 0 4px 0 #3a5c45;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    text-align: center;
    background: rgba(3, 10, 5, 0.86);
    overflow-y: auto;
}

.overlay[hidden] {
    display: none;
}

.overlay.clear {
    background: rgba(3, 10, 5, 0.25);
}

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

.overlay.big-title h2 {
    font-size: clamp(28px, 8vw, 72px);
    color: #fff;
    text-shadow: 0 0 14px var(--lime), 0 0 40px var(--lime), 0 5px 0 #1b5a0c;
}

.overlay-text {
    margin: 0;
    max-width: 440px;
    font-family: 'Courier New', monospace;
    font-size: clamp(11px, 2.5vw, 14px);
    line-height: 1.45;
    color: #dcf5e2;
}

.legend {
    display: flex;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.legend[hidden] {
    display: none;
}

.legend li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #cfe9d6;
}

.legend svg {
    width: 34px;
    height: 34px;
}

.legend b {
    font-family: var(--pixel-font);
    font-size: 10px;
    font-weight: 400;
    color: var(--lime);
}

.legend b.bad {
    color: #ff8a8a;
}

.difficulty {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(400px, 100%);
}

.difficulty[hidden] {
    display: none;
}

.diff-btn {
    --c: var(--lime);
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 9px 12px;
    font-family: var(--pixel-font);
    color: #fff;
    background: #0a1a0e;
    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;
}

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

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

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

.diff-desc {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #b7d6c0;
}

.diff-btn:hover,
.diff-btn:focus-visible {
    background: color-mix(in srgb, var(--c) 20%, #0a1a0e);
    outline: none;
    transform: scale(1.02);
}

.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: #06100a;
    background: linear-gradient(#c8ff7a, #7ad61f);
    border: 3px solid #2a5a0c;
    border-radius: 8px;
    box-shadow: 0 4px 0 #2a5a0c, 0 0 12px rgba(157, 255, 58, 0.5);
    cursor: pointer;
    touch-action: manipulation;
}

.ov-btn.alt {
    background: linear-gradient(#d9e5dc, #98b3a0);
    border-color: #3a5c45;
    box-shadow: 0 4px 0 #3a5c45;
}

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

/* Phones: the menu is a full-screen sheet (the scene box is far too small to hold it) */
@media (max-width: 640px) {
    .overlay:not(.clear) {
        position: fixed;
        z-index: 50;
        top: 44px; /* leave the Arcade link tappable */
        gap: 14px;
        padding: 24px 16px;
        justify-content: flex-start;
        background: rgba(3, 10, 5, 0.94);
    }
    .overlay:not(.clear) > :first-child { margin-top: auto; }
    .overlay:not(.clear) > :last-child { margin-bottom: auto; }
    .overlay:not(.clear) h2 { font-size: 22px; }
    .overlay:not(.clear) .overlay-text { font-size: 13px; }
    .overlay:not(.clear) .legend { gap: 18px; }
}

@media (max-width: 520px) {
    .overlay.clear { gap: 7px; padding: 8px; }
}
