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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-size-md);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Scrollbars (dark, matches the theme instead of the OS default) ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-light) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: var(--color-border-light);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-gold-pressed);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

input,
button,
select {
  font: inherit;
  color: inherit;
}

input::placeholder {
  color: var(--color-text-faint);
  opacity: 0.8;
}

/* ---------- Layout shell ---------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.page-header__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--font-size-lg);
}

.page-header__title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.page-content {
  flex: 1;
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-10);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.page-content > section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.home-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4) var(--space-2);
  max-width: var(--max-content-width);
  margin: 0 auto;
  width: 100%;
}

.home-hero h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  letter-spacing: 0.01em;
}

.home-hero .accent {
  color: var(--color-gold);
}

.home-hero p {
  color: var(--color-text-muted);
}

/* ---------- Responsive grid ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

.grid--cards {
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .grid--cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid--2col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .grid--3col {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Card ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.card--clickable {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color 120ms ease;
}

.card--clickable:hover {
  border-color: var(--color-gold);
}

.card__icon {
  font-size: var(--font-size-xl);
  color: var(--color-gold);
}

.card__title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.card__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.card__list li {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  padding-left: var(--space-3);
  position: relative;
}

.card__list li::before {
  content: "\2022";
  color: var(--color-gold);
  position: absolute;
  left: 0;
}

.card__link {
  display: inline-block;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: color 120ms ease;
}

.card__link:hover {
  color: var(--color-gold);
  text-decoration: underline;
}

.card__meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
}

.card__badge {
  align-self: flex-start;
  font-size: var(--font-size-sm);
  color: var(--color-text-faint);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  user-select: none;
  transition: filter 60ms ease, transform 60ms ease;
}

.btn-primary {
  background: var(--color-gold);
  color: var(--color-on-gold);
}

.btn-secondary {
  background: transparent;
  color: var(--color-gold);
  border-color: var(--color-gold-pressed);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

/* ---------- Chip / Toggle ---------- */

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  user-select: none;
  transition: filter 60ms ease, border-color 120ms ease, color 120ms ease;
}

.chip.is-selected {
  border-color: var(--color-gold);
  color: var(--color-gold);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  background: var(--color-surface);
}

.segmented__option {
  padding: var(--space-2) var(--space-4);
  border-radius: calc(var(--radius-md) - 3px);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  transition: filter 60ms ease, background 120ms ease, color 120ms ease;
}

.segmented__option.is-selected {
  background: var(--color-gold);
  color: var(--color-on-gold);
}

/* ---------- Checkbox ---------- */

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.checkbox-row__box {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 5px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-on-gold);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.checkbox-row.is-checked .checkbox-row__box {
  background: var(--color-gold);
  border-color: var(--color-gold);
}

.checkbox-row__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.checkbox-row__hint {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--color-text-faint);
  font-weight: 400;
}

/* ---------- Pressed / active state ----------
   Applied globally via js/shared/pressed.js to every [data-pressable]
   element. Uses filter so it works regardless of the element's own
   background/foreground colors. */

[data-pressable] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

[data-pressable].is-pressed,
[data-pressable]:active {
  filter: brightness(0.72);
}

/* ---------- Stat tile ---------- */

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.stat-tile__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-tile__value {
  font-family: var(--font-mono);
  font-size: var(--font-size-xl);
  font-weight: 700;
}

.stat-tile__value.is-gold {
  color: var(--color-gold);
}

.stat-tile__value.is-danger {
  color: var(--color-danger);
}

.stat-tile__value.is-success {
  color: var(--color-success);
}

.stat-tile__sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-faint);
}

/* ---------- Form fields ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.field input,
.field select {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--color-gold);
}

/* Small standalone number input (Auto-Bet's win/loss multiplier) — not
   wrapped in .field, so it needs its own dark-theme styling instead of
   falling back to the browser's default white input. */
.autobet-factor-input {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

.autobet-factor-input:focus {
  outline: none;
  border-color: var(--color-gold);
}

.field__display {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-gold);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  opacity: 0.9;
}

.field-suffix {
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.8;
}

/* ---------- Section header / eyebrow ---------- */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.section-intro {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

/* ---------- Stamp badge ---------- */

.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border: 1px dashed var(--color-gold);
  color: var(--color-gold);
  border-radius: var(--radius-sm);
  transform: rotate(-3deg);
}

.stamp--muted {
  border-color: var(--color-text-faint);
  color: var(--color-text-faint);
}

.stamp--danger {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* ---------- Removable entity card (vehicle, expense, etc.) ---------- */

.entity-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.entity-card__remove {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  color: var(--color-danger);
  font-size: var(--font-size-sm);
  line-height: 1;
  cursor: pointer;
}

.entity-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  align-items: end;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.entity-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

@media (min-width: 640px) {
  .entity-row {
    grid-template-columns: 1.4fr 1fr 1fr auto;
  }
}

.entity-row__remove {
  justify-self: start;
  background: transparent;
  border: none;
  color: var(--color-danger);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: var(--space-2);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 480px) {
  .field-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.empty-state {
  color: var(--color-text-faint);
  font-size: var(--font-size-sm);
  padding: var(--space-6) 0;
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

/* ---------- Results table ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

table.data-table th {
  text-align: right;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

table.data-table th:first-child,
table.data-table td:first-child {
  text-align: left;
}

table.data-table td {
  text-align: right;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  white-space: nowrap;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr.is-cheapest td {
  color: var(--color-text);
  background: rgba(198, 151, 73, 0.08);
}

table.data-table tr.is-cheapest td:first-child {
  color: var(--color-gold);
  font-weight: 700;
}

.table-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
}

/* ---------- Legend ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  justify-content: center;
  margin-top: var(--space-3);
}

.legend__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: var(--space-1);
  vertical-align: middle;
}

/* ---------- List row (biggest expenses etc.) ---------- */

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
}

.list-row:last-child {
  border-bottom: none;
}

.list-row__value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------- Savings badge ---------- */

.savings-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-gold);
  white-space: nowrap;
}

/* ---------- Explanation / formula panel ---------- */

.explain {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.explain summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--color-gold);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}

.explain summary::-webkit-details-marker {
  display: none;
}

.explain summary::after {
  content: "+";
  font-size: 1rem;
  line-height: 1;
  color: var(--color-text-faint);
  transition: transform 150ms ease;
}

.explain[open] summary::after {
  content: "\2212";
}

.explain-body {
  padding: 0 var(--space-5) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.explain-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.explain-item__title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.explain-item__formula {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-gold);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  width: fit-content;
}

.explain-item__text {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ---------- Slider (range input) ---------- */

.slider-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.slider-field__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.slider-field__value {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-gold);
  white-space: nowrap;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-on-gold);
  box-shadow: var(--shadow-card);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-on-gold);
  box-shadow: var(--shadow-card);
}

/* ---------- Chart tooltip (line chart hover/touch) ---------- */

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text);
  white-space: nowrap;
  box-shadow: var(--shadow-card);
}

.chart-tooltip__title {
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.chart-tooltip__row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.chart-tooltip__swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---------- Pause game wide layout (table + sidebar) ---------- */

.pause-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.pause-layout__main,
.pause-layout__side {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

@media (min-width: 1040px) {
  .pause-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .pause-layout__main {
    flex: 1 1 auto;
    min-width: 0;
  }
  .pause-layout__side {
    flex: 0 0 340px;
    width: 340px;
  }
  .pause-layout__side .grid--3col {
    grid-template-columns: 1fr;
  }
}

/* ---------- Roulette table ---------- */

.roulette-table__inner {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.roulette-table__main {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 3px;
  width: 100%;
  cursor: pointer;
  user-select: none;
}

.roulette-chip-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.roulette-chip {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-gold);
  color: var(--color-on-gold);
  border: 2px solid #f2ede4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 800;
  pointer-events: none;
}

.roulette-outside-button {
  position: relative;
}

.roulette-outside-button__chip {
  position: absolute;
  top: -8px;
  right: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-gold);
  color: var(--color-on-gold);
  border: 2px solid #f2ede4;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 800;
}

.roulette-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: clamp(0.55rem, 2.1vw, 0.85rem);
  font-weight: 700;
  color: #f2ede4;
  pointer-events: none;
}

.roulette-cell--red {
  background: #7a2b28;
}

.roulette-cell--black {
  background: #23262c;
}

.roulette-cell--zero {
  flex: 1 1 0;
  background: #1f5c3f;
  border-radius: var(--radius-sm);
}

.roulette-numbers {
  flex: 12 1 0;
  aspect-ratio: 4 / 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
}

.roulette-columns {
  flex: 2 1 0;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
}

.roulette-outside-button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 42px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  border: 2px solid var(--color-border);
  color: var(--color-text);
  font-size: clamp(0.6rem, 1.6vw, var(--font-size-sm));
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: filter 60ms ease, border-color 120ms ease;
}

.roulette-columns .roulette-outside-button {
  height: auto;
}

.roulette-outside-button:hover {
  border-color: var(--color-gold-pressed);
}

.roulette-dozens,
.roulette-outside {
  display: flex;
  gap: 3px;
}

.roulette-dozens .roulette-outside-button,
.roulette-outside .roulette-outside-button {
  flex: 1;
}

.roulette-history {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.roulette-history-box {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: var(--space-2);
  max-height: 220px;
  overflow-y: auto;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.roulette-history__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: #f2ede4;
}

.roulette-history__badge--red {
  background: #7a2b28;
}

.roulette-history__badge--black {
  background: #23262c;
}

.roulette-history__badge--green {
  background: #1f5c3f;
}

.roulette-last-spin {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.roulette-last-spin__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: #f2ede4;
  flex-shrink: 0;
}

/* ---------- Compact stat grid (Pause games) ---------- */

.stat-compact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 var(--space-4);
}

@media (min-width: 640px) {
  .stat-compact-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 960px) {
  .stat-compact-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-compact-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.stat-compact-item__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  overflow-wrap: break-word;
}

.stat-compact-item__value {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 700;
  overflow-wrap: break-word;
}

/* ---------- Placeholder page ---------- */

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  color: var(--color-text-muted);
}

/* ---------- Blackjack table ---------- */

.bj-table {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.bj-seat {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bj-seat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bj-seat__total {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--color-text);
}

.bj-hands {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.bj-hand {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  min-width: 180px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  transition: border-color 120ms ease, opacity 120ms ease;
}

.bj-hand--active {
  border-color: var(--color-gold);
}

.bj-hand--bust,
.bj-hand--lose {
  border-color: var(--color-danger);
}

.bj-hand--win,
.bj-hand--blackjack {
  border-color: var(--color-success);
}

.bj-hand--push {
  border-color: var(--color-border-light);
}

.bj-hand__row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.bj-hand__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.bj-hand__total {
  font-weight: 700;
  color: var(--color-text);
}

.bj-hand__outcome {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bj-hand__outcome--win,
.bj-hand__outcome--blackjack {
  color: var(--color-success);
}

.bj-hand__outcome--lose,
.bj-hand__outcome--bust {
  color: var(--color-danger);
}

.bj-hand__hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-gold);
}

.bj-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 64px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: #f2ede4;
  color: #23262c;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.1;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.bj-card--red {
  color: #a13c36;
}

.bj-card--hidden {
  background: repeating-linear-gradient(45deg, #2a3140, #2a3140 4px, #232833 4px, #232833 8px);
  border: 1px solid var(--color-border-light);
}

.bj-last-round {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

/* ---------- Higher / Lower ---------- */

.hl-board {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.hl-controls {
  flex: 1 1 260px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Empty during the guessing/round-over phases — without this the flex gap
   above it would still reserve space and push the buttons down. */
#bet-amount-field:empty {
  display: none;
}

.hl-stage {
  flex: 2 1 380px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.hl-guess-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: border-color 120ms ease, filter 60ms ease;
}

.hl-guess-btn:hover {
  border-color: var(--color-gold-pressed);
}

.hl-guess-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.hl-guess-btn__arrow {
  font-weight: 800;
}

.hl-guess-btn__prob {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

.hl-payout-preview {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.hl-payout-field {
  flex: 1 1 160px;
}

.hl-stage-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  min-height: 176px;
}

.hl-card-wrap {
  position: relative;
  display: inline-flex;
}

.hl-skip-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border-light);
  color: var(--color-text-muted);
  cursor: pointer;
  font-weight: 800;
  transition: filter 60ms ease, color 120ms ease;
}

.hl-skip-badge:hover {
  color: var(--color-gold);
}

.hl-big-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: 118px;
  height: 168px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: #f2ede4;
  color: #23262c;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.hl-big-card--red {
  color: #a13c36;
}

.hl-big-card--hidden {
  background: repeating-linear-gradient(45deg, #2a3140, #2a3140 4px, #232833 4px, #232833 8px);
  border: 1px solid var(--color-border-light);
}

.hl-big-card--mini {
  width: 64px;
  height: 90px;
  font-size: 1.2rem;
  border-radius: var(--radius-sm);
}

/* Single horizontal line, never wraps — scrolls sideways once it overflows. */
.hl-history {
  display: flex;
  gap: var(--space-3);
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.hl-history-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.hl-history-item__tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.hl-history-item__tag--start {
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
}

.hl-history-item__tag--win {
  background: rgba(79, 140, 130, 0.18);
  color: var(--color-success);
}

.hl-history-item__tag--push {
  background: rgba(198, 151, 73, 0.18);
  color: var(--color-gold);
}

.hl-history-item__tag--lose {
  background: rgba(181, 86, 79, 0.18);
  color: var(--color-danger);
}

/* Small badge between two history cards showing the guess made (▲/▼) and
   whether it won, pushed, or lost. Vertically centered against the taller
   card+tag column next to it. */
.hl-history-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.hl-history-arrow--win {
  background: rgba(79, 140, 130, 0.18);
  color: var(--color-success);
}

.hl-history-arrow--push {
  background: rgba(198, 151, 73, 0.18);
  color: var(--color-gold);
}

.hl-history-arrow--lose {
  background: rgba(181, 86, 79, 0.18);
  color: var(--color-danger);
}

/* ---------- Dice ---------- */

.dice-slider-wrap {
  position: relative;
  padding-top: var(--space-6);
  padding-bottom: var(--space-2);
}

.dice-slider-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.dice-slider-track {
  position: relative;
}

.dice-slider {
  width: 100%;
  cursor: grab;
}

.dice-slider:active {
  cursor: grabbing;
}

input[type="range"].dice-slider::-webkit-slider-runnable-track {
  background: var(--dice-track, var(--color-surface-raised));
}

input[type="range"].dice-slider::-moz-range-track {
  background: var(--dice-track, var(--color-surface-raised));
}

/* Sits exactly on the track's centerline, at the roll's landing spot. */
.dice-roll-dot {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 3px solid currentColor;
  box-shadow: 0 0 0 2px var(--color-surface-raised);
  pointer-events: none;
  z-index: 2;
}

.dice-roll-dot.is-win {
  color: var(--color-success);
}

.dice-roll-dot.is-lose {
  color: var(--color-danger);
}

.dice-roll-marker {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  white-space: nowrap;
  pointer-events: none;
}

.dice-roll-marker.is-win {
  color: var(--color-success);
  border-color: var(--color-success);
}

.dice-roll-marker.is-lose {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.dice-field-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-5);
}

.dice-field-row .field {
  flex: 1 1 140px;
  min-width: 120px;
}

.field-with-icon {
  display: flex;
  gap: var(--space-2);
}

.field-with-icon input {
  flex: 1 1 auto;
  min-width: 0;
}

.dice-swap-btn {
  flex-shrink: 0;
  width: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.dice-swap-btn:hover {
  border-color: var(--color-gold-pressed);
  color: var(--color-gold);
}

.dice-history {
  display: flex;
  gap: var(--space-2);
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.dice-history-chip {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.dice-history-chip.is-win {
  background: rgba(79, 140, 130, 0.18);
  color: var(--color-success);
}

.dice-history-chip.is-lose {
  background: rgba(181, 86, 79, 0.18);
  color: var(--color-danger);
}
