:root{color-scheme:dark;--ink:#24362d;--gold:#edc06d;--pale:#ffefd0;--invite-art:url("art/invitation.webp");font-family:"Hiragino Sans","Yu Gothic",Meiryo,sans-serif;background:#101811;color:var(--pale)}
*,*::before,*::after{box-sizing:border-box}
body{margin:0}
#game{min-height:100svh;max-width:600px;margin:auto;padding-top:max(12px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));background:#192c22}
h1,h2,p,figure{margin:0} h1,h2{font-family:"Hiragino Mincho ProN","Yu Mincho",serif;line-height:1.18} p{line-height:1.65}
button,a,input{font:inherit}
button,a{touch-action:manipulation}
button{cursor:pointer;color:inherit}
button:disabled{cursor:default;opacity:.55}
a{color:inherit}
:focus-visible{outline:3px solid #c48227;outline-offset:3px}
.top{height:48px;display:flex;align-items:center;padding:0 102px 0 15px;border-bottom:1px solid #715838}
.top .quiet{font-weight:700;min-height:44px}
.top span{font-size:.78em;color:#e8c786}
.game-menu{position:fixed;z-index:5;top:calc(max(12px,env(safe-area-inset-top)) + 2px);right:max(15px,env(safe-area-inset-right),calc((100% - 600px)/2 + 15px))}
.game-menu-toggle{display:flex;gap:6px;align-items:center;justify-content:center;min-width:44px;min-height:44px;padding:0 9px;border:0;border-radius:9px;background:transparent;color:#ffefd0;font-size:.875rem;font-weight:700;position:relative;isolation:isolate}
.game-menu-toggle::before{content:"";position:absolute;z-index:-1;inset:6px 0;border:1px solid #a58958;border-radius:7px;background:#203328}
.game-menu-toggle[aria-expanded="true"]::before{border-color:var(--gold);background:#2b4434}
.game-menu-icon{flex:none;width:13px;height:2px;border-radius:1px;background:currentColor;box-shadow:0 -4px currentColor,0 4px currentColor}
.game-menu-panel{position:absolute;top:calc(100% + 1px);right:0;width:min(218px,calc(100vw - 30px));padding:4px 9px;border:1px solid #a58958;border-radius:10px;background:#203328;box-shadow:0 6px 20px #0d170f70}
.game-menu-panel>*{display:flex;align-items:center;width:100%;min-height:44px;padding:6px 8px;border:0;background:none;text-align:left;text-decoration:none;font-size:.94rem}
.game-menu-panel>*+*{border-top:1px solid #a5895859}
.game-menu-return{color:#ffda91;font-weight:700}
.quiet{border:0;background:transparent;padding:0 6px;min-height:44px}
.cover{display:grid;isolation:isolate;position:relative;padding-bottom:12px}
#screen:has(>.cover){min-height:calc(100svh - 76px);display:grid;align-content:center}
.picture{--art-height:clamp(140px,27svh,235px);height:var(--art-height);background-color:#312b1d;position:relative;overflow:hidden}
.puzzle-top .picture{--art-height:clamp(102px,19svh,182px)}
.picture:not(.trophy)::before{content:"";position:absolute;inset:0;background:var(--scene) 56% 47% / cover no-repeat}
.hero{--art-height:clamp(235px,43svh,470px);--scene:url("art/stationmaster.webp")}
.gates{--scene:url("art/gates.webp")}
.lamps{--scene:url("art/lamps.webp")}
.bell{--scene:url("art/railways.webp");--art-height:clamp(190px,32svh,320px)}
.trophy{background-image:var(--invite-art);background-size:cover;background-position:center;height:clamp(250px,47svh,420px)}
.invitation .trophy{height:clamp(193px,34svh,340px)}
.cover .picture::after{content:"";position:absolute;inset:55% 0 0;background:linear-gradient(transparent,#192c22)}
.cover-copy{margin-top:-21px;position:relative;padding:0 clamp(18px,6vw,38px) 12px;display:grid;gap:13px;text-align:center}
.cover h1{color:#ffe7af;font-size:clamp(2rem,8vw,3.15rem);letter-spacing:.03em}
.cover p{color:#f3dfb8}.marker{color:#ffd98c!important;font-weight:bold}
.gold,.outline,.puzzle button,.plain{min-height:46px;border-radius:8px;border:1px solid #9b6939;padding:8px 12px;text-align:center;text-decoration:none;font-weight:700}
.gold{background:linear-gradient(#ffdf99,#e4a23d);border:1px solid #f3cc86;color:#302317;box-shadow:inset 0 0 0 1px #b67832,0 4px 14px #100b04a0;letter-spacing:.055em}
.outline{background:#263b2e;border-color:#ab8852;color:#ffefc8}
.gold:active,.outline:active,.puzzle button:active{transform:translateY(1px)}
.chapters{font-size:.83rem;color:#e4cd9f;padding-top:4px}
.chapters ul{list-style:none;margin:7px 0 0;padding:0;display:flex;gap:4px}
.chapters li{flex:1;border:1px solid #8f7953;border-radius:6px;padding:8px 0}
.chapters li::before{content:"🔒 ";font-size:.7em}
.site-return{display:grid;place-items:center;justify-self:center;min-height:44px;padding:6px 12px;color:#edd3a2;font-size:.88rem;text-underline-offset:4px}
#screen:has(>.invitation){align-content:start}
.invitation .cover-copy{gap:12px}
.visit-letter{display:grid;gap:7px;margin-top:3px;padding:11px 12px 12px;text-align:left;border:1px solid #e4c18a;border-radius:8px;background:linear-gradient(138deg,#ffedce,#eed5a5);box-shadow:inset 0 0 0 2px #ba9458,0 4px 14px #101511a0}
.visit-letter p{font:700 .93rem/1.32 "Yu Mincho","Hiragino Mincho ProN",serif;color:#39291b}
.visit-follow{display:flex;align-items:center;justify-content:center;gap:10px;min-height:44px;padding:8px 10px;border:1px solid #6a7448;border-radius:6px;background:#284034;color:#fff2d0;text-decoration:none;font-size:.96rem;font-weight:700;line-height:1.18}
.visit-follow:hover{background:#314d3d}
.visit-instagram-icon{display:inline-block;position:relative;flex:none;width:18px;height:18px;border:1.6px solid currentColor;border-radius:5px}
.visit-instagram-icon::before{position:absolute;content:"";inset:4px;border:1.4px solid currentColor;border-radius:50%}
.visit-instagram-icon::after{position:absolute;content:"";width:2.4px;height:2.4px;top:2px;right:2px;background:currentColor;border-radius:50%}
.visit-more{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.visit-more a{display:grid;align-content:center;gap:3px;min-height:45px;padding:6px 5px;border:1px solid #897651;border-radius:7px;text-decoration:none;color:#f7e5be;line-height:1.15}
.visit-more strong{font-size:clamp(.76rem,3.52vw,.86rem)}
.visit-more span{font-size:.68rem;color:#e2cda5}
.cover .visit-hours{margin-top:-3px;color:#e7d3ac;font-size:.85rem;line-height:1.35}
.visit-hours strong{margin-right:.4em;font-weight:600}
.visit-contact{display:grid;gap:6px;padding:8px;border:1px solid #826947;border-radius:8px;background:#22382e;text-align:left}
.visit-contact h2{padding:3px 2px 2px;color:#ffedc2;font-size:.9rem}
.visit-channel{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:7px;min-height:45px;padding:4px 8px;border:1px solid #756745;border-radius:5px;background:#1c3028;text-decoration:none;color:#fff3d2}
.visit-channel strong{font-size:.9rem;line-height:1.25}
.visit-time{font-size:.76rem;color:#efc574}
.visit-channel:hover,.visit-more a:hover{border-color:#e8bd70}
.invitation .cover-copy>small{font-size:.72rem;color:#dbc7a4}
.puzzle{position:relative;background:linear-gradient(165deg,#fff1d5,#ffebc0);color:var(--ink);padding:16px clamp(12px,4vw,24px) 22px;display:grid;gap:8px;overflow:clip;border-top:1px solid #e6bd75}
.puzzle h1{font-size:clamp(1.65rem,6vw,2.45rem)}
.puzzle button,.plain{background:#fff8e8;color:#2e4035;border-color:#a48959}
.puzzle .main-action{background:#294b3c;border-color:#294b3c;color:#fff3d5}
.bar,.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.bar{justify-content:space-between}
.eyebrow{font-size:.82rem;color:#6c4b26;font-weight:bold}
.eyebrow span{font-weight:400;margin-left:3px}
.instruction{font-weight:650}
.secondary{font-size:.92rem;color:#594b38}
.status{min-height:1.65em;color:#2b4538;font-weight:650}
.status:empty{min-height:0}
.path-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:3px;margin:2px 0 0;background:#6d5738;padding:4px;border-radius:8px;box-shadow:0 0 0 1px #91704a}
.path-grid .cell{position:relative;padding:0;min-height:45px;aspect-ratio:1.16;border-radius:5px;border-color:#bca16e;background:#f5e3b8;font-size:.87rem;line-height:1.1;box-shadow:inset 0 1px 0 #fff5d6}
.cell.wall{opacity:1;background:repeating-linear-gradient(135deg,#d2c2a4 0 5px,#c7b69a 6px 9px);border-color:#c8b597}
.cell[aria-pressed=true]{background:#edb653;color:#322711}
.cell.current{box-shadow:inset 0 0 0 2px #553a15}
.cell.switch{border:1px dashed #794a24}
.cell[data-cell="25"][aria-pressed=false]{background:#ffe6a3;box-shadow:inset 0 0 0 2px #9b6328}
.cell.star-tile{background:#f9d98e;color:#4d3216;border-color:#ad7d3a}
.cell.star-tile[aria-pressed=true]{background:#ba8540;color:#211c0d}
.cell.sealed{background:#735a50;color:#fff1c7}
.path-grid .cell.suggested{outline:3px solid #f8ba4b;outline-offset:-4px;box-shadow:inset 0 0 0 2px #62431d}
.cell.current span{font-weight:bold}
.cell.closed:not([aria-pressed=true]){background:#5b574b;color:#fff1c7}
.cell.open:not([aria-pressed=true]){background:#c6dac0;color:#243b2e}
.cell-face{position:relative;z-index:1}
.cell-face small{display:block;font-size:.76em;margin-top:2px}
.cell-face:has(>small:only-child){font-variant-numeric:tabular-nums}
.trace{position:absolute;pointer-events:none;background:#f8d57d;opacity:.85;z-index:0}
.trace.north,.trace.south{width:6px;height:calc(50% + 1px);left:calc(50% - 3px)}
.trace.north{top:-1px}.trace.south{bottom:-1px}
.trace.east,.trace.west{height:6px;width:calc(50% + 1px);top:calc(50% - 3px)}
.trace.east{right:-1px}.trace.west{left:-1px}
.gate-state{font-weight:700;font-size:.88rem;margin-bottom:2px}
.path-state{display:flex;gap:10px;align-items:center;justify-content:space-between}
.path-state strong{font-size:.88rem;color:#513a20}
details{background:#f5e2b9;padding:0 10px 5px;border-radius:7px}
summary{cursor:pointer;min-height:44px;padding:10px 0;display:list-item;font-weight:650}
details p{padding:0 0 5px}
.hints{display:grid;gap:6px;border-left:3px solid #c2934d;padding-left:10px}
.oil-board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;border:1px solid #876342;border-radius:10px;padding:6px;background:linear-gradient(#754f33,#5a3b2a)}
.cylinder,.puzzle .cylinder{display:grid;justify-items:center;gap:3px;padding:6px 4px;color:#2e4035;background:#ffefca;border:1px solid #bf9460;border-radius:6px}
.puzzle .cylinder[aria-pressed=true]{outline:2px solid #633818;outline-offset:-4px;background:#ffe097}
.cylinder.charged,.puzzle .cylinder.charged{background:#ffe195;box-shadow:inset 0 0 12px #b87537a0}
.oil-name{font-size:.84rem;white-space:nowrap;font-weight:700}
.oil-count{font-size:1.1rem;font-weight:750;font-variant-numeric:tabular-nums}
.oil-count small{font-size:.72em;font-weight:500}
.oil-gauge{width:70%;height:clamp(49px,9vh,84px);position:relative;display:block;background:linear-gradient(90deg,#c3a07a,#fff1d2 35%,#dbc09e);border:2px solid #634220;border-radius:10px 10px 5px 5px;overflow:hidden}
.oil-gauge i{position:absolute;inset:auto 0 0;height:var(--level);background:linear-gradient(110deg,#a65918,#ed9b26 45%,#ba671a);border-top:1px solid #f9cd73}
.oil-gauge b{position:absolute;inset:auto 0 var(--target);border-top:2px dashed #281a11}
.oil-example .oil-gauge{height:36px}
.oil-example{margin:3px 0}
.train-boards{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.train-panel{border-radius:8px;background:#354e3f;padding:4px;color:#ffefca;min-width:0;--engine:#488459}
.train-panel.violet{background:#4b405e;--engine:#8158a6}
.train-panel p{font-size:.72rem;white-space:nowrap;text-align:center;padding:3px 0 5px;font-weight:650}
.train-track{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:2px}
.track-tile{display:grid;place-items:center;position:relative;aspect-ratio:1;background:linear-gradient(#f2d4a3,#dcb680);border:1px solid #a37447;border-radius:4px;font-size:.83rem;color:#3d2918}
.track-tile.barrier{background:repeating-linear-gradient(135deg,#8e684e 0 4px,#aa7e59 5px 7px);border-color:#ae8866}
.track-tile.station{background:#ffdd86;border:2px solid #b97828}
.track-tile.station.occupied{box-shadow:inset 0 0 0 2px #6c491d,0 0 6px #e8ba69;font-weight:900}
.track-tile.occupied span{position:absolute;z-index:2;font-weight:bold;color:#fff6d2;font-size:.72rem}
.locomotive{position:absolute;z-index:1;width:76%;height:57%;border-radius:38% 20% 22% 25%;border:1px solid #342924;background:linear-gradient(var(--engine),#292f2e);box-shadow:0 2px 1px #3a281b80;pointer-events:none}
.locomotive::before,.locomotive::after{content:"";position:absolute;border-radius:50%;background:#28282c;border:1px solid #dec19a;width:26%;height:36%;bottom:-16%}
.locomotive::before{left:13%}.locomotive::after{right:13%}
.direction-pad,.direction-demo{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.direction-pad button{padding:3px 5px;font-size:1.4rem;background:linear-gradient(#fff6e0,#eac590)}
.direction-demo{grid-template-columns:1fr 1fr;margin:4px 0}
.direction-demo div{display:grid;gap:3px;padding:6px;text-align:center;background:#efe1b7;border-radius:5px}
.direction-demo strong{font-size:1.35rem}
.result{border:1px solid #b99053;padding:13px;display:grid;gap:9px;background:#f9e7ba;border-radius:9px}
.result strong{display:block;font-size:1.23rem;color:#31503b}
.walkthrough{display:grid;gap:6px;margin:7px 0 6px;padding-top:7px;border-top:1px solid #c2a270}
.spark{position:absolute;top:66%;left:50%;width:8px;height:8px;border-radius:1px;background:#ffd883;pointer-events:none;animation:burst .8s ease-out both}
.clear-light,.bell-light{position:absolute;inset:0;pointer-events:none;opacity:0;mix-blend-mode:screen}
.gate-cleared .clear-light{background:linear-gradient(90deg,transparent,#ffb13599,transparent);animation:reveal 1.05s ease-out}
.lamps-cleared .clear-light{background:radial-gradient(ellipse at 28% 44%,#ffd582,transparent 32%),radial-gradient(ellipse at 73% 44%,#ffd582,transparent 32%);animation:reveal 1.05s ease-out}
.tiles-cleared .clear-light,.bell-light{background:radial-gradient(ellipse at 62% 62%,#ffeab1,transparent 53%);animation:reveal 1.15s ease-out}
.bell-light{animation-duration:1.9s}
@keyframes reveal{0%{opacity:0}23%{opacity:.88}100%{opacity:0}}
@keyframes burst{0%{transform:translate(0,0) rotate(0deg);opacity:1}100%{transform:translate(var(--x),var(--y)) rotate(var(--r));opacity:0}}
@media(max-height:700px){.hero{--art-height:clamp(180px,37svh,255px)}.puzzle-top .picture{--art-height:clamp(85px,16svh,111px)}}
@media(max-height:620px) and (max-width:380px){
  .puzzle-top .picture{--art-height:55px}
  .puzzle[data-puzzle]{gap:5px;padding-top:9px}
  .puzzle[data-puzzle] p{line-height:1.42}
  .puzzle[data-puzzle="1"] .gate-state{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .puzzle[data-puzzle="3"] .train-boards{width:100%;max-width:270px;justify-self:center}
}
@media(max-width:350px){.path-grid{gap:2px}.path-grid .cell{min-height:44px}}
@media(prefers-reduced-motion:reduce){.spark,.clear-light,.bell-light{animation:none}.spark{display:none}}
