/* ============================================================================
   Character select deck — the main menu IS the character screen.
   Five collectible "toy cards" with REAL in-game character art, a persistent
   gold chip, locked-card unlock pricing, and a per-character permanent-upgrade
   drawer (tier ladders, gold-priced).

   Art direction: flat, color-blocked, chunky — Murakami / Dom2D toy energy.
   Each card is a dark colour-tinted "portrait window" (halftone grill + soft
   colour halo) over a dark body, thick coloured outline, fat pressable pill.
============================================================================ */

/* Hide desktop menu chrome — the flow is a one-tap character pick. */
body.charselect-menu #openingScreen .menu-buttons-row { display: none !important; }
body.charselect-menu #openingScreen .menu-test-mode-btn { display: none !important; }

/* Short windows must scroll instead of clipping: the screen is a centering
   flexbox with overflow hidden, which crops BOTH edges when content overflows.
   margin:auto keeps it centered while making the top reachable by scroll. */
body.charselect-menu #openingScreen { overflow-y: auto; }
body.charselect-menu #openingScreen .menu-container { margin-top: auto; margin-bottom: auto; }

.cs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-top: 4px;
}

/* ── Topbar: gold chip ─────────────────────────────────────────────────── */
.cs-topbar {
    display: flex;
    justify-content: center;
    width: 100%;
}
.cs-gold-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px 8px 12px;
    border-radius: 100px;
    background: #15130d;
    box-shadow:
        inset 0 0 0 2px color-mix(in srgb, var(--menu-gold, #D8A62E) 55%, #000),
        0 4px 0 #0a0906,
        0 10px 22px rgba(0,0,0,0.45);
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.5px;
    color: var(--menu-gold-light, #F0C85B);
}
.cs-gold-chip.is-denied { animation: csShake 0.4s; }

/* Flat coin dot (no emoji, no image) */
.cs-coin {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: linear-gradient(160deg, #ffe08a 20%, #d8a62e 65%, #9c7420);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.35);
    flex-shrink: 0;
}

/* ── Card row ──────────────────────────────────────────────────────────── */
.cs-row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 16px;
    width: 100%;
    max-width: 1120px;
    flex-wrap: wrap;
}

.cs-card {
    --c:  #4169E1;   /* signature colour   (set per character below) */
    --c2: #83b0ee;   /* light tint         */
    --cd: #23408f;   /* dark shade (shadow)*/
    position: relative;
    display: flex;
    flex-direction: column;
    width: 204px;
    padding: 0;
    border: none;
    cursor: pointer;
    overflow: hidden;
    border-radius: 24px;
    background: #131318;
    box-shadow:
        inset 0 0 0 3px color-mix(in srgb, var(--c) 60%, #000),
        0 6px 0 var(--cd),
        0 16px 30px rgba(0,0,0,0.55);
    transition: transform 0.13s cubic-bezier(.34,1.56,.64,1), box-shadow 0.13s ease;
    -webkit-tap-highlight-color: transparent;
    /* Entry animates FROM hidden; the resting state is the base state so other
       animations (unlock pop) can safely replace `animation` without the card
       falling back to opacity:0. `backwards` covers the stagger delay. */
    animation: csIn 0.55s cubic-bezier(.34,1.56,.64,1) backwards;
}
.cs-card:nth-child(1) { animation-delay: 0.05s; }
.cs-card:nth-child(2) { animation-delay: 0.11s; }
.cs-card:nth-child(3) { animation-delay: 0.17s; }
.cs-card:nth-child(4) { animation-delay: 0.23s; }
.cs-card:nth-child(5) { animation-delay: 0.29s; }
@keyframes csIn { from { opacity: 0; transform: translateY(26px); } }

.cs-card:hover {
    transform: translateY(-5px);
    box-shadow:
        inset 0 0 0 3px var(--c),
        0 11px 0 var(--cd),
        0 24px 42px rgba(0,0,0,0.6);
}
.cs-card:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--c), 0 3px 0 var(--cd), 0 8px 18px rgba(0,0,0,0.5); }

/* ── Hero window: dark colour-tinted panel + halftone grill + halo ─────── */
.cs-hero {
    position: relative;
    height: 132px;
    overflow: hidden;
    border-bottom: 3px solid color-mix(in srgb, var(--c) 55%, #000);
    background:
        radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--c) 38%, transparent) 0%, transparent 46%),
        radial-gradient(rgba(255,255,255,0.09) 1.3px, transparent 1.6px) 0 0 / 13px 13px,
        linear-gradient(180deg, color-mix(in srgb, var(--c) 20%, #0c0c11), color-mix(in srgb, var(--c) 9%, #08080b));
}
/* flat confetti accents — muted so the character reads first */
.cs-hero::before {
    content: '';
    position: absolute;
    top: 13px; left: 15px;
    width: 11px; height: 11px;
    background: color-mix(in srgb, var(--c2) 70%, #000);
    border-radius: 3px;
    transform: rotate(18deg);
    opacity: 0.5;
}
.cs-hero::after {
    content: '';
    position: absolute;
    bottom: 13px; right: 17px;
    width: 8px; height: 8px;
    background: color-mix(in srgb, var(--c2) 70%, #000);
    border-radius: 50%;
    opacity: 0.5;
}

/* Real character art canvas (drawn by charselect.js) */
.cs-art {
    position: relative;
    z-index: 2;
    display: block;
    width: 118px;
    height: 118px;
    margin: 7px auto 0;
    animation: csFloat 3.6s ease-in-out infinite;
}
.cs-card:hover .cs-art { animation-duration: 2.2s; }
@keyframes csFloat {
    0%,100% { transform: translateY(0); }
    50%     { transform: translateY(-4px); }
}

/* ── Body ─────────────────────────────────────────────────────────────── */
.cs-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 13px 14px 16px;
    flex: 1 1 auto;
}
.cs-name {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 19px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #fff;
    line-height: 1;
}
.cs-desc {
    font-family: 'Sora', sans-serif;
    font-weight: 500;
    font-size: 11.5px;
    line-height: 1.45;
    color: #c7c7d0;
    text-align: center;
}

/* Actions pinned to the bottom so all five cards line up */
.cs-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    width: 100%;
}
.cs-cta {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 12.5px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #141418;
    padding: 9px 26px;
    border-radius: 100px;
    background: linear-gradient(180deg, var(--c2), var(--c));
    box-shadow: 0 4px 0 var(--cd);
    transition: transform 0.1s;
}
.cs-card:hover .cs-cta { transform: translateY(-1px); }
.cs-card:active .cs-cta { transform: translateY(2px); box-shadow: 0 2px 0 var(--cd); }

.cs-upgrade-btn {
    display: inline-flex;
    align-items: center;
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--c2) 80%, #fff);
    background: transparent;
    border: 2px solid color-mix(in srgb, var(--c) 55%, #000);
    border-radius: 100px;
    padding: 6px 16px;
    cursor: pointer;
    transition: border-color 0.12s ease, color 0.12s ease, transform 0.1s;
}
.cs-upgrade-btn:hover { border-color: var(--c); color: #fff; transform: translateY(-1px); }
.cs-card.is-upgrading .cs-upgrade-btn { border-color: var(--c); color: #fff; background: color-mix(in srgb, var(--c) 22%, transparent); }

/* ── Locked cards ─────────────────────────────────────────────────────── */
.cs-card.is-locked .cs-hero { filter: saturate(0.25) brightness(0.7); }
.cs-card.is-locked .cs-art { filter: grayscale(0.9) brightness(0.5) contrast(1.05); animation: none; }
.cs-card.is-locked .cs-name { color: #8f8f9a; }
.cs-card.is-locked .cs-desc { color: #77777f; }
.cs-card.is-locked {
    box-shadow:
        inset 0 0 0 3px color-mix(in srgb, var(--c) 22%, #000),
        0 6px 0 #101014,
        0 16px 30px rgba(0,0,0,0.5);
}
.cs-card.is-locked:hover {
    transform: translateY(-3px);
    box-shadow:
        inset 0 0 0 3px color-mix(in srgb, var(--c) 45%, #000),
        0 9px 0 #101014,
        0 20px 36px rgba(0,0,0,0.55);
}

.cs-unlock-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #141210;
    padding: 8px 16px;
    border-radius: 100px;
    background: linear-gradient(180deg, var(--menu-gold-light, #F0C85B), var(--menu-gold, #D8A62E));
    box-shadow: 0 4px 0 #6e5312;
    transition: transform 0.1s;
}
.cs-lock-ico { display: inline-flex; width: 13px; height: 13px; color: #141210; }
.cs-lock-ico svg { width: 100%; height: 100%; }
.cs-unlock-price {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding-left: 8px;
    border-left: 2px solid rgba(0,0,0,0.25);
}
.cs-unlock-price .cs-coin { width: 11px; height: 11px; }

/* Armed confirm state: pill pulses, card outline warms up */
.cs-card.is-armed {
    box-shadow:
        inset 0 0 0 3px var(--menu-gold, #D8A62E),
        0 6px 0 #6e5312,
        0 16px 34px rgba(216,166,46,0.25);
}
.cs-card.is-armed .cs-unlock-pill { animation: csPulse 0.9s ease-in-out infinite; }
@keyframes csPulse {
    0%,100% { transform: scale(1); }
    50%     { transform: scale(1.06); }
}

/* Denied: can't afford */
.cs-card.is-denied { animation: csShake 0.4s; }
@keyframes csShake {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(3px); }
}

/* Just unlocked: pop + colour floods back */
.cs-card.is-just-unlocked { animation: csUnlockPop 0.9s cubic-bezier(.34,1.56,.64,1); }
.cs-card.is-just-unlocked .cs-hero,
.cs-card.is-just-unlocked .cs-art { filter: none; transition: filter 0.45s ease; }
@keyframes csUnlockPop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.07) rotate(-1.2deg); }
    65%  { transform: scale(0.98) rotate(0.6deg); }
    100% { transform: scale(1); }
}

/* ── Signature colours (c = body, c2 = light tint, cd = dark shadow) ───── */
.cs-card.is-bonker  { --c: #4169E1; --c2: #83b0ee; --cd: #23408f; }
.cs-card.is-lasher  { --c: #2ECC71; --c2: #8de7b4; --cd: #17703e; }
.cs-card.is-volt    { --c: #16b9f0; --c2: #8fe6ff; --cd: #0a6f96; }
.cs-card.is-drbeam  { --c: #AA66FF; --c2: #d3b1ff; --cd: #5e2f99; }
.cs-card.is-gambler { --c: #eab23f; --c2: #ffdf94; --cd: #9c7420; }

/* ── Launching: chosen card locks pressed + glows, others fade back ────── */
.cs-row.is-launching .cs-card { pointer-events: none; }
.cs-row.is-launching .cs-card:not(.is-launching) { opacity: 0.4; transform: scale(0.96); }
.cs-card.is-launching {
    transform: translateY(4px);
    box-shadow: inset 0 0 0 3px var(--c), 0 0 48px color-mix(in srgb, var(--c) 65%, transparent);
}

/* ── Upgrade sheet: fixed overlay, never grows the menu page ──────────── */
.cs-sheet-backdrop {
    --c: #4169E1;
    --c2: #83b0ee;
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(5, 5, 9, 0.72);
}
.cs-sheet-backdrop.is-open { display: flex; animation: csFade 0.18s ease; }
@keyframes csFade { from { opacity: 0; } }

.cs-sheet {
    width: min(560px, 100%);
    max-height: min(78vh, 640px);
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    background: #101015;
    box-shadow:
        inset 0 0 0 3px color-mix(in srgb, var(--c) 50%, #000),
        0 24px 60px rgba(0,0,0,0.65),
        0 0 90px color-mix(in srgb, var(--c) 18%, transparent);
    padding: 18px 20px 16px;
    text-align: left;
    animation: csSheetIn 0.28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes csSheetIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cs-sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.cs-sheet-title {
    flex: 1;
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--c2) 75%, #fff);
}
.cs-gold-mini { font-size: 13px; padding: 6px 14px 6px 10px; }
.cs-sheet-close {
    background: transparent;
    border: none;
    color: #8f8f9a;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 9px;
    border-radius: 10px;
    transition: color 0.12s ease, background 0.12s ease;
}
.cs-sheet-close:hover { color: #fff; background: rgba(255,255,255,0.07); }

.cs-sheet-empty {
    font-family: 'Sora', sans-serif;
    font-size: 13px;
    color: #8f8f9a;
    padding: 10px 0 4px;
}

/* POWER meter — the "one more run" hook: visible permanent progress. */
.cs-power {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.cs-power-label {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 10px;
    letter-spacing: 3px;
    color: #9a9aa4;
}
.cs-power-bar {
    flex: 1;
    height: 12px;
    border-radius: 100px;
    background: #1b1b22;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    overflow: hidden;
}
.cs-power-fill {
    display: block;
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c2) 80%, #fff));
    box-shadow: 0 0 12px color-mix(in srgb, var(--c) 55%, transparent);
    transition: width 0.45s cubic-bezier(.34,1.56,.64,1);
}
.cs-power-count {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 11px;
    color: color-mix(in srgb, var(--c2) 70%, #fff);
    min-width: 40px;
    text-align: right;
}

/* Track rows — one line each; blurb lives in the hover title. */
.cs-sheet-body {
    overflow-y: auto;
    padding-right: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cs-group-label {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 9.5px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #6f6f78;
    margin: 8px 2px 3px;
}
.cs-group-label:first-child { margin-top: 0; }

.cs-urow {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 12px;
    background: #15151b;
}
.cs-urow.is-bought { animation: csTrackPop 0.45s cubic-bezier(.34,1.56,.64,1); }
@keyframes csTrackPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.025); }
    100% { transform: scale(1); }
}
.cs-urow-name {
    flex: 1;
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 12.5px;
    color: #e8e8ee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cs-urow.is-maxed .cs-urow-name { color: #82828c; }

.cs-urow-pips { display: flex; gap: 3px; flex-shrink: 0; }
.cs-pip {
    width: 12px; height: 6px;
    border-radius: 3px;
    background: #26262f;
}
.cs-pip.is-filled { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 85%, #fff), var(--c)); }

.cs-urow-buy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 168px;
    justify-content: space-between;
    border: none;
    cursor: pointer;
    border-radius: 100px;
    padding: 6px 12px;
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 11px;
    color: #b9b9c2;
    background: #1e1e26;
    box-shadow: inset 0 0 0 2px #26262f;
    transition: transform 0.1s, box-shadow 0.12s ease, color 0.12s ease;
}
/* Affordable = lit in the character color; unaffordable stays quiet. */
.cs-urow-buy.is-afford {
    color: #141418;
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, #fff), var(--c));
    box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 45%, #000);
}
.cs-urow-buy.is-afford:hover { transform: translateY(-1px); }
.cs-urow-buy.is-afford:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 45%, #000); }
.cs-urow-buy.is-denied { animation: csShake 0.4s; }
.cs-urow-gain { white-space: nowrap; }
.cs-urow-price {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}
.cs-urow-price .cs-coin { width: 10px; height: 10px; }
.cs-urow-max {
    flex-shrink: 0;
    min-width: 168px;
    text-align: center;
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 10px;
    letter-spacing: 2.5px;
    padding: 7px 0;
    border-radius: 100px;
    color: color-mix(in srgb, var(--c) 75%, #fff);
    background: color-mix(in srgb, var(--c) 14%, transparent);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 35%, #000);
}

/* Buy floater: the gained amount pops up from the row and fades. */
.cs-floater {
    position: absolute;
    right: 14px;
    top: -4px;
    pointer-events: none;
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 13px;
    color: color-mix(in srgb, var(--c2) 70%, #fff);
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
    animation: csFloatUp 0.9s ease-out forwards;
}
@keyframes csFloatUp {
    0%   { opacity: 0; transform: translateY(6px) scale(0.9); }
    18%  { opacity: 1; transform: translateY(-2px) scale(1.08); }
    100% { opacity: 0; transform: translateY(-26px) scale(1); }
}

/* ── Portrait / narrow: compact horizontal cards, drawer full-width ────── */
@media (max-width: 1140px) {
    .cs-row { max-width: 700px; }
}
@media (max-width: 720px), (orientation: portrait) {
    .cs { gap: 12px; }
    .cs-row { flex-direction: column; gap: 12px; max-width: 440px; align-items: stretch; }
    .cs-card {
        flex-direction: row;
        align-items: stretch;
        width: 100%;
    }
    .cs-hero {
        width: 96px;
        height: auto;
        min-height: 96px;
        flex-shrink: 0;
        position: relative;   /* anchor .cs-art here, not the card */
        border-bottom: none;
        border-right: 3px solid color-mix(in srgb, var(--c) 60%, #000);
    }
    /* inset+margin centering: the csFloat animation owns `transform`, so a
       translate(-50%,-50%) centering would be clobbered every frame */
    .cs-art { width: 78px; height: 78px; position: absolute; inset: 0; margin: auto; }
    .cs-card:hover .cs-art { animation: none; }
    .cs-body { flex: 1; align-items: flex-start; text-align: left; gap: 6px; padding: 12px 14px; }
    .cs-desc { text-align: left; min-height: 0; font-size: 11px; }
    .cs-name { font-size: 17px; }
    .cs-actions { flex-direction: row; align-items: center; gap: 10px; }
    .cs-cta { padding: 8px 18px; }
    .cs-sheet-backdrop { padding: 12px; }
    .cs-sheet { max-height: 90vh; padding: 14px 14px 12px; }
    .cs-urow-buy, .cs-urow-max { min-width: 0; }
    .cs-urow-gain { display: none; }   /* price-only pill keeps rows one-line */
}

/* Portrait: hide the hero carousel so the stacked cards always fit. */
@media (orientation: portrait) {
    body.charselect-menu #openingScreen .menu-hero-section { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .cs-art, .cs-card:hover .cs-art { animation: none; }
    .cs-card.is-armed .cs-unlock-pill { animation: none; }
}
