:root {
  color-scheme: light;
  --ink: #251d18;
  --paper: #f4e6c8;
  --paper-light: #fff9e9;
  --wood: #6c3f2c;
  --wood-dark: #3c241d;
  --red: #a52f2d;
  --red-dark: #6f1d20;
  --blue: #245d68;
  --gold: #d49b38;
  --green: #315d42;
  --line: #5d4638;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html { background: #211813; color: var(--ink); overflow-x: hidden; }
body { margin: 0; min-width: 280px; background: #d8c398; background-image: repeating-linear-gradient(0deg, rgba(73,49,33,.035) 0 1px, transparent 1px 4px); overflow-x: hidden; }
button, input { font: inherit; }
button { min-height: 44px; }
button:focus-visible, input:focus-visible { outline: 4px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 7px var(--blue); }
[hidden] { display: none !important; }

.masthead {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px clamp(12px, 3vw, 38px);
  color: #fff7df;
  background: var(--wood-dark);
  border-bottom: 7px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand span { display: grid; place-items: center; width: 46px; height: 46px; border: 3px solid #fff0c5; background: var(--red); font: 900 25px/1 serif; transform: rotate(-3deg); }
.brand b { font-size: 14px; letter-spacing: .08em; }
.header-title small { display: block; color: #e7c878; font-weight: 800; }
.header-title h1 { margin: 2px 0 0; font: 900 clamp(18px, 3vw, 28px)/1.1 serif; letter-spacing: .06em; }
.sound-toggle, .ranking-toggle { border: 2px solid #efdca9; background: transparent; color: #fff7df; padding: 8px 13px; cursor: pointer; font-weight: 800; }

main { width: min(1180px, 100%); margin: 0 auto; padding: 18px clamp(10px, 2.5vw, 28px) 36px; }
.screen { animation: sheet-in .38s ease-out both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px); } }

.start-screen { min-height: 650px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr); border: 4px solid var(--wood-dark); background: var(--paper); box-shadow: 10px 12px 0 rgba(45,29,20,.26); }
.start-world { position: relative; min-height: 610px; overflow: hidden; background: #e6b55c; border-right: 4px solid var(--wood-dark); }
.start-world::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 58px, rgba(75,43,29,.08) 59px 60px); }
.sun-disc { position: absolute; width: 170px; height: 170px; border: 8px double var(--red); border-radius: 50%; background: #fff2b0; top: 54px; right: 60px; box-shadow: 0 0 0 14px rgba(255,242,176,.28); }
.street { position: absolute; left: 0; right: 0; bottom: 0; height: 230px; display: flex; align-items: end; gap: 4px; padding: 0 20px; background: #48606a; border-top: 10px solid var(--wood-dark); }
.street span { flex: 1; min-width: 50px; height: 130px; background: var(--paper-light); border: 5px solid var(--wood-dark); position: relative; }
.street span:nth-child(2n) { height: 185px; background: #c86643; }
.street span::before { content: ""; position: absolute; left: 15%; right: 15%; top: 25px; height: 40px; border: 4px solid var(--wood-dark); background: #f5d273; box-shadow: 0 62px 0 #f5d273, 0 62px 0 4px var(--wood-dark); }
.press-silhouette { position: absolute; left: 55px; bottom: 118px; width: 255px; height: 300px; background: var(--wood); border: 12px solid var(--wood-dark); box-shadow: 16px 12px 0 rgba(51,27,19,.24); }
.press-silhouette b { position: absolute; left: 62px; top: 36px; display: grid; place-items: center; width: 110px; height: 110px; border-radius: 50%; background: var(--paper); border: 10px solid var(--ink); font: 900 62px/1 serif; }
.press-silhouette i { position: absolute; left: 22px; right: 22px; bottom: 56px; height: 42px; border: 8px solid var(--ink); background: #d0953e; }
.press-silhouette em { position: absolute; width: 145px; height: 18px; right: -95px; top: 46px; background: var(--ink); transform: rotate(-19deg); transform-origin: left; }
.paper-flight i { position: absolute; display: grid; place-items: center; width: 62px; height: 74px; background: #fff9e9; border: 3px solid var(--ink); font: 900 34px/1 serif; font-style: normal; box-shadow: 5px 6px 0 rgba(47,29,20,.2); animation: paper-bob 3s ease-in-out infinite; }
.paper-flight i:nth-child(1) { left: 46%; top: 32%; transform: rotate(9deg); }
.paper-flight i:nth-child(2) { left: 58%; top: 44%; transform: rotate(-8deg); animation-delay: -.5s; }
.paper-flight i:nth-child(3) { left: 71%; top: 29%; transform: rotate(5deg); animation-delay: -1s; }
.paper-flight i:nth-child(4) { left: 81%; top: 43%; transform: rotate(-12deg); animation-delay: -1.5s; }
@keyframes paper-bob { 50% { translate: 0 -13px; } }
.start-copy { padding: clamp(26px, 5vw, 58px) clamp(22px, 4vw, 48px); align-self: center; }
.edition-label { margin: 0 0 10px; color: var(--red-dark); font: 900 13px/1.3 monospace; letter-spacing: .14em; }
.start-copy h2, .result-screen h2 { margin: 0; font: 900 clamp(31px, 5vw, 54px)/1.22 serif; letter-spacing: .04em; }
.start-copy > p:not(.edition-label, .small-note) { line-height: 1.9; font-weight: 650; }
.start-steps { list-style: none; padding: 0; margin: 24px 0; display: grid; gap: 10px; }
.start-steps li { display: grid; grid-template-columns: 45px 1fr; align-items: center; border-bottom: 2px solid #95775c; padding-bottom: 9px; font-weight: 800; }
.start-steps b { display: grid; place-items: center; width: 38px; height: 38px; background: var(--ink); color: var(--paper-light); font: 900 22px/1 serif; }
.main-button, .print-button, .next-button { border: 0; color: #fff; background: var(--red-dark); box-shadow: 5px 5px 0 var(--wood-dark); padding: 14px 20px; font-weight: 900; cursor: pointer; }
.main-button:hover, .print-button:hover, .next-button:hover { transform: translate(-1px, -1px); box-shadow: 7px 7px 0 var(--wood-dark); }
.small-note { font-size: 13px; font-weight: 800; color: #614c40; }

.play-screen { display: grid; gap: 12px; }
.status-ribbon { display: grid; grid-template-columns: repeat(4, 1fr); border: 4px solid var(--wood-dark); background: var(--paper-light); }
.status-ribbon div { padding: 9px 13px; border-right: 2px solid var(--wood-dark); }
.status-ribbon div:last-child { border: 0; }
.status-ribbon small { display: block; color: #6c5141; font-weight: 800; }
.status-ribbon strong { font: 900 22px/1.25 monospace; }
.warning-banner { display: grid; grid-template-columns: 50px 1fr; align-items: center; gap: 10px; padding: 8px 14px; color: #fff; border: 3px solid var(--wood-dark); }
.warning-banner.calm { background: var(--green); }
.warning-banner.warning { background: #9a5b15; }
.warning-banner.danger { background: var(--red-dark); animation: danger-pulse 1s ease-in-out infinite alternate; }
@keyframes danger-pulse { to { box-shadow: inset 0 0 0 5px #f3c967; } }
.warning-stamp { display: grid; place-items: center; width: 38px; height: 38px; border: 3px solid currentColor; border-radius: 50%; font: 900 21px/1 serif; }
.warning-banner b, .warning-banner span { display: block; }

.press-world { display: grid; grid-template-columns: minmax(240px, .78fr) minmax(380px, 1.5fr); grid-template-areas: "town town" "ticket machine" "cabinet machine"; gap: 12px; touch-action: pan-y; }
.town-strip { grid-area: town; position: relative; min-height: 130px; overflow: hidden; border: 5px solid var(--wood-dark); background: #d9a74f; }
.town-strip p { position: absolute; left: 15px; bottom: 9px; z-index: 3; margin: 0; padding: 6px 10px; background: var(--paper-light); border: 2px solid var(--ink); }
.town-strip p b { margin-right: 12px; }
.town-strip p span { color: #614334; }
.town-sun { position: absolute; right: 5%; top: 12px; width: 72px; height: 72px; border-radius: 50%; border: 5px double var(--red); background: #fff0a4; }
.roofline { display: flex; align-items: end; gap: 3px; position: absolute; left: 0; right: 0; bottom: 0; height: 96px; padding: 0 6%; }
.roofline i { flex: 1; height: 55px; background: #f6e7c5; border: 4px solid var(--wood-dark); clip-path: polygon(50% 0, 100% 31%, 100% 100%, 0 100%, 0 31%); }
.roofline i:nth-child(2n) { height: 76px; background: #b9573c; }
.delivery-track { position: absolute; left: 4%; right: 4%; bottom: 0; height: 25px; border-top: 4px solid var(--ink); z-index: 2; }
.delivery-cart { position: absolute; left: 0; bottom: 2px; width: 40px; height: 30px; display: grid; place-items: center; color: #fff; background: var(--blue); border: 3px solid var(--ink); font-weight: 900; transition: left .5s ease; }
.order-ticket { grid-area: ticket; margin: 0; min-height: 245px; padding: 14px; background: var(--paper-light); border: 4px solid var(--wood-dark); box-shadow: inset 0 0 0 4px #cfb989; }
.order-ticket header { display: flex; justify-content: space-between; border-bottom: 3px double var(--ink); padding-bottom: 7px; font-weight: 900; }
.order-ticket header b { color: var(--red-dark); }
.order-ticket h2 { margin: 17px 0 8px; text-align: center; font: 900 clamp(48px, 9vw, 78px)/1 serif; }
.order-ticket ruby rt { font: 800 14px/1.3 sans-serif; letter-spacing: .15em; }
.order-ticket > p { margin: 12px 0; text-align: center; font-size: 19px; font-weight: 900; }
.copy-target { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid var(--ink); padding-top: 9px; }
.copy-target b { font: 900 21px/1 monospace; }
.copy-target em { font-style: normal; }
.type-cabinet { grid-area: cabinet; padding: 12px; background: var(--wood); border: 6px solid var(--wood-dark); color: #fff9e9; }
.cabinet-label h3 { margin: 0; font: 900 22px/1.2 serif; }
.cabinet-label span { display: block; min-height: 38px; margin-top: 5px; font-size: 13px; color: #f7d99c; }
.type-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-block { aspect-ratio: 1; min-height: 58px; border: 5px solid #211713; background: #c68a4a; color: #251812; box-shadow: inset 0 0 0 3px #ebba70, 3px 4px 0 #211713; font: 900 clamp(28px, 5vw, 42px)/1 serif; cursor: grab; touch-action: pan-y; }
.type-block[aria-pressed="true"] { background: #fff0a8; color: var(--red-dark); box-shadow: inset 0 0 0 4px var(--red), 3px 4px 0 #211713; }
.type-block.used { opacity: .36; cursor: default; }
.press-console { grid-area: machine; padding: clamp(12px, 2.5vw, 24px); color: #fff8e8; background: var(--wood-dark); border: 6px solid #1d1410; box-shadow: inset 0 0 0 3px #93643d; }
.compose-zone { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding-bottom: 15px; border-bottom: 3px solid #d1a860; }
.compose-label b, .compose-label span { display: block; }
.compose-label span { color: #dfcba1; font-size: 12px; }
.type-slots { display: flex; justify-content: center; gap: 12px; }
.type-slot { width: clamp(66px, 10vw, 96px); height: clamp(72px, 11vw, 103px); border: 5px dashed #d9b875; background: #2a201a; color: #f7e0a6; font: 900 clamp(34px, 6vw, 58px)/1 serif; cursor: pointer; touch-action: pan-y; }
.type-slot.filled { border-style: solid; background: #c98b4a; color: #1e1713; box-shadow: inset 0 0 0 3px #edbd72; }
.type-slot.drop-ready { outline: 5px solid #fff1a5; }
.clear-types, .emergency-button, .retry-button { border: 2px solid #f0d99f; background: #4b3428; color: #fff7dd; padding: 9px 12px; cursor: pointer; font-weight: 800; }
.press-machine { position: relative; min-height: 232px; margin: 16px 0 10px; overflow: hidden; border: 5px solid #17100d; background: #765039; }
.press-machine::before, .press-machine::after { content: ""; position: absolute; top: 15px; bottom: 15px; width: 20px; background: #211915; border: 4px solid #b98650; }
.press-machine::before { left: 25px; } .press-machine::after { right: 25px; }
.roller { position: absolute; left: 16%; right: 16%; top: 31px; height: 104px; border-radius: 52px; border: 10px solid #17100d; background: #234b54; box-shadow: inset 0 0 0 8px #3c7880; transition: transform .25s ease; }
.roller b { position: absolute; left: calc(50% - 33px); top: 9px; display: grid; place-items: center; width: 66px; height: 66px; border: 5px solid #efe1bd; border-radius: 50%; color: #efe1bd; font: 900 38px/1 serif; }
.paper-path { position: absolute; left: 20%; right: 20%; bottom: 10px; height: 90px; display: grid; place-items: center; background: var(--paper-light); border: 5px solid var(--ink); color: var(--ink); transform: skew(-2deg); }
.paper-path span { font: 900 clamp(23px, 5vw, 44px)/1 serif; letter-spacing: .12em; }
.heat-stack { position: absolute; z-index: 3; right: 40px; top: 25px; width: 44px; text-align: center; }
.heat-stack small { display: block; color: #fff0b7; font-weight: 800; }
.heat-stack > div { height: 125px; padding: 4px; border: 3px solid #fff0b7; background: #30231d; display: flex; align-items: end; }
.heat-stack i { display: block; width: 100%; height: 12%; background: #d5a33f; transition: height .35s ease, background-color .35s ease; }
.heat-stack b { display: block; margin-top: 4px; font-size: 11px; white-space: nowrap; translate: -10px 0; }
.press-machine.printing .roller { transform: rotate(14deg) scale(1.03); }
.press-machine.jammed { animation: machine-shake .28s linear 2; }
.press-machine.release { box-shadow: inset 0 0 0 8px #f4d96d; }
@keyframes machine-shake { 33% { transform: translateX(-5px); } 66% { transform: translateX(5px); } }
.resource-ledger { display: grid; grid-template-columns: repeat(4, 1fr); border: 2px solid #d4b477; }
.resource-ledger span { padding: 8px; text-align: center; border-right: 1px solid #d4b477; }
.resource-ledger span:last-child { border: 0; }
.resource-ledger b { display: block; font: 900 21px/1.2 monospace; color: #f4cf6b; }
.press-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 15px; }
.press-controls label { display: block; padding: 11px; border: 2px solid #ba925b; }
.press-controls label > span { display: flex; justify-content: space-between; }
.press-controls em { color: #f6ce69; font-style: normal; font-weight: 900; }
.press-controls input { width: 100%; accent-color: #e2ad3c; min-height: 32px; }
.press-controls small { display: block; text-align: justify; text-align-last: justify; color: #dfcba1; }
.risk-copy { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.risk-copy b { color: #ffce69; }
.action-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.print-button { background: var(--red); min-height: 58px; font-size: 18px; }
.emergency-button:disabled, .print-button:disabled { opacity: .45; cursor: not-allowed; }
.cause-text { min-height: 48px; margin: 15px 0 3px; padding: 10px; background: #fff6dc; color: var(--ink); border-left: 8px solid var(--gold); font-weight: 900; }
.cause-detail { margin: 0; color: #e7d3ac; font-size: 13px; }
.edition-line { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 0; border: 4px solid var(--wood-dark); background: var(--paper-light); }
.edition-line li { display: grid; grid-template-columns: 38px 1fr; align-items: center; padding: 8px; border-right: 2px solid var(--wood-dark); opacity: .55; }
.edition-line li:last-child { border: 0; }
.edition-line span { display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid currentColor; border-radius: 50%; font-weight: 900; }
.edition-line li.current { opacity: 1; background: #f2cf79; }
.edition-line li.done { opacity: 1; color: var(--green); }

.quiz-screen, .result-screen { width: min(820px, 100%); margin: 25px auto; padding: clamp(22px, 5vw, 52px); border: 5px solid var(--wood-dark); background: var(--paper-light); box-shadow: 10px 10px 0 rgba(40,24,16,.25); }
.quiet-press { position: relative; width: 180px; height: 110px; margin: 0 auto 20px; background: var(--wood); border: 7px solid var(--wood-dark); }
.quiet-press span { position: absolute; display: grid; place-items: center; width: 64px; height: 64px; left: 51px; top: 13px; border-radius: 50%; background: #264e56; border: 5px solid var(--ink); color: #fff5d5; font: 900 34px/1 serif; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 4px double var(--ink); }
.quiz-head h2 { margin: 5px 0 11px; font: 900 clamp(25px, 5vw, 38px)/1.25 serif; }
.quiz-head span { padding: 7px 10px; background: var(--ink); color: #fff; font-weight: 900; white-space: nowrap; }
.quiz-question { min-height: 65px; font-size: clamp(20px, 4vw, 29px); font-weight: 900; line-height: 1.55; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.quiz-choice { width: 100%; min-width: 0; min-height: 58px; padding: 10px; border: 3px solid var(--ink); background: #f4deaa; color: var(--ink); font-weight: 900; cursor: pointer; overflow-wrap: anywhere; }
.quiz-choice.correct { background: #d8ecd0; border-style: double; border-width: 6px; }
.quiz-choice.wrong { background: #f0c2b7; text-decoration: line-through; }
.quiz-feedback { min-height: 65px; padding: 10px; border-left: 8px solid var(--blue); background: #e8e2cd; line-height: 1.7; font-weight: 800; }
.result-screen { text-align: center; }
.result-town { display: flex; align-items: end; justify-content: center; gap: 5px; min-height: 150px; margin-bottom: 22px; border-bottom: 8px solid var(--ink); }
.result-town span { width: 98px; padding: 28px 6px 12px; color: #fff8db; background: var(--red); border: 5px solid var(--ink); font: 900 24px/1 serif; }
.result-town span:nth-child(2n) { padding-top: 55px; background: var(--blue); }
.result-screen > p:not(.edition-label) { line-height: 1.8; font-weight: 700; }
.score-sheet { display: grid; place-items: center; width: min(360px, 100%); margin: 24px auto; padding: 14px; border: 5px double var(--ink); background: #f2d58e; }
.score-sheet strong { font: 900 clamp(48px, 10vw, 74px)/1 monospace; }
.score-sheet span { font-weight: 900; color: var(--red-dark); }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }
.result-actions .ranking-toggle { color: var(--ink); border-color: var(--ink); }
.ranking-panel { margin: 20px auto 0; width: min(620px, 100%); max-width: 100%; padding: 14px; background: #fffdf5; color: #1f1814; border: 4px solid var(--ink); text-align: left; overflow-x: auto; scroll-margin-top: 10px; }
.ranking-panel .itc-ranking__tabs button { color: #1f1814; background: #fffdf5; }
.ranking-panel .itc-ranking__tabs button[aria-pressed="true"] { color: #fff; background: #265f68; }
.ranking-panel .itc-ranking__table { min-width: 420px; }

footer { padding: 22px 15px; color: #eadbb8; background: var(--wood-dark); text-align: center; font-size: 13px; line-height: 1.7; }

@media (max-width: 820px) {
  .masthead { grid-template-columns: auto 1fr; }
  .header-title { min-width: 0; }
  .brand b { display: none; }
  .sound-toggle { grid-column: 1 / -1; justify-self: end; min-height: 38px; margin-top: -49px; }
  .start-screen { grid-template-columns: 1fr; }
  .start-world { min-height: 360px; border-right: 0; border-bottom: 4px solid var(--wood-dark); }
  .press-silhouette { left: 8%; bottom: 55px; transform: scale(.72); transform-origin: left bottom; }
  .street { height: 150px; }
  .sun-disc { width: 105px; height: 105px; right: 10%; top: 30px; }
  .paper-flight i { width: 48px; height: 57px; font-size: 25px; }
  .press-world { grid-template-columns: 1fr; grid-template-areas: "town" "ticket" "cabinet" "machine"; }
  .type-cabinet { min-height: 0; }
  .type-block { aspect-ratio: auto; min-height: 64px; }
}

@media (max-width: 580px) {
  main { padding: 10px 7px 25px; }
  .masthead { gap: 8px; padding: 8px; }
  .brand span { width: 39px; height: 39px; font-size: 21px; }
  .header-title { padding-right: 78px; }
  .header-title h1 { font-size: 17px; }
  .header-title small { font-size: 11px; }
  .sound-toggle { font-size: 12px; padding: 6px 9px; }
  .start-screen { min-height: 0; box-shadow: 4px 5px 0 rgba(45,29,20,.25); }
  .start-world { min-height: 305px; }
  .start-copy { padding: 25px 18px; }
  .status-ribbon { grid-template-columns: 1fr 1fr; }
  .status-ribbon div:nth-child(2) { border-right: 0; }
  .status-ribbon div:nth-child(-n+2) { border-bottom: 2px solid var(--wood-dark); }
  .warning-banner { grid-template-columns: 42px 1fr; font-size: 13px; }
  .town-strip p { left: 5px; right: 5px; bottom: 5px; font-size: 12px; }
  .order-ticket { min-height: 220px; }
  .compose-zone { grid-template-columns: 1fr; }
  .compose-label { text-align: center; }
  .clear-types { justify-self: center; }
  .press-console { padding: 10px; }
  .press-machine { min-height: 210px; }
  .roller { left: 8%; right: 8%; }
  .paper-path { left: 11%; right: 11%; }
  .heat-stack { right: 14px; }
  .resource-ledger { grid-template-columns: 1fr 1fr; }
  .resource-ledger span:nth-child(2) { border-right: 0; }
  .resource-ledger span:nth-child(-n+2) { border-bottom: 1px solid #d4b477; }
  .press-controls { grid-template-columns: 1fr; gap: 9px; }
  .risk-copy { display: grid; }
  .action-row { grid-template-columns: 1fr; }
  .edition-line { grid-template-columns: 1fr 1fr; }
  .edition-line li:nth-child(2) { border-right: 0; }
  .edition-line li:nth-child(-n+2) { border-bottom: 2px solid var(--wood-dark); }
  .quiz-screen, .result-screen { margin: 10px auto; padding: 19px 12px; box-shadow: 4px 5px 0 rgba(40,24,16,.25); }
  .quiz-choices { grid-template-columns: 1fr; }
  .quiz-choice { min-height: 54px; }
  .result-town span { width: 24%; font-size: 18px; }
  .ranking-panel { padding: 8px; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
