:root {
    --accent: #e040fb;
    --glow: var(--accent);
    --gold: #ffd23f;
    --ink: #fdeeff;
    --pixel-font: 'Press Start 2P', 'Courier New', monospace;
    --pegs: 4;
    --slot: clamp(26px, min(44px, calc((100vw - 176px) / var(--pegs))), 44px);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 10px 12px 28px;
    font-family: var(--pixel-font);
    color: var(--ink);
    background:
        radial-gradient(circle at 50% 0%, #5a1a6e 0%, transparent 62%),
        repeating-linear-gradient(0deg, transparent 0 38px, rgba(224, 64, 251, 0.06) 38px 40px),
        #0d0412;
    background-attachment: fixed;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.home {
    display: inline-block;
    margin-bottom: 8px;
    padding: 6px 4px;
    font-size: 10px;
    color: #f08bff;
    text-decoration: none;
    text-shadow: 0 0 8px var(--accent);
}

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

/* ---------- Cabinet ---------- */
.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(224, 64, 251, 0.45), 0 10px 30px rgba(0, 0, 0, 0.7);
    background:
        repeating-linear-gradient(90deg, transparent 0 46px, rgba(224, 64, 251, 0.07) 46px 47px),
        linear-gradient(#2b1038, #190a22);
}

.marquee {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 12px;
    background: #000;
    border: 3px solid var(--glow);
    border-radius: 6px;
    box-shadow: 0 0 16px var(--glow), inset 0 0 12px rgba(224, 64, 251, 0.3);
}

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

.mq-icon {
    flex: none;
    width: 26px;
    height: 26px;
}

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

.hud {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.hud-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 7px 4px;
    background: #140820;
    border: 2px solid #5a2a72;
    border-radius: 4px;
}

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

.hud .value {
    font-size: 13px;
    color: var(--gold);
    text-shadow: 0 0 8px rgba(255, 210, 63, 0.6);
    font-variant-numeric: tabular-nums;
}

/* ---------- Board ---------- */
.board {
    padding: 8px;
    background: #050109;
    border: 3px solid var(--glow);
    border-radius: 8px;
    box-shadow: 0 0 14px rgba(224, 64, 251, 0.5), inset 0 0 14px #000;
}

.rows {
    position: relative;
    max-height: max(200px, calc(100vh - 540px));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #5a2a72 transparent;
}

.row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 4px 0;
}

.row + .row {
    border-top: 1px solid #1d0c28;
}

.slots {
    display: flex;
    gap: 5px;
}

.slot {
    position: relative;
    flex: none;
    width: var(--slot);
    height: var(--slot);
    margin: 0;
    padding: 3px;
    border: 2px dashed #3d1f52;
    border-radius: 50%;
    background: #0f0618;
}

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

.row.past .slot,
.row.secret .slot.shown {
    border: 2px solid transparent;
    background: #150a20;
}

/* the guess being built */
.row.now {
    background: rgba(224, 64, 251, 0.08);
    border-radius: 10px;
}

.row.now .slot {
    border-color: #8a4aa6;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.row.now .slot.active {
    border: 2px solid var(--gold);
    box-shadow: 0 0 10px rgba(255, 210, 63, 0.6);
}

.row.later {
    opacity: 0.38;
}

.row.secret {
    margin-bottom: 6px;
    padding-bottom: 8px;
    border-bottom: 2px solid #3d1f52;
}

.row.secret .slot {
    border: 2px solid #5a2a72;
    background: repeating-linear-gradient(45deg, #1a0a26 0 5px, #240f33 5px 10px);
}

.row.secret .slot::after {
    content: '?';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: calc(var(--slot) * 0.45);
    color: #c58be0;
}

.row.secret .slot.shown::after {
    content: none;
}

/* clue pegs */
.clues {
    flex: none;
    display: grid;
    grid-template-columns: repeat(var(--clue-cols, 2), 10px);
    gap: 4px;
    width: calc(var(--clue-cols, 2) * 10px + (var(--clue-cols, 2) - 1) * 4px);
}

.clue {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #3d1f52;
    background: transparent;
}

.clue.exact {
    border-color: #fff;
    background: #fff;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.clue.near {
    border-color: var(--gold);
    background: transparent;
}

/* ---------- Symbol palette ---------- */
.palette {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}

.sym {
    flex: 1;
    min-width: 0;
    max-width: 52px;
    aspect-ratio: 1;
    margin: 0;
    padding: 6px;
    border: 2px solid #5a2a72;
    border-radius: 10px;
    background: #140820;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sym svg {
    display: block;
    width: 100%;
    height: 100%;
}

.sym:active {
    transform: scale(0.9);
    background: #2a1040;
}

.sym:disabled {
    opacity: 0.4;
}

.sym:focus-visible,
.slot:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.status {
    min-height: 34px;
    margin-top: 10px;
    padding: 8px 6px;
    font-size: 8px;
    line-height: 1.8;
    text-align: center;
    color: #b88acb;
    background: #140820;
    border: 2px solid #5a2a72;
    border-radius: 4px;
}

.status.good { color: #7dffb0; text-shadow: 0 0 8px rgba(125, 255, 176, 0.6); }
.status.bad { color: #ff8a8a; }
.status.warn { color: var(--gold); }

/* ---------- Control area ---------- */
.panel {
    margin: 10px -16px 0;
    padding: 12px 16px;
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(#5a1f78, #36124a);
    border-top: 4px solid #8a3aaa;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.4);
}

.panel [hidden] {
    display: none !important;
}

.idle {
    font-size: 9px;
    color: #d6a8ea;
}

.controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.act {
    flex: 1;
    padding: 14px 4px;
    font-family: var(--pixel-font);
    font-size: 8px;
    color: #1a0a22;
    background: linear-gradient(#ffe27a, #ffb020);
    border: 3px solid #7a4d00;
    border-radius: 8px;
    box-shadow: 0 4px 0 #7a4d00;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.act.alt {
    background: linear-gradient(#f6e6fb, #b99cc6);
    border-color: #5c3f6e;
    box-shadow: 0 4px 0 #5c3f6e;
}

.act:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #5c3f6e;
}

.act:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

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

.base {
    height: 14px;
    margin: 0 -16px;
    border-radius: 0 0 4px 4px;
    background: repeating-linear-gradient(90deg, #090310 0 24px, var(--accent) 24px 28px);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.6);
}

/* ---------- Level picker ---------- */
.menu {
    position: fixed;
    inset: 44px 0 0 0; /* leaves the Arcade link tappable */
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 16px 28px;
    text-align: center;
    background: rgba(10, 3, 16, 0.96);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.menu[hidden] {
    display: none;
}

.menu > :first-child { margin-top: auto; }
.menu > :last-child { margin-bottom: auto; }

.menu h2 {
    margin: 0;
    font-size: clamp(15px, 4.6vw, 22px);
    font-weight: 400;
    color: #fff;
    text-shadow: 0 0 8px var(--accent), 0 0 22px var(--accent);
}

.menu-text,
.menu-tip {
    margin: 0;
    max-width: 380px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #f2dcf8;
}

.menu-tip {
    font-size: 12px;
    color: #c79ad9;
}

.menu-key {
    margin: 0;
    padding: 0;
    list-style: none;
    max-width: 380px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #f2dcf8;
    text-align: left;
}

.menu-key li {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
}

.menu-key b {
    color: var(--gold);
}

.levels {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, 100%);
}

.lvl {
    --c: #7dffb0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 12px;
    font-family: var(--pixel-font);
    color: #fff;
    background: #140820;
    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;
    -webkit-tap-highlight-color: transparent;
}

.lvl.hard { --c: var(--gold); }
.lvl.crazy { --c: #ff5d73; }

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

.lvl-info {
    font-size: 8px;
    line-height: 1.6;
    color: #fff;
}

.lvl-best {
    font-size: 7px;
    color: #c79ad9;
}

.lvl:hover,
.lvl:focus-visible {
    background: color-mix(in srgb, var(--c) 18%, #140820);
    outline: none;
    transform: scale(1.02);
}

@media (max-width: 480px) {
    .body { padding: 10px 10px 0; }
    .panel { margin: 10px -10px 0; padding: 12px 10px; }
    .base { margin: 0 -10px; }
    .bezel { padding: 8px; }
    .mq-icon { width: 22px; height: 22px; }
}

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