/* styles.css — "The Midnight Salon" (doc 05). Blue ALWAYS means Chips, red ALWAYS
   means Mult — never decorative. Brass = interactive metal. Violet is rationed. */

:root{
  /* base — deep wine/aubergine, not black */
  --bg-void:#140812; --bg-felt:#2a0e22; --bg-raise:#3d1630; --line:#5a2848;
  /* metal + paper */
  --brass:#c8973f; --brass-hi:#f0d89a; --bone:#f4ead9; --ash:#b9a7b3;
  /* LOAD-BEARING scoring colors — reserved */
  --chips:#3d8bff; --mult:#ff3d5a; --score:#f0d89a;
  /* arcane accent — the one glow */
  --arcane:#a855f7;
  /* semantics */
  --win:#4ecb8b; --danger:#ff6b6b;

  --step--1:.875rem; --step-0:1rem; --step-1:1.25rem; --step-2:1.75rem;
  --step-3:2.5rem; --step-4:4rem;

  /* spacing scale — a 4px rhythm so vertical/horizontal gaps stop drifting into ad-hoc
     2/6/10/18px one-offs. --edge is the app's shared horizontal inset (used by #app and the
     topbar/progress rows so their left edges line up). Card gaps stay tuned separately
     (--hand-gap) since the 8-card hand fit is geometry, not rhythm. */
  --edge:12px; --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px;

  --display:"Cormorant Garamond",Georgia,"Times New Roman",serif;
  --ui:"Sofia Sans",Inter,system-ui,-apple-system,sans-serif;
  --mono:"JetBrains Mono","SF Mono",ui-monospace,"Cascadia Mono",monospace;
}

*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{
  background:
    radial-gradient(120% 80% at 50% -10%, #3a1330 0%, var(--bg-void) 60%),
    var(--bg-void);
  color:var(--bone); font-family:var(--ui); font-size:var(--step-0);
  -webkit-font-smoothing:antialiased; overflow:hidden;
}
/* faint candle flicker on the backdrop — the ONLY idle motion (doc 05) */
body::before{
  content:""; position:fixed; inset:0; pointer-events:none; z-index:0;
  background:radial-gradient(60% 40% at 50% 8%, rgba(240,216,154,.06), transparent 70%);
  animation:flicker 6s ease-in-out infinite;
}
@keyframes flicker{0%,100%{opacity:.7}45%{opacity:.9}70%{opacity:.6}}

/* all numbers are tabular mono so counters don't jitter (doc 05, non-negotiable) */
.num{font-family:var(--mono);font-variant-numeric:tabular-nums;letter-spacing:-.01em}

/* ── table frame ─────────────────────────────────────────────────────────── */
#app{
  position:relative; z-index:1; height:100%;
  max-width:460px; margin:0 auto; display:flex; flex-direction:column;
  padding:env(safe-area-inset-top) var(--edge) calc(var(--edge) + env(safe-area-inset-bottom));
}
/* #board wraps the interactive table so it can be made `inert` behind the overlay (a11y) */
#board{display:flex; flex-direction:column; flex:1; min-height:0}

/* Topbar is meta-chrome (ante label + meta currency + Ranks), so it stays quiet: the
   gameplay-critical numbers live in the progress readout and Score Engine below, and must
   out-weigh anything up here. align-items:center so the display ante label sits level with
   the 44px Ranks pill. */
.topbar{display:flex;justify-content:space-between;align-items:center;gap:var(--sp-3);padding:var(--sp-2) var(--sp-1) var(--sp-1)}
.topbar .ante{font-family:var(--display);font-size:var(--step-1);letter-spacing:.02em}
/* Omens: rationed violet meta currency, deliberately at --step--1 so it reads as secondary
   to the round score below it (it was inheriting body --step-0 and competing with gameplay). */
.topbar .omens{color:var(--arcane);font-size:var(--step--1)}
.progress{height:8px;border:1px solid var(--line);border-radius:6px;background:var(--bg-felt);overflow:hidden;margin:var(--sp-1) var(--sp-1)}
.progress > i{display:block;height:100%;width:0;background:linear-gradient(90deg,var(--brass),var(--brass-hi));transition:width .35s ease}
/* The score-to-target readout is a PRIMARY gameplay number (second only to the Score Engine),
   so it's promoted to --step-1 in bone while the hand-name label stays a quiet --step--1 ash. */
.progress-label{display:flex;justify-content:space-between;align-items:baseline;gap:var(--sp-3);color:var(--ash);padding:var(--sp-1) var(--sp-1) var(--sp-2)}
.progress-label #hand-name-top{font-size:var(--step--1)}
.progress-label .score-readout{font-size:var(--step-1);color:var(--bone)}
.progress-label .score-readout #target{color:var(--ash)}

/* ── skill tree node visual language (shared by the tree-view grid; see .st-grid below) ──
   The old inline horizontal-scroll .jokers row was replaced by a dedicated full-height tree
   sheet (#skilltree-sheet). The node's locked/affordable/unlocked look is reused verbatim; only
   the layout around it (absolute grid positions + SVG connectors) is new. */
.skill-node{
  border-radius:8px;padding:4px 6px;box-sizing:border-box;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
  border:1px dashed var(--line);background:var(--bg-void);color:var(--ash);
  font-family:var(--ui);cursor:pointer;transition:transform .1s ease, background .15s ease;
}
.skill-node .node-label{font-size:var(--step--1);font-weight:700;line-height:1.1;text-align:center;overflow-wrap:anywhere}
.skill-node .node-cost{font-size:var(--step--1);font-family:var(--mono)}
.skill-node.affordable{border-style:solid;border-color:var(--arcane);color:var(--bone)}
.skill-node.unlocked{border-style:solid;border-color:var(--brass-hi);background:linear-gradient(180deg,var(--brass),#a9772c);color:#231208}
.skill-node:disabled{cursor:not-allowed;opacity:.45}
.skill-node:active:not(:disabled){transform:translateY(1px)}
.skill-node:focus-visible{outline:3px solid var(--brass-hi);outline-offset:2px;z-index:3}

.play-area{
  flex:1;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:6px;
  color:var(--ash);text-align:center;min-height:60px;position:relative;border-radius:12px;
  border:1px dashed var(--line); /* matches .joker-slot's empty-droppable-slot convention */
  transition:box-shadow .15s ease, border-color .15s ease;
}
.play-area .hint{max-width:22ch;line-height:1.4}

/* drag-drop affordance: brass glow while a card you're dragging is armed over the zone */
#play-area.drop-armed,
#discard.drop-armed{box-shadow:inset 0 0 0 2px var(--brass-hi), 0 0 20px rgba(240,216,154,.35)}

/* ── hand of cards ───────────────────────────────────────────────────────── */
/* nowrap: the 8-card hand must stay a single row. At a fixed 60px, 8 cards + gaps (522px) never
   fit even the desktop container (460px cap - 24px inset = 436px content), so the width is fluid:
   it fills the available row and shrinks on narrower viewports instead of wrapping to two rows
   (the pre-existing 375px bug). --card-w is derived from the real content width — min(container
   cap, viewport) minus the app inset (--edge*2) minus the 7 inter-card gaps, divided by 8 —
   clamped so cards never balloon past 58px or shrink below a legible 38px. Height tracks width at
   the original 60:86 aspect. NB: main.js reads card geometry via getBoundingClientRect() at
   drag-start, so this CSS-driven sizing is transparent to the drag model (no inline/JS size). */
.hand{--hand-gap:5px;display:flex;gap:var(--hand-gap);justify-content:center;flex-wrap:nowrap;padding:var(--sp-2) 0;position:relative}
.card{
  --card-w:clamp(38px, (min(460px, 100vw) - var(--edge) * 2 - var(--hand-gap) * 7) / 8, 58px);
  width:var(--card-w);height:calc(var(--card-w) * 86 / 60);border-radius:12px;background:var(--bone);color:#1a1a1a;
  border:1px solid var(--line); position:relative; cursor:grab; touch-action:none;
  display:flex;flex-direction:column;justify-content:space-between;padding:5px 6px;
  font-weight:700; user-select:none; transition:transform .12s ease, box-shadow .12s ease;
  font-variant-numeric:tabular-nums;
}
.card .corner{font-size:.95rem;line-height:1}
.card .corner.br{align-self:flex-end;transform:rotate(180deg)}
.card.red{color:#8a1020}          /* hearts/diamonds glyph color (not the load-bearing red) */
.card[aria-pressed="true"]{transform:translateY(-8px);box-shadow:0 0 0 2px var(--brass),0 6px 14px rgba(0,0,0,.45)}
.card:focus-visible{outline:3px solid var(--brass);outline-offset:2px}
.card.scoring{animation:flash .28s ease}
@keyframes flash{0%{box-shadow:0 0 0 2px #fff}100%{box-shadow:none}}

/* drag-to-reorder (cosmetic, mouse+touch via Pointer Events, see main.js). Note: transform
   (scale + fake-3D tilt) is written directly by JS during the drag, not here -- this rule
   only owns the glow/positioning, so it can't fight the per-frame tilt with its own value. */
.card.dragging{
  position:absolute; z-index:10; cursor:grabbing; pointer-events:none;
  box-shadow:0 0 0 3px var(--brass-hi),0 12px 26px rgba(0,0,0,.55);
}

/* ── the Score Engine ────────────────────────────────────────────────────── */
.engine{
  border:1px solid var(--line);border-radius:12px;background:var(--bg-felt);
  padding:var(--sp-3);margin:var(--sp-2) 0;text-align:center;
}
.engine .hand-name{font-family:var(--display);font-size:var(--step-1);color:var(--ash);min-height:1.4em}
.reels{display:flex;align-items:center;justify-content:center;gap:10px;margin-top:4px}
.reel{display:flex;flex-direction:column;align-items:center;min-width:92px}
.reel .label{font-size:var(--step--1);letter-spacing:.14em}
.reel .val{font-size:var(--step-2)}
.reel.chips .label{color:var(--chips)} .reel.chips .val{color:var(--chips)}
.reel.mult  .label{color:var(--mult)}  .reel.mult  .val{color:var(--mult)}
.reels .x{font-size:var(--step-1);color:var(--ash)}
.product{margin-top:6px;font-size:var(--step-3);color:var(--score);min-height:1.1em}
.engine.slam{animation:slam .18s ease}
@keyframes slam{0%{transform:scale(1)}40%{transform:scale(1.04)}100%{transform:scale(1)}}
/* brass pulse marking an auto-filled (not typed) value -- distinct from the plain brass
   focus-visible outline so a suggested name reads as "the game did this", not "you tabbed here" */
@keyframes suggestPop{
  0%{box-shadow:0 0 0 0 rgba(200,151,63,0);transform:scale(1)}
  30%{box-shadow:0 0 0 3px var(--brass);transform:scale(1.015)}
  100%{box-shadow:0 0 0 0 rgba(200,151,63,0);transform:scale(1)}
}

/* ── bottom controls (thumb zone) ────────────────────────────────────────── */
.counts{display:flex;justify-content:center;gap:var(--sp-4);color:var(--ash);font-size:var(--step--1);padding:var(--sp-1) 0 var(--sp-2)}
.counts b{color:var(--bone)}
.actions{display:flex;gap:var(--sp-3);padding-bottom:var(--sp-1)}
#auto-play{flex:0 0 76px}
#hint-btn{flex:0 0 64px}
/* Explanation of the engine's own suggested play (LLM-backed, docs/LLM_FEATURES.md) --
   fills in async after a click, so starts hidden; absent text never leaves a layout gap. */
/* A small callout card, not bare italic text loose in the layout -- reads as a distinct
   native-style "tip" bubble. Settles in with the same spring fade+rise as .house-commentary
   once the LLM response actually arrives (see main.js's hidden->rAF->class sequencing). */
.hint-text{
  font-style:italic;color:var(--arcane);font-size:var(--step--1);text-align:center;
  margin:var(--sp-2) 0 0;padding:8px 14px;border-radius:10px;
  background:var(--bg-raise);border:1px solid var(--line);
  opacity:0;transform:translateY(4px);
  transition:opacity .25s cubic-bezier(0.32,0.72,0,1),transform .25s cubic-bezier(0.32,0.72,0,1);
}
.hint-text[hidden]{display:none}
.hint-text.loaded{opacity:1;transform:translateY(0)}
.btn{
  flex:1;min-height:52px;border-radius:12px;font-family:var(--ui);font-size:var(--step-1);
  font-weight:700;cursor:pointer;border:2px solid var(--brass);background:transparent;color:var(--brass-hi);
  transition:transform .1s cubic-bezier(0.32,0.72,0,1), opacity .1s ease, background .15s ease;
}
/* iOS press feedback (ios-native-ui): scale + opacity, not a translate nudge -- applies to
   every .btn, brass-filled primary included, same treatment .lb-trigger already had. */
.btn:active{transform:scale(.96);opacity:.85}
.btn.primary{background:linear-gradient(180deg,var(--brass),#a9772c);color:#231208;border-color:var(--brass-hi)}
.btn:disabled{opacity:.4;cursor:not-allowed}
.btn:focus-visible{outline:3px solid var(--brass-hi);outline-offset:2px}

.install{position:fixed;top:8px;right:8px;z-index:5;font-size:var(--step--1);min-height:auto;padding:6px 10px;flex:0}
.ios-hint{position:fixed;bottom:8px;left:8px;right:8px;z-index:5;background:var(--bg-raise);border:1px solid var(--line);border-radius:10px;padding:8px 12px;font-size:var(--step--1);color:var(--ash)}

.overlay{position:absolute;inset:0;z-index:4;display:grid;place-items:center;background:rgba(20,8,18,.86);backdrop-filter:blur(2px);text-align:center;padding:24px}
.overlay[hidden]{display:none}          /* author `display:grid` above otherwise beats the UA [hidden] rule */
.overlay h2{font-family:var(--display);font-size:var(--step-3);margin:.2em 0}
.overlay p{color:var(--ash);max-width:26ch;margin:.4em auto 1.2em}
.overlay .won{color:var(--win)}
/* Stack the (up to two) actions vertically as full-width buttons in a thumb-friendly column --
   the primary label ("Bank Omens & Continue") is long enough that a side-by-side layout wrapped
   awkwardly at 375px. iOS-alert convention for long actions; primary sits on top (HTML order). */
.overlay-actions{display:flex;flex-direction:column;gap:10px;align-items:stretch;width:min(100%,280px);margin:0 auto}
.overlay-actions .btn{flex:0 0 auto}

/* ── leaderboard (the one online feature — degrades to nothing when offline) ── */
/* topbar: group Omens + the Ranks trigger on the right, keep ante on the left. flex-wrap +
   flex-end keeps it tolerant of a third small trigger (e.g. an incoming skill-tree button)
   dropping to a second line, right-aligned, instead of assuming exactly two items. */
.topbar-right{display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:var(--sp-2)}
.lb-trigger{
  min-height:44px;padding:0 12px;border-radius:10px;border:1px solid var(--brass);
  background:transparent;color:var(--brass-hi);font-family:var(--ui);font-size:var(--step--1);
  font-weight:700;cursor:pointer;transition:transform .1s ease, background .15s ease;
}
.lb-trigger:active{transform:scale(.96)}                 /* iOS press feedback (ios-native-ui) */
.lb-trigger:focus-visible{outline:3px solid var(--brass-hi);outline-offset:2px}

/* House commentary (LLM-backed, docs/LLM_FEATURES.md): fills in async after the overlay is
   already shown, so it starts hidden and empty -- absent text never leaves a layout gap. */
/* Settles in with a spring fade+rise once the LLM response arrives, rather than popping in --
   see main.js's showHouseCommentary() for the hidden->rAF->class sequencing this depends on. */
.house-commentary{
  font-style:italic;color:var(--arcane);text-align:center;margin:0 auto .8em;max-width:320px;
  opacity:0;transform:translateY(4px);
  transition:opacity .3s cubic-bezier(0.32,0.72,0,1),transform .3s cubic-bezier(0.32,0.72,0,1);
}
.house-commentary[hidden]{display:none}
.house-commentary.loaded{opacity:1;transform:translateY(0)}

/* loss-overlay submit row: name input + Submit Score, shown only when phase === 'lost' */
.overlay-submit{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin:0 auto 1.2em;max-width:320px}
.overlay-submit[hidden]{display:none}
.lb-input{
  flex:1 1 160px;min-height:52px;border-radius:12px;border:2px solid var(--line);
  background:var(--bg-void);color:var(--bone);font-family:var(--ui);font-size:var(--step-0);padding:0 14px;
}
.lb-input::placeholder{color:var(--ash)}
.lb-input:focus-visible{outline:3px solid var(--brass);outline-offset:2px;border-color:var(--brass)}
.lb-input.suggested{animation:suggestPop .5s cubic-bezier(0.32,0.72,0,1)}
.overlay-submit .btn{flex:0 1 150px}

/* bottom sheet (ios-native-ui): slides up from the bottom edge, dims a backdrop, drag grip.
   Anchored inside the safe area; centered modal #overlay stays reserved for the blocking state. */
.sheet-backdrop{position:fixed;inset:0;z-index:5;background:rgba(20,8,18,.6);backdrop-filter:blur(2px)}
.sheet-backdrop[hidden]{display:none}
.sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:6;max-width:460px;margin:0 auto;
  display:flex;flex-direction:column;max-height:80vh;
  background:var(--bg-raise);border-top:1px solid var(--line);border-radius:18px 18px 0 0;
  padding:8px 16px calc(16px + env(safe-area-inset-bottom));
  transform:translateY(100%);transition:transform .32s cubic-bezier(0.32,0.72,0,1);
}
.sheet.open{transform:translateY(0)}                     /* spring-flavored present/dismiss */
.sheet[hidden]{display:none}
.sheet-grip{width:36px;height:5px;border-radius:3px;background:var(--line);margin:6px auto 10px}
.sheet-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:6px}
.sheet-head h2{font-family:var(--display);font-size:var(--step-2);margin:0}
.sheet-done{flex:0 0 auto;min-height:44px;padding:0 16px;font-size:var(--step-0)}
.lb-status{color:var(--ash);font-size:var(--step--1);margin:4px 2px;min-height:1.2em}
.lb-list{list-style:none;margin:0;padding:0;overflow-y:auto;overscroll-behavior:contain}
/* center-aligned (not baseline) so the avatar image sits level with the text rows beside it,
   like a native contacts/leaderboard list row rather than a text-only line */
.lb-row{display:flex;align-items:center;gap:10px;padding:9px 6px;border-bottom:1px solid var(--line)}
/* leader glow: a subtle brass tint on rank 1's row -- tasteful "playful poker" personality
   from an existing token (--brass at low alpha), not a new palette entry */
.lb-row:first-child{background:linear-gradient(90deg, rgba(200,151,63,.14), transparent 70%)}
.lb-rank{font-family:var(--mono);color:var(--brass);min-width:2.5ch;text-align:right}
.lb-avatar{width:22px;height:22px;border-radius:50%;flex-shrink:0;border:1.5px solid var(--line);background:var(--bg-void)}
.lb-avatar[hidden]{display:none}
.lb-flag{min-width:1.4em;text-align:center}                /* empty (no geolocation match) collapses to the same gap, no layout jump */
.lb-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lb-ante{font-family:var(--mono);color:var(--bone)}
.lb-omens{font-family:var(--mono);color:var(--arcane);min-width:5ch;text-align:right}

.lb-share{border-top:1px solid var(--line);margin-top:8px;padding-top:12px}
.lb-share-label{color:var(--ash);font-size:var(--step--1);margin:0 0 6px}
.lb-share-row{display:flex;align-items:center;gap:8px}
.lb-seed-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);color:var(--bone)}
/* compact inline action, not a full-size primary button -- this is a secondary affordance
   inside a sheet row, not competing with Play/Discard for thumb-zone weight */
.lb-share-row .btn{flex:0 0 auto;min-height:44px;padding:0 14px;font-size:var(--step--1)}
/* "printed card" framing for the QR: a bone-colored quiet-zone card rather than a bare image
   dropped on the dark sheet background, where a stark white QR square would otherwise clash.
   Sized so an 104x104 requested image (main.js) plus this padding lands on a clean 120x120 box.
   Starts invisible and settles in with a spring scale+fade once it actually loads (ios-native-ui
   motion: springy, not floaty) -- see main.js's showSeedShare() for the hidden->rAF->class
   sequencing this depends on (same pattern the leaderboard sheet's own open uses). */
.lb-seed-qr{
  display:block;margin-top:10px;width:120px;height:120px;padding:8px;box-sizing:border-box;
  background:var(--bone);border-radius:12px;border:1px solid var(--line);
  opacity:0;transform:scale(.92);
  transition:opacity .25s cubic-bezier(0.32,0.72,0,1),transform .25s cubic-bezier(0.32,0.72,0,1);
}
.lb-seed-qr[hidden]{display:none}
.lb-seed-qr.loaded{opacity:1;transform:scale(1)}

/* ── skill-tree sheet: a FULL-height variant of the bottom sheet (ios-native-ui "Navigation
   feel": a distinct place presented over the table). A branching diagram needs the whole
   viewport, unlike the leaderboard's 80vh list. Same slide-up transform + open/close mechanics. */
.sheet-full{
  max-width:none;max-height:100%;top:0;
  height:100dvh;border-radius:0;
  padding:calc(8px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
}
.st-hint{color:var(--ash);font-size:var(--step--1);margin:2px 2px 8px}
/* Scroll container: pans the oversized grid on BOTH axes ("scroll on" was the explicit ask --
   21 nodes across 5 tiers don't fit one screen). Momentum feel + no page-bounce bubbling. */
.st-grid-wrap{
  flex:1;overflow:auto;position:relative;border-radius:12px;
  overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  background:radial-gradient(1200px 800px at 30% 0%, rgba(122,42,71,.10), transparent 70%);
}
/* Sized to its content's real pixel dimensions (set inline by renderSkillTree), NOT the viewport,
   so it can scroll. position:relative anchors the absolute nodes + the SVG connector overlay. */
.st-grid{position:relative}
/* Connector overlay sits UNDER the nodes; one <line> per prerequisite edge, arbitrary cross-cell
   (e.g. spade_echo's prereqs span the chips + mult lanes), so it's an absolute SVG, not borders. */
.st-connectors{position:absolute;top:0;left:0;pointer-events:none;z-index:0;overflow:visible}
.st-edge{stroke:var(--line);stroke-width:2;stroke-dasharray:4 5;opacity:.75}
.st-edge--on{stroke:var(--brass);stroke-width:2.5;stroke-dasharray:none;opacity:1}
/* Nodes: reuse .skill-node's look, positioned absolutely on the grid (left/top/size set inline). */
.st-grid .skill-node{position:absolute;margin:0;max-width:none;z-index:1}
.st-grid .skill-node.unlocked{z-index:2}
.st-tier-label{
  position:absolute;left:0;font-family:var(--mono);font-size:var(--step--1);color:var(--ash);
  opacity:.6;pointer-events:none;
}

.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}

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