:root {
  color-scheme: light;
  --paper: #f4efe3;
  --cream: #fffbef;
  --ink: #352a33;
  --faded-ink: #645b5c;
  --rule: #d4cabc;
  --copper: #9b4935;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 50% 20%, #fffdf58c, transparent 70%),
    var(--paper);
}
body::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  opacity: .095;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.64' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath filter='url(%23g)' opacity='.8' d='M0 0h160v160H0z'/%3E%3C/svg%3E");
  background-size: 142px 142px;
}
button, input {
  font: inherit;
  color: inherit;
}
button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled, input:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid #39758a;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
svg {
  display: block;
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.game {
  position: relative;
  width: min(100%, 900px);
  margin-inline: auto;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.topbar, .brand, .utility, .heading, .funds, .place, .rule-heading {
  display: flex;
  align-items: center;
}
.topbar { gap: 6px; }
.brand {
  min-height: 44px;
  gap: 6px;
  margin-left: -4px;
  padding: 0 5px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  white-space: nowrap;
}
.brand svg { width: 20px; height: 20px; stroke-width: 1.8; }
.topbar-line {
  flex: 1;
  height: 1px;
  margin: 0 8px;
  background: var(--rule);
}
.utility {
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  gap: 7px;
  padding: 0 7px;
  border-radius: 7px;
  color: var(--faded-ink);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}
.utility svg { width: 19px; height: 19px; }
.help-button { margin-right: -4px; }
#sound[aria-pressed="true"] .sound-off, #sound:not([aria-pressed="true"]) .sound-on { display: none; }
.heading {
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin: 12px 0 17px;
}
h1, h2 { font-family: var(--serif); }
h1 {
  margin: 0;
  font-size: clamp(35px, 9vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.wallet {
  flex: 0 0 auto;
  padding-bottom: 1px;
  text-align: right;
}
.field-label {
  display: block;
  color: var(--faded-ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .085em;
  text-transform: uppercase;
}
.funds {
  justify-content: flex-end;
  gap: 5px;
  margin-top: 3px;
  line-height: 1;
  font-size: clamp(18px, 4vw, 24px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
}
.funds svg { width: 18px; height: 18px; color: #916042; }
.funds strong { font-weight: 700; }
.stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1.4;
  overflow: hidden;
  border-radius: 13px;
  background: #d4e5e3;
  box-shadow: 0 1px 2px #372d361e, 0 9px 24px -17px #3d3136a6;
}
.stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
  inset: 0;
  border: 1px solid #4939363d;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px #fff9e850;
}
#scene {
  display: block;
  width: 100%;
  height: 100%;
}
.scene-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.place, .multiplier {
  background: #fffaedf0;
  border: 1px solid #49393642;
  color: var(--ink);
  box-shadow: 0 2px 3px #4a43561a;
}
.place {
  align-self: flex-start;
  gap: 5px;
  min-height: 26px;
  padding: 3px 8px 3px 6px;
  max-width: 66%;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 650;
}
.place svg { width: 16px; height: 16px; color: #775344; }
.multiplier {
  display: block;
  padding: 3px 9px 4px;
  border-radius: 6px;
  font: 700 clamp(22px, 4vw, 32px)/1.02 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -.045em;
  white-space: nowrap;
}
.console { padding-top: 15px; }
.daylight:not(:empty) { padding-left: 6px; margin-left: 1px; border-left: 1px solid #97867a80; }
.round-line { display: flex; align-items: center; gap: 7px; margin: 0 1px 9px; font-size: 14px; color: var(--faded-ink); font-variant-numeric: tabular-nums; }
.round-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #76746b; }
.console:has(.action[data-mode="cash"]) .round-dot { background: #306b61; }
.controls {
  display: grid;
  grid-template-columns: minmax(114px, .82fr) minmax(0, 1.38fr);
  gap: 10px;
  align-items: end;
}
.stake-control { min-width: 0; }
.stake-control .field-label { margin: 0 0 5px 2px; }
.stepper {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  border: 1px solid #a99f95;
  border-radius: 8px;
  background: #fcf9ef;
}
.stepper button, .stepper input {
  min-width: 0;
  height: 44px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  text-align: center;
}
.stepper button {
  padding: 0;
  color: var(--faded-ink);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}
.stepper input {
  width: 100%;
  padding: 0;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper :disabled { opacity: .48; }
.action {
  display: grid;
  place-content: center;
  min-height: 46px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #7e3a2b;
  border-radius: 8px;
  color: #fff9ed;
  background: linear-gradient(175deg, #a95039, #934431);
  box-shadow: inset 0 1px #ffd8ad38, 0 2px 0 #6e392823;
  font-size: clamp(15px, 3.8vw, 19px);
  font-weight: 700;
  line-height: 1.16;
  text-wrap: balance;
}
.action:active:not(:disabled) { transform: translateY(1px); }
.action:disabled { opacity: .65; }
.action[data-mode="cash"]:not(:disabled) {
  border-color: #345957;
  background: #396865;
}
.status {
  min-height: 2.7em;
  margin: 10px 1px 0;
  color: var(--faded-ink);
  font-size: 13px;
  line-height: 1.35;
}
.refill {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--copper);
  background: var(--cream);
  font-size: 13px;
  font-weight: 650;
}
.history {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  margin: 12px 0 0;
  padding: 10px 0 3px;
  border-top: 1px solid var(--rule);
  list-style: none;
  scrollbar-width: thin;
}
.history:empty { display: none; }
.history > * {
  flex: none;
  padding: 3px 7px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--faded-ink);
  font-size: 11px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.history [data-kind="bank"] { border-color: #abbcaf; color: #2e5c50; }
.history [data-kind="crash"] { border-color: #d4b6aa; color: #874634; }
dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 40px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #938374;
  border-radius: 15px;
  background: #fcf7eb;
  color: var(--ink);
  box-shadow: 0 16px 60px #241e3152;
}
dialog::backdrop { background: #28232dd1; }
.rule-sheet { padding: 18px 22px 21px; }
.rule-heading { justify-content: space-between; gap: 10px; }
.rule-heading h2 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -.035em; }
.rule-heading .utility { margin-right: -9px; }
.rule-list { margin: 14px 0 0; padding-left: 1.5em; font-size: 15px; line-height: 1.48; }
.rule-list li { margin: 0 0 12px; padding-left: 3px; }
.rule-list li::marker { font-family: var(--serif); font-weight: 700; color: var(--copper); }
.demo-note { margin: 16px 0 0; padding-top: 13px; border-top: 1px solid var(--rule); color: var(--faded-ink); font-size: 13px; line-height: 1.45; }

@media (hover: hover) {
  .brand:hover { color: var(--copper); }
  .utility:hover, .stepper button:hover:not(:disabled) { background: #d9cfba60; color: var(--ink); }
  .action:hover:not(:disabled) { background: #8f4030; }
  .refill:hover { border-color: var(--copper); }
}
@media (min-width: 600px) {
  .game { padding: 16px 30px 25px; }
  .topbar { gap: 10px; }
  .topbar-line { margin: 0 14px; }
  .heading { margin: 14px 0 20px; }
  .stage { aspect-ratio: 1.65; border-radius: 16px; }
  .scene-hud { top: 17px; left: 17px; right: 17px; }
  .place { min-height: 30px; padding: 4px 10px 4px 8px; font-size: 12px; }
  .place svg { width: 18px; height: 18px; }
  .multiplier { padding: 4px 13px 6px; }
  .console { padding-top: 17px; }
  .controls { grid-template-columns: minmax(180px, .75fr) minmax(0, 1.25fr); gap: 16px; }
  .stepper { grid-template-columns: 48px minmax(0, 1fr) 48px; }
  .stepper button, .stepper input { height: 50px; }
  .action { min-height: 52px; }
  .field-label { font-size: 11px; }
  .funds svg { width: 21px; height: 21px; }
}
@media (min-width: 740px) and (max-height: 800px) {
  .game { width: min(100%, max(680px, calc((100svh - 235px) * 1.65 + 60px))); padding-top: 8px; }
  .heading { margin: 6px 0 14px; }
  h1 { font-size: 50px; }
  .console { padding-top: 11px; }
}
@media (max-width: 379px) {
  h1 { font-size: clamp(27px, 8.25vw, 31px); }
  .wallet .funds { font-size: 16px; gap: 3px; }
  .wallet .funds svg { width: 15px; height: 15px; }
}
@media (max-width: 349px) {
  .game { padding-inline: 12px; }
  .heading { margin-block: 8px 13px; }
  .scene-hud { top: 9px; left: 9px; right: 9px; }
  .controls { gap: 7px; }
  .stepper { grid-template-columns: 31px minmax(0, 1fr) 31px; }
}
