/* ============================================================
   main.css — Design tokens, reset, layout, navigation
   Mobile-first. Desktop is just "wider mobile".
   ============================================================ */

/* -- Tokens ---------------------------------------------------- */
:root {
  /* Base palette — dark felt casino */
  --bg:           #07100c;
  --bg-2:         #0c1813;
  --felt:         #0a1f17;
  --felt-2:       #0d2a1f;
  --ink:          #e8efe9;
  --ink-2:        #a8b3ad;
  --ink-3:        #6c7770;
  --line:         rgba(255, 255, 255, 0.08);
  --line-strong:  rgba(255, 255, 255, 0.16);

  /* Accents */
  --gold:         #d4af37;
  --gold-2:       #f1d271;
  --red:          #d4364a;
  --red-2:        #b32437;
  --black:        #1a1a1a;
  --green:        #1a7a4d;
  --green-2:      #25a566;

  /* Hot / cold / due */
  --hot-1:        #ffd166;
  --hot-2:        #ef476f;
  --cold-1:       #4cc9f0;
  --cold-2:       #4361ee;
  --due:          #ffb84d;

  /* Glass */
  --glass-bg:        rgba(16, 28, 22, 0.55);
  --glass-bg-soft:   rgba(16, 28, 22, 0.35);
  --glass-border:    rgba(255, 255, 255, 0.07);
  --glass-border-2:  rgba(255, 255, 255, 0.12);
  --glass-shadow:    0 10px 40px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.04) inset;

  /* Geometry */
  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --radius-pill: 999px;

  --header-h:   56px;
  --nav-h:      64px;
  --fab-size:   60px;

  /* Safe area (iOS) */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Type scale */
  --fs-xs:   11px;
  --fs-sm:   13px;
  --fs-base: 15px;
  --fs-md:   16px;
  --fs-lg:   18px;
  --fs-xl:   22px;
  --fs-2xl:  28px;
}

/* -- Reset ----------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  /* Subtle radial felt glow */
  background:
    radial-gradient(1200px 800px at 50% -10%, rgba(26, 122, 77, 0.12), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, rgba(212, 175, 55, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
em { font-style: normal; color: var(--gold-2); }

/* -- App shell ------------------------------------------------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

/* -- App header ------------------------------------------------ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: linear-gradient(to bottom, rgba(7, 16, 12, 0.95), rgba(7, 16, 12, 0.7));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.app-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.app-brand__mark {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.app-brand__mark .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.app-brand__mark .dot--red   { background: var(--red); }
.app-brand__mark .dot--black { background: #2a2a2a; border: 1px solid #444; }
.app-brand__mark .dot--green { background: var(--green); }

.app-brand__text { min-width: 0; }
.app-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  line-height: 1.1;
}
.app-title span {
  color: var(--gold);
  font-weight: 600;
  margin-left: 4px;
}
.app-subtitle {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-top: 2px;
}

.app-header__actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* -- Main content area ----------------------------------------- */
.app-main {
  flex: 1 1 auto;
  padding: 16px 16px calc(var(--nav-h) + 96px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  animation: panelIn 0.25s ease both;
}
.tab-panel.is-active { display: flex; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -- Icon buttons ---------------------------------------------- */
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: var(--fs-md);
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: #14241c; border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn--danger:hover { color: var(--red); border-color: rgba(212, 54, 74, 0.5); }

.info-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}
.info-btn:hover { color: var(--gold); border-color: var(--gold); }

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip-btn:hover { background: #14241c; }
.chip-btn.is-active {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--gold);
  color: var(--gold-2);
}

.select-sm {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: var(--fs-sm);
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path fill="%23a8b3ad" d="M5 6L0 0h10z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 26px;
}

/* -- Bottom Navigation ---------------------------------------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(7, 16, 12, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  z-index: 80;
}
.bottom-nav::before {
  /* gradient hairline */
  content: "";
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold) 50%, transparent);
  opacity: 0.4;
}
.app .bottom-nav {
  /* Constrain to app width on tablet/desktop */
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 720px;
}
.nav-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 8px 4px;
  position: relative;
  transition: color 0.15s ease;
}
.nav-item i { font-size: 18px; }
.nav-item.is-active { color: var(--gold-2); }
.nav-item.is-active::after {
  content: "";
  position: absolute;
  top: 6px;
  width: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}
.nav-item:active { transform: scale(0.96); }

/* -- Floating action button ----------------------------------- */
.fab {
  position: fixed;
  right: max(16px, calc(50% - 720px / 2 + 16px));
  bottom: calc(var(--nav-h) + 16px + var(--safe-bottom));
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-2) 100%);
  color: #1a1a1a;
  border: none;
  font-size: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  box-shadow:
    0 8px 24px rgba(212, 175, 55, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.fab:hover { transform: translateY(-2px); }
.fab:active { transform: translateY(0) scale(0.95); }

/* -- Card heads ----------------------------------------------- */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.card-title small.muted {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-weight: 400;
}
.card-head__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.card-lede {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  margin-bottom: 12px;
  line-height: 1.45;
}
.meta {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* -- Empty state ---------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: var(--fs-sm);
}
.empty-state i { font-size: 28px; opacity: 0.6; }
.empty-state strong { color: var(--ink-2); }

/* -- Spin strip ----------------------------------------------- */
.spin-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 8px;
  margin: 0 -2px;
}
.spin-strip::-webkit-scrollbar { display: none; }
.spin-strip { scrollbar-width: none; }

.spin-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--fs-md);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  position: relative;
}
.spin-chip.is-new {
  animation: chipPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.spin-chip--red   { background: linear-gradient(160deg, #e8506b 0%, #b32437 100%); }
.spin-chip--black { background: linear-gradient(160deg, #2c2c2c 0%, #0d0d0d 100%); }
.spin-chip--green { background: linear-gradient(160deg, #2bbd7a 0%, #126b41 100%); }

@keyframes chipPop {
  0%   { transform: scale(0.4) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

/* -- Quick stat tiles ----------------------------------------- */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat-tile {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.stat-tile__label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-tile__value {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-top: 4px;
  color: var(--ink);
  line-height: 1.1;
}
.stat-tile__value .num-dot {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
  font-size: var(--fs-sm);
  line-height: 28px;
  text-align: center;
  color: #fff;
  font-weight: 700;
}

/* -- Hot/Cold ------------------------------------------------- */
.hotcold {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.hotcold__col { min-width: 0; }
.hotcold__heading {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.hotcold__heading small {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-weight: 400;
}
.hotcold__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hotcold__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}
.hotcold__chip .num {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.hotcold__chip .num--red   { background: var(--red); }
.hotcold__chip .num--black { background: #2a2a2a; }
.hotcold__chip .num--green { background: var(--green); }
.hotcold__chip .count {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 500;
}

/* -- Streaks -------------------------------------------------- */
.streaks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.streak {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.streak__label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.streak__current {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--gold-2);
  margin-top: 2px;
}
.streak__current.is-zero { color: var(--ink-3); }
.streak__longest {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 4px;
}

/* -- Even money ----------------------------------------------- */
.even-money {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.even-money__item {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.even-money__label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.even-money__bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  margin-top: 8px;
  overflow: hidden;
  display: flex;
}
.even-money__bar > span {
  height: 100%;
  transition: width 0.3s ease;
}
.even-money__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  font-size: var(--fs-sm);
}
.even-money__row span:first-child { color: var(--ink-2); }
.even-money__row span:last-child { font-weight: 600; }

/* -- Bar list (dozens / columns) ------------------------------ */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-list__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.bar-list__label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.bar-list__label strong { color: var(--ink); }
.bar-list__bar {
  grid-column: 1 / -1;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}
.bar-list__bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(to right, var(--green), var(--green-2));
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}
.bar-list__bar.is-due > span { background: linear-gradient(to right, var(--due), #ff8c1a); }
.bar-list__pct {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 520px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* -- Sleepers ------------------------------------------------- */
.sleepers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sleeper {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.sleeper__num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  text-align: center;
  line-height: 32px;
  font-weight: 700;
  color: #fff;
  font-size: var(--fs-sm);
}
.sleeper__bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}
.sleeper__bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(to right, var(--due), var(--hot-2));
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}
.sleeper__score {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}
.sleeper__gaps {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-left: 4px;
}

/* -- Chi-square test ------------------------------------------ */
.chi-test {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chi-test__verdict {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.chi-test__verdict.is-positive { border-color: rgba(76, 201, 240, 0.4); }
.chi-test__verdict.is-warning  { border-color: rgba(255, 184, 77, 0.4); }
.chi-test__verdict.is-noise    { border-color: var(--line); }
.chi-test__badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.chi-test__badge.is-positive { background: rgba(76, 201, 240, 0.15); color: var(--cold-1); }
.chi-test__badge.is-warning  { background: rgba(255, 184, 77, 0.15); color: var(--due); }
.chi-test__badge.is-noise    { background: rgba(168, 179, 173, 0.15); color: var(--ink-2); }
.chi-test__heading {
  font-weight: 700;
  font-size: var(--fs-md);
}
.chi-test__sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}
.chi-test__breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.chi-test__breakdown strong { color: var(--ink); }

/* -- Frequency table ------------------------------------------ */
.freq-table {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}
.freq-cell {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.freq-cell::before {
  /* background heat */
  content: "";
  position: absolute;
  inset: 0;
  background: var(--heat, transparent);
  opacity: var(--heat-opacity, 0);
  transition: opacity 0.25s ease;
}
.freq-cell > * { position: relative; }
.freq-cell__num {
  font-weight: 700;
  font-size: var(--fs-sm);
}
.freq-cell__count {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}
.freq-cell__num--red   { color: #ff7a8a; }
.freq-cell__num--black { color: #d0d0d0; }
.freq-cell__num--green { color: #4cd49a; }

/* -- Bankroll ------------------------------------------------- */
.bankroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bankroll__big {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.bankroll__balance {
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.5px;
}
.bankroll__balance.is-up   { color: var(--green-2); }
.bankroll__balance.is-down { color: var(--red); }
.bankroll__pl {
  font-size: var(--fs-md);
  font-weight: 700;
}
.bankroll__pl.is-up   { color: var(--green-2); }
.bankroll__pl.is-down { color: var(--red); }
.bankroll__row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.bankroll__row strong { color: var(--ink); }
.bankroll__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-2);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.bankroll__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bankroll__field label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-3);
}
.bankroll__field input,
.bankroll__field select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-family: inherit;
}
.bankroll__field input:focus,
.bankroll__field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

/* -- Simulator ------------------------------------------------ */
.simulator {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.simulator__form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.simulator__form .full { grid-column: 1 / -1; }
.simulator__run {
  display: flex;
  gap: 8px;
  align-items: center;
}
.simulator__run button {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #1a1a1a;
  border: none;
  font-weight: 700;
  font-size: var(--fs-md);
}
.simulator__run button:disabled { opacity: 0.5; cursor: not-allowed; }
.simulator__result {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.simulator__result.is-empty {
  text-align: center;
  color: var(--ink-3);
  font-size: var(--fs-sm);
  padding: 24px 14px;
}
.simulator__big {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.simulator__big .pl {
  font-size: var(--fs-xl);
  font-weight: 800;
}
.simulator__big .pl.is-up   { color: var(--green-2); }
.simulator__big .pl.is-down { color: var(--red); }
.simulator__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.simulator__meta strong { color: var(--ink); }
.simulator__curve {
  height: 80px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.simulator__curve svg { width: 100%; height: 100%; display: block; }
.simulator__strategy {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.5;
  background: var(--bg-2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
}
.simulator__strategy h4 {
  font-size: var(--fs-sm);
  color: var(--gold-2);
  margin-bottom: 4px;
  font-weight: 600;
}

/* -- Sectors -------------------------------------------------- */
.sectors {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.sector__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sector__name {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--gold-2);
}
.sector__pct {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  font-weight: 600;
}
.sector__nums {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.5px;
}
.sector__bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.sector__bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(to right, var(--green), var(--green-2));
  border-radius: var(--radius-pill);
}
.sector__bar.is-over > span { background: linear-gradient(to right, var(--gold), var(--gold-2)); }
.sector__bar.is-under > span { background: linear-gradient(to right, var(--cold-1), var(--cold-2)); }

/* -- Number detail card --------------------------------------- */
#numberDetailBody {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nd-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.nd-row strong { color: var(--ink); }
.nd-mini-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.nd-mini-strip .spin-chip {
  width: 30px;
  height: 30px;
  font-size: 12px;
  animation: none;
}

/* -- Toast ---------------------------------------------------- */
.toast-root {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: min(90vw, 360px);
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s ease both;
  pointer-events: auto;
  text-align: center;
}
.toast.is-out { animation: toastOut 0.2s ease both; }
.toast--success { border-color: var(--green); }
.toast--error   { border-color: var(--red); }
.toast--info    { border-color: var(--gold); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* -- Modal ---------------------------------------------------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-root.is-open { display: flex; }
.modal-root__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease both;
}
.modal-root__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  animation: sheetIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@media (min-width: 600px) {
  .modal-root {
    align-items: center;
  }
  .modal-root__panel {
    border-radius: var(--radius-lg);
    max-height: 80vh;
    margin: 0 16px;
  }
}
.modal-root__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-root__head h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
}
.modal-root__body {
  padding: 16px;
  overflow-y: auto;
  line-height: 1.55;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}
.modal-root__body h3 {
  font-size: var(--fs-md);
  color: var(--gold-2);
  margin: 14px 0 6px;
  font-weight: 600;
}
.modal-root__body h3:first-child { margin-top: 0; }
.modal-root__body p { margin-bottom: 8px; }
.modal-root__body ul { padding-left: 0; margin-bottom: 10px; }
.modal-root__body li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 4px;
}
.modal-root__body li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
}
.modal-root__body strong { color: var(--ink); }
.modal-root__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--gold-2);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetIn {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* -- Settings list -------------------------------------------- */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: none; }
.setting__label {
  display: flex;
  flex-direction: column;
}
.setting__name {
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--ink);
}
.setting__desc {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}

/* -- Toggle switch -------------------------------------------- */
.toggle {
  position: relative;
  width: 46px;
  height: 26px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--ink-2);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle.is-on { background: rgba(212, 175, 55, 0.2); border-color: var(--gold); }
.toggle.is-on::after { transform: translateX(20px); background: var(--gold); }

/* -- Responsive tweaks ---------------------------------------- */
@media (min-width: 720px) {
  .stat-tiles { grid-template-columns: repeat(4, 1fr); }
  .hotcold, .streaks, .even-money {
    grid-template-columns: repeat(2, 1fr);
  }
  .simulator__meta { grid-template-columns: repeat(4, 1fr); }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Mode toggle (Tracker / Play)
   ============================================================ */
.mode-toggle {
  display: inline-flex;
  background: rgba(12, 24, 19, 0.85);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 3px;
  margin-left: auto;
  margin-right: 6px;
  flex-shrink: 0;
}
.mode-toggle__opt {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all 0.2s ease;
}
.mode-toggle__opt i {
  font-size: 13px;
}
.mode-toggle__label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.15;
}
.mode-toggle__label strong {
  font-size: 12px;
  letter-spacing: 0.3px;
}
.mode-toggle__label small {
  font-size: 9px;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.mode-toggle__opt.is-active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(56, 189, 248, 0.15));
  border-color: rgba(56, 189, 248, 0.5);
  color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}
.app.is-mode-play .mode-toggle__opt.is-active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.3), rgba(241, 210, 113, 0.15));
  border-color: var(--gold);
  color: var(--gold-2);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

/* Mode Banner */
.mode-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  font-size: var(--fs-sm);
  line-height: 1.35;
}
.mode-banner__icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.mode-banner__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mode-banner__content strong {
  font-size: var(--fs-sm);
  letter-spacing: 0.2px;
}
.mode-banner__content span {
  font-size: var(--fs-xs);
  opacity: 0.85;
}

.mode-banner--track {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--ink);
}
.mode-banner--track .mode-banner__icon {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}
.mode-banner--track strong { color: #38bdf8; }

.mode-banner--play {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(26, 122, 77, 0.12));
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--ink);
}
.mode-banner--play .mode-banner__icon {
  background: rgba(212, 175, 55, 0.2);
  color: var(--gold-2);
  border: 1px solid rgba(212, 175, 55, 0.4);
}
.mode-banner--play strong { color: var(--gold-2); }

/* Header Brand Badge */
#appTitleBadge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.app:not(.is-mode-play) #appTitleBadge {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.app.is-mode-play #appTitleBadge {
  background: rgba(212, 175, 55, 0.2);
  color: var(--gold-2);
  border: 1px solid rgba(212, 175, 55, 0.4);
}

/* Experiment Button */
.icon-btn--experiment {
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.3);
  background: rgba(212, 175, 55, 0.08);
}
.icon-btn--experiment:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.35);
}

/* Mode-aware subtitle */
.app.is-mode-play .app-subtitle {
  color: var(--gold-2);
}
.app.is-mode-play .app-subtitle::before {
  content: "🎰 ";
  margin-right: 4px;
}
.app:not(.is-mode-play) .app-subtitle {
  color: #38bdf8;
}
.app:not(.is-mode-play) .app-subtitle::before {
  content: "● ";
  color: #38bdf8;
  margin-right: 4px;
  animation: telemetryPulse 2s ease-in-out infinite;
}
@keyframes telemetryPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.app-subtitle {
  display: inline-flex;
  align-items: center;
}

/* Mode-specific viewport rules */
.app.is-mode-play .bottom-nav {
  display: none !important;
}
.app.is-mode-play #undoBtn {
  display: none !important;
}
.app.is-mode-play .app-main {
  padding-bottom: calc(40px + var(--safe-bottom));
}

/* Subtle top-bar accent that changes with mode */
.app.is-mode-play::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  z-index: 100;
  pointer-events: none;
  animation: shimmer 3s ease-in-out infinite;
}
.app:not(.is-mode-play)::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #38bdf8, transparent);
  z-index: 100;
  pointer-events: none;
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ============================================================
   Monte Carlo / Random Sim
   ============================================================ */
.sim-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.sim-form .full { grid-column: 1 / -1; }
.sim-form__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sim-form__field label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.sim-form__field select,
.sim-form__field input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-family: inherit;
}
.sim-form__field input:focus,
.sim-form__field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
.sim-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sim-run-btn {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #1a1a1a;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: var(--fs-md);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
  transition: transform 0.1s;
}
.sim-run-btn:hover { transform: translateY(-1px); }
.sim-run-btn:active { transform: scale(0.98); }
.sim-run-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.sim-status {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.sim-status.is-busy { color: var(--gold-2); }

.sim-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.sim-summary__cell {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.sim-summary__label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.sim-summary__value {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-top: 2px;
}
.sim-summary__value.is-up   { color: var(--green-2); }
.sim-summary__value.is-down { color: var(--red); }
@media (min-width: 520px) {
  .sim-summary { grid-template-columns: repeat(4, 1fr); }
  .sim-form { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   Chart (Canvas)
   ============================================================ */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.chart-wrap--small { height: 180px; }
.chart-wrap--dist  { height: 230px; }
.chart-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.chart-tooltip {
  position: absolute;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: opacity 0.15s ease;
}
.chart-tooltip__title {
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 10px;
}
.chart-tooltip__value {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: #fff;
  margin-top: 2px;
}

.card-subtitle-small {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  font-weight: 400;
}

.chart-explainer {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 12px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.chart-explainer--tip {
  border-left-color: #38bdf8;
  background: rgba(56, 189, 248, 0.06);
  color: #a8d5e5;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.swatch--primary-curve { background: var(--gold); }
.swatch--mean-curve    { background: #4cc9f0; }
.swatch--loss          { background: linear-gradient(135deg, #f87171, #b91c1c); }
.swatch--profit        { background: linear-gradient(135deg, #34d399, #059669); }
.swatch--breakeven     { background: #ffffff; border: 1px dashed rgba(255, 255, 255, 0.6); }
