/* Look shared by the card games (Spider, Pyramid, TriPeaks): the arcade cabinet, the felt table and the cards themselves.
   A game's main.css sets --accent / --felt-a / --felt-b and lays out its own table. */

:root {
    --accent: #3ddc84;
    --glow: var(--accent);
    --felt-a: #1b7a4a;
    --felt-b: #0b4026;
    --gold: #ffd23f;
    --ink: #eaf4fb;
    --pixel-font: 'Press Start 2P', 'Courier New', monospace;
    --gap: 2px;
    --cab: color-mix(in srgb, var(--accent) 22%, #07100c);
    --cab-dark: color-mix(in srgb, var(--accent) 12%, #040806);
    --edge: color-mix(in srgb, var(--accent) 55%, #1a2a22);
    --dim: color-mix(in srgb, var(--accent) 35%, #9fb3aa);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 10px 6px 28px;
    font-family: var(--pixel-font);
    color: var(--ink);
    background:
        radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 28%, #07100c) 0%, transparent 62%),
        repeating-linear-gradient(0deg, transparent 0 38px, color-mix(in srgb, var(--accent) 6%, transparent) 38px 40px),
        #060d0a;
    background-attachment: fixed;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

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

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

/* ---------- Cabinet ---------- */
.cabinet {
    position: relative;
    width: min(100%, var(--max, 640px));
    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: 8px 8px 0;
    border: 4px solid #000;
    border-radius: 18px 18px 4px 4px;
    box-shadow: 0 0 0 3px var(--glow), 0 0 28px color-mix(in srgb, var(--glow) 45%, transparent), 0 10px 30px rgba(0, 0, 0, 0.7);
    background:
        repeating-linear-gradient(90deg, transparent 0 46px, color-mix(in srgb, var(--accent) 8%, transparent) 46px 47px),
        linear-gradient(var(--cab), var(--cab-dark));
}

.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 color-mix(in srgb, var(--glow) 30%, transparent);
}

.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;
    font-family: system-ui, sans-serif;
    font-size: 22px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 8px var(--accent);
}

.mq-icon.red {
    color: #ff5d73;
}

/* ---------- Play area ---------- */
.bezel {
    margin-top: 8px;
    padding: 6px;
    background: #030806;
    border: 3px solid var(--edge);
    border-radius: 10px;
    box-shadow: inset 0 0 14px #000;
}

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

.hud-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 7px 4px;
    background: var(--cab-dark);
    border: 2px solid var(--edge);
    border-radius: 4px;
}

.hud .label {
    font-size: 8px;
    color: var(--dim);
}

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

/* The felt. It is a size container so a game can size its cards from the table's own width (cqw). */
.table {
    container-type: inline-size;
    padding: 6px;
    background: radial-gradient(ellipse at 50% 20%, var(--felt-a), var(--felt-b));
    border: 3px solid var(--glow);
    border-radius: 8px;
    box-shadow: 0 0 14px color-mix(in srgb, var(--glow) 50%, transparent), inset 0 0 22px rgba(0, 0, 0, 0.7);
}

.table.won {
    border-color: var(--gold);
    box-shadow: 0 0 24px rgba(255, 210, 63, 0.8), inset 0 0 22px rgba(0, 0, 0, 0.7);
}

.status {
    min-height: 34px;
    margin-top: 8px;
    padding: 8px 6px;
    font-size: 8px;
    line-height: 1.8;
    text-align: center;
    color: var(--dim);
    background: var(--cab-dark);
    border: 2px solid var(--edge);
    border-radius: 4px;
}

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

/* ---------- Cards ---------- */
/* A game gives the table --cw (card width) and --ch (card height) and places each .pcard with left / top */
.pcard {
    position: absolute;
    width: var(--cw);
    height: var(--ch);
    overflow: hidden;
    border-radius: calc(var(--cw) * 0.13);
    background: #fbfaf5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.3);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.pcard.red { color: #d62828; }
.pcard.black { color: #14161c; }

.pcard .rk {
    position: absolute;
    left: 7%;
    top: 6%;
    font-size: calc(var(--cw) * 0.36);
    white-space: nowrap;
    letter-spacing: -0.04em;
}

.pcard .rk i {
    font-style: normal;
    font-size: 0.92em;
}

.pcard .st {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 5%;
    text-align: center;
    font-size: calc(var(--cw) * 0.62);
    opacity: 0.92;
}

.pcard.down {
    background: #fff;
    padding: calc(var(--cw) * 0.08);
}

.pcard .back {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: calc(var(--cw) * 0.08);
    background: repeating-linear-gradient(45deg, #2b5fd6 0 3px, #1f47a8 3px 6px);
}

.pcard.sel {
    transform: translateY(-3px);
    box-shadow: 0 0 0 2px #fff, 0 0 12px 3px var(--gold);
    z-index: 30 !important;
}

.pcard.hint,
.slot.hint {
    box-shadow: 0 0 0 3px #fff, 0 0 14px 4px var(--gold);
    animation: hint 0.6s ease-in-out infinite alternate;
    z-index: 30 !important;
}

.pcard.blocked {
    filter: brightness(0.5);
    cursor: default;
}

@keyframes hint {
    from { box-shadow: 0 0 0 2px var(--gold), 0 0 4px 1px var(--gold); }
    to { box-shadow: 0 0 0 3px #fff, 0 0 16px 5px var(--gold); }
}

/* An empty spot where cards could go */
.slot {
    position: absolute;
    width: var(--cw);
    height: var(--ch);
    border: 2px dashed rgba(255, 255, 255, 0.28);
    border-radius: calc(var(--cw) * 0.13);
    background: rgba(0, 0, 0, 0.14);
    color: rgba(255, 255, 255, 0.4);
    font-family: system-ui, sans-serif;
    font-size: calc(var(--cw) * 0.5);
    display: grid;
    place-items: center;
    cursor: pointer;
}

/* Stock and waste piles under the pyramid or peaks */
.hand {
    display: flex;
    justify-content: center;
    gap: calc(var(--cw) * 0.7);
    margin-top: 10px;
}

.pile {
    position: relative;
    width: var(--cw);
    height: var(--ch);
}

.badge {
    position: absolute;
    right: -6px;
    bottom: -7px;
    z-index: 40;
    min-width: 22px;
    padding: 4px 4px 3px;
    font-family: var(--pixel-font);
    font-size: 8px;
    text-align: center;
    color: #0a1a14;
    background: var(--gold);
    border: 2px solid #000;
    border-radius: 999px;
    pointer-events: none;
}

/* ---------- Control area ---------- */
.panel {
    margin: 8px -8px 0;
    padding: 12px 8px;
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(color-mix(in srgb, var(--accent) 45%, #0c1a14), color-mix(in srgb, var(--accent) 25%, #07100c));
    border-top: 4px solid color-mix(in srgb, var(--accent) 65%, #1a2a22);
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.4);
}

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

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

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

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

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

.act:disabled {
    opacity: 0.45;
    cursor: default;
}

.act:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #3e5a4c;
}

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

.base {
    height: 14px;
    margin: 0 -8px;
    border-radius: 0 0 4px 4px;
    background: repeating-linear-gradient(90deg, #030a07 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: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 16px 28px;
    text-align: center;
    background: rgba(4, 10, 7, 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(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: #d6eee2;
}

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

.menu-tip 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: #07120d;
    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: #94b8a8;
}

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

@media (min-width: 560px) {
    body { padding: 10px 12px 28px; }
    .body { padding: 10px 16px 0; }
    .panel { margin: 10px -16px 0; padding: 12px 16px; }
    .base { margin: 0 -16px; }
    .bezel { padding: 10px; }
    .controls { gap: 10px; }
}

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