* { box-sizing: border-box; }

html {
  background: #1e0a52;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: #fff;
  font: 1em/1.5 "Avenir Next", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: -60%;
  z-index: -1;
  background: repeating-conic-gradient(from 0deg at 50% 50%, #2a0e6c 0 6deg, #3b1793 6deg 12deg);
  animation: rays 180s linear infinite;
}

@keyframes rays { to { transform: rotate(360deg); } }

#app {
  max-width: 76em;
  margin: 0 auto;
  padding: 1em 1em 2em;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.75em;
}

.brand {
  margin: 0;
  white-space: nowrap;
  font-size: 2.4em;
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  color: #ffd23f;
  text-shadow: 3px 3px 0 #ff2e93;
}

.balance {
  margin: 0;
  white-space: nowrap;
  padding: 0.4em 1.1em;
  border-radius: 999px;
  background: #ffd23f;
  box-shadow: 0 4px 0 #ff9f1c;
  color: #1a0b4d;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.balance #coins { font-size: 24px; }
.balance.pop { animation: pop 0.5s ease-out; }

@keyframes pop {
  30% { transform: scale(1.18) rotate(-2deg); }
  100% { transform: scale(1); }
}

.sound {
  padding: 0.4em 0.75em;
  white-space: nowrap;
  border: 2px solid #d9ccff;
  border-radius: 999px;
  background: #6d3fe0;
  box-shadow: 0 3px 0 #3b1793;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.sound:hover { background: #7d52f0; }

.lab-link {
  padding: 0.4em 0.75em;
  white-space: nowrap;
  border: 2px solid #d9ccff;
  border-radius: 999px;
  background: #6d3fe0;
  box-shadow: 0 3px 0 #3b1793;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.lab-link:hover { background: #7d52f0; }
.sound[aria-pressed="false"] { background: #2a0e6c; color: #d9ccff; }

.hero {
  margin: 1.25em 0 1em;
  text-align: center;
}

h1 {
  margin: 0 auto 0.4em;
  max-width: 44em;
  font-size: 2.5em;
  font-weight: 900;
  line-height: 1.15;
  text-wrap: balance;
}

h2 {
  margin: 0 0 0.4em;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
}

.status {
  min-height: 1.5em;
  margin: 0;
  color: #ffd23f;
  font-weight: 700;
}

.layout {
  display: grid;
  gap: 1.75em;
}

.stage { text-align: center; }

.panel { min-width: 0; width: 100%; }

.wheel-wrap {
  position: relative;
  width: min(100%, 34em, calc(100vh - 9em));
  min-width: 17em;
  margin: 0 auto;
  aspect-ratio: 1;
}

.wheel-wrap.shake { animation: shake 0.7s ease-in-out; }

@keyframes shake {
  15% { transform: translate(-6px, 3px) rotate(-0.6deg); }
  30% { transform: translate(6px, -3px) rotate(0.6deg); }
  45% { transform: translate(-5px, -2px) rotate(-0.4deg); }
  60% { transform: translate(5px, 3px) rotate(0.4deg); }
  80% { transform: translate(-2px, 1px); }
}

.bulbs {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #ff2e93;
  box-shadow: 0 0.8em 2em rgba(0, 0, 0, 0.45), inset 0 0 0 0.35em #ffd23f;
}

.bulb {
  position: absolute;
  width: 3.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0.5em 0.1em #fff;
  animation: twinkle 1.8s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.11s);
}

.bulb:nth-child(3n) { background: #22d3ee; box-shadow: 0 0 0.5em 0.1em #22d3ee; }
.bulb:nth-child(3n + 1) { background: #ffd23f; box-shadow: 0 0 0.5em 0.1em #ffd23f; }

@keyframes twinkle {
  50% { opacity: 0.35; transform: translate(-50%, -50%) scale(0.8); }
}

.is-spinning .bulb {
  animation: chase 0.45s steps(2, end) infinite;
  animation-delay: calc(var(--i) * 0.03s);
}

@keyframes chase {
  0% { opacity: 1; }
  50% { opacity: 0.2; }
  100% { opacity: 1; }
}

.rotor {
  position: absolute;
  inset: 5.5%;
  width: 89%;
  height: 89%;
  border-radius: 50%;
  box-shadow: 0 0 0 0.3em #ffd23f, 0 0.5em 1em rgba(0, 0, 0, 0.4);
  will-change: transform;
}

.orbit {
  position: absolute;
  inset: 5.5%;
  pointer-events: none;
}

.ball {
  position: absolute;
  left: 50%;
  top: 3.4%;
  width: 3.6%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 30%, #d8d4ee 70%, #a39bd0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.pointer {
  position: absolute;
  top: -1.2%;
  left: 50%;
  z-index: 3;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 0.9em solid transparent;
  border-right: 0.9em solid transparent;
  border-top: 1.6em solid #ffd23f;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.5));
}

.spin-core {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 27%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 0.3em solid #fff;
  border-radius: 50%;
  background: #ff9f1c;
  box-shadow: 0 0.35em 0 #c96a00, 0 0 0 0.35em #ff2e93, 0 0 1.5em 0.4em rgba(255, 210, 63, 0.7);
  color: #1a0b4d;
  font-family: inherit;
  cursor: pointer;
  animation: breathe 1.6s ease-in-out infinite;
}

.spin-core:hover { background: #ffd23f; }
.spin-core:active { transform: translate(-50%, calc(-50% + 4px)); }
.spin-core:disabled { animation: none; filter: saturate(0.4); cursor: not-allowed; }

@keyframes breathe {
  50% { box-shadow: 0 0.35em 0 #c96a00, 0 0 0 0.35em #ff2e93, 0 0 2.4em 0.9em rgba(255, 210, 63, 0.95); }
}

.spin-word {
  font-size: 2.1em;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

.spin-sub {
  margin-top: 0.2em;
  font-size: 0.85em;
  font-weight: 800;
}

.win-banner {
  position: absolute;
  top: 17%;
  left: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6em 1.4em;
  transform: translateX(-50%) scale(0);
  border: 0.25em solid #fff;
  border-radius: 1em;
  background: #ff2e93;
  box-shadow: 0 0.4em 0 #b01264, 0 0 2em rgba(255, 46, 147, 0.8);
  pointer-events: none;
  white-space: nowrap;
}

.win-banner.show { animation: banner 2.6s ease-out forwards; }

@keyframes banner {
  0% { transform: translateX(-50%) scale(0) rotate(-8deg); }
  14% { transform: translateX(-50%) scale(1.25) rotate(3deg); }
  24% { transform: translateX(-50%) scale(1) rotate(0); }
  86% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.9); opacity: 0; }
}

.win-tier {
  font-size: 2em;
  font-weight: 900;
  color: #ffd23f;
}

.win-amount {
  font-size: 3em;
  font-weight: 900;
  line-height: 1;
}

.result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75em;
  min-height: 3.5em;
  margin: 1.25em 0 0.5em;
  font-size: 18px;
  font-weight: 800;
}

.ball-chip {
  flex: none;
  display: grid;
  place-items: center;
  width: 3em;
  height: 3em;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #1a0b4d;
  font-variant-numeric: tabular-nums;
}

.ball-chip.red { background: #ff2e63; }
.ball-chip.black { background: #1a0b4d; }
.ball-chip.green { background: #12d6a0; color: #1a0b4d; }

#result-text { text-align: left; }

.history-title {
  margin: 0 0 0.4em;
  color: #d9ccff;
  font-size: 14px;
  font-weight: 700;
}

.history {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35em;
  min-height: 2.2em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history li {
  display: grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
}

.history .red { background: #ff2e63; }
.history .black { background: #1a0b4d; }
.history .green { background: #12d6a0; color: #1a0b4d; }

.streak {
  margin: 0 0 1em;
  padding: 0.5em 1em;
  border-radius: 999px;
  background: #22d3ee;
  color: #1a0b4d;
  font-weight: 900;
  text-align: center;
  animation: pop 0.5s ease-out;
}

.board {
  padding: 1.1em;
  border: 3px solid #d9ccff;
  border-radius: 1.2em;
  background: rgba(26, 11, 77, 0.78);
}

.outside {
  margin-bottom: 0.9em;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.6em;
}

/* Real table: 3 columns (1-2-3, 4-5-6 ...) on phones, horizontal on wide screens */
.numbers {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  gap: 0.4em;
}

.cell.num { grid-row: var(--vr); grid-column: var(--vc); }

.cell {
  position: relative;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.8em;
  padding: 0.3em;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 0.7em;
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.cell.red { background: #ff2e63; }
.cell.black { background: #1a0b4d; }
.cell.zero { grid-row: 1; grid-column: 1 / -1; background: #12d6a0; color: #1a0b4d; }

.cell.color {
  min-height: 3.6em;
  font-size: 19px;
}

.cell small { font-size: 13px; font-weight: 700; }

.cell:hover { transform: translateY(-2px); border-color: #fff; }

.cell[aria-pressed="true"] {
  border-color: #ffd23f;
  box-shadow: 0 0 0 3px #ffd23f, 0 0 1em rgba(255, 210, 63, 0.8);
}

.cell[data-chips]::after,
.spot[data-chips]::after {
  content: attr(data-chips);
  position: absolute;
  top: -0.7em;
  right: -0.5em;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 1.8em;
  height: 1.8em;
  padding: 0 0.25em;
  border: 2px dashed #fff;
  border-radius: 999px;
  background: #ffd23f;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
  color: #1a0b4d;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

/* Chips on a number sit in the middle of it, like on a real table */
.cell.num[data-chips]::after {
  top: 50%;
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
}

/* Split and corner dots */
.spot {
  position: absolute;
  z-index: 3;
  width: 22px;
  height: 22px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.spot:focus-visible { outline: 3px solid #ffd23f; outline-offset: -3px; }

.cell.preview {
  border-color: #ffd23f;
  box-shadow: 0 0 0 2px #ffd23f;
}

.spot[data-chips]::after {
  top: 50%;
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
  min-width: 1.7em;
  height: 1.7em;
}

.spot:disabled { cursor: not-allowed; }
.spot.hit { animation: spotHit 0.55s ease-in-out 4; }

@keyframes spotHit {
  50% { transform: translate(-50%, -50%) scale(1.6); }
}

.cell.hit { animation: hit 0.55s ease-in-out 4; }

@keyframes hit {
  50% { transform: scale(1.18); background: #ffd23f; color: #1a0b4d; }
}

.cell:disabled { opacity: 0.6; cursor: not-allowed; }

.bet-summary {
  min-height: 1.5em;
  margin: 1em 0 0.6em;
  font-weight: 800;
  color: #ffd23f;
}

button { font: inherit; }

.ghost {
  padding: 0.7em 1em;
  border: 3px solid #d9ccff;
  border-radius: 0.8em;
  background: #6d3fe0;
  box-shadow: 0 4px 0 #2a0e6c;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.ghost:hover { background: #7d52f0; }
.ghost:active { transform: translateY(2px); box-shadow: 0 2px 0 #2a0e6c; }
.ghost:disabled { opacity: 0.55; transform: none; }

.primary {
  display: block;
  width: 100%;
  margin-bottom: 0.6em;
  padding: 0.85em 1em;
  border: 0;
  border-radius: 0.8em;
  background: #ffd23f;
  box-shadow: 0 5px 0 #ff9f1c;
  color: #1a0b4d;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #ff9f1c; }

button:disabled { cursor: not-allowed; }

.attention { background: #ffd23f; color: #1a0b4d; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em;
  margin-top: 1em;
}

.bet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em;
}

.rules { margin-top: 1.5em; }
.rules ul { margin: 0; padding-left: 1.2em; color: #d9ccff; }
.rules li { margin-bottom: 0.3em; }

.tools { margin-top: 1.5em; color: #d9ccff; }
.tools summary { cursor: pointer; padding: 0.25em 0; font-weight: 700; }
.hint { margin: 0.5em 0; font-size: 14px; }

code {
  padding: 0 0.3em;
  border-radius: 0.3em;
  background: #1a0b4d;
}

.log {
  max-height: 11em;
  margin: 0.5em 0 0;
  padding: 0.6em 0.6em 0.6em 2em;
  overflow: auto;
  border-radius: 0.6em;
  background: #1a0b4d;
  font-size: 13px;
}

footer {
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 2px solid rgba(255, 255, 255, 0.2);
  color: #d9ccff;
  font-size: 14px;
}

footer p { margin: 0; }

.fx {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

dialog {
  width: min(92vw, 27em);
  padding: 0;
  border: 5px solid #ffd23f;
  border-radius: 1.5em;
  background: #3b1793;
  color: #fff;
  box-shadow: 0 0 3em rgba(255, 46, 147, 0.7);
}

dialog[open] { animation: dialogIn 0.35s ease-out; }

dialog::backdrop { background: rgba(14, 4, 40, 0.8); }

@keyframes dialogIn {
  0% { transform: scale(0.7) rotate(-2deg); opacity: 0; }
  70% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

.sheet { padding: 1.5em; }

.reward { text-align: center; }
.reward p { margin: 0 0 1.1em; font-size: 18px; }

.coin {
  display: grid;
  place-items: center;
  width: 6.5em;
  height: 6.5em;
  margin: 0 auto 1em;
  border: 0.5em solid #ff9f1c;
  border-radius: 50%;
  background: #ffd23f;
  box-shadow: 0 0 2em rgba(255, 210, 63, 0.8);
  color: #1a0b4d;
  font-size: 45px;
  font-weight: 900;
  animation: spinCoin 2.4s ease-in-out infinite;
}

.coin.empty {
  border-color: #d9ccff;
  background: #8a78c9;
  box-shadow: none;
  animation: none;
}

@keyframes spinCoin {
  50% { transform: translateY(-0.5em) scale(1.08) rotate(4deg); }
}

.note { margin: 0 0 1em; color: #d9ccff; }

.options { display: grid; gap: 0.6em; margin-bottom: 0.8em; }

.option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5em;
  padding: 0.85em 1em;
  border: 3px solid rgba(255, 255, 255, 0.45);
  border-radius: 0.8em;
  background: #1a0b4d;
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.option:hover { border-color: #ffd23f; }
.option span { color: #ffd23f; font-weight: 800; }

.dialog-msg { min-height: 1.5em; margin: 0 0 0.8em; color: #ffd23f; font-weight: 700; }

.close { width: 100%; }

/* Tablet and desktop layouts */
@media (min-width: 800px) {
  .hero { text-align: left; }
  h1 { margin-left: 0; }

  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5em;
    align-items: start;
  }

  .stage {
    position: sticky;
    top: 1em;
  }

  .cell { min-height: 2.8em; }
}

@media (min-width: 1100px) {
  #app { padding: 1.5em 2em 3em; }

  .layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 3em;
  }

  .cell { min-height: 3.2em; font-size: 17px; }

  .numbers {
    grid-template-columns: minmax(2.2em, 0.8fr) repeat(12, minmax(0, 1fr));
    gap: 0.3em;
  }

  .cell.num { grid-row: var(--hr); grid-column: var(--hc); padding: 0.2em; font-size: 16px; }
  .cell.zero { grid-row: 1 / 4; grid-column: 1; }
  .spot { width: 18px; height: 18px; }
}

/* Keep the header and wheel legible on smaller screens */
@media (max-width: 799px) {
  .brand { font-size: 28px; }
  h1 { font-size: 28px; }
  .spin-word { font-size: 28px; }
  .spin-sub { font-size: 12px; }
  .win-tier { font-size: 28px; }
  .win-amount { font-size: 40px; }
  .wheel-wrap { min-width: 0; }
}

/* Phones: logo and coins on the first row, simulator and sound below */
@media (max-width: 600px) {
  .top { flex-wrap: wrap; row-gap: 0.7em; }
  .top-right { display: contents; }
  .brand { order: 1; }
  .balance { order: 2; }
  .top::after { content: ""; order: 3; flex-basis: 100%; }
  .lab-link, .sound { order: 4; flex: 1 1 0; text-align: center; }
}

@media (max-width: 420px) {
  .brand { font-size: 24px; }
  h1 { font-size: 24px; }
  .top-right { gap: 0.35em; }
  .balance { padding: 0.4em 0.6em; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .bulb, .spin-core, .coin { animation: none; }
}
