:root {
  color-scheme: dark;
  --ink: #0b100e;
  --panel: #141e19;
  --surface: #1c2720;
  --line: #34453a;
  --paper: #f1f3e9;
  --muted: #b2c0b6;
  --green: #86dda0;
  --gold: #f0c875;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 12px; }
body { margin: 0; background: var(--ink); color: var(--paper); font: 1rem/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
a { color: inherit; text-underline-offset: .22em; }
a:hover { color: var(--green); }
button, input, select, textarea { font: inherit; }
button, input, select, textarea { border: 1px solid #546958; border-radius: 7px; background: var(--surface); color: var(--paper); }
button, select, input { min-height: 44px; }
button { cursor: pointer; padding: .5em .85em; font-weight: 650; }
button:enabled:hover { background: #2c3c30; border-color: #8fa68e; }
button:disabled { opacity: .52; cursor: default; }
select, input, textarea { max-width: 100%; padding: .55rem .75rem; }
select { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link { position: absolute; top: -120px; z-index: 2; padding: 14px; background: var(--panel); }
.skip-link:focus { top: 0; }
.wrap { width: min(1100px,calc(100% - 48px)); margin-inline: auto; }
.site-header, footer { border-bottom: 1px solid var(--line); }
.nav, .nav div, footer>.wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.nav { min-height: 68px; }
.nav a, .brand, .breadcrumb a { text-decoration: none; }
.nav div a { color: var(--muted); font-size: .92rem; padding-block: 12px; }
.nav div a:hover, .breadcrumb a:hover { color: var(--green); text-decoration: underline; }
.brand { font-weight: 850; letter-spacing: .05em; }
main { padding: 24px 0 65px; }
.breadcrumb { color: var(--muted); display: flex; gap: .65rem; align-items: center; font-size: .84rem; }
.breadcrumb span[aria-hidden] { color: #79897c; }
.hero { margin: 18px 0 26px; }
h1, h2, h3, p, dl, ol { margin: 0; }
h1, h2 { letter-spacing: -.045em; line-height: 1.08; }
h1 { font-size: clamp(2.1rem,5.5vw,4.4rem); }
h1 span { color: #b6c9b9; white-space: nowrap; }
.hero p { max-width: 77ch; color: var(--muted); margin-top: 12px; font-size: 1.06rem; }
h2 { font-size: clamp(1.5rem,3.4vw,2.25rem); }
.simulator { border: 1px solid #4d6252; border-radius: 16px; overflow: hidden; background: var(--panel); }
.sim-settings, .sim-foot, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sim-settings { padding: 12px 24px; border-bottom: 1px solid var(--line); }
.sim-settings label { font-size: .93rem; font-weight: 650; }
.sim-body { display: grid; grid-template-columns: minmax(0,1.08fr) minmax(0,1fr); }
.stage { min-height: 295px; position: relative; overflow: hidden; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 55%,#3c5340 0%,#223c30 53%,#152a22 100%); border-right: 1px solid var(--line); }
.chart-marks { position: absolute; width: 100%; height: 100%; inset: 0; }
#trial-art { z-index: 1; width: min(72%,350px); height: 240px; object-fit: contain; filter: drop-shadow(4px 12px 12px #0b191aaa); }
.stage .token { position: absolute; width: 22%; max-width: 95px; height: auto; left: 59%; top: 14%; z-index: 1; filter: drop-shadow(0 0 10px #f7ce6888); display: none; }
.stage[data-state="found"] .token { display: block; }
.stage[data-state="animating"] #trial-art { animation: rattle .32s ease-in-out infinite alternate; transform-origin: center 80%; }
@keyframes rattle { 0% { transform: rotate(-2deg); } 60% { transform: translateY(-3px) rotate(1deg); } 100% { transform: rotate(2deg); } }
.sim-console { padding: clamp(16px,2.4vw,32px); }
.metrics { display: grid; grid-template-columns: auto auto; align-items: end; gap: 12px; margin-bottom: 24px; }
.metrics div { min-width: 0; }
.metrics span, .odds dt { display: block; font-size: .8rem; color: var(--muted); }
.metrics strong, .odds dd { display: block; font-variant-numeric: tabular-nums; font-weight: 740; line-height: 1.15; }
#trial-count { font-size: clamp(1.6rem,3.2vw,2.7rem); overflow-wrap: anywhere; }
#chance-per-chest { font-size: clamp(1rem,1.7vw,1.26rem); color: var(--gold); margin-top: 7px; }
.actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.actions button { padding-inline: 3px; }
.actions .primary { grid-column: 1/-1; background: var(--gold); color: #241c0d; border-color: #e2b361; display: flex; justify-content: center; align-items: center; gap: 10px; }
.actions .primary:enabled:hover { background: #ffdb93; }
.trial-status { display: block; margin: 12px 0 0; font-size: .92rem; }
.utility { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.utility button, #clear-history { border: 0; padding: 8px 0; background: none; color: var(--green); font-size: .9rem; }
.utility button:hover, #clear-history:enabled:hover { text-decoration: underline; background: transparent; }
.sim-console p:not(:empty):not(.trial-status) { margin-top: 8px; font-size: .91rem; }
#share-fallback { margin-top: 8px; min-height: 7em; width: 100%; }
.sim-foot { padding: 12px 24px; border-top: 1px solid var(--line); background: #19241d; color: #c3cfc4; font-size: .83rem; }
.sim-foot a { white-space: nowrap; }
.muted,.fine { color: var(--muted); }
.fine { font-size: .85rem; margin-top: 8px; }
#scenario-note { margin-top: 14px; }
.notice, #storage-status:not(:empty) { margin: 14px 0; padding: 12px 16px; border-left: 3px solid var(--gold); background: var(--panel); }
.calculator,.related,.history,.reading>section { margin-top: 38px; padding-top: 32px; border-top: 1px solid var(--line); }
.calculator>p { margin-top: 10px; }
.calc-layout { display: grid; grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); gap: clamp(22px,5vw,70px); margin-top: 24px; }
.inputs { display: flex; flex-direction: column; align-items: stretch; }
.inputs label { font-size: .94rem; font-weight: 650; margin-bottom: 5px; }
.inputs label:not(:first-child) { margin-top: 15px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick button { font-size: .85rem; font-weight: 550; }
.error { color: #ffc7a8; font-size: .87rem; }
.error:not(:empty) { margin-top: 5px; }
.odds { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); background: var(--panel); padding: 18px; border-radius: 9px; gap: 12px; }
.odds dd { margin: 5px 0 0; font-size: clamp(1.2rem,2.5vw,2rem); overflow-wrap: anywhere; }
.odds div:first-child dd { color: var(--green); }
table { width: 100%; border-collapse: collapse; margin-top: 24px; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
th, td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
thead th { font-size: .84rem; font-weight: 550; color: var(--muted); }
th { text-align: left; }
td, th:not(:first-child) { text-align: right; }
tbody th { font-weight: 500; }
.section-heading { margin-bottom: 10px; }
#history-list { padding-left: 1.5em; }
#history-list li { margin: 6px 0; }
.reading { max-width: 840px; }
.reading h2, .related h2 { margin-bottom: 18px; }
.reading ol { padding-left: 1.55em; }
.reading li { margin-bottom: .75em; padding-left: .35em; }
.reading li::marker { color: var(--green); font-weight: 650; }
.reading p, .reading li { color: #c6d1c8; }
.reading p + p { margin-top: 10px; }
details { border-bottom: 1px solid var(--line); }
summary { padding: 14px 0; cursor: pointer; font-weight: 600; }
summary:hover { color: var(--green); }
details p:last-child { padding-bottom: 18px; }
.related>div { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.related a { padding: 16px 20px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; }
.related strong, .related span { display: block; }
.related span { font-size: .9rem; color: var(--muted); margin-top: 4px; }
footer { border-top: 1px solid var(--line); padding: 22px 0; font-size: .9rem; }
@media(max-width: 720px) {
  .wrap { width: calc(100% - 28px); }
  .nav { min-height: 55px; }
  .nav, .nav div { gap: 13px; }
  .nav div a { font-size: .82rem; }
  main { padding-top: 12px; }
  .hero { margin: 10px 0 15px; }
  .hero p { font-size: .95rem; margin-top: 7px; }
  .sim-body,.calc-layout,.related>div { grid-template-columns: minmax(0,1fr); }
  .sim-settings { padding: 8px 12px; }
  .sim-settings label { font-size: .85rem; }
  .sim-settings select { min-width: 0; }
  .stage { min-height: 0; height: clamp(124px,36vw,200px); border-right: 0; border-bottom: 1px solid var(--line); }
  #trial-art { width: 70%; height: 96%; }
  .stage .token { width: 14%; }
  .sim-console { padding: 12px; }
  .metrics { margin-bottom: 12px; }
  .metrics strong { margin-top: 2px; }
  .actions button { font-size: .93rem; }
  .sim-foot { padding: 8px 12px; align-items: flex-start; font-size: .77rem; }
  .targets th, .targets td { padding: 8px 3px; }
  .calc-layout { gap: 20px; }
  .section-heading { align-items: flex-start; }
  .section-heading button { flex: none; }
}
@media(max-width: 375px) {
  .nav, .nav div { gap: 9px; }
  .brand { font-size: .91rem; }
}
@media(prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
