/* SIC BO — staging. Five-tone palette shared with other hakoniwa tools. */
: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: #3a5a7a; --felt-2: #2d4a66;
  --win: #3aa893; --lose: #e8483f;
}
* { 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: 10px; }
.brand h1 { margin: 0; font-size: clamp(1.2rem, 6vw, 2rem); letter-spacing: 0.14em; color: var(--c-dark); }
.pip { font-size: 1.2rem; color: var(--c-teal); }
.tagline { color: var(--muted); font-size: 0.82rem; margin: 4px 0 12px; }

.panel { max-width: 560px; margin: 0 auto; padding: 0 12px; }

/* ---- tools bar ---- */
.play-tools { display: flex; gap: 8px; margin: 6px 0 10px; justify-content: center; }
.tool-btn { flex: 1; max-width: 200px; display: flex; align-items: center; justify-content: center;
  text-align: center; text-decoration: none; line-height: 1.2;
  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); }

/* ---- stats rail ---- */
.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); }

/* ---- dice zone ---- */
.dice-zone { display: flex; gap: 12px; align-items: center; margin-bottom: 12px;
  background: radial-gradient(130% 90% at 50% 0%, var(--felt) 0%, var(--felt-2) 95%);
  border-radius: 16px; padding: 14px 16px;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.25); }
.dice-trio { display: flex; gap: 10px; flex: 0 0 auto; }
.die { width: 68px; height: 68px; filter: drop-shadow(0 3px 8px rgba(0,0,0,0.3)); }
.die svg { width: 100%; height: 100%; display: block; border-radius: 12px; }
.die.rolling { animation: diceShake 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes diceShake {
  0%   { transform: rotate(0) scale(1); }
  15%  { transform: rotate(-12deg) scale(0.92); }
  30%  { transform: rotate(10deg) scale(1.08); }
  45%  { transform: rotate(-9deg) scale(0.96); }
  60%  { transform: rotate(7deg) scale(1.04); }
  75%  { transform: rotate(-4deg) scale(0.98); }
  90%  { transform: rotate(2deg) scale(1.01); }
  100% { transform: rotate(0) scale(1); }
}
.dice-info { flex: 1; min-width: 0; text-align: center; }
.dice-total { font-size: 2.4rem; font-weight: 700; color: #fff; line-height: 1; font-family: 'Cinzel', serif; }
.dice-label { font-size: 0.66rem; color: rgba(255,255,255,0.75); letter-spacing: 0.1em; margin-top: 4px; }

/* ---- message ---- */
.message { text-align: center; min-height: 2em; font-size: 0.9rem; padding: 10px 8px;
  border-radius: 10px; margin: 8px 0; color: var(--muted); }
.message.win  { background: rgba(58,168,147,0.12); color: var(--win);  border: 1px solid rgba(58,168,147,0.35); font-weight: 600; }
.message.lose { background: rgba(232,72,63,0.10);  color: var(--lose); border: 1px solid rgba(232,72,63,0.30); font-weight: 600; }

/* ---- bet section ---- */
.bet-section { margin: 10px 0; }
.bet-row { display: flex; gap: 8px; margin-bottom: 8px; }

/* Big / Small */
.bet-btn { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 12px 8px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); cursor: pointer; transition: 0.15s; }
.bet-btn:disabled { opacity: 0.4; cursor: default; }
.bet-btn.is-active { border-color: var(--c-teal); background: rgba(112,193,179,0.09); }
.bet-btn.is-active .bet-name { color: var(--c-teal); }
.bet-name { font-family: 'Cinzel', serif; font-size: 0.88rem; letter-spacing: 0.06em; }
.bet-range { font-size: 0.6rem; color: var(--muted); }
.bet-pay { font-size: 0.7rem; font-weight: 600; color: var(--c-blue); }

/* Any Triple — wide */
.bet-wide { flex: 1; }

/* Single Die row */
.single-row { flex-direction: column; align-items: stretch; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.single-label { font-size: 0.66rem; color: var(--muted); letter-spacing: 0.05em; margin-bottom: 6px; }
.single-faces { display: flex; gap: 6px; }
.face-btn { position: relative; flex: 1; height: 40px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface-2); font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 600;
  color: var(--ink); cursor: pointer; transition: 0.12s; }
.face-btn:disabled { opacity: 0.35; cursor: default; }
.face-btn.is-active { border-color: var(--c-teal); background: rgba(112,193,179,0.12); color: var(--c-teal); }
.single-pay { font-size: 0.6rem; color: var(--muted); text-align: center; margin-top: 4px; }

/* ---- bet amount — 共通チップ規格 C1（丸56px・白破線枠・内側リング影／blackjack基準・タップ加算） ---- */
.chip-betline { margin: 8px 0; }
.chiprow { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.chip { box-sizing: border-box; width: 56px; height: 56px; border-radius: 50%;
  border: 3px dashed rgba(255,255,255,0.7); color: #fff;
  font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 0.9rem; cursor: pointer;
  transition: transform 0.12s;
  box-shadow: 0 5px 12px -5px rgba(40,42,41,0.5), inset 0 0 0 4px rgba(255,255,255,0.12); }
.chip:active { transform: scale(0.92); }
.chip:disabled { opacity: 0.4; cursor: default; }
.chip.c1 { background: #b9c3c7; color: var(--c-dark); }
.chip.c5 { background: var(--c-blue); }
.chip.c25 { background: var(--c-teal); }
.chip.c100 { background: var(--c-dark); border-color: var(--c-yellow); color: var(--c-yellow); }
.chip.is-active { transform: scale(1.12); box-shadow: 0 0 0 3px var(--c-yellow), inset 0 0 0 4px rgba(255,255,255,0.12); }
.chip-hint { text-align: center; font-size: 0.66rem; color: var(--muted); margin-bottom: 6px; }
.bet-actions { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.bet-act-btn { font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; font-weight: 600;
  padding: 5px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer; }
.bet-act-btn:disabled { opacity: 0.35; cursor: default; }
.bet-act-btn:active:not(:disabled) { background: var(--surface-2); }
/* スポットに載せたチップ（額面tier色のバッジ） */
.placed { position: absolute; top: -8px; right: -6px; min-width: 30px; height: 30px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; font-weight: 700; color: #fff;
  border: 2px dashed rgba(255,255,255,0.75); box-shadow: 0 2px 6px -1px rgba(40,42,41,0.5); }
.placed.c1 { background: #b9c3c7; color: var(--c-dark); }
.placed.c5 { background: var(--c-blue); }
.placed.c25 { background: var(--c-teal); }
.placed.c100 { background: var(--c-dark); border-color: var(--c-yellow); color: var(--c-yellow); }
/* 解決後の勝敗ハイライト */
.spot-win { border-color: var(--c-teal) !important; box-shadow: 0 0 0 3px rgba(112,193,179,0.45); }
.spot-lose { opacity: 0.5; }

/* ---- roll button ---- */
.roll-btn { width: 100%; font-family: 'Cinzel', serif; letter-spacing: 0.06em;
  padding: 16px; border-radius: 14px; border: none; color: #fff; background: var(--c-red);
  cursor: pointer; font-size: 1rem; transition: transform 0.08s, filter 0.15s; margin: 10px 0; }
.roll-btn:active:not(:disabled) { transform: translateY(1px); }
.roll-btn:disabled { opacity: 0.38; filter: grayscale(0.3); cursor: default; background: var(--muted); }

/* ---- history ---- */
.history-section { margin: 16px 0 8px; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.history-title { font-family: 'Cinzel', serif; font-size: 0.82rem; letter-spacing: 0.04em; }
.link-btn { background: none; border: none; color: var(--c-blue); font-size: 0.72rem; cursor: pointer; font-family: inherit; }
.history-strip { display: flex; flex-direction: column; gap: 5px; max-height: 280px; overflow-y: auto; padding-bottom: 4px; }
.hp-entry { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 0.78rem; }
.hp-win  { border-color: rgba(58,168,147,0.4); background: rgba(58,168,147,0.06); }
.hp-lose { border-color: rgba(232,72,63,0.25); background: rgba(232,72,63,0.05); }
.hp-dice { font-weight: 700; color: var(--ink); flex: 0 0 auto; min-width: 110px; }
.hp-bet  { flex: 1; color: var(--muted); font-size: 0.72rem; }
.hp-right { flex: 0 0 auto; text-align: right; }
.hp-net  { display: block; font-weight: 700; font-size: 0.86rem; }
.hp-bal  { display: block; font-size: 0.62rem; color: var(--muted); }
.hp-empty { font-size: 0.72rem; color: var(--muted); text-align: center; padding: 10px 0; margin: 0; }
.pos { color: var(--win); }
.neg { color: var(--lose); }

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

/* ---- footer ---- */
.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); }

/* ---- tabs ---- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 100px; margin: 6px 0 10px; }
.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); }

/* ---- panels ---- */
.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; } }

/* ---- game controls (below history) ---- */
.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); }

/* ---- action buttons ---- */
.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.run { width: 100%; margin-top: 4px; }

/* ---- sim 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; margin-bottom: 14px; }
.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); }
.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); }

/* ---- sim progress ---- */
.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; }

/* ---- sim results ---- */
.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; }

/* ---- HE table in sim ---- */
.he-section { margin: 14px 0; }
.he-section h3 { font-family: 'Cinzel', serif; font-size: 0.84rem; letter-spacing: 0.05em; margin: 0 0 10px; }
.he-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.he-table th, .he-table td { padding: 7px 8px; border: 1px solid var(--line); text-align: left; }
.he-table th { background: var(--surface-2); font-family: 'Cinzel', serif; font-size: 0.7rem; letter-spacing: 0.04em; }
.he-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.he-table tr.he-low td:first-child { color: var(--win); font-weight: 600; }
.he-table tr.he-high td:first-child { color: var(--lose); }
.he-loading { font-size: 0.78rem; color: var(--muted); text-align: center; padding: 12px; }

/* ---- 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; }
.sheet .field { margin-bottom: 12px; }
.sheet-note { font-size: 0.78rem; color: var(--muted); margin: 8px 0 14px; }
.x { background: none; border: none; font-size: 1.5rem; color: var(--muted); cursor: pointer; line-height: 1; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }

/* ---- toast ---- */
.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%); }
