* { box-sizing: border-box }

:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  color: #f3f2e8;
  background: #191713;
  --muted: #cccac3;
  --amber: #ffcb81;
  --edge: #585653;
}

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden }
main {
  height: 100%;
  position: relative;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible { outline: 2px solid #a2fbef; outline-offset: 2px; z-index: 1 }
button:disabled { cursor: default }

.scene { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: transparent }
.scene:focus-visible { outline-offset: -3px }
canvas { display: block; width: 100%; height: 100% }

.controls {
  --gutter: max(18px, env(safe-area-inset-left), env(safe-area-inset-right));
  position: absolute;
  inset-inline: 0;
  bottom: max(17px, calc(env(safe-area-inset-bottom) + 8px));
  width: min(520px, calc(100% - var(--gutter) - var(--gutter)));
  margin-inline: auto;
}
.hud {
  display: grid;
  grid-template-columns: 44px minmax(78px, 1fr) minmax(75px, 125px) 76px 46px;
  align-items: center;
  gap: 6px;
  min-height: 65px;
  padding: 3px 6px;
  border: 1px solid #161616;
  border-radius: 4px;
  background: #242423f5;
  box-shadow: 0 3px 12px #000a, inset 0 1px 0 #ffffff18;
}
.menu-button, .auto-button {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid #3e3d3a;
  border-radius: 3px;
  background: #232322;
}
.menu-button { border-color: transparent; background: transparent }
.hud button:not(:disabled):hover, .reset-button:not(:disabled):hover { background-color: #3a3936 }
.hud button:not(:disabled):active { filter: brightness(1.24) }

.menu-icon, .menu-icon::before, .menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}
.menu-icon { position: relative }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0 }
.menu-icon::before { top: -6px }
.menu-icon::after { top: 6px }

.readout { min-width: 0; display: grid; gap: 3px }
.balance { padding-inline: clamp(1px, 1.5vw, 13px) 0 }
.label { color: var(--muted); font-size: 10px; line-height: 1.12; letter-spacing: .075em; text-transform: uppercase }
.amount { display: block; font-weight: 720; font-size: clamp(15px, 3.8vw, 22px); line-height: 1; font-variant-numeric: tabular-nums }
.bet {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  min-height: 56px;
  overflow: clip;
  padding-inline-start: 9px;
  border: 1px solid #0c0c0c;
  border-radius: 3px;
  background: #161616;
}
.bet::after { content: ""; position: absolute; bottom: 0; left: 0; width: 22px; height: 2px; background: #d7d4ca; pointer-events: none }
.bet-steps { display: grid; border-inline-start: 1px solid #333231 }
.bet-steps button {
  display: grid;
  place-items: center;
  min-height: 27px;
  padding: 0;
  border: 0;
  background: #242423;
}
.bet-steps button:first-child { border-bottom: 1px solid #383735 }
.bet-steps button:focus-visible { outline-offset: -3px }
.bet-steps button:disabled .chevron { opacity: .3 }
.chevron { width: 8px; height: 8px; border-top: 2px solid; border-right: 2px solid; transform: translateY(2px) rotate(-45deg) }
.chevron.down { transform: translateY(-2px) rotate(135deg) }

.spin-button {
  place-self: center;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 5px;
  width: 76px;
  height: 76px;
  margin-block: -8px;
  padding: 0 0 2px;
  border: 2px solid #111;
  border-radius: 50%;
  background: #282827;
  color: #fffdf2;
  box-shadow: inset 0 0 0 1px #6e6a61, 0 2px 7px #0009;
  font-size: 9px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.spin-button:disabled { opacity: .64 }
.spin-icon {
  display: block;
  position: relative;
  width: 34px;
  height: 34px;
  border: 4px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  transform: rotate(-29deg);
}
.spin-icon::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -6px;
  border: 6px solid transparent;
  border-inline-start-color: currentColor;
  border-inline-end-width: 0;
  transform: rotate(54deg);
}
.spin-button[aria-busy="true"] .spin-icon { animation: revolve 1s linear infinite }
@keyframes revolve { to { transform: rotate(331deg) } }

.auto-button {
  align-content: center;
  gap: 2px;
  padding: 0 3px 4px;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .075em;
  text-transform: uppercase;
}
.auto-icon { font-size: 22px; line-height: 22px }
.auto-button[aria-pressed="true"] { color: var(--amber); border-color: #bc9b63; background: #3b3424 }
.auto-button:disabled { opacity: .5 }

.hud-notice, #message {
  position: absolute;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 24px);
  transform: translateX(-50%);
  box-sizing: border-box;
  margin: 0;
  padding: 7px 12px;
  border-radius: 5px;
  background: #18201cf5;
  color: #f6e6c8;
  font-size: 13px;
  text-align: center;
}
.hud-notice { bottom: calc(100% + 3px) }
#message { top: 14px; box-shadow: 0 0 18px #0006 }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }

dialog {
  width: min(360px, calc(100% - 30px));
  padding: 18px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: #202923;
  color: inherit;
  box-shadow: 0 10px 32px #0007;
}
dialog::backdrop { background: #060a08b8 }
dialog header { display: flex; justify-content: space-between; align-items: center; gap: 16px }
dialog h2 { margin: 0; font-size: 18px }
dialog p { color: var(--muted); font-size: 14px; line-height: 1.5 }
.close-button, .reset-button {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--edge);
  border-radius: 5px;
  background: #252f29;
}
.close-button { width: 42px; font-size: 23px }
.reset-button:disabled { opacity: .55 }

@media (max-width: 420px) {
  .hud { grid-template-columns: 39px minmax(0, 1fr) minmax(69px, 92px) 61px 42px; gap: 4px; padding-inline: 5px; min-height: 61px }
  .spin-button { width: 60px; height: 60px; gap: 3px }
  .spin-icon { width: 27px; height: 27px; border-width: 3px }
  .label { font-size: 9px; letter-spacing: .035em }
  .bet { padding-inline-start: 5px; grid-template-columns: minmax(0, 1fr) 26px }
}
@media (prefers-reduced-motion: reduce) {
  .spin-button[aria-busy="true"] .spin-icon { animation: none }
}
@media (max-width: 360px) {
  .hud { grid-template-columns: 36px minmax(45px, 1fr) minmax(64px, 1fr) 52px 38px; gap: 3px; padding-inline: 4px }
  .spin-button { width: 52px; height: 52px }
  .bet .amount { font-size: 14px }
}
@media (max-width: 300px) {
  .controls { --gutter: 10px }
  .hud { grid-template-columns: 32px minmax(40px, 1fr) minmax(60px, 1fr) 48px 34px }
  .spin-button { width: 48px; height: 48px }
}
@media (max-height: 440px) {
  .controls { bottom: max(9px, calc(env(safe-area-inset-bottom) + 5px)) }
  .hud { min-height: 56px }
  .bet { min-height: 48px }
  .bet-steps button { min-height: 23px }
  .spin-button { max-width: 62px; max-height: 62px }
}
