:root {
  color-scheme: light;
  --paper: #e7d7b5;
  --paper-light: #f3e7c9;
  --ink: #283331;
  --red: #d9472f;
  --yellow: #dfa51f;
  --teal: #4b7b78;
  --shadow: #171d1c;
  font-family: Rockwell, "Roboto Slab", Georgia, serif;
  color: var(--ink);
  background: #75654b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; overscroll-behavior: none; }
body {
  min-height: 100dvh;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  background: repeating-linear-gradient(92deg, #78684f 0 17px, #705f48 18px 33px, #826f53 34px 49px);
  touch-action: manipulation;
}
button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.workbench { width: min(100%, 1080px); margin: 0 auto; display: grid; gap: 7px; }

.ticket-bar {
  min-height: 58px; display: grid; grid-template-columns: 76px 1fr 58px; align-items: center; gap: 8px;
  padding: 5px 7px; background: var(--paper); border: 2px solid var(--ink); box-shadow: 4px 4px 0 #2b2118;
  transform: rotate(-.15deg);
}
.ticket-bar a, .ticket-bar button { min-width: 56px; min-height: 56px; border: 0; background: var(--ink); color: var(--paper-light); display: grid; place-items: center; text-decoration: none; font: 800 .72rem ui-monospace, monospace; }
.ticket-bar div { min-width: 0; text-align: center; line-height: 1; }
.ticket-bar small { display: block; font: 700 .59rem ui-monospace, monospace; letter-spacing: .11em; }
.ticket-bar strong { display: block; margin-top: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: clamp(.86rem, 3vw, 1.22rem); letter-spacing: .035em; }

.press-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; isolation: isolate;
  background: var(--paper-light); border: 5px solid var(--ink); box-shadow: 7px 8px 0 #281f17;
}
canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.curtain { position: absolute; inset: 0; z-index: 10; display: none; place-items: center; padding: 18px; overflow-y: auto; background: #2c332fd9; }
.curtain-visible { display: grid; }
.poster, .paper-strip, .tool-bench, .hanging-sign, .jammed-sheet, .final-poster {
  width: min(100%, 650px); max-height: 100%; overflow-y: auto; padding: clamp(18px, 4vw, 34px); color: var(--ink); background: var(--paper-light);
  box-shadow: 10px 12px 0 #121716; text-align: center;
}
.intro-poster { transform: rotate(-1deg); background: linear-gradient(105deg, transparent 49.5%, #d7c49d 50%, transparent 50.5%), var(--paper-light); }
.serial { margin: 0 0 10px; font: 900 .68rem ui-monospace, monospace; letter-spacing: .12em; }
h1, h2, p { text-wrap: balance; }
h1 { margin: 0; font-size: clamp(2rem, 8vw, 5rem); line-height: .79; letter-spacing: -.065em; }
h1 em { color: var(--red); font-style: normal; font-size: .58em; }
h2 { margin: 7px 0 11px; font-size: clamp(1.55rem, 5vw, 3.2rem); line-height: .9; }
.poster p:not(.serial), .paper-strip p, .tool-bench p, .jammed-sheet p, .final-poster p { line-height: 1.4; }
.poster > small { display: block; margin-top: 9px; font: 700 .65rem ui-monospace, monospace; }

.lever, .plain { min-height: 56px; min-width: 200px; padding: 10px 18px; cursor: pointer; font-weight: 950; }
.lever { border: 3px solid var(--ink); color: var(--paper-light); background: var(--red); box-shadow: 5px 5px 0 var(--ink); }
.lever:active { translate: 3px 3px; box-shadow: 2px 2px 0 var(--ink); }
.plain { border: 0; color: var(--ink); background: transparent; text-decoration: underline 3px var(--yellow); display: inline-grid; place-items: center; }
.paper-strip { transform: rotate(.8deg); border-left: 18px solid var(--yellow); }
.paper-strip > span, .jammed-sheet > span, .hanging-sign > span { font: 900 .7rem ui-monospace, monospace; letter-spacing: .14em; }
.hanging-sign { width: min(90%, 430px); border-top: 13px solid var(--ink); }
.jammed-sheet { width: min(95%, 520px); background: var(--yellow); transform: rotate(-1.2deg); }
.tool-bench { width: min(100%, 760px); }
.tool-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tool-options button { min-height: 112px; padding: 14px; border: 4px solid var(--ink); background: var(--paper); box-shadow: 5px 5px 0 var(--ink); cursor: pointer; }
.tool-options b, .tool-options span { display: block; }
.tool-options b { margin-bottom: 7px; color: var(--red); font-size: 1.25rem; }
.tool-options span { font: 700 .78rem ui-monospace, monospace; }
.final-poster { background: var(--red); color: var(--paper-light); transform: rotate(.4deg); }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.result-grid span { min-height: 70px; display: grid; place-content: center; border: 3px solid var(--paper-light); }
.result-grid small, .result-grid b { display: block; }
.result-grid small { font: 800 .55rem ui-monospace, monospace; }
.result-grid b { font-size: clamp(1.1rem, 4vw, 2rem); }
.final-poster .plain { color: var(--paper-light); text-decoration-color: var(--yellow); }

.console {
  position: absolute; z-index: 5; left: 10px; right: 10px; bottom: 9px; display: grid;
  grid-template-columns: .65fr .8fr .7fr 1.6fr .9fr 56px; gap: 5px; padding: 5px; background: #ded0b0e8; border: 3px solid var(--ink); box-shadow: 3px 3px 0 #171d1c99;
}
.console[hidden] { display: none; }
.roll, .ink-gauge { min-height: 48px; display: grid; align-content: center; text-align: center; border-right: 2px dashed #8c795c; }
.console small { font: 900 .5rem ui-monospace, monospace; letter-spacing: .08em; }
.console b { font: 950 clamp(.68rem, 2.1vw, 1rem) ui-monospace, monospace; }
.console .combo b { color: var(--red); }
.ink-gauge { grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; padding: 0 7px; }
.ink-gauge i, .boss-meter i { height: 13px; overflow: hidden; border: 2px solid var(--ink); background: var(--paper-light); }
.ink-gauge i span, .boss-meter i span { width: 0%; height: 100%; display: block; background: var(--red); transition: width 160ms linear; }
.console button { min-width: 56px; min-height: 56px; border: 0; background: var(--ink); color: var(--paper-light); }
.boss-meter { position: absolute; z-index: 6; top: 10px; left: 50%; translate: -50% 0; width: min(88%, 540px); display: grid; grid-template-columns: 1.4fr 2fr .6fr; gap: 8px; align-items: center; padding: 8px 12px; background: var(--yellow); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.boss-meter[hidden] { display: none; }
.boss-meter small, .boss-meter b { font: 900 .68rem ui-monospace, monospace; }

.instruction { position: absolute; z-index: 7; left: 50%; top: 76px; translate: -50% 0; width: min(calc(100% - 22px), 560px); padding: 10px 14px; color: var(--paper-light); background: var(--ink); border-left: 12px solid var(--yellow); box-shadow: 5px 5px 0 #0008; text-align: center; pointer-events: none; }
.instruction[hidden] { display: none; }
.instruction b, .instruction span { display: block; }
.instruction b { color: var(--yellow); }
.instruction span { font: 700 .72rem ui-monospace, monospace; }
.instruction.surprise { background: var(--red); border-color: var(--paper-light); }
.instruction.boss-note { top: 70px; background: #283331; border-color: var(--red); }

.touch-rig { min-height: 150px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; user-select: none; -webkit-user-select: none; }
.joystick { min-height: 150px; display: grid; place-items: center; align-content: center; gap: 3px; background: #d6c39e; border: 4px solid var(--ink); touch-action: none; }
.joystick-ring { position: relative; width: 116px; height: 116px; border-radius: 50%; border: 5px dotted var(--ink); background: repeating-conic-gradient(#c3ad85 0 8deg, #ddcba7 8deg 16deg); }
#joystickKnob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: var(--teal); border: 4px solid var(--ink); box-shadow: 4px 4px 0 #171d1c88; transform: translate(0, 0); transition: transform 100ms ease-out; }
.joystick[data-active="true"] #joystickKnob { transition: none; }
.joystick small { font: 900 .59rem ui-monospace, monospace; }
.strike { min-width: 126px; min-height: 126px; aspect-ratio: 1; align-self: center; justify-self: center; border-radius: 50%; border: 5px solid var(--ink); background: var(--red); color: var(--paper-light); box-shadow: 7px 8px 0 var(--ink); touch-action: none; }
.strike span, .strike b { display: block; }
.strike span { font-size: 2rem; }
.strike b { font-size: 1rem; letter-spacing: .05em; }
.strike:active, .strike.pressed { translate: 4px 5px; box-shadow: 3px 3px 0 var(--ink); }
footer { padding: 5px 12px; color: #eee2c7; background: #283331; text-align: center; font: 700 .68rem/1.35 ui-monospace, monospace; }
.qa-tools { position: fixed; z-index: 40; right: 6px; bottom: 6px; display: flex; gap: 3px; opacity: .82; }
.qa-tools[hidden] { display: none; }
.qa-tools button { min-height: 36px; border: 2px solid var(--ink); background: var(--yellow); font: 700 .6rem ui-monospace, monospace; }

@media (hover: hover) and (pointer: fine) {
  .touch-rig { display: none; }
  .press-stage { max-height: calc(100dvh - 90px); }
  .ticket-bar a:hover, .ticket-bar button:hover { background: var(--red); }
}

@media (max-width: 600px) {
  .touch-rig { display: grid !important; }
  .press-stage { border-width: 3px; }
  .curtain { padding: 10px; }
  .curtain:has(.intro-poster), .curtain:has(.final-poster), .curtain:has(.tool-bench) { align-items: start; }
  .poster, .final-poster, .tool-bench { padding: 16px 14px; }
  .intro-poster p:not(.serial) { font-size: .83rem; }
  .console { left: 4px; right: 4px; bottom: 4px; grid-template-columns: .6fr .72fr .6fr 1.25fr .78fr 44px; gap: 2px; padding: 3px; }
  .console button { min-width: 44px; min-height: 48px; }
  .ink-gauge { gap: 3px; padding: 0 3px; }
  .touch-rig { min-height: 142px; }
  .joystick { min-height: 142px; }
  .joystick-ring { width: 108px; height: 108px; }
  .strike { min-width: 112px; min-height: 112px; }
  footer { font-size: .58rem; }
}

@media (min-width: 601px) and (max-width: 900px) {
  .touch-rig { display: grid !important; }
}

@media (max-width: 410px) {
  .ticket-bar div small { display: none; }
  .ticket-bar { grid-template-columns: 64px 1fr 56px; }
  .ticket-bar a { font-size: .64rem; }
  .serial { font-size: .55rem; }
  .lever, .plain { min-width: 180px; }
  .tool-options { grid-template-columns: 1fr; }
  .result-grid { gap: 3px; }
  .instruction { top: 57px; padding: 7px 9px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  body { padding-block: 0; }
  .workbench { width: min(100%, 1080px); grid-template-columns: minmax(0, 1fr) 150px; grid-template-rows: 56px minmax(0, 1fr); gap: 4px; }
  .ticket-bar { grid-column: 1 / -1; min-height: 56px; }
  .ticket-bar a, .ticket-bar button { min-height: 56px; }
  .press-stage { grid-column: 1; grid-row: 2; max-height: calc(100dvh - 60px); }
  .touch-rig { grid-column: 2; grid-row: 2; min-height: 0; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; gap: 4px; }
  .joystick { min-height: 0; border-width: 3px; }
  .joystick-ring { width: 86px; height: 86px; border-width: 3px; }
  #joystickKnob { width: 46px; height: 46px; margin: -23px; border-width: 3px; }
  .joystick small { display: none; }
  .strike { min-width: 76px; min-height: 76px; border-width: 3px; box-shadow: 4px 4px 0 var(--ink); }
  .strike span { display: none; }
  footer { display: none; }
  .poster, .paper-strip, .tool-bench, .hanging-sign, .jammed-sheet, .final-poster { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
