:root{
  --ink:#1b1b1b; --line:#16794f; --led:#ff9a2a; --ledbg:#0e0e0d; --paper:#f7f7f4;
  --sans:'M PLUS 1p','Hiragino Sans','Yu Gothic',sans-serif;
  --dot:'DotGothic16','Osaka-mono',monospace;
}
*{box-sizing:border-box;margin:0;padding:0}
[hidden],.hidden{display:none!important}
html,body{height:100%;overflow:hidden;background:#2a2c2e;color:var(--ink);font-family:var(--sans);touch-action:manipulation;-webkit-text-size-adjust:100%;text-size-adjust:100%;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}
button,a{font-family:inherit;color:inherit;background:none;border:0;cursor:pointer;touch-action:manipulation;text-decoration:none}
#squeeze{position:fixed;inset:0;transform-origin:50% 55%;will-change:transform}
#view{position:absolute;inset:0}
#view canvas{display:block;width:100%;height:100%;touch-action:none}
.screen{position:fixed;inset:0;z-index:10}
#boot-err{position:fixed;inset:auto 8px 8px 8px;z-index:99;background:#fff;color:#b00;font:12px/1.4 monospace;white-space:pre-wrap;padding:10px}

/* ---------- 読み込み中（駅の電光掲示板） ---------- */
#loading{position:fixed;inset:0;z-index:60;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:26px;background:#1d1e20;transition:opacity .35s}
#loading.out{opacity:0;pointer-events:none}
.board{width:min(560px,88vw);background:var(--ledbg);border:6px solid #3b3d40;border-top-width:10px;padding:14px 16px 12px;box-shadow:inset 0 0 0 2px #000}
.board-row{display:flex;align-items:baseline;gap:14px;font-family:var(--dot);color:var(--led);white-space:nowrap;overflow:hidden}
.board .kind{font-size:clamp(16px,4.4vw,22px);color:#7fd16a}
.board-text{font-size:clamp(20px,5.6vw,32px);letter-spacing:.06em;animation:ledBlink 1.6s steps(1) infinite}
@keyframes ledBlink{0%,70%{opacity:1}71%,100%{opacity:.45}}
.dots{margin-top:12px;height:8px;background:repeating-linear-gradient(90deg,#3a2410 0 6px,transparent 6px 9px)}
.dots i{display:block;height:100%;width:0;background:repeating-linear-gradient(90deg,var(--led) 0 6px,transparent 6px 9px);transition:width .2s}
.rails{width:min(560px,88vw);height:auto;overflow:visible}
.headlight{animation:comeIn 2.4s linear infinite}
@keyframes comeIn{0%{transform:translateX(330px);opacity:0}10%{opacity:1}90%{opacity:1}100%{transform:translateX(-10px);opacity:0}}

/* ---------- 主観の演出 ---------- */
#fxPerfume{position:fixed;inset:0;z-index:3;pointer-events:none;background:radial-gradient(ellipse at 50% 55%,rgba(230,170,225,.18),rgba(200,120,200,.42));opacity:0}
#fxVig{position:fixed;inset:0;z-index:3;pointer-events:none;background:radial-gradient(ellipse at 50% 50%,rgba(0,0,0,0) 45%,rgba(10,6,4,.85) 100%);opacity:0}
#fxFlash{position:fixed;inset:0;z-index:4;pointer-events:none;opacity:0;background:radial-gradient(ellipse at center,rgba(255,255,255,0) 30%,rgba(255,236,200,.75) 100%)}
#fxFlash.red{background:radial-gradient(ellipse at center,rgba(255,0,0,0) 30%,rgba(200,20,10,.7) 100%)}

/* ---------- 遊び中 ---------- */
#hud{position:fixed;inset:0;z-index:5;pointer-events:none}
.led{position:absolute;left:50%;top:max(8px,env(safe-area-inset-top));transform:translateX(-50%);width:min(520px,calc(100vw - 80px));display:flex;align-items:baseline;gap:10px;padding:7px 12px 6px;background:var(--ledbg);border:4px solid #3b3d40;border-top-width:7px;font-family:var(--dot);color:var(--led);white-space:nowrap;overflow:hidden}
.led-text{flex:1;min-width:0;font-size:clamp(12px,3.5vw,19px);overflow:hidden;text-overflow:clip}
.led-text.dest{color:#7fd16a}
.led-sec{flex:none;font-weight:400;font-size:clamp(18px,5vw,24px)}
.led.warn .led-sec{color:#ff4b3a}
.say{position:absolute;left:0;top:0;transform:translate(-50%,-100%);padding:6px 11px;background:#fff;color:var(--ink);font-weight:800;font-size:clamp(15px,4.2vw,19px);border-radius:14px 14px 14px 3px;white-space:nowrap;box-shadow:0 2px 6px rgba(0,0,0,.25)}
.say.dufu{font-family:var(--sans);font-weight:900;letter-spacing:.04em}
.hint{position:absolute;right:calc(env(safe-area-inset-right) + 20px);bottom:calc(env(safe-area-inset-bottom) + 160px);color:#fff;font-weight:800;font-size:15px;text-shadow:0 1px 6px rgba(0,0,0,.8)}
.touch{position:absolute;inset:0;pointer-events:none}
.stickzone{position:absolute;left:0;bottom:0;width:55%;height:72%;pointer-events:auto;touch-action:none}
.stick{position:absolute;width:120px;height:120px;margin:-60px 0 0 -60px;border-radius:50%;border:3px solid rgba(255,255,255,.55);background:rgba(0,0,0,.18)}
.knob{position:absolute;left:50%;top:50%;width:50px;height:50px;margin:-25px 0 0 -25px;border-radius:50%;background:rgba(255,255,255,.8)}
.push{position:absolute;right:calc(env(safe-area-inset-right) + 18px);bottom:calc(env(safe-area-inset-bottom) + 22px);width:112px;height:112px;border-radius:50%;background:#16794f;border:4px solid #0d4e33;box-shadow:0 6px 0 #0d4e33,0 10px 20px rgba(0,0,0,.35);pointer-events:auto;display:flex;align-items:center;justify-content:center;transition:transform .06s}
.push svg{width:64px;height:64px;transform:rotate(-8deg)}
.grab{position:absolute;right:calc(env(safe-area-inset-right) + 140px);bottom:calc(env(safe-area-inset-bottom) + 30px);width:84px;height:84px;border-radius:50%;background:#3b3d40;border:4px solid #1f2022;pointer-events:auto;display:flex;align-items:center;justify-content:center}
.grab svg{width:50px;height:50px}
.grab.on{background:#ff9a2a;border-color:#a85a10;box-shadow:0 0 0 6px rgba(255,154,42,.35)}
.push.on{transform:translateY(5px) scale(.96);box-shadow:0 1px 0 #0d4e33}
.quit{position:absolute;right:calc(env(safe-area-inset-right) + 8px);top:max(10px,env(safe-area-inset-top));width:40px;height:40px;pointer-events:auto;background:rgba(0,0,0,.35);border-radius:50%;display:flex;align-items:center;justify-content:center}
.quit svg{width:18px;height:18px}

/* ---------- タイトル（駅名標） ---------- */
#title{display:flex;flex-direction:column;align-items:flex-start;padding:max(22px,env(safe-area-inset-top)) 18px max(14px,env(safe-area-inset-bottom));background:linear-gradient(180deg,rgba(20,22,24,.25),rgba(20,22,24,0) 40%,rgba(20,22,24,0) 62%,rgba(20,22,24,.72))}
.ekimei{background:var(--paper);width:min(520px,100%);padding:12px 18px 0;box-shadow:0 8px 24px rgba(0,0,0,.3);transform:rotate(-1deg)}
.ekimei .ruby{font-size:11px;font-weight:800;letter-spacing:.18em;color:#555}
.ekimei h1{font-size:clamp(30px,9vw,52px);font-weight:900;line-height:1.15;letter-spacing:.02em;white-space:nowrap}
.band{margin:8px -18px 0;display:flex;justify-content:space-between;padding:6px 18px 8px;background:var(--line);color:#fff;font-weight:800;font-size:13px}
.band span:first-child::before{content:'';display:inline-block;border:6px solid transparent;border-right-color:#fff;margin-right:6px;vertical-align:-1px}
.band span:last-child::after{content:'';display:inline-block;border:6px solid transparent;border-left-color:#fff;margin-left:6px;vertical-align:-1px}
.sub{word-break:auto-phrase;margin-top:14px;color:#fff;font-weight:800;font-size:15px;line-height:1.5;text-shadow:0 1px 8px rgba(0,0,0,.8)}
.title-actions{margin-top:auto;display:flex;align-items:center;gap:18px}
.go{min-width:min(210px,56vw);padding:13px 26px;font-weight:900;font-size:24px;letter-spacing:.2em;color:#fff;background:var(--line);border-radius:6px;box-shadow:0 5px 0 #0d4e33,0 10px 22px rgba(0,0,0,.3);transition:transform .08s}
.go:active{transform:translateY(4px);box-shadow:0 1px 0 #0d4e33}
.go.small{font-size:19px;min-width:160px;padding:10px 20px;letter-spacing:.1em}
.text-btn{font-weight:800;font-size:16px;color:#fff;padding:8px 2px;border-bottom:2px solid rgba(255,255,255,.7);text-shadow:0 1px 6px rgba(0,0,0,.6)}
.foot{display:flex;flex-wrap:wrap;gap:6px 14px;margin-top:12px}
.mini{display:inline-flex;align-items:center;min-height:36px;padding:0 4px;font-size:13px;font-weight:800;color:rgba(255,255,255,.92);white-space:nowrap;text-shadow:0 1px 4px rgba(0,0,0,.7)}

/* ---------- 遊び方（駅の掲示物） ---------- */
#how{display:flex;align-items:center;justify-content:center;padding:14px;background:rgba(20,22,24,.6)}
.notice{width:min(440px,100%);max-height:calc(100svh - 28px);overflow:hidden;background:#fdfcf6;border-top:10px solid var(--line);padding:16px 20px 14px;display:flex;flex-direction:column;align-items:center}
.notice h2{font-size:24px;font-weight:900;margin-bottom:10px;align-self:flex-start}
.notice ol{list-style:none;counter-reset:n;font-size:15px;line-height:1.55;display:flex;flex-direction:column;gap:9px;width:100%}
.notice li{counter-increment:n;display:grid;grid-template-columns:26px 1fr;gap:6px;word-break:auto-phrase}
.notice li::before{content:counter(n);font-family:var(--dot);color:var(--line);font-size:20px;line-height:1.1}
.notice .keys{font-size:12px;color:#555;margin:12px 0;text-align:center;line-height:1.5}
.notice .credit{font-size:10px;color:#777;margin-top:10px;text-align:center;line-height:1.4}

/* ---------- 結果 ---------- */
#result{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:max(14px,env(safe-area-inset-top)) 14px max(12px,env(safe-area-inset-bottom));background:rgba(20,22,24,.55)}
#ticket{display:block;max-width:100%;filter:drop-shadow(0 10px 18px rgba(0,0,0,.45))}
.result-actions{display:flex;flex-direction:column;align-items:center;gap:8px}
.result-actions .row{display:flex;gap:16px}

@media (min-width:1000px) and (min-height:700px){
  .go{font-size:32px;min-width:300px;padding:18px 34px}
  .ekimei{width:640px}
  .ekimei h1{font-size:64px}
  .sub{font-size:18px}
}
@media (max-height:560px) and (orientation:landscape){
  #title{padding-top:12px}
  .ekimei h1{font-size:34px}
  .sub{margin-top:8px;font-size:13px}
  .push{width:92px;height:92px}
  .push svg{width:52px;height:52px}
  .grab{width:70px;height:70px;right:calc(env(safe-area-inset-right) + 118px);bottom:calc(env(safe-area-inset-bottom) + 26px)}
  .grab svg{width:42px;height:42px}
  #result{flex-direction:row;gap:18px}
  .notice{padding:10px 16px}
  .notice ol{gap:4px;font-size:14px}
  .notice .keys{margin:6px 0}
}
@media (max-height:700px) and (orientation:portrait){
  .sub{font-size:14px}
}
/* 支援ボタン（共通 support.js）は #result の直下に入る。横長では3列目になってはみ出すので、ボタンの列の下に置く */
@media (max-height:560px) and (orientation:landscape){
  #result{display:grid;grid-template-columns:auto auto;grid-template-rows:1fr auto auto 1fr;column-gap:18px;row-gap:0;justify-content:center;align-items:center}
  #result>#ticket{grid-column:1;grid-row:1/5}
  #result>.result-actions{grid-column:2;grid-row:2}
  #result>#tmSupport{grid-column:2;grid-row:3}
}
