:root {
  color-scheme: dark;
  --felt: #0d6b43;
  --felt-deep: #07452e;
  --ink: #f7f1df;
  --muted: #b8c6ba;
  --line: rgba(255, 255, 255, 0.18);
  --panel: #151a1e;
  --panel-soft: #1d2528;
  --red: #c82d2d;
  --black: #111316;
  --green: #16804e;
  --gold: #d7ae52;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 25% 10%, rgba(215, 174, 82, 0.18), transparent 28rem),
    radial-gradient(circle at 82% 26%, rgba(102, 185, 208, 0.12), transparent 24rem),
    linear-gradient(140deg, #061713 0%, #102321 46%, #161719 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 0 14px;
  background: #242c2f;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.34);
  background: #303a3e;
}

button.primary {
  border-color: #efcf78;
  background: #d7ae52;
  color: #191305;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 8px 10px;
  background: #101618;
  color: var(--ink);
}

.app-shell {
  width: 100%;
  margin: 0 auto;
  padding: 14px 18px 34px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(360px, 1.15fr);
  gap: 18px;
  min-height: 440px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(130deg, rgba(13, 107, 67, 0.94), rgba(9, 55, 43, 0.94));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.wheel-panel {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
  min-height: 420px;
  padding: 24px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 36px),
    linear-gradient(145deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.22));
}

.wheel {
  position: relative;
  width: min(72vw, 330px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    conic-gradient(from -4deg, #16804e 0 9.73deg, transparent 9.73deg 360deg),
    repeating-conic-gradient(from 5.73deg, #b92525 0 9.73deg, #101112 9.73deg 19.46deg);
  box-shadow: inset 0 0 0 12px #6e4522, inset 0 0 0 24px #e1ba66, 0 26px 42px rgba(0, 0, 0, 0.36);
  transition: transform 760ms cubic-bezier(0.2, 0.78, 0.16, 1);
}

.wheel::before {
  content: "";
  position: absolute;
  inset: 58px;
  border-radius: 50%;
  background: radial-gradient(circle, #d8bd7b 0 22%, #6a341a 23% 34%, #111 35% 100%);
  border: 7px solid #d7ae52;
}

.wheel-ring {
  position: absolute;
  inset: 24px;
  border: 2px dashed rgba(255, 255, 255, 0.32);
  border-radius: 50%;
}

.wheel-pocket {
  position: relative;
  z-index: 2;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  border: 4px solid #f5dda2;
  font-size: 1.65rem;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.36);
}

.result-strip {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.label,
.eyebrow,
label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.chip {
  min-width: 54px;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  font-weight: 900;
}

.chip.red { background: var(--red); }
.chip.black { background: var(--black); }
.chip.green,
.chip.neutral { background: var(--green); }

.controls-panel {
  padding: 26px;
  background: rgba(11, 16, 18, 0.74);
}

.eyebrow {
  margin: 0 0 5px;
  color: #efcf78;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1 {
  max-width: 680px;
  margin: 0 0 20px;
  font-size: clamp(2rem, 4vw, 4.35rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metrics-grid article {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
}

.metrics-grid span,
.stats-list span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metrics-grid strong {
  font-size: 1.25rem;
}

.bet-form {
  display: grid;
  gap: 13px;
}

.form-row.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.simulation-options {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 150px) minmax(220px, 1.1fr);
  gap: 12px;
  align-items: end;
}

.toggle-label {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.toggle-label input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

label {
  display: grid;
  gap: 7px;
}

.chip-area,
.active-bets-panel {
  display: grid;
  gap: 8px;
}

.chip-rack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip-button,
.table-chip {
  width: 54px;
  height: 54px;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 4px dashed rgba(20, 26, 28, 0.48);
  background:
    radial-gradient(circle, #fff8d7 0 34%, #d7ae52 35% 62%, #7d2424 63% 100%);
  color: #151006;
  font-size: 0.8rem;
  font-weight: 900;
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.28);
}

.chip-button:nth-child(2) {
  background: radial-gradient(circle, #fff8d7 0 34%, #66b9d0 35% 62%, #15485a 63% 100%);
}

.chip-button:nth-child(3) {
  background: radial-gradient(circle, #fff8d7 0 34%, #d7ae52 35% 62%, #7d2424 63% 100%);
}

.chip-button:nth-child(4) {
  background: radial-gradient(circle, #fff8d7 0 34%, #80cb82 35% 62%, #14572b 63% 100%);
}

.chip-button:nth-child(5) {
  background: radial-gradient(circle, #fff8d7 0 34%, #f2a7b2 35% 62%, #7a1934 63% 100%);
}

.chip-button:nth-child(6) {
  background: radial-gradient(circle, #fff8d7 0 34%, #c8c8d4 35% 62%, #303441 63% 100%);
}

.chip-button.selected {
  outline: 3px solid #fff1a7;
  outline-offset: 3px;
}

.active-bets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.active-bets span {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 0.8rem;
}

.active-bets strong {
  color: var(--ink);
}

.actions {
  display: grid;
  grid-template-columns: 1fr minmax(100px, 128px) repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.rounds-label {
  min-width: 0;
}

.table-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 1400px) {
  .table-section {
    overflow-x: auto;
  }
}

.roulette-table {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 1280px;
  grid-template-columns: repeat(14, minmax(78px, 1fr));
  grid-template-rows: repeat(5, 84px);
  gap: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(145deg, #0d764a, var(--felt-deep));
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.045), 0 18px 46px rgba(0, 0, 0, 0.28);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 0;
  color: #fff;
  font-weight: 900;
  font-size: 1.15rem;
  user-select: none;
  z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.24);
}

.cell:hover {
  border-color: #fff1a7;
  box-shadow: inset 0 0 0 2px rgba(255, 241, 167, 0.5);
}

.cell.zero {
  grid-column: 1;
  background: var(--green);
}

.cell.red { background: var(--red); }
.cell.black { background: var(--black); }
.cell.zero,
.cell.red,
.cell.black {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.62);
}

.cell.bet-zone {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 0.96rem;
}

.cell.bet-zone.red { background: rgba(200, 45, 45, 0.72); }
.cell.bet-zone.black { background: rgba(17, 19, 22, 0.82); }

.cell.column-bet {
  font-size: 0.86rem;
}

.cell.has-bet {
  z-index: 3;
}

.bet-spot {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  z-index: 5;
  width: 38px;
  height: 38px;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 0;
  font-weight: 900;
  line-height: 1;
  opacity: 1;
  box-shadow: none;
}

.bet-spot::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 232, 145, 0.78);
  box-shadow: 0 0 0 1px rgba(38, 28, 8, 0.3);
}

.bet-spot:hover {
  background: rgba(255, 241, 167, 0.16);
  border-color: rgba(255, 246, 190, 0.78);
  color: #fff8d7;
  font-size: 0.62rem;
  box-shadow: 0 0 0 4px rgba(255, 241, 167, 0.16), 0 6px 16px rgba(0, 0, 0, 0.42);
}

.bet-spot:hover::after,
.bet-spot.has-bet::after {
  content: none;
}

.bet-spot.has-bet {
  border-color: transparent;
  background: transparent;
}

.street-spot,
.sixline-spot {
  width: 42px;
  height: 38px;
  border-radius: 50%;
}

.zero-spot {
  width: 38px;
  height: 38px;
}

.table-chip {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 38px;
  height: 38px;
  border-width: 3px;
  font-size: 0.58rem;
  pointer-events: none;
  z-index: 6;
}

.bet-spot .table-chip {
  inset: 50% auto auto 50%;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  border-width: 3px;
  font-size: 0.52rem;
}

.history-panel {
  min-height: 360px;
  width: min(100%, 640px);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(13, 17, 19, 0.92);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.2rem;
}

.stats-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.stats-list span {
  display: grid;
  gap: 4px;
  padding: 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.stats-list strong {
  color: var(--ink);
  font-size: 1rem;
}

.history-list {
  display: grid;
  gap: 7px;
  max-height: 382px;
  margin: 0;
  padding-left: 20px;
  overflow: auto;
}

.history-list li {
  padding: 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
}

.win { color: #7fe09a; }
.loss { color: #ff9a91; }

@media (max-width: 980px) {
  .stage,
  .table-section {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-section { margin-bottom: 20px; }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 9px 9px 28px;
  }

  .controls-panel,
  .wheel-panel {
    padding: 16px;
  }

  .form-row.split,
  .simulation-options,
  .actions {
    grid-template-columns: 1fr;
  }

  .roulette-table {
    min-width: 980px;
    grid-template-columns: repeat(14, 70px);
    grid-template-rows: repeat(5, 68px);
    gap: 0;
    padding: 0;
    overflow-x: auto;
  }

  .cell {
    font-size: 0.84rem;
  }

  .table-chip {
    width: 28px;
    height: 28px;
    font-size: 0.5rem;
  }

  .bet-spot {
    width: 34px;
    height: 34px;
    font-size: 0.54rem;
  }

  .street-spot,
  .sixline-spot {
    width: 36px;
    height: 34px;
  }

  .bet-spot .table-chip {
    width: 29px;
    height: 29px;
    font-size: 0.48rem;
  }
}
