/* Shared chrome for the Chinchilla Games catalog and the per-game shims.
   The playable game keeps its own style.css and does not load this file. */
:root {
    --bg: #0c0912;
    --panel: #171226;
    --line: rgba(255, 255, 255, 0.10);
    --text: #eef0f6;
    --muted: #9a94ad;
    --pink: #ff0048;
    --purple: #8b00ff;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(900px 520px at 50% -12%, rgba(139, 0, 255, 0.24), transparent 70%),
        var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 20px;
    flex-wrap: wrap;
}

.brand {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.brand:hover { color: var(--text); }

.title {
    margin: 0;
    flex: 1;
    font-size: clamp(18px, 3vw, 28px);
    font-weight: 900;
    letter-spacing: 0.01em;
    background: linear-gradient(90deg, #ff0048, #ff6aa2 45%, #8b00ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    margin: 20px 20px 0;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

/* Live star goals under the board: what today's remaining stars cost. */
.goals {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 6px 16px 0;
}

.goal {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
    white-space: nowrap;
}

.goal.met {
    color: #0d2418;
    background: #8ce0a8;
    border-color: #8ce0a8;
}

.wrap {
    max-width: 1040px;
    margin: 0 auto;
    padding: 24px 16px 70px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #1a1430, #141022);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

a.card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 0, 72, 0.55);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.card.locked { opacity: 0.6; cursor: default; }

.card-emoji {
    font-size: 34px;
    line-height: 1;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5));
}

/* Drawn card icons: same chinchilla as the games, so the menu matches them and
   nothing depends on an emoji font being installed. */
.card-icon {
    display: block;
    width: 52px;
    height: 52px;
}

.card h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 900;
}

.card p {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.5;
}

.badge {
    align-self: flex-start;
    margin-top: auto;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 11px;
    border-radius: 999px;
}

.card-best {
    font-size: 12px;
    font-weight: 800;
    color: var(--amber, #ffd15c);
    letter-spacing: 0.02em;
}

.badge.live {
    background: linear-gradient(90deg, var(--pink), var(--purple));
    color: #fff;
}

.badge.soon {
    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);
}

.btn {
    display: inline-block;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 18px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, transform 0.12s ease;
}

.btn:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }

.btn.primary {
    border: 0;
    background: linear-gradient(90deg, var(--pink), var(--purple));
    color: #fff;
    box-shadow: 0 10px 26px rgba(255, 0, 72, 0.28);
}

/* ---------- playable games ---------- */

.play-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 12px 10px;
}

/* A phone held upright gets a 206px-tall park, which is not really playable.
   Say so, without blocking the game. */
.rotate-hint {
    display: none;
    margin: 0 0 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--amber, #ffd15c);
}

@media (max-width: 560px) and (orientation: portrait) {
    .rotate-hint { display: block; }
}

/* Short landscape screens: the board is height-bound, so every row of chrome
   above or below it costs tiles. Drop the prose and tighten the furniture. */
#stage {
    width: 100%;
    max-width: min(1180px, calc((100vh - 200px) * 16 / 9));
    aspect-ratio: 16 / 9;
    display: block;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #14101f;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
    touch-action: none;
}

.hud { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.tray {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 12px 16px 20px;
}

.part {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    position: relative;
    font: inherit;
    cursor: pointer;
    user-select: none;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.part:hover { transform: translateY(-2px); border-color: rgba(255, 0, 72, 0.55); }
.part.empty { opacity: 0.35; cursor: default; }
.part.empty:hover { transform: none; border-color: var(--line); }

/* Not open yet. Reads as "later", not as "too expensive". */
.part.locked {
    opacity: 0.4;
    cursor: default;
    filter: grayscale(0.7);
}
.part.locked:hover { transform: none; border-color: var(--line); }
.part.locked .part-count { color: var(--muted); }
.part.picked { border-color: rgba(255, 0, 72, 0.85); background: rgba(255, 0, 72, 0.16); }

.part-name { font-size: 13px; font-weight: 700; }

.part-count {
    min-width: 22px;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    background: rgba(255, 0, 72, 0.22);
    border-radius: 999px;
    padding: 2px 6px;
}

.chip {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 7px 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    color: #ffd7e3;
    white-space: nowrap;
}

.chip b { color: #fff; }

.btn.track { padding: 8px 14px; font-size: 12px; }

.btn.track.picked {
    border: 0;
    color: #fff;
    background: linear-gradient(90deg, var(--pink), var(--purple));
    box-shadow: 0 6px 18px rgba(255, 0, 72, 0.22);
}

.overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 5, 14, 0.74);
    backdrop-filter: blur(4px);
    z-index: 80;
}

.overlay.show { display: flex; }

.overlay .box {
    text-align: center;
    padding: 30px 38px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #1d1533, #150f24);
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.7);
    animation: pop 0.26s ease-out;
}

@keyframes pop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.overlay h2 {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(90deg, #ff0048, #8b00ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.overlay p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* ---------- shims ---------- */

.shim {
    max-width: 720px;
    margin: 0 auto;
    padding: 46px 18px 80px;
    text-align: center;
}

.shim-art {
    font-size: 76px;
    line-height: 1;
    filter: drop-shadow(0 16px 34px rgba(0, 0, 0, 0.6));
}

.shim h1 {
    margin: 18px 0 10px;
    font-size: clamp(24px, 4vw, 38px);
    font-weight: 900;
    background: linear-gradient(90deg, #ff0048, #ff6aa2 45%, #8b00ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.shim .lede {
    margin: 0 auto;
    max-width: 540px;
    color: var(--muted);
    font-size: 14.5px;
    line-height: 1.6;
}

.shim-card {
    margin-top: 26px;
    padding: 22px 24px 24px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #1a1430, #141022);
    text-align: left;
}

.shim-card h2 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.shim-card ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.85;
}

.shim-card li::marker { color: var(--pink); }

.shim-actions {
    margin-top: 26px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .topbar {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .card { padding: 18px; }

    /* Phones: the HUD is a wrapping row of small chips under the title instead
       of a single line that pushes the page sideways. */
    .brand { font-size: 11px; }
    .title { flex-basis: 100%; font-size: 20px; }
    .hud {
        width: 100%;
        gap: 6px;
        order: 2;
    }
    .chip {
        font-size: 11px;
        padding: 5px 9px;
        white-space: nowrap;
    }
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    .tagline {
        font-size: 12px;
        padding: 0 12px;
        margin: 8px 0;
    }
    #stage {
        max-width: calc(100vw - 16px);
        border-radius: 12px;
    }
    .part { padding: 6px 10px; gap: 6px; }
    .part-name { font-size: 12px; }

    /* Seven cards stacked take ~190px and squeeze the board to 206px. One
       scrollable row gives that height back to the game. */
    .tray {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px 12px 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tray::-webkit-scrollbar { display: none; }
    .part { flex: 0 0 auto; }
}

/* Short landscape screens: the board is height-bound, so every row of chrome
   above or below it costs tiles. This block sits last on purpose — the tray and
   stage rules above it would otherwise win on source order. */
@media (max-height: 500px) and (orientation: landscape) {
    .rotate-hint { display: none; }
    .tagline { display: none; }
    .topbar { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; align-items: center; }
    .title { flex: 0 0 auto; }
    .hud {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        min-width: 0;
    }
    .hud::-webkit-scrollbar { display: none; }
    .chip { font-size: 10.5px; padding: 4px 8px; }
    .btn { padding: 6px 9px; font-size: 11px; }
    .play-wrap { padding: 0 6px 4px; }
    #stage {
        max-width: min(1180px, calc((100vh - 132px) * 16 / 9));
        border-radius: 10px;
    }
    .tray {
        padding: 4px 8px 6px;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }
    .tray::-webkit-scrollbar { display: none; }
    .part { padding: 4px 8px; flex: 0 0 auto; }
    .goals { padding: 2px 8px 0; }
    .goal { font-size: 10px; padding: 3px 7px; }
}

/* Which build the tab is actually running: after a report that a fix "did not
   work", the answer is usually a stale script. */
.build-tag {
    margin: 2px 0 10px;
    text-align: right;
    padding-right: 18px;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.28);
}

/* Two bars under the board: how much of today's quota is served, and how much of
   the day is left. The HUD chips say the numbers; the bars are the glance. */
.daybar {
    width: min(1180px, calc(100% - 24px));
    margin: 6px auto 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.daybar-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.daybar-track.thin { height: 4px; }

.daybar-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.25s linear;
}

.daybar-fill.quota { background: linear-gradient(90deg, #ff0048, #8b00ff); }
.daybar-fill.time { background: #4fe3c0; }

/* Level-up picker: three cards over a dimmed board. */
.cards {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px;
    background: rgba(10, 8, 18, 0.72);
}

.cards.show { display: flex; }

.card-pick {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 220px;
    padding: 18px 16px;
    text-align: left;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: linear-gradient(180deg, #241c38, #171226);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.card-pick:hover { transform: translateY(-3px); border-color: rgba(255, 0, 72, 0.8); }
.card-pick b { font-size: 16px; font-weight: 900; }
.card-pick span { font-size: 13px; color: var(--muted); line-height: 1.4; }

@media (max-width: 640px) {
    .cards { flex-direction: column; gap: 10px; }
    .card-pick { width: min(100%, 340px); padding: 14px; }
}

/* Portrait mode. A game opts in with <body class="portrait"> and draws a
   720x1280 canvas. The page itself becomes one screen tall and never scrolls: the
   header, the board and whatever strip the game needs at the bottom are laid out
   in a column, and the board takes whatever height is left. That matters because
   a phone browser keeps its own address bar in that viewport - dvh already
   excludes it, so nothing is planned around a height the user cannot see. */
body.portrait {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.portrait .topbar { flex: 0 0 auto; }
body.portrait .tagline { flex: 0 0 auto; }

body.portrait .play-wrap {
    flex: 1 1 auto;
    min-height: 0;
    /* Top-aligned: centring the canvas left a gap under the header that varied
       with the leftover height (68px on the phone), which read as a dead band. */
    align-items: flex-start;
    padding: 5px 8px 6px;
}

/* Intrinsic 720x1280 plus both max constraints: the canvas keeps 9:16 and fits
   whatever box is left, so a short viewport narrows it instead of clipping it. */
body.portrait #stage {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 9 / 16;
}

body.portrait .tray,
body.portrait #daybar,
body.portrait #goals,
body.portrait #rotateHint {
    flex: 0 0 auto;
    margin: 0;
}

@media (max-width: 640px) {
    body.portrait .tagline { display: none; }
    body.portrait .brand { display: none; }
    body.portrait .title { font-size: 17px; }
    body.portrait .topbar { padding: 6px 8px 2px; }
    body.portrait .hud { gap: 4px; }
    body.portrait .chip { font-size: 10px; padding: 3px 6px; }
    body.portrait .tray {
        justify-content: flex-start;
        padding: 5px 6px;
        border-radius: 14px 14px 0 0;
        background: #14101f;
        overflow-x: auto;
    }
    body.park #rotateHint { display: none; }
    body.park #daybar,
    body.park #goals {
        padding: 2px 8px;
        background: #14101f;
    }
    body.portrait .build-tag { display: none; }
}
/* A game whose numbers live on the canvas keeps only its buttons in the header,
   pushed to the far right so the title owns the left. */
.hud-end {
    margin-left: auto;
}

/* Header with no numbers in it: title and buttons share one row, buttons right. */
@media (max-width: 640px) {
    body.compact-hud .topbar { flex-wrap: nowrap; }
    body.compact-hud .title { flex-basis: auto; font-size: 18px; }
    body.compact-hud .hud { width: auto; margin-left: auto; }
}

/* Play-count badge: the gradient is for games that get played, a flat chip for the
   ones nobody has opened yet. */
.badge.idle {
    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);
}
