:root {
    --accent: #ff5c8a;
    --glow: var(--accent);
    --p0: #ffd23f;
    --p0-edge: #9a7600;
    --p1: #38e6ff;
    --p1-edge: #0b7f94;
    --gold: #ffd23f;
    --ink: #fbeef6;
    --dim: #c58aaa;
    --line: #7a2a60;
    --pixel-font: 'Press Start 2P', 'Courier New', monospace;
    --gap: 4px;
    --body-pad: 16px;
    --bezel-pad: 10px;
    /* page padding + everything around the board, left and right */
    --chrome-x: calc(24px + 2 * (16px + var(--body-pad) + var(--bezel-pad)));
    /* Disc size follows the screen so the whole cabinet fits without scrolling */
    --cell: clamp(30px, min(58px, calc((100vw - var(--chrome-x) - 6 * var(--gap)) / 7), calc((100vh - 420px) / 6.8)), 58px);
    --rail: calc(var(--cell) * 0.8);
}

* {
    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%, #53194a 0%, transparent 62%),
        repeating-linear-gradient(0deg, transparent 0 38px, rgba(255, 92, 138, 0.045) 38px 40px),
        #12061a;
    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: #ff8fb0;
    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 var(--body-pad) 0;
    border: 4px solid #000;
    border-radius: 18px 18px 4px 4px;
    box-shadow: 0 0 0 3px var(--glow), 0 0 28px rgba(255, 92, 138, 0.45), 0 10px 30px rgba(0, 0, 0, 0.7);
    background:
        repeating-linear-gradient(90deg, transparent 0 46px, rgba(255, 92, 138, 0.07) 46px 47px),
        linear-gradient(#3f1535, #220b25);
}

.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(255, 92, 138, 0.3);
}

.mq-title {
    font-size: clamp(12px, 4vw, 17px);
    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: 28px;
    height: 28px;
}

/* ---------- Play area ---------- */
.bezel {
    margin-top: 10px;
    padding: var(--bezel-pad);
    background: #0d0412;
    border: 3px solid var(--line);
    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: #1c0a22;
    border: 2px solid var(--line);
    border-radius: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.hud-item.mid {
    flex: 0 0 22%;
}

.hud-item.p0 { --c: var(--p0); }
.hud-item.p1 { --c: var(--p1); }

/* whose turn it is */
.hud-item.turn {
    border-color: var(--c);
    box-shadow: 0 0 12px color-mix(in srgb, var(--c) 70%, transparent);
}

.hud .label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
    text-transform: uppercase;
    color: var(--dim);
}

.hud .turn .label {
    color: var(--c);
}

.hud .value {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--gold);
    text-shadow: 0 0 8px rgba(255, 210, 63, 0.6);
    font-variant-numeric: tabular-nums;
}

.hud .value b {
    font-weight: 400;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 6px var(--c);
}

.field {
    display: flex;
    justify-content: center;
}

.board {
    display: flex;
    gap: var(--gap);
    margin-top: var(--rail);
    padding: 6px;
    background: #7b2a62;
    border: 3px solid var(--glow);
    border-radius: 8px;
    box-shadow: 0 0 14px rgba(255, 92, 138, 0.5), inset 0 0 14px rgba(0, 0, 0, 0.55);
}

/* ---------- Columns and discs ---------- */
.col {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    width: var(--cell);
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: calc(var(--cell) / 2);
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.col:disabled {
    cursor: default;
}

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

.cell {
    position: relative;
    flex: none;
    width: var(--cell);
    height: var(--cell);
    border-radius: 50%;
    background: radial-gradient(circle at 50% 42%, #0a0410 58%, #230c2c 74%);
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.12);
}

.disc {
    --c: var(--p0);
    --edge: var(--p0-edge);
    position: absolute;
    inset: 7%;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: calc(var(--cell) * 0.3);
    color: var(--edge);
    background: radial-gradient(circle at 36% 30%, #fff 0 7%, var(--c) 32%, var(--edge) 135%);
    box-shadow: inset 0 0 0 calc(var(--cell) * 0.08) color-mix(in srgb, var(--edge) 55%, transparent), 0 0 8px color-mix(in srgb, var(--c) 55%, transparent);
    pointer-events: none;
}

.disc.p1 {
    --c: var(--p1);
    --edge: var(--p1-edge);
}

.disc::after {
    content: attr(data-mark);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.disc.fall {
    animation: fall calc(0.26s + 0.05s * var(--rows)) linear both;
}

@keyframes fall {
    0% { transform: translateY(calc(var(--rows) * -1 * (var(--cell) + var(--gap)) - var(--rail))); animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.6); }
    62% { transform: translateY(0); animation-timing-function: ease-out; }
    78% { transform: translateY(-9%); animation-timing-function: ease-in; }
    92%, 100% { transform: translateY(0); }
}

.disc.win {
    z-index: 1;
    animation: win 0.5s ease-in-out infinite alternate;
}

@keyframes win {
    from { transform: scale(1); box-shadow: inset 0 0 0 calc(var(--cell) * 0.08) color-mix(in srgb, var(--edge) 55%, transparent), 0 0 8px var(--c); }
    to { transform: scale(1.12); box-shadow: inset 0 0 0 calc(var(--cell) * 0.08) color-mix(in srgb, var(--edge) 55%, transparent), 0 0 20px 4px #fff; }
}

/* the disc about to be dropped, floating above the column */
.ghost {
    --c: var(--p0);
    --edge: var(--p0-edge);
    position: absolute;
    left: 14%;
    right: 14%;
    top: calc(-1 * var(--rail) + 2px);
    height: calc(var(--cell) * 0.72);
    display: none;
    border-radius: 50%;
    background: radial-gradient(circle at 36% 30%, #fff 0 7%, var(--c) 32%, var(--edge) 135%);
    opacity: 0.55;
    pointer-events: none;
}

.ghost.p1 {
    --c: var(--p1);
    --edge: var(--p1-edge);
}

.col:focus-visible .ghost,
.col.sel .ghost {
    display: block;
}

@media (hover: hover) {
    .col:not(:disabled):hover .ghost {
        display: block;
    }
}

.board.locked .ghost,
.board.done .ghost {
    display: none !important;
}

.board.done .col,
.board.locked .col {
    cursor: default;
}

.board.done {
    box-shadow: 0 0 24px rgba(255, 210, 63, 0.7), inset 0 0 14px rgba(0, 0, 0, 0.55);
}

.status {
    min-height: 34px;
    margin-top: 10px;
    padding: 8px 6px;
    font-size: 8px;
    line-height: 1.8;
    text-align: center;
    text-transform: uppercase;
    color: var(--dim);
    background: #1c0a22;
    border: 2px solid var(--line);
    border-radius: 4px;
}

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

/* ---------- Control area ---------- */
.panel {
    margin: 10px calc(-1 * var(--body-pad)) 0;
    padding: 12px var(--body-pad);
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(#6a2455, #3b1331);
    border-top: 4px solid #a8447f;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.4);
}

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

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

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

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

.act.alt {
    background: linear-gradient(#f6e6ee, #c9a3b8);
    border-color: #6a4258;
    box-shadow: 0 4px 0 #6a4258;
}

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

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

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

/* ---------- Opponent 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(13, 4, 18, 0.96);
    overflow-y: auto;
    overscroll-behavior: contain;
    --accent: #ff5c8a;
}

.menu[hidden] {
    display: none;
}

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

.menu h2 {
    margin: 0;
    font-size: clamp(16px, 5vw, 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: #f5dce8;
}

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

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

@media (max-width: 480px) {
    :root {
        --body-pad: 10px;
        --bezel-pad: 8px;
        --gap: 3px;
    }
    .mq-icon { width: 24px; height: 24px; }
}

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