:root {
  color-scheme: light;
  --bg: #f5f0e8;
  --surface: #fffdfa;
  --surface-strong: #f9efe0;
  --ink: #27231f;
  --muted: #71675c;
  --line: #ded0bd;
  --gold: #f2b92f;
  --gold-deep: #b97805;
  --silver: #cfd4dc;
  --silver-deep: #7a8390;
  --teal: #137c72;
  --red: #b43b2f;
  --shadow: 0 20px 42px rgba(52, 39, 23, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(242, 185, 47, 0.16), transparent 32rem),
    linear-gradient(180deg, #fffaf2, var(--bg));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 780;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--teal);
  box-shadow: 0 10px 22px rgba(19, 124, 114, 0.14);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(19, 124, 114, 0.32);
  outline-offset: 2px;
}

.game-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 46px;
  display: grid;
  gap: 18px;
}

.game-header,
.stage-panel,
.stats-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: var(--shadow);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
}

.eyebrow,
.game-header h1,
.game-header p,
.result-strip p,
.probability-panel p {
  margin: 0;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 860;
  letter-spacing: 0;
  text-transform: uppercase;
}

.game-header h1 {
  margin-top: 4px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.lede {
  margin-top: 6px;
  color: var(--muted);
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.14fr) minmax(320px, 0.86fr);
  gap: 18px;
  align-items: start;
}

.stage-panel,
.stats-panel {
  padding: 18px;
}

.box-stage {
  min-height: 340px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(39, 35, 31, 0.04), rgba(39, 35, 31, 0.08)),
    #ebe7e2;
}

.box-card {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.bar-stack {
  position: relative;
  width: 92px;
  height: 72px;
}

.bar {
  position: absolute;
  left: 8px;
  width: 74px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(39, 35, 31, 0.55);
  border-radius: 6px 10px 6px 10px;
  color: rgba(0, 0, 0, 0);
  transform: skewX(-18deg);
}

.bar:first-child {
  top: 4px;
}

.bar:last-child {
  top: 34px;
}

.bar.gold {
  background: linear-gradient(135deg, #ffe088, var(--gold) 62%, var(--gold-deep));
}

.bar.silver {
  background: linear-gradient(135deg, #f8fbff, var(--silver) 62%, var(--silver-deep));
}

.box-visual {
  width: 100%;
  min-height: 154px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  border: 3px solid #24211d;
  border-radius: 6px;
  background:
    linear-gradient(115deg, #ffffff 0 58%, #e5e0da 58%),
    #ffffff;
}

.slot {
  width: 68px;
  height: 14px;
  border-radius: 999px;
  background: #12100f;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.18);
}

.box-visual strong {
  font-size: 24px;
  letter-spacing: 0;
}

.result-strip {
  min-height: 90px;
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
}

.result-strip > div:first-child {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
}

.result-strip p {
  grid-column: 2;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(19, 124, 114, 0.12);
}

.result-strip[data-state="first-silver"] .status-dot {
  background: var(--silver-deep);
}

.result-strip[data-state="lose"] .status-dot {
  background: var(--red);
}

.draw-preview {
  display: flex;
  gap: 8px;
}

.draw-token {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(39, 35, 31, 0.45);
  border-radius: 8px;
  font-weight: 900;
}

.draw-token.gold {
  background: #ffe6a3;
  color: #6f4500;
}

.draw-token.silver {
  background: #eef1f5;
  color: #4d5661;
}

.draw-token.unknown {
  background: #fffdf9;
  color: var(--muted);
}

.control-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.primary {
  border-color: #99cec6;
  background: #e4f7f3;
  color: #0f665f;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 2px 0 0;
  font-size: 26px;
  letter-spacing: 0;
}

.stats-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid div,
.probability-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  padding: 12px;
}

.stats-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.stats-grid dd {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.probability-panel {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.probability-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.probability-panel strong {
  font-size: clamp(34px, 6vw, 48px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.probability-panel meter {
  width: 100%;
  height: 16px;
}

.probability-panel p {
  color: var(--muted);
}

.probability-panel .theory {
  color: var(--teal);
  font-weight: 820;
}

.round-log {
  min-height: 122px;
  max-height: 230px;
  margin: 14px 0 0;
  padding: 0 0 0 22px;
  overflow-y: auto;
  color: var(--muted);
  scrollbar-gutter: stable;
}

.round-log li + li {
  margin-top: 6px;
}

@media (max-width: 920px) {
  .game-header,
  .game-grid {
    grid-template-columns: 1fr;
  }

  .game-header {
    display: grid;
  }
}

@media (max-width: 680px) {
  .game-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .game-header,
  .stage-panel,
  .stats-panel {
    padding: 14px;
  }

  .box-stage,
  .control-row,
  .stats-grid,
  .result-strip {
    grid-template-columns: 1fr;
  }

  .box-stage {
    min-height: auto;
  }

  .control-row button {
    width: 100%;
    justify-content: center;
  }
}
