:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #171b16;
  color: #f8e8cc;
  --gold: #ffd086;
  --green: #1c3c33;
  --ink: #171b16;
  --line: #68553d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse at 50% 18%, #3b3021, #171b16 72%); }
main { max-width: 475px; margin: auto; padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.masthead { display: flex; gap: 8px; align-items: end; justify-content: space-between; padding: 0 3px 10px; }
.byline { display: inline-block; color: var(--gold); font-size: .65rem; letter-spacing: .15em; font-weight: 700; text-decoration: none; }
h1 { margin: 3px 0 0; color: #fff0d1; font-family: Georgia, "Songti SC", serif; font-size: clamp(1.3rem, 6vw, 2.25rem); line-height: .98; }
.top-actions { display: flex; gap: 4px; }
button, select, .secondary { font: inherit; cursor: pointer; color: inherit; }
button { border: 1px solid var(--line); border-radius: 8px; }
.top-actions button { padding: 4px 5px; font-size: .72rem; background: #252c23; min-height: 44px; }
:focus-visible { outline: 2px solid #ffdf8f; outline-offset: 3px; }
a { color: var(--gold); }
.cabinet { overflow: hidden; border: 1px solid #94663f; border-radius: 14px; box-shadow: 0 12px 45px #0009; background: #221e18; }
.scoreboard { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 6px 12px; background: #282319; }
.scoreboard div:first-child, .scoreboard div:last-child { display: flex; align-items: center; gap: 7px; }
.scoreboard span { color: #efd7ad; font-size: .63rem; font-weight: 700; letter-spacing: .06em; }
.scoreboard output { font: 700 1.6rem/1 Georgia, serif; color: var(--gold); font-variant-numeric: tabular-nums; }
.tickets { display: flex; justify-content: center; gap: clamp(2px, 1vw, 5px); }
.tickets i { width: 5px; height: 14px; background: #ffc379; border-radius: 6px 6px 2px 2px; border-bottom: 3px solid #b66c48; }
.tickets i.spent { opacity: .2; }
.stage { position: relative; width: 100%; background: #233f38; aspect-ratio: 400 / 480; touch-action: manipulation; }
#field { display: block; width: 100%; height: 100%; }
.curtain { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; background: #100e0b4d; overflow: auto; }
.panel { width: min(100%, 318px); padding: clamp(11px, 4vw, 22px); background: #182921f7; border: 1px solid #a37a4e; border-radius: 13px; text-align: center; box-shadow: 0 10px 35px #0008; }
.panel h2 { margin: 0 0 8px; font: 700 clamp(1.22rem, 5vw, 1.7rem)/1.15 Georgia, "Songti SC", serif; }
.panel p { margin: 6px 0 13px; line-height: 1.35; font-size: .9rem; }
.panel p:empty { display: none; }
.panel .challenge { color: var(--gold); font-weight: bold; }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0; }
select { background: #28362a; padding: 6px; border-radius: 5px; border: 1px solid var(--line); }
.primary, .secondary { display: block; width: 100%; min-height: 44px; padding: 8px 5px; border-radius: 8px; line-height: 1.1; font-weight: 700; text-decoration: none; }
.primary { border: 1px solid #ffe2aa; background: var(--gold); color: #271a0e; }
.secondary { border: 1px solid transparent; background: none; color: #f5d8aa; font-size: .84rem; align-content: center; }
.secondary:hover { background: #ffffff12; }
.result-panel { padding-block: 10px; }
.result-panel img { display: block; width: min(100%, 220px); margin: auto; border-radius: 8px; }
.result-panel p { font-size: .78rem; margin: 5px 0 7px; }
.result-panel .primary { min-height: 42px; }
.result-panel .secondary { min-height: 40px; }
.controls { display: grid; grid-template-columns: minmax(85px, 1fr) minmax(60px, .9fr) minmax(74px, 1fr); gap: 8px; align-items: stretch; padding: 9px; background: #2a231a; }
.controls button { min-height: 57px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; font-weight: 800; letter-spacing: .02em; }
.grip { background: #264c40; border-color: #547364; }
.grip.held { background: #3b6956; }
.trigger { color: #fff2d5; background: #a23725; border-color: #d87752; }
.trigger:active { background: #c6492e; }
.controls button:disabled { opacity: .48; }
.status { align-self: center; text-align: center; color: #ead4b1; font-size: .7rem; }
.guide, footer { padding: 0 5px; color: #d5c4a6; }
.guide h2 { font-family: Georgia, "Songti SC", serif; font-size: 1.15rem; margin: 15px 0 5px; }
.guide p, footer { font-size: .82rem; line-height: 1.5; margin: 6px 0; }
summary { cursor: pointer; color: var(--gold); padding-block: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (pointer: coarse) { .desktop-tip { display: none; } }
@media (max-width: 360px) { .scoreboard { gap: 6px; padding-inline: 7px; } .top-actions { gap: 2px; } }
@media (pointer: coarse) and (max-height: 720px) and (orientation: portrait) {
  .stage { max-height: calc(100svh - 165px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 305px; }
  .result-panel img { width: min(100%, 160px); }
}
