/* BACCARAT — shares the hakoniwa five-tone palette with BLACKJACK 21 / ROULETTE.
 * Mobile-first: card table, betting felt, and the full scoreboard "roads". */
:root {
  --c-dark: #50514F; --c-red: #F25F5C; --c-yellow: #FFE066; --c-blue: #247BA0; --c-teal: #70C1B3;
  --bg: #f4f6f5; --surface: #fff; --surface-2: #eef1f0; --ink: #50514F; --muted: #8c8e8b;
  --line: rgba(80,81,79,0.16); --line-soft: rgba(80,81,79,0.08);
  --felt: #2f8f6e; --felt-2: #25785c; --green: #1f8f5f;
  --win: #3aa893; --lose: #e8483f;
  --road-red: #d8453f; --road-blue: #2f6fb0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: radial-gradient(120% 70% at 50% -8%, #fff 0%, #f2f4f3 60%, #e7eae9 100%) fixed;
  color: var(--ink); line-height: 1.6; padding-bottom: 24px;
}
h1, h2, h3 { font-family: 'Cinzel', serif; }
a { color: var(--c-blue); text-decoration: none; } a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ---- header ---- */
.topbar { text-align: center; padding: 16px 16px 8px; }
.brand { display: flex; align-items: center; justify-content: center; gap: 9px; }
.brand h1 { margin: 0; font-size: clamp(1.2rem, 6vw, 2rem); letter-spacing: 0.14em; color: var(--c-dark); }
.pip { font-size: 0.7rem; } .pip.red { color: var(--c-red); } .pip.blue { color: var(--c-blue); }
.tagline { color: var(--muted); font-size: 0.82rem; margin: 4px 0 12px; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 100px; }
.tab { font-family: 'Cinzel', serif; font-size: 0.78rem; letter-spacing: 0.06em; border: none; background: transparent; color: var(--muted); padding: 8px 20px; border-radius: 100px; cursor: pointer; transition: 0.2s; }
.tab.is-active { color: #fff; background: var(--c-blue); }

.panel { display: none; max-width: 560px; margin: 0 auto; padding: 0 12px; }
.panel.is-active { display: block; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- play tools / rail ---- */
.play-tools { display: flex; gap: 8px; margin: 6px 0 10px; }
.tool-btn { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.tool-btn:active { background: var(--surface-2); }
.rail { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.chip-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 7px 8px; text-align: center; }
.chip-stat .ck { display: block; font-size: 0.56rem; color: var(--muted); letter-spacing: 0.06em; }
.chip-stat span:last-child { font-weight: 600; font-size: 0.95rem; color: var(--c-blue); }

/* ---- card table ---- */
.table-zone { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;
  background: radial-gradient(130% 100% at 50% 0%, var(--felt) 0%, var(--felt-2) 95%);
  border-radius: 14px; padding: 12px 10px; box-shadow: inset 0 0 30px rgba(0,0,0,0.22); min-height: 120px; }
.hand-side { position: relative; border-radius: 10px; padding: 8px; border: 1px solid rgba(255,255,255,0.18); transition: box-shadow 0.2s; }
.hand-side.player { background: rgba(36,123,160,0.16); }
.hand-side.banker { background: rgba(216,69,63,0.16); }
.hand-side.win { box-shadow: 0 0 0 2px var(--c-yellow), 0 0 16px rgba(255,224,102,0.6); }
.hand-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hand-side.banker .hand-head { flex-direction: row; }
.hand-name { font-family: 'Cinzel', serif; font-size: 0.66rem; letter-spacing: 0.1em; color: #fff; }
.hand-total { font-size: 1.3rem; font-weight: 700; color: #fff; min-width: 1.2em; text-align: center; }
.cards { display: flex; gap: 6px; min-height: 70px; align-items: center; perspective: 900px; }
.banker .cards { justify-content: flex-end; }
/* realistic card with a 3D flip (back ⇆ face) for the squeeze */
.card-slot { width: 46px; height: 66px; flex: 0 0 auto; position: relative; }
.card-slot.squeezable { cursor: grab; touch-action: none; }
.card-slot.squeezable:active { cursor: grabbing; }
.card3d { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(180deg); transition: transform 0.5s cubic-bezier(0.2,0.8,0.2,1); }
.card-slot.facedown .card3d { transform: rotateY(0deg); }
/* squeeze (絞り): no rotation — the face sits under the back, and the back is
 * peeled away (clip-path, set live in JS) to uncover the face in any direction. */
.card-slot.peel .card3d { transform: none !important; transform-style: flat; }
/* during the peel the full face is hidden — you only see the lifted flap (the card's
 * underside = its marks). On reveal, JS fades the full face in. */
.card-slot.peel .card-face { transform: none; backface-visibility: visible; -webkit-backface-visibility: visible; z-index: 1; opacity: 0; }
.card-slot.peel .card-back { transform: none; backface-visibility: visible; -webkit-backface-visibility: visible; z-index: 2; will-change: clip-path; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5)); }
/* the lifted flap = the corner of the SAME card folding up — its underside shows the
 * face marks (folded over, reflected in JS), with a fold shadow. This is the real peel. */
.card-flap { position: absolute; inset: 0; z-index: 3; opacity: 0; overflow: hidden; transform-origin: 0 0; will-change: transform; border-radius: 6px;
  background: linear-gradient(160deg, #fff, #f1efe8); border: 1px solid rgba(0,0,0,0.2); box-shadow: 0 6px 15px rgba(0,0,0,0.6); }
.card-flap.red { color: #d8453f; } .card-flap.black { color: #2a2a2a; }
.card-flap::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, rgba(0,0,0,0.22), rgba(0,0,0,0) 55%); }
.card-back, .card-face { position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
.card-back { transform: rotateY(0deg); border: 3px solid #fff;
  background: repeating-linear-gradient(45deg, #285a86 0 5px, #2f6fb0 5px 10px); box-shadow: inset 0 0 0 2px #d8b86a, 0 2px 6px rgba(0,0,0,0.4); }
.card-back::after { content: '❖'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(236,217,160,0.85); font-size: 1.1rem; }
.card-face { transform: rotateY(180deg); background: linear-gradient(160deg, #fff, #f3f1ea); border: 1px solid rgba(0,0,0,0.16);
  display: flex; align-items: center; justify-content: center; }
.card-face.red { color: #d8453f; } .card-face.black { color: #2a2a2a; }
/* center marks must lay out identically on the face AND on the lifted flap (the flap
 * holds a copy of fi.center). Scoping these to .card-face only made number pips work
 * (their .ppip rule is global) but left the single centered A/court glyph un-centered
 * inside the flap — so the squeeze view of A/J/Q/K looked nothing like the reveal. */
.card-face .pips, .card-flap .pips { position: absolute; inset: 6px 5px; }
.ppip { position: absolute; transform: translate(-50%, -50%); font-size: 0.62rem; line-height: 1; }
.ppip.flip { transform: translate(-50%, -50%) rotate(180deg); }
.card-face .pip.big, .card-flap .pip.big { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 1.7rem; line-height: 1; }
/* court figure = a bare glyph (no frame box) so it can be large enough to show on the
 * peeled flap without a box overflowing into the corner rank index. */
.card-face .court, .card-flap .court { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1; }
.court-fig { font-size: 2.2rem; line-height: 1; }
.court-suit { font-size: 0.74rem; line-height: 1.1; }
.card-face .ci { position: absolute; z-index: 1; font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.58rem; line-height: 0.95; text-align: center; }
.card-face .ci .cs { display: block; font-size: 0.56rem; }
.card-face .ci.tl { top: 3px; left: 4px; }
.card-face .ci.br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.card-slot.deal-in { animation: dealIn 0.36s cubic-bezier(0.2,0.8,0.3,1); }
@keyframes dealIn { from { opacity: 0; transform: translateY(-20px) translateX(40px) rotate(-8deg) scale(0.9); } to { opacity: 1; transform: none; } }
.card-slot.facedown.squeezable .card3d { box-shadow: 0 0 0 1px rgba(255,224,102,0.0); }
.card-slot.hint .card-back { animation: cardHint 1s ease infinite alternate; }
@keyframes cardHint { from { box-shadow: inset 0 0 0 2px #d8b86a, 0 2px 6px rgba(0,0,0,0.4); } to { box-shadow: inset 0 0 0 2px #ffe066, 0 0 12px rgba(255,224,102,0.7); } }
/* your hand: dealt bigger to squeeze. dealer hand: opened by the dealer button. */
.card-slot.big { width: 52px; height: 74px; }
.card-slot.big .card-face .pip, .card-slot.big .card-flap .pip { font-size: 1.9rem; }
.card-slot.dealer { opacity: 0.96; }
.card-slot.dealer .card-back { filter: brightness(0.9); }
.hand-side.mine-side { box-shadow: inset 0 0 0 1.5px rgba(255,224,102,0.5); }
.hand-side.dealer-side { opacity: 0.82; }
.role-tag:empty { display: none; }
.role-tag { position: absolute; top: 5px; left: 50%; transform: translateX(-50%); z-index: 2; font-family: 'JetBrains Mono', monospace; font-size: 0.5rem; letter-spacing: 0.08em; color: var(--c-dark); background: var(--c-yellow); padding: 1px 8px; border-radius: 100px; white-space: nowrap; }
.dealer-side .role-tag { color: #fff; background: rgba(0,0,0,0.4); }
.dealer-open { display: block; margin: 4px auto 8px; font-family: 'Cinzel', serif; letter-spacing: 0.06em; font-size: 0.82rem; color: #fff;
  background: var(--c-dark); border: 1px solid rgba(255,224,102,0.4); border-radius: 100px; padding: 9px 20px; cursor: pointer; animation: dealerPulse 1.1s ease infinite alternate; }
.dealer-open:active { transform: translateY(1px); }
@keyframes dealerPulse { from { box-shadow: 0 0 0 0 rgba(255,224,102,0.0); } to { box-shadow: 0 0 0 4px rgba(255,224,102,0.25); } }
/* your hand, brought close (手元) — bigger cards to squeeze right in front of you */
.you-zone { margin: 8px 0 4px; padding: 10px 12px 12px; border-radius: 16px;
  background: radial-gradient(120% 110% at 50% 0%, #2c8a6a, #1e6a4e 95%); box-shadow: inset 0 0 0 2px rgba(255,224,102,0.5), inset 0 0 26px rgba(0,0,0,0.26), 0 4px 14px -8px rgba(0,0,0,0.5); animation: youIn 0.35s ease; }
@keyframes youIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.you-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.you-label { font-family: 'Cinzel', serif; font-size: 0.72rem; letter-spacing: 0.08em; color: var(--c-yellow); }
.you-total { font-size: 1.6rem; font-weight: 700; color: #fff; min-width: 1.2em; text-align: center; }
.you-cards { display: flex; gap: 12px; justify-content: center; align-items: center; min-height: 106px; perspective: 1100px; }
.you-cards .card-slot { width: 72px; height: 104px; }
.you-cards .card-face .pip.big, .you-cards .card-flap .pip.big { font-size: 3.4rem; }
.you-cards .court-fig { font-size: 3.7rem; }
.you-cards .court-suit { font-size: 0.95rem; }
.you-cards .ppip { font-size: 0.92rem; }
.you-cards .card-face .ci { font-size: 0.8rem; }
.you-cards .card-face .ci .cs { font-size: 0.72rem; }
.you-cards .card-back::after { font-size: 1.6rem; }
.squeeze-hint { text-align: center; font-size: 0.74rem; color: var(--c-blue); margin: 2px 0 0; min-height: 1em; }

/* ---- result banner ---- */
.banner { text-align: center; padding: 9px; border-radius: 10px; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.banner.result { color: #fff; animation: pop 0.4s ease; }
.banner.result.player { background: var(--c-blue); }
.banner.result.banker { background: var(--road-red); }
.banner.result.tie { background: var(--green); }
.banner .b-score { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 0.92rem; }
.banner .b-who { font-family: 'Cinzel', serif; letter-spacing: 0.08em; font-size: 0.92rem; }
.banner .nat { background: var(--c-yellow); color: var(--c-dark); font-size: 0.6rem; padding: 1px 6px; border-radius: 100px; margin-left: 6px; font-family: 'JetBrains Mono', monospace; letter-spacing: 0; }
@keyframes pop { 0% { transform: scale(0.92); opacity: 0; } 60% { transform: scale(1.02); } 100% { transform: scale(1); opacity: 1; } }

/* ---- betting felt — real big-table arc layout (SVG fan) ---- */
.felt { position: relative; border-radius: 14px; padding: 6px;
  background: radial-gradient(130% 120% at 50% 100%, #2a8466 0%, #1f6b4f 70%, #18553a 100%);
  box-shadow: inset 0 0 0 2px rgba(216,184,106,0.4), inset 0 0 30px rgba(0,0,0,0.28); }
.felt.locked { opacity: 0.9; }
.felt-board { position: relative; }
/* iOS Safari ignores a viewBox's intrinsic height when height:auto → it collapses
 * to ~150px and the fan breaks. aspect-ratio pins the box; app.js also sets an
 * explicit pixel height as a belt-and-suspenders fallback. */
.felt-svg { width: 100%; height: auto; aspect-ratio: 360 / 258; display: block; }
.felt-svg text { user-select: none; pointer-events: none; }
.seg { cursor: pointer; transition: filter 0.12s; }
.felt.locked .seg { cursor: default; }
.seg-player { fill: rgba(226,75,70,0.24); stroke: #ef5e56; stroke-width: 2.5; }
.seg-banker { fill: rgba(233,196,74,0.22); stroke: #edca54; stroke-width: 2.5; }
.seg-tie { fill: rgba(31,143,95,0.6); stroke: #eef0e6; stroke-width: 2; }
.seg-ppair { fill: rgba(226,75,70,0.2); stroke: #ef5e56; stroke-width: 1.8; }
.seg-bpair { fill: rgba(233,196,74,0.2); stroke: #edca54; stroke-width: 1.8; }
.seg:active { filter: brightness(1.35); }
.seg-label { text-anchor: middle; font-family: 'Cinzel', serif; font-weight: 700; font-size: 17px; letter-spacing: 4px; paint-order: stroke; stroke: rgba(0,0,0,0.4); stroke-width: 0.7px; }
.lab-player { fill: #ff665c; } .lab-banker { fill: #f4d062; }
.tie-lab { text-anchor: middle; font-family: 'Cinzel', serif; font-weight: 700; font-size: 12px; fill: #eef0e6; }
.pair-lab { text-anchor: middle; font-family: 'Cinzel', serif; font-weight: 700; font-size: 10px; }
.pair-lab.pl { fill: #f06b64; } .pair-lab.bk { fill: #ecca5c; }
.mini { text-anchor: middle; font-family: 'JetBrains Mono', monospace; font-size: 8px; fill: #cfe8d8; }
.mini.gold { fill: #ecd9a0; }
.legend { text-anchor: middle; font-family: 'JetBrains Mono', monospace; font-size: 8.5px; fill: rgba(255,255,255,0.66); letter-spacing: 0.4px; }
.legend.dim { fill: rgba(255,255,255,0.42); font-size: 8px; }
.seg.win, g.win .seg { stroke: #ffe066; stroke-width: 3.5; animation: segWin 0.7s ease infinite alternate; }
@keyframes segWin { from { filter: drop-shadow(0 0 3px rgba(255,224,102,0.6)); } to { filter: drop-shadow(0 0 8px rgba(255,224,102,1)); } }

/* chips overlay */
.chips-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.chip-badge { position: absolute; transform: translate(-50%, -50%); min-width: 24px; height: 24px; padding: 0 5px; border-radius: 100px;
  color: #3a3a1a; border: 2px solid #fff; font-size: 0.64rem; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 5px rgba(0,0,0,0.5); }
.chip-badge.c1 { background: #8fc0d8; } .chip-badge.c5 { background: #f4a6a4; }
.chip-badge.c25 { background: #8fd6bb; } .chip-badge.c100 { background: #c9b86a; }
.chip-badge.win { animation: chipWin 0.6s ease infinite alternate; box-shadow: 0 0 0 2px var(--c-yellow), 0 1px 4px rgba(0,0,0,0.45); }
@keyframes chipWin { from { transform: translate(-50%, -50%) scale(1); } to { transform: translate(-50%, -50%) scale(1.18); } }
.chip-badge.lose { animation: chipLose 0.6s ease forwards; }
@keyframes chipLose { to { opacity: 0; transform: translate(-50%, -150%) scale(0.6); } }

.message { text-align: center; margin: 12px 0 4px; font-size: 0.9rem; color: var(--ink); min-height: 1.3em; }

/* ---- chips ---- */
.chiprow { display: flex; justify-content: center; gap: 12px; margin: 8px 0; }
.chip { width: 54px; height: 54px; border-radius: 50%; border: 3px dashed rgba(255,255,255,0.8); color: #fff; font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: transform 0.1s; }
.chip:active { transform: scale(0.92); }
.chip.is-active { transform: scale(1.12); box-shadow: 0 0 0 3px var(--c-yellow); }
.chip.c1 { background: var(--c-blue); } .chip.c5 { background: var(--c-red); }
.chip.c25 { background: var(--green); } .chip.c100 { background: var(--c-dark); border-color: var(--c-yellow); color: var(--c-yellow); }

/* ---- controls ---- */
.controls { display: grid; gap: 8px; margin: 8px 0; }
.bet-controls { grid-template-columns: 1fr 1fr 1fr 1.4fr; }
.action { font-family: 'Cinzel', serif; letter-spacing: 0.05em; padding: 14px 8px; border-radius: 12px; border: none; color: #fff; background: var(--c-blue); cursor: pointer; transition: transform 0.08s, filter 0.2s; font-size: 0.9rem; }
.action:active { transform: translateY(1px); }
.action:disabled { opacity: 0.4; filter: grayscale(0.4); cursor: default; }
.action.deal { background: var(--c-red); }
.action.ghost { background: transparent; color: var(--c-blue); border: 1px solid var(--c-blue); font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; padding: 13px 4px; }
.action.run { width: 100%; margin-top: 4px; }

.game-controls { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.gc-label { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.08em; }
.gc-btn { flex: 1; min-width: 64px; font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); cursor: pointer; }
.gc-btn.warn { color: var(--lose); border-color: rgba(232,72,63,0.4); }

/* ============================== ROADS (scoreboard) ============================== */
.boards { margin: 14px 0 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.boards-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.boards-title { font-family: 'Cinzel', serif; font-size: 0.9rem; }
.link-btn { background: none; border: none; color: var(--c-blue); font-size: 0.72rem; cursor: pointer; }
.road-block { margin-bottom: 10px; }
.road-block.sm { margin-bottom: 0; }
.road-label { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.04em; margin-bottom: 4px; }
.road-label span { opacity: 0.7; font-size: 0.54rem; }
.road-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line-soft); border-radius: 8px; background:
  repeating-linear-gradient(0deg, transparent 0, transparent 21px, var(--line-soft) 21px, var(--line-soft) 22px),
  repeating-linear-gradient(90deg, transparent 0, transparent 21px, var(--line-soft) 21px, var(--line-soft) 22px); }
.grid { position: relative; }
.derived { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* bead plate: filled discs */
.bcell { position: absolute; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.bead-cell { width: 20px; height: 20px; margin: 2px; border-radius: 50%; color: #fff; font-size: 0.66rem; }
.o-P { } .o-B { } .o-T { }
.bead-cell.o-P { background: var(--road-blue); }
.bead-cell.o-B { background: var(--road-red); }
.bead-cell.o-T { background: var(--green); }
/* big road: hollow rings */
.big-cell { width: 16px; height: 16px; margin: 3px; border-radius: 50%; border: 2px solid; background: transparent; }
.big-cell.o-P { border-color: var(--road-blue); }
.big-cell.o-B { border-color: var(--road-red); }
.big-cell.o-T.lead { border-color: var(--green); }
.tie-slash { position: absolute; width: 22px; height: 2px; background: var(--green); transform: rotate(-45deg); border-radius: 2px; }
.tie-n { position: absolute; font-size: 0.5rem; color: var(--green); font-weight: 700; }
.pd { position: absolute; width: 5px; height: 5px; border-radius: 50%; }
.pd.bp { top: -1px; right: -1px; background: var(--road-red); }
.pd.pp { bottom: -1px; left: -1px; background: var(--road-blue); }
.bead-cell .pd.bp { top: 0; right: 0; } .bead-cell .pd.pp { bottom: 0; left: 0; }
/* derived roads: big-eye = hollow, small = filled, cockroach = slash */
.dcell { position: absolute; width: 9px; height: 9px; margin: 2px; border-radius: 50%; }
.dcell.red { background: var(--road-red); border: 1.5px solid var(--road-red); }
.dcell.blue { background: var(--road-blue); border: 1.5px solid var(--road-blue); }
#bigeye .dcell { background: transparent; }
.dcell.slash { background: transparent; border: none; width: 12px; height: 2px; border-radius: 2px; margin: 5px 0; transform: rotate(-45deg); transform-origin: left center; }
.dcell.slash.red { background: var(--road-red); } .dcell.slash.blue { background: var(--road-blue); }

/* prediction markers */
.predict { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 4px 2px; }
.pred-cap { font-size: 0.62rem; color: var(--muted); }
.pred-row { display: flex; align-items: center; gap: 5px; }
.pred-l { font-size: 0.66rem; font-weight: 700; }
.pred-row:nth-of-type(1) .pred-l { color: var(--road-red); }
.pred-row:nth-of-type(2) .pred-l { color: var(--road-blue); }
.pm { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pm.red { background: var(--road-red); } .pm.blue { background: var(--road-blue); }
.pm.none { background: transparent; border: 1px dashed var(--muted); }
.boards-note { font-size: 0.68rem; color: var(--muted); margin: 8px 0 0; }

/* ---- history ---- */
.history { margin: 14px 0; }
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-title { font-family: 'Cinzel', serif; font-size: 0.9rem; }
.history-list { display: flex; flex-direction: column; gap: 5px; }
.hl-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 0.74rem; }
.hl-num { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.hl-num.o-P { background: var(--road-blue); } .hl-num.o-B { background: var(--road-red); } .hl-num.o-T { background: var(--green); }
.hl-mid { flex: 1; color: var(--muted); }
.hl-mid b { color: var(--c-yellow); background: var(--c-dark); padding: 0 4px; border-radius: 3px; font-size: 0.62rem; }
.hl-delta.pos { color: var(--win); } .hl-delta.neg { color: var(--lose); }

.play-foot { text-align: center; margin: 18px 0 8px; font-size: 0.82rem; }

/* ---- simulation form ---- */
.sim-form { margin-top: 6px; }
.sim-intro { font-size: 0.82rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c-blue); border-radius: 10px; padding: 11px 13px; }
.seg { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 3px; margin: 10px 0; }
.seg-btn { font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; border: none; background: transparent; color: var(--muted); padding: 7px 18px; border-radius: 8px; cursor: pointer; }
.seg-btn.is-active { background: var(--surface); color: var(--c-blue); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.block { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px; padding: 12px; margin: 10px 0; display: grid; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 0.72rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.help { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 0.6rem; cursor: help; font-style: normal; }
.field select, .field input[type="number"] { font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px; appearance: none; }
.field input[type="range"] { width: 100%; accent-color: var(--c-blue); }
.detail-only { display: none; } .detail-only.show { display: block; }

.sim-progress { margin: 12px 0; display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--c-blue); transition: width 0.1s; }
#progText { font-size: 0.72rem; color: var(--muted); min-width: 36px; }

.sim-results { margin-top: 14px; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 8px; text-align: center; }
.stat .sk { display: block; font-size: 0.56rem; color: var(--muted); letter-spacing: 0.04em; margin-bottom: 3px; }
.stat .sv { font-size: 1rem; font-weight: 600; color: var(--c-blue); }
.sv.pos { color: var(--win); } .sv.neg { color: var(--lose); }
.chart-wrap { margin-top: 14px; }
.chart-wrap h3 { font-size: 0.82rem; color: var(--muted); margin: 0 0 6px; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.04em; }
canvas { width: 100%; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.sim-meta { font-size: 0.72rem; color: var(--muted); margin-top: 10px; }

/* ---- bottom sheets ---- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(50,52,50,0.45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-width: 560px; margin: 0 auto; max-height: 88dvh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.2,0.8,0.2,1); }
.sheet-backdrop.is-open .sheet { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 1.1rem; }
.x { background: none; border: none; font-size: 1.5rem; color: var(--muted); cursor: pointer; line-height: 1; }
.sheet .field { margin-bottom: 12px; }
.sheet-note { font-size: 0.78rem; color: var(--muted); margin: 8px 0 14px; }
#infoBody table { border-collapse: collapse; width: 100%; font-size: 0.78rem; }
#infoBody th, #infoBody td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; }
#infoBody th { background: var(--surface-2); font-family: 'Cinzel', serif; font-size: 0.74rem; }
#infoBody td:last-child, #infoBody th:last-child { text-align: right; }

/* ---- helptip / toast ---- */
.helptip { position: fixed; z-index: 80; max-width: 220px; background: var(--c-dark); color: #fff; font-size: 0.74rem; line-height: 1.5; padding: 9px 11px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.helptip.show { opacity: 1; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); z-index: 90; background: var(--c-dark); color: #fff; font-size: 0.82rem; padding: 11px 18px; border-radius: 100px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translateX(-50%); }

.foot { max-width: 560px; margin: 30px auto 0; padding: 18px 16px; text-align: center; color: var(--muted); font-size: 0.74rem; border-top: 1px solid var(--line); }
