/* ── Reset & base ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Card / fan sizes are set by layout.js; these are fallbacks */
  --card-w: 110px;
  --card-h: 154px;
  --tableau-fan: 34px;
  --tableau-fan-down: 18px;
  --waste-fan: 54px;
  --gap: 8px;
  --board-pad: 14px;
  /* Type scale (set by layout.js, sensible fallbacks here) */
  --corner-fz: 18px;
  --center-fz: 50px;
  --pip-fz: 22px;
  --face-fig-fz: 56px;
  --foundation-fz: 38px;
  --felt-1: #27854c;
  --felt-2: #1e6b3c;
  --felt-3: #144326;
  --gold: #f0c040;
  --red: #d42020;
  --black: #1a1a1a;
  --hint: #66e0ff;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0c1f14;
  color: #fff;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── HUD ── */
.hud {
  --pad-y: 12px;
  --pad-x: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: calc(var(--pad-y) + env(safe-area-inset-top, 0px));
  padding-bottom: var(--pad-y);
  padding-left: calc(var(--pad-x) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--pad-x) + env(safe-area-inset-right, 0px));
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  gap: 16px;
  position: relative;
}
.hud-spacer { flex: 1; }
.action-btn.hud-action {
  padding: 8px 14px;
  font-size: 13px;
}
.hud-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  width: 38px; height: 38px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.hud-btn:hover { background: rgba(255,255,255,0.18); }
.hud-btn[aria-pressed="true"] {
  background: rgba(102, 224, 255, 0.22);
  border-color: rgba(102, 224, 255, 0.7);
  box-shadow: 0 0 12px rgba(102, 224, 255, 0.35);
}

/* Hamburger menu (always visible — secondary controls live here) */
.hud-menu-btn { display: flex; }
.hud-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: calc(8px + env(safe-area-inset-right, 0px));
  min-width: 200px;
  background: rgba(20, 30, 25, 0.97);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 6px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.hud-menu-panel.hidden { display: none; }
.menu-item {
  background: none;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus { background: rgba(255,255,255,0.1); outline: none; }
.menu-item.hidden { display: none; }

/* ── Board ── */
.board {
  flex: 1;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, var(--felt-1) 0%, var(--felt-2) 60%, var(--felt-3) 100%),
    repeating-linear-gradient(45deg, transparent, transparent 30px,
      rgba(255,255,255,0.012) 30px, rgba(255,255,255,0.012) 31px);
  padding: var(--board-pad);
  padding-left: calc(var(--board-pad) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--board-pad) + env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--row-gap, 16px);
  overflow: auto;
  min-height: 0;
}

.top-row {
  display: flex;
  gap: var(--gap);
  align-items: flex-start;
}
.spacer { flex: 1; min-width: 20px; }

.tableau {
  display: flex;
  gap: var(--gap);
  align-items: flex-start;
}

/* ── Piles ── */
.pile {
  width: var(--card-w);
  min-height: var(--card-h);
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
}
.pile:not(.tableau-col) { height: var(--card-h); }

.pile.stock,
.pile.waste,
.pile.foundation {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.18);
  font-size: var(--foundation-fz);
}
.pile.foundation {
  border: 2px dashed rgba(255,255,255,0.2);
}
.pile.waste {
  margin-left: 4px;
}
/* Tighten the gap between the four foundation (ace) piles by 1px each. */
.pile.foundation + .pile.foundation {
  margin-left: -1px;
}

.pile.tableau-col { border-radius: 8px; }
.pile.tableau-col:empty {
  border: 2px dashed rgba(255,255,255,0.15);
  height: var(--card-h);
}

.pile.drop-target {
  box-shadow: 0 0 0 3px var(--gold);
}
.pile.drop-invalid {
  box-shadow: 0 0 0 3px rgba(229, 80, 80, 0.6);
}

.pile.stock.empty-recycle {
  cursor: pointer;
  background: rgba(255,255,255,0.05);
}
.pile.stock.empty-recycle::after {
  content: '↻';
  position: absolute;
  font-size: calc(var(--foundation-fz) * 0.95);
  color: rgba(255,255,255,0.3);
}
.pile.stock.exhausted {
  cursor: not-allowed;
  opacity: 0.5;
}
.pile.stock.exhausted::after {
  content: '✕';
  position: absolute;
  font-size: calc(var(--foundation-fz) * 0.8);
  color: rgba(229, 80, 80, 0.6);
}

/* ── Cards ── */
.card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 1px 2px 4px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: top 0.18s ease-out, left 0.18s ease-out, transform 0.15s, box-shadow 0.15s;
  will-change: transform, top, left;
  top: 0;
  left: 0;
}
.card.no-transition { transition: none !important; }
.card.face-down {
  background: linear-gradient(135deg, #1a3a8f 0%, #12286e 100%);
  border: 1px solid rgba(255,255,255,0.12);
}
.card.face-down::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 5px;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 5px,
      rgba(255,255,255,0.08) 5px, rgba(255,255,255,0.08) 6px),
    repeating-linear-gradient(-45deg, transparent, transparent 5px,
      rgba(255,255,255,0.08) 5px, rgba(255,255,255,0.08) 6px);
  border: 1px solid rgba(255,255,255,0.15);
}

.card-corner { font-weight: 800; line-height: 0.78; }
.card-corner.tl {
  position: absolute;
  top: 10px; left: 3px;
  font-size: var(--corner-fz);
  text-align: center;
  /* Strip the font's intrinsic ascender padding so the glyph cap sits flush
     to `top`. Without this, even with line-height: 0.78 the visible rank
     drifts ~3-5 px below the box top because of font metrics. */
  padding-top: 0;
  margin-top: -0.12em;
}
.card-corner.br {
  position: absolute;
  bottom: 10px; right: 3px;
  font-size: var(--corner-fz);
  text-align: center;
  transform: rotate(180deg);
  margin-bottom: -0.12em;
}
.card-corner.tr {
  position: absolute;
  top: 10px; right: 3px;
  font-size: var(--corner-fz);
  text-align: center;
  margin-top: -0.12em;
}
.card.simple {
  border-radius: 2px;
}
.card.simple .card-corner.tl { top: 5px; left: 0px; }
.card.simple .card-corner.tr { top: 5px; }
.card.simple .card-corner.br { bottom: 1px; }
.card.simple .card-corner {
  font-size: calc(var(--card-w) * 0.38);
  font-weight: 800;
  line-height: 0.65;
}
.card.simple .card-corner.tr {
  font-size: calc(var(--card-w) * 0.46);
}
.card.simple .card-center {
  font-size: calc(var(--card-w) * 0.95);
  font-weight: 700;
  text-shadow: 1px 2px 3px rgba(0,0,0,0.18);
  align-items: flex-end;
  padding-bottom: 2px;
}
/* Simple/small mode: custom SVG diamond/club glyphs (drop-in replacements
   for ♦/♣) with shape tweaks to distinguish them from hearts/spades. */
.card.simple .suit-svg {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.12em;
  fill: currentColor;
}
.card-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--center-fz);
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }

/* Card interaction states */
.card.dragging {
  cursor: grabbing;
  z-index: 1000;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  transform: scale(1.04);
  transition: none;
}
/* Use a pointer cursor on every card so the click hot-point is easy to
   locate; drag still works (the cursor flips to `grabbing` via .dragging). */
.card.face-up { cursor: pointer; }

/* Hint highlight (pulsing cyan ring) */
@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--hint), 0 0 24px rgba(102,224,255,0.7); }
  50%      { box-shadow: 0 0 0 5px var(--hint), 0 0 36px rgba(102,224,255,1); }
}
.card.hint-source,
.pile.hint-target {
  animation: hint-pulse 0.9s ease-in-out 0s 4;
  z-index: 50;
}

/* Flip animation */
@keyframes flip {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}
.card.flipping { animation: flip 0.3s ease-in-out; }

/* Invalid bounce */
@keyframes invalid-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.card.invalid-shake { animation: invalid-shake 0.2s ease-in-out; }

/* Foundation suit colors */
.pile.foundation {
  background: rgba(255,255,255,0.06);
  font-size: var(--foundation-fz);
  border-width: 2px;
}
.pile.foundation[data-suit="hearts"],
.pile.foundation[data-suit="diamonds"] {
  color: rgba(255, 120, 120, 0.85);
  border-color: rgba(255, 120, 120, 0.55);
  text-shadow: 0 0 10px rgba(212, 32, 32, 0.35);
}
.pile.foundation[data-suit="spades"],
.pile.foundation[data-suit="clubs"] {
  color: rgba(245, 245, 245, 0.75);
  border-color: rgba(245, 245, 245, 0.5);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.45);
}
.pile.foundation:has(.card) {
  color: transparent;
  text-shadow: none;
  background: transparent;
  border-style: solid;
  border-color: rgba(255,255,255,0.08);
}

/* ── Drag layer ── */
.drag-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
.drag-layer .card { pointer-events: none; }

/* ── Coach toast ── */
.coach-toast {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.94);
  color: #fff;
  border: 1px solid rgba(102, 224, 255, 0.6);
  border-radius: 10px;
  padding: 12px 18px 12px 18px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  pointer-events: auto;
  cursor: pointer;
  z-index: 10000;
  max-width: 90%;
  min-width: 280px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}
.coach-toast.show {
  opacity: 1;
  transform: translate(-50%, 4px);
}
.coach-toast.hidden { display: none; }
.coach-toast.pinned {
  border-color: rgba(240, 192, 64, 0.85);
  box-shadow: 0 6px 24px rgba(240,192,64,0.25), 0 6px 20px rgba(0,0,0,0.5);
}
.coach-toast .coach-text::before {
  content: '🦉 ';
  margin-right: 4px;
}
.coach-toast .coach-text { padding-right: 18px; }
.coach-toast .card-mark {
  font-weight: 800;
  font-size: 1.3em;
  line-height: 1;
  vertical-align: -0.05em;
  padding: 0 1px;
}
.coach-toast .card-mark.red   { color: #ff6b6b; }
.coach-toast .card-mark.black { color: #f0f0f0; }
.coach-toast .coach-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.coach-toast .coach-actions .action-btn {
  padding: 6px 14px;
  font-size: 12px;
}
.coach-toast .coach-dismiss {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.coach-toast .coach-dismiss:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

/* ── Status bar (XP / Score / Time) ── */
.status-bar {
  --pad-y: 10px;
  --pad-x: 20px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 16px;
  padding-top: var(--pad-y);
  padding-bottom: calc(var(--pad-y) + env(safe-area-inset-bottom, 0px));
  padding-left: calc(var(--pad-x) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--pad-x) + env(safe-area-inset-right, 0px));
  background: rgba(0,0,0,0.3);
  border-top: 1px solid rgba(255,255,255,0.05);
}
.status-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}
.status-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 2px;
}
.status-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.status-bar.no-timer .status-timer { display: none; }
.action-btn {
  padding: 10px 22px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: rgba(255,255,255,0.12);
  color: #fff;
  letter-spacing: 0.3px;
  transition: background .15s, transform .1s;
}
.action-btn:hover { background: rgba(255,255,255,0.2); }
.action-btn:active { transform: translateY(1px); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.hidden { display: none; }
.action-btn.primary {
  background: linear-gradient(135deg, var(--gold), #d4a020);
  color: #1a1a1a;
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(240,192,64,0.3);
}
.action-btn.primary:hover { background: linear-gradient(135deg, #f5cc55, #e0ac28); }

/* Pip layout */
.card .pips {
  position: absolute;
  inset: calc(16% + 10px) 24% calc(16% + 10px);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  /* minmax(0, 1fr) — not bare 1fr — so a pip glyph taller than 1/7 of the
     container doesn't force its row to grow to min-content. With bare 1fr,
     ranks 7-10 (which use 5-6 of the 7 rows) overflow the container and
     stack from the top, pushing the middle pip below the card center. */
  grid-template-rows: repeat(7, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  pointer-events: none;
  font-size: var(--pip-fz);
  line-height: 1;
  font-weight: 700;
}
/* Compensate for ♥/♠/♦/♣ glyph baseline asymmetry: the visual center of
   each suit glyph sits ~0.055em below the line-box center, which makes
   non-flipped pips read low and flipped pips read high — most noticeable
   on dense layouts (7, 8, 9, 10). The translateY pulls each glyph back to
   its cell center. */
.card .pips span { display: block; transform: translateY(-0.055em); }
.card .pips span.flip { transform: rotate(180deg) translateY(-0.055em); }
.card .face-figure {
  position: absolute;
  left: 16%;
  right: 16%;
  height: 44%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--face-fig-fz);
  line-height: 1;
  pointer-events: none;
  text-shadow: 1px 2px 3px rgba(0,0,0,0.18);
}
.card .face-figure.top { top: calc(6% + 10px); }
.card .face-figure.bot { bottom: calc(6% + 10px); transform: rotate(180deg); }

/* ── Win overlay ── */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.3s;
}
.win-overlay.hidden { display: none; }

.fountain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.fountain .f-card {
  position: absolute;
  width: 50px; height: 70px;
  border-radius: 5px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
}

.win-card {
  background: linear-gradient(160deg, #fffef8, #f5f0e0);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  padding: 36px 44px;
  text-align: center;
  width: 360px;
  color: #1a1a1a;
  position: relative;
  z-index: 1;
  animation: pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes pop-in {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.win-emoji { font-size: 48px; margin-bottom: 4px; }
.win-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.win-subtitle {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #888;
  margin-bottom: 18px;
}
.win-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 24px;
}
.win-stat { display: flex; flex-direction: column; align-items: center; }
.win-stat span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #888;
}
.win-stat strong {
  font-size: 24px;
  color: #1a472a;
  font-variant-numeric: tabular-nums;
}

/* ── Custom modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: linear-gradient(160deg, #fffef8, #f5f0e0);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  padding: 28px 32px;
  text-align: center;
  width: min(520px, 92vw);
  max-height: 86vh;
  overflow: auto;
  color: #1a1a1a;
  animation: pop-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.modal-message {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
}
.modal-body { margin-bottom: 16px; }
.modal-body:empty { margin-bottom: 0; }
.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.modal-buttons .action-btn {
  color: #1a1a1a;
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.15);
}
.modal-buttons .action-btn:hover { background: rgba(0,0,0,0.12); }
.modal-buttons .action-btn.primary {
  background: linear-gradient(135deg, var(--gold), #d4a020);
  color: #1a1a1a;
  border-color: transparent;
}

/* Level picker (modal-body content) */
.level-grid {
  display: flex;
  gap: 10px;
  flex-direction: column;
  margin-bottom: 6px;
}
.level-card {
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: background .15s, border-color .15s, transform .1s;
}
.level-card:hover { background: rgba(0,0,0,0.04); }
.level-card.selected {
  border-color: var(--gold);
  background: rgba(240,192,64,0.18);
  box-shadow: 0 0 0 2px var(--gold);
}
.level-card .lvl-name {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 2px;
}
.level-card .lvl-tag {
  font-size: 12px;
  color: #555;
}

/* Scoreboard — graphical "am I improving?" view */
.score-empty {
  padding: 18px;
  color: #777;
  font-size: 14px;
  text-align: center;
}
.sb-root { display: flex; flex-direction: column; gap: 14px; }
.sb-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  padding-bottom: 0;
}
.sb-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 8px 4px 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #666;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.sb-tab:hover { color: #1a472a; }
.sb-tab.active {
  color: #1a472a;
  border-bottom-color: var(--gold);
}
.sb-tab.empty { opacity: 0.5; }
.sb-tab-content { min-height: 100px; }
.sb-level {
  background: rgba(0,0,0,0.04);
  border-radius: 12px;
  padding: 12px 12px 14px;
}
.sb-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sb-name {
  font-size: 16px;
  font-weight: 800;
  color: #1a472a;
}
.sb-count {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sb-empty {
  font-size: 13px;
  color: #888;
  padding: 10px 0;
}
.sb-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.sb-card {
  background: rgba(255,255,255,0.65);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.sb-card-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
}
.sb-card-val {
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
  color: #1a472a;
}
.sb-card-sub {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}
.sb-card-delta {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.sb-card-delta.good    { color: #1a8a3d; }
.sb-card-delta.bad     { color: #c14242; }
.sb-card-delta.neutral { color: #888; }
.sb-sparks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sb-spark {
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
  padding: 6px 10px;
}
.sb-spark-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-bottom: 2px;
}
.sb-spark-svg {
  width: 100%;
  height: 36px;
  display: block;
}
.sb-wl-strip {
  display: flex;
  gap: 3px;
  padding: 4px 0 2px;
}
.sb-wl {
  flex: 1 1 auto;
  min-width: 4px;
  height: 14px;
  border-radius: 2px;
}
.sb-wl.win  { background: #4dbd6d; }
.sb-wl.loss { background: #d36363; }

/* ── Responsive (HUD/status-bar density only — card sizing is handled
       fluidly by layout.js and CSS vars) ── */
@media (max-width: 800px) {
  .hud { --pad-y: 10px; --pad-x: 14px; gap: 6px; }
  .status-bar { --pad-y: 8px; --pad-x: 14px; gap: 12px; }
  .status-value { font-size: 18px; }
}

@media (max-width: 500px) {
  .hud { --pad-y: 8px; --pad-x: 8px; gap: 4px; }
  .action-btn.hud-action { padding: 6px 10px; font-size: 12px; }
  .status-bar { --pad-y: 6px; --pad-x: 10px; gap: 8px; }
  .status-value { font-size: 16px; }
}

/* ── Draw pile position (settings) ── */
body[data-draw-side="right"] .top-row { flex-direction: row-reverse; }
body[data-draw-side="left"]  .top-row { flex-direction: row; }

/* Mirror the HUD halves to match: stock/waste on left → action buttons on
   right, coach/menu on left; stock/waste on right → vice versa. */
body[data-draw-side="left"]  .hud { flex-direction: row-reverse; }
body[data-draw-side="right"] .hud { flex-direction: row; }
/* Pop the menu panel on whichever side the menu button sits on. */
body[data-draw-side="left"] .hud-menu-panel {
  right: auto;
  left: calc(8px + env(safe-area-inset-left, 0px));
}

/* ── Settings dialog ── */
.settings-section {
  margin-bottom: 16px;
  text-align: left;
}
.settings-section:last-child { margin-bottom: 0; }
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.settings-toggle input { width: 18px; height: 18px; cursor: pointer; }
.settings-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-bottom: 8px;
  font-weight: 700;
}
.settings-options { display: flex; gap: 8px; }
.settings-opt,
.settings-opt-draw {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.6);
  color: #1a1a1a;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.settings-opt:hover,
.settings-opt-draw:hover { background: rgba(0,0,0,0.04); }
.settings-opt.selected,
.settings-opt-draw.selected {
  border-color: var(--gold);
  background: rgba(240,192,64,0.18);
  box-shadow: 0 0 0 2px var(--gold);
}
