/* ANDAR BAHAR — staging. Five-tone palette shared with 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); }
.tagline { color: var(--muted); font-size: 0.82rem; margin: 4px 0 12px; }

/* ---- 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; text-decoration: none; display: inline-flex; align-items: center; }
.tab.is-active, .tab:hover { color: #fff; background: var(--c-blue); }
a.tab { color: var(--muted); }
a.tab:hover { text-decoration: none; }

/* ---- panels ---- */
.panel { max-width: 560px; margin: 0 auto; padding: 0 12px; }
.panel:not(.is-active) { display: none; }

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

/* ---- joker display ---- */
.joker-area { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 0 8px; }
.joker-label { font-size: 0.68rem; color: var(--muted); letter-spacing: 0.08em; text-align: center; margin-top: 4px; }
.joker-card {
  width: 64px; height: 88px; border-radius: 10px; border: 2px solid var(--c-yellow);
  background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 1.4rem; font-weight: 700; color: var(--c-dark);
  box-shadow: 0 4px 14px -4px rgba(255,224,102,0.5);
}
.joker-card .suit { font-size: 1.1rem; }
.joker-card.red { color: var(--lose); }
.joker-card.empty { color: var(--muted); font-size: 0.8rem; }

/* ---- bet areas (felt) ---- */
.bet-table {
  background: radial-gradient(130% 90% at 50% 0%, var(--felt) 0%, var(--felt-2) 95%);
  border-radius: 16px; padding: 12px;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.25);
  margin-bottom: 10px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.bet-zone {
  border-radius: 12px; border: 2px dashed rgba(255,255,255,0.25);
  padding: 10px 8px; text-align: center; position: relative; cursor: pointer;
  min-height: 80px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.bet-zone:hover { border-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.06); }
.bet-zone.is-selected { border-color: var(--c-yellow); background: rgba(255,224,102,0.12); }
.bet-zone.winner-flash { animation: flash-win 0.6s ease; }
.bet-zone.loser-flash { animation: flash-lose 0.6s ease; }
@keyframes flash-win  { 0%,100%{box-shadow:none} 50%{box-shadow:0 0 0 3px var(--win)} }
@keyframes flash-lose { 0%,100%{box-shadow:none} 50%{box-shadow:0 0 0 3px var(--lose)} }

.bet-zone-label { font-family: 'Cinzel', serif; font-size: 1.05rem; font-weight: 700; color: rgba(255,255,255,0.9); letter-spacing: 0.06em; }
.bet-zone-payout { font-size: 0.62rem; color: rgba(255,255,255,0.5); margin-top: 2px; }
.bet-zone-amount { font-size: 0.8rem; color: var(--c-yellow); font-weight: 600; margin-top: 4px; min-height: 18px; }

/* chip stack on bet zone */
.placed-chips { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.placed-chip {
  width: 26px; height: 26px; border-radius: 50%; border: 2px dashed rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.52rem; font-weight: 700; color: #fff;
}
.placed-chip.c1  { background: #b9c3c7; color: var(--c-dark); }
.placed-chip.c5  { background: var(--c-blue); }
.placed-chip.c25 { background: var(--c-teal); }
.placed-chip.c100 { background: var(--c-dark); border-color: var(--c-yellow); color: var(--c-yellow); }
.placed-chip.c500 { background: #7E57C2; }

/* ---- card columns ---- */
.deal-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 10px; }
.deal-col { display: flex; flex-direction: column; gap: 4px; }
.deal-col-label { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.06em; text-align: center; margin-bottom: 2px; }
.cards-strip { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; min-height: 30px; }
.mini-card {
  width: 32px; height: 44px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 0.72rem; font-weight: 700; color: var(--ink);
  gap: 0;
}
.mini-card .suit { font-size: 0.62rem; }
.mini-card.red { color: var(--lose); }
.mini-card.match { border-color: var(--c-yellow); background: rgba(255,224,102,0.12); color: var(--c-dark); box-shadow: 0 0 0 2px var(--c-yellow); }

/* ---- chip row — C1 spec ---- */
.chip-betline { margin: 8px 0; }
.chip-hint { text-align: center; font-size: 0.66rem; color: var(--muted); margin-bottom: 6px; }
.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);
  display: flex; align-items: center; justify-content: center; }
.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.c500 { background: #7E57C2; }
.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); }

/* ---- deal / new-game buttons ---- */
.deal-btn { width: 100%; font-family: 'Cinzel', serif; letter-spacing: 0.06em;
  padding: 16px; border-radius: 14px; border: none; color: #fff; background: var(--c-blue);
  cursor: pointer; font-size: 1rem; transition: transform 0.08s, filter 0.15s; margin: 10px 0; }
.deal-btn:active:not(:disabled) { transform: translateY(1px); }
.deal-btn:disabled { opacity: 0.38; filter: grayscale(0.3); cursor: default; background: var(--muted); }
.new-game-btn { width: 100%; font-family: 'Cinzel', serif; letter-spacing: 0.06em;
  padding: 16px; border-radius: 14px; border: none; color: #fff; background: var(--c-teal);
  cursor: pointer; font-size: 1rem; margin: 10px 0; }
.new-game-btn:active { transform: translateY(1px); }
.rebet-btn { width: 100%; font-family: 'Cinzel', serif; letter-spacing: 0.06em;
  padding: 12px; border-radius: 12px; border: 1px solid var(--c-teal); color: var(--c-teal); background: transparent;
  cursor: pointer; font-size: 0.88rem; margin: 0 0 8px; }
.rebet-btn:active { background: rgba(112,193,179,0.1); }

/* ---- clear button ---- */
.clear-btn { width: 100%; font-family: 'JetBrains Mono', monospace;
  padding: 10px; border-radius: 10px; border: 1px solid rgba(232,72,63,0.3); color: var(--lose); background: transparent;
  cursor: pointer; font-size: 0.8rem; margin-bottom: 6px; }
.clear-btn:active { background: rgba(232,72,63,0.06); }

/* ---- 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; }
.message.info { background: rgba(36,123,160,0.08); color: var(--c-blue); border: 1px solid rgba(36,123,160,0.25); }

/* ---- 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; }
.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-left { font-weight: 700; color: var(--ink); flex: 0 0 auto; min-width: 60px; }
.hp-mid  { flex: 1; color: var(--muted); font-size: 0.68rem; }
.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); }

/* ---- game controls ---- */
.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); }
.gc-btn:active { background: var(--surface-2); }

/* ---- sim tab ---- */
.sim-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.sim-field { display: flex; flex-direction: column; gap: 3px; }
.sim-field label { font-size: 0.62rem; color: var(--muted); letter-spacing: 0.06em; }
.sim-field input, .sim-field select {
  font-family: 'JetBrains Mono', monospace; font-size: 0.88rem; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.sim-run-btn { grid-column: 1/-1; font-family: 'Cinzel', serif; padding: 14px; border-radius: 12px;
  border: none; color: #fff; background: var(--c-blue); cursor: pointer; font-size: 0.95rem; }
.sim-run-btn:active { filter: brightness(0.9); }
.sim-run-btn:disabled { opacity: 0.5; cursor: default; }
#simResults { display: none; }
.sim-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.sim-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; text-align: center; }
.sim-stat .s-label { font-size: 0.58rem; color: var(--muted); letter-spacing: 0.06em; display: block; margin-bottom: 3px; }
.sim-stat .s-val { font-size: 1rem; font-weight: 700; color: var(--c-blue); }
.canvas-wrap { margin: 8px 0; }
.canvas-label { font-size: 0.62rem; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 4px; }
canvas { width: 100%; height: 180px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); display: block; }

/* ---- footer ---- */
.play-foot { text-align: center; margin: 18px 0 8px; font-size: 0.82rem; }
.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); }
