:root {
  --ink: #2b2140; --ink2: #6b5f86; --glass: rgba(255, 255, 255, .62); --glass2: rgba(255, 255, 255, .86); --line: rgba(255, 255, 255, .75);
  --pink: #ff8fb1; --sky: #7cc7ff; --lav: #b48cff; --mint: #7ee0b8; --gold: #ffc66b; --ver: #d23a48;
  --grid: rgba(60, 40, 110, .08); --cross: rgba(60, 40, 110, .3); --lineC: #7e8cff;
  --shadow: 0 18px 50px rgba(60, 40, 110, .22);
  --round: "Hiragino Maru Gothic ProN", "SF Pro Rounded", ui-rounded, -apple-system, sans-serif;
  --jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --lc: #f15a7a;
}
body.night { --ink: #eef0ff; --ink2: #aab0d8; --glass: rgba(26, 24, 58, .55); --glass2: rgba(30, 28, 66, .84); --line: rgba(255, 255, 255, .16); --shadow: 0 18px 50px rgba(0, 0, 0, .45); --grid: rgba(255, 255, 255, .07); --cross: rgba(255, 255, 255, .3); --lineC: #9fa9ff; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1530; }
body { font: 14px/1.5 var(--round); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* sky + scene */
.sky { position: fixed; inset: -3%; background-size: cover; background-position: center; opacity: 0; transition: opacity 1.4s ease; animation: drift 60s ease-in-out infinite alternate; }
.sky.on { opacity: 1; }
@keyframes drift { to { transform: scale(1.06) translate(-1%, -1%); } }
#scene { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.tint { position: fixed; inset: 0; z-index: 1; pointer-events: none; transition: background 1s; }
body.in-station .tint { background: linear-gradient(180deg, rgba(30, 16, 60, .08), rgba(30, 16, 60, .32)); }
body.in-map .tint { background: rgba(30, 16, 60, .12); }

/* top bar */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 8; display: flex; align-items: center; gap: 10px; padding: 16px 22px; }
.brand { all: unset; cursor: pointer; font-weight: 800; letter-spacing: .06em; font-size: 15px; padding: 7px 14px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%); border: 1px solid var(--line); box-shadow: var(--shadow); }
.brand b, h1 b, .bt b { color: var(--pink); }
.pill { padding: 7px 14px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); font-size: 13px; color: var(--ink2); box-shadow: var(--shadow); }
.pill:empty { display: none; }
.pill b { color: var(--ink); }
.sp { flex: 1; }
.tbtn { all: unset; cursor: pointer; padding: 7px 13px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); font-size: 13px; box-shadow: var(--shadow); transition: transform .15s; }
.tbtn:hover { transform: translateY(-1px); }
.tbtn span { display: inline-block; min-width: 20px; text-align: center; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--ver); color: #fff; font-weight: 800; font-size: 11.5px; }

/* screens */
.screen { position: fixed; inset: 0; z-index: 4; display: none; }
.screen.on { display: block; animation: fadein .5s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

/* home */
.title { position: absolute; left: 6vw; top: 15vh; width: min(560px, 88vw); color: #fff; }
.title .kana { font: 600 15px var(--jp); letter-spacing: .5em; opacity: .95; text-shadow: 0 2px 14px rgba(50, 20, 90, .5); }
.title h1 { font: 800 clamp(52px, 8vw, 96px)/1 var(--round); letter-spacing: -.01em; margin: 8px 0 14px; text-shadow: 0 4px 30px rgba(50, 20, 90, .45); }
.lede { font-size: 17px; line-height: 1.6; margin: 0 0 26px; text-shadow: 0 2px 14px rgba(40, 20, 80, .6); max-width: 520px; }
.ticket { width: min(470px, 88vw); border-radius: 18px; background: linear-gradient(135deg, #e9f5ff, #f4ecff); color: #2b2140; box-shadow: 0 24px 60px rgba(40, 20, 80, .35); position: relative; overflow: hidden; border: 1px solid #fff; }
.ticket::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, rgba(126, 140, 255, .06) 0 6px, transparent 6px 14px); pointer-events: none; }
.t-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: #2b2140; color: #fff; font-size: 12px; letter-spacing: .08em; font-weight: 700; }
.t-jp { font: 800 15px var(--jp); letter-spacing: .3em; }
.t-route { display: flex; align-items: center; gap: 14px; padding: 18px 20px 10px; position: relative; }
.t-st b { font: 800 30px var(--jp); letter-spacing: .12em; display: block; line-height: 1.1; }
.t-st small { color: #6b5f86; font-weight: 700; letter-spacing: .06em; }
.t-line { flex: 1; text-align: center; font-size: 12px; color: #6b5f86; font-weight: 700; }
.t-line i { display: block; height: 4px; border-radius: 4px; background: linear-gradient(90deg, #f15a7a, #4d8cff, #2fb383, #a06cf0, #f5a524, #2b2140); margin-bottom: 6px; }
.t-foot { display: flex; align-items: center; gap: 10px; padding: 10px 18px 16px; border-top: 2px dashed rgba(43, 33, 64, .15); position: relative; }
.t-foot span { flex: 1; font-size: 13px; color: #6b5f86; font-weight: 700; }
.go { all: unset; cursor: pointer; padding: 11px 20px; border-radius: 999px; font-weight: 800; font-size: 14.5px; color: #fff; background: linear-gradient(90deg, #ff8fb1, #b48cff); box-shadow: 0 10px 26px rgba(180, 80, 160, .35); transition: transform .15s; }
.go:hover { transform: translateY(-2px); }
.chara { position: absolute; right: 3vw; bottom: 0; height: 88vh; z-index: 3; pointer-events: none; filter: drop-shadow(0 20px 40px rgba(40, 20, 80, .35)); transition: transform .9s cubic-bezier(.2, .9, .2, 1), opacity .7s; }
.chara img { height: 100%; display: block; animation: breathe 4.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes breathe { 50% { transform: scaleY(1.008) translateY(-2px); } }

/* map */
.mapcard { position: absolute; left: 50%; top: 72px; transform: translateX(-50%); width: min(1220px, calc(100vw - 40px)); bottom: 200px; border-radius: 28px; background: var(--glass2); backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.maphead { padding: 18px 26px 4px; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.maphead h2 { margin: 0; font-size: 20px; }
.maphead p { margin: 0; color: var(--ink2); font-size: 13.5px; }
.mapwrap { flex: 1; overflow: auto; padding: 0 10px 10px; }
#mapSvg { width: 100%; min-width: 860px; display: block; }
#mapSvg .st { cursor: pointer; }
#mapSvg .st:hover .node { transform: scale(1.18); }
#mapSvg .node { transition: transform .2s; transform-box: fill-box; transform-origin: center; }
#mapSvg text { font-family: var(--round); fill: var(--ink); }
#mapSvg .kj { font: 800 15px var(--jp); fill: var(--ink); letter-spacing: .08em; }
#mapSvg .en { font-size: 11.5px; fill: var(--ink2); font-weight: 600; }
#mapSvg .locked { opacity: .38; }
#mapSvg .locked .st { cursor: default; }
#mapSvg .train { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }

/* station sign (eki-meihyō) */
.sign { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); width: min(760px, calc(100vw - 40px)); background: #fbfbfd; color: #1f1a2e; border-radius: 14px; box-shadow: 0 16px 40px rgba(30, 16, 60, .28); text-align: center; padding-top: 6px; z-index: 5; }
.sign .num { position: absolute; left: 16px; top: 12px; width: 48px; height: 48px; border: 4px solid var(--lc); border-radius: 10px; display: grid; place-items: center; font: 800 18px/1 var(--jp); background: #fff; }
.sign .num small { display: block; font-size: 10px; letter-spacing: .04em; color: var(--lc); }
.sign .kana { font: 600 12px var(--jp); letter-spacing: .4em; color: #6d6680; }
.sign .kanji { font: 800 36px/1.1 var(--jp); letter-spacing: .32em; margin-left: .32em; }
.sign .roma { font-size: 13.5px; font-weight: 700; letter-spacing: .14em; margin: 2px 0 6px; }
.sign .band { display: flex; align-items: center; justify-content: space-between; height: 28px; padding: 0 16px; background: var(--lc); color: #fff; font-weight: 700; font-size: 12.5px; border-radius: 0 0 14px 14px; }
.sign .band .mid { opacity: .95; letter-spacing: .04em; }
.sign .band .pv, .sign .band .nx { min-width: 150px; opacity: .9; }
.sign .band .pv { text-align: left; } .sign .band .nx { text-align: right; }
.sign .back { position: absolute; right: 14px; top: 14px; all: unset; cursor: pointer; }
.sign .lid { position: absolute; right: 16px; top: 16px; font-size: 11.5px; font-weight: 700; color: var(--lc); }

/* workspace */
.ws { position: absolute; left: 50%; transform: translateX(-50%); top: 200px; bottom: 196px; width: min(1220px, calc(100vw - 40px)); border-radius: 26px; padding: 14px; background: var(--glass2); backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; gap: 14px; z-index: 4; }
.ws:empty { display: none; }
.panel { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; border-radius: 18px; }
.panel.side { flex: 0 0 300px; }
.plot { position: relative; flex: 1; min-height: 120px; }
.qt-chart { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.tools { display: flex; gap: 8px; align-items: center; padding: 0 2px 8px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(126, 140, 255, .12); }
.seg button { all: unset; cursor: pointer; padding: 5px 14px; border-radius: 999px; font-weight: 700; font-size: 12.5px; color: var(--ink2); }
.seg button.on { background: #7e8cff; color: #fff; }
.cap { font-size: 12.5px; color: var(--ink2); font-weight: 700; }
.cap b { color: var(--ink); }

/* quiz cards */
.cards { display: flex; gap: 14px; flex: 1; align-items: stretch; justify-content: center; }
.ccard { all: unset; cursor: pointer; flex: 0 1 180px; border-radius: 18px; background: rgba(255, 255, 255, .7); border: 2px solid transparent; box-shadow: 0 8px 22px rgba(80, 40, 140, .12); display: flex; flex-direction: column; align-items: center; padding: 10px; transition: transform .15s, border-color .15s; }
body.night .ccard { background: rgba(255, 255, 255, .06); }
.ccard:hover { transform: translateY(-3px); border-color: var(--pink); }
.ccard canvas { width: 100%; flex: 1; min-height: 140px; }
.ccard.right { border-color: #1fae7a; background: rgba(126, 224, 184, .35); }
.ccard.wrong { border-color: #ef4f6c; background: rgba(255, 179, 194, .35); }
.facts { display: grid; grid-template-columns: repeat(4, auto); gap: 6px 22px; justify-content: center; padding: 6px 0 14px; font-size: 15px; }
.facts div { text-align: center; } .facts small { display: block; color: var(--ink2); font-weight: 700; font-size: 11.5px; letter-spacing: .04em; } .facts b { font-size: 20px; }

/* code */
.editor { position: relative; flex: 1; min-height: 140px; border-radius: 16px; background: #1e1b33; overflow: hidden; display: flex; }
.gut { padding: 14px 8px 14px 12px; color: #6f6996; font: 13.5px/1.6 var(--mono); text-align: right; user-select: none; white-space: pre; }
.edwrap { position: relative; flex: 1; overflow: auto; }
.edwrap pre, .edwrap textarea { margin: 0; padding: 14px 14px 14px 6px; font: 13.5px/1.6 var(--mono); white-space: pre; tab-size: 4; border: 0; min-height: 100%; }
.edwrap pre { position: absolute; inset: 0; color: #e8e6ff; pointer-events: none; overflow: visible; }
.edwrap textarea { position: relative; width: 100%; height: 100%; resize: none; outline: none; background: transparent; color: transparent; caret-color: #ff8fb1; overflow: hidden; display: block; }
.edwrap textarea::selection { background: rgba(126, 140, 255, .35); }
.tk-k { color: #ff8fb1; } .tk-s { color: #b6f0c8; } .tk-n { color: #ffc66b; } .tk-c { color: #7d78a8; font-style: italic; } .tk-f { color: #8fd0ff; } .tk-b { color: #ff6b6b; background: rgba(255, 107, 107, .15); border-radius: 3px; }
.errline { background: rgba(255, 79, 108, .22); display: inline-block; width: 100%; }
.runbar { display: flex; gap: 8px; align-items: center; padding: 8px 2px 0; }
.btn { all: unset; cursor: pointer; padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 13px; background: rgba(126, 140, 255, .14); color: var(--ink); transition: transform .15s; }
.btn:hover { transform: translateY(-1px); }
.btn.run { background: linear-gradient(90deg, #7cc7ff, #7e8cff); color: #fff; box-shadow: 0 8px 20px rgba(80, 100, 220, .3); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.kbd { font-size: 11.5px; color: var(--ink2); }
.console { margin-top: 8px; height: 120px; overflow: auto; border-radius: 14px; background: rgba(30, 27, 51, .9); color: #d9d6f5; font: 12.5px/1.5 var(--mono); padding: 10px 12px; white-space: pre-wrap; }
.console .e { color: #ff9aae; } .console .m { color: #8a85b8; }
.tests { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
.tests span { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(126, 140, 255, .14); }
.tests span.p { background: rgba(31, 174, 122, .18); color: #128a5f; } .tests span.f { background: rgba(239, 79, 108, .16); color: #c42f4f; }
body.night .tests span.p { color: #7ee0b8; } body.night .tests span.f { color: #ffb3c2; }

/* dialogue */
.vn { position: fixed; z-index: 7; left: 50%; bottom: 22px; transform: translateX(-50%); width: min(980px, calc(100vw - 40px)); }
body.in-home .vn { left: 6vw; transform: none; width: min(760px, calc(100vw - 12vw - 30vw)); min-width: 320px; }
.box { position: relative; border-radius: 26px; padding: 24px 26px 16px; min-height: 140px; background: var(--glass2); backdrop-filter: blur(26px) saturate(180%); -webkit-backdrop-filter: blur(26px) saturate(180%); border: 1.5px solid var(--line); box-shadow: var(--shadow); }
.name { position: absolute; top: -18px; left: 24px; padding: 5px 16px 5px 6px; border-radius: 999px; color: #fff; font-weight: 800; letter-spacing: .04em; font-size: 14px; display: flex; align-items: center; gap: 8px; background: linear-gradient(90deg, #7cc7ff, #7e8cff); box-shadow: 0 8px 22px rgba(80, 40, 140, .3); }
.name img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: 50% 30%; background: #fff; border: 2px solid #fff; }
.name small { font-weight: 600; opacity: .9; font-size: 11px; letter-spacing: 0; }
.dots { position: absolute; top: 12px; right: 20px; display: flex; gap: 5px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(126, 140, 255, .2); }
.dots i.d { background: #7e8cff; } .dots i.c { background: var(--pink); transform: scale(1.25); }
.line { font-size: 17.5px; line-height: 1.6; min-height: 56px; white-space: pre-wrap; }
.line .cur { display: inline-block; width: 8px; height: 17px; vertical-align: -3px; margin-left: 2px; background: var(--pink); border-radius: 2px; animation: blink .9s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.line code { font: 14.5px var(--mono); background: rgba(126, 140, 255, .16); padding: 1px 6px; border-radius: 6px; }
.term { border-bottom: 2px dotted var(--pink); cursor: help; font-weight: 700; }
.next { position: absolute; right: 22px; bottom: 12px; font-size: 13px; font-weight: 800; color: var(--pink); cursor: pointer; animation: nudge 1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ch { all: unset; cursor: pointer; padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 13.5px; background: #fff; color: #3a2d5c; border: 2px solid transparent; box-shadow: 0 6px 18px rgba(80, 40, 140, .14); transition: transform .15s, border-color .15s; }
body.night .ch { background: rgba(255, 255, 255, .12); color: #fff; }
.ch:hover { transform: translateY(-2px); border-color: var(--pink); }
.ch.right { background: #7ee0b8; color: #11372b; } .ch.wrong { background: #ffb3c2; color: #5a1426; }
.ch.go2 { background: linear-gradient(90deg, #7cc7ff, #7e8cff); color: #fff; }
.ask { display: flex; gap: 8px; margin-top: 10px; }
.ask input { flex: 1; border: 2px solid rgba(126, 140, 255, .3); border-radius: 999px; padding: 9px 16px; font: 15px var(--round); outline: none; background: rgba(255, 255, 255, .8); color: #2b2140; }
.ask input:focus { border-color: var(--pink); }

/* glossary */
.gloss { position: fixed; z-index: 30; max-width: 320px; padding: 12px 14px; border-radius: 16px; background: #fff; color: #2b2140; box-shadow: 0 18px 40px rgba(40, 20, 80, .3); font-size: 13.5px; line-height: 1.5; }
.gloss b { display: block; font-size: 14.5px; margin-bottom: 2px; color: #7e5cf0; }

/* modal + stamps */
.modal { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; background: rgba(40, 20, 70, .38); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal.on { display: grid; animation: fadein .25s; }
.mcard { width: min(560px, 92vw); max-height: 86vh; overflow: auto; border-radius: 28px; padding: 26px 28px 22px; background: rgba(255, 253, 248, .97); color: #2b2140; box-shadow: 0 30px 80px rgba(40, 20, 80, .35); text-align: center; }
.mcard.wide { width: min(900px, 94vw); }
.mcard h2 { margin: 6px 0 2px; font-size: 22px; }
.mcard p { color: #6b5f86; margin: 4px 0 16px; }
.mcard .acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.stampbig { width: 220px; height: 220px; margin: 0 auto; }
.stampbig svg { width: 100%; height: 100%; animation: stampin .55s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes stampin { 0% { transform: scale(1.8) rotate(-14deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1) rotate(var(--rot, -6deg)); } }
.book { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; margin-top: 14px; }
.slot { aspect-ratio: 1; border-radius: 16px; border: 2px dashed rgba(107, 95, 134, .25); display: grid; place-items: center; position: relative; }
.slot svg { width: 92%; height: 92%; }
.slot .ph { font: 800 18px var(--jp); color: rgba(107, 95, 134, .3); letter-spacing: .1em; }
.slot small { position: absolute; bottom: 4px; left: 0; right: 0; font-size: 10.5px; color: #8a7aa8; font-weight: 700; }
.bookline { text-align: left; font-weight: 800; margin: 16px 0 0; display: flex; align-items: center; gap: 8px; }
.bookline i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* boot */
#boot { position: fixed; inset: 0; z-index: 40; background: #f6f2ff; display: grid; place-items: center; transition: opacity .8s; }
#boot.gone { opacity: 0; pointer-events: none; }
#boot .bt { font: 800 36px var(--round); letter-spacing: .06em; color: #2b2140; }
#boot .bs { text-align: center; color: #8a7aa8; font-size: 13px; margin-top: 6px; }
.credits { position: fixed; left: 50%; transform: translateX(-50%); bottom: 3px; z-index: 6; font-size: 10px; color: rgba(255, 255, 255, .75); text-shadow: 0 1px 4px rgba(0, 0, 0, .5); white-space: nowrap; }

@media (max-width: 900px) {
  .chara { opacity: .25; right: -20vw; }
  body.in-home .vn { left: 50%; transform: translateX(-50%); width: calc(100vw - 32px); }
  .ws { flex-direction: column; top: 190px; overflow: auto; }
  .panel.side { flex: 0 0 auto; }
  .sign .band .pv, .sign .band .nx { min-width: 0; font-size: 11px; }
  .title { left: 16px; top: 80px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.mcard .ch, body.night .mcard .ch { background: #fff; color: #3a2d5c; border-color: #ece6f7; }
.name .mono { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: #7e8cff; display: grid; place-items: center; font: 800 14px var(--round); font-style: normal; }

.name .kface { width: 30px; height: 30px; border-radius: 50%; background: #fff no-repeat; background-size: 230%; background-position: 50% 14%; border: 2px solid #fff; display: block; }
.vn .side { position: absolute; right: -196px; bottom: -22px; height: 236px; pointer-events: none; filter: drop-shadow(0 14px 26px rgba(30, 16, 60, .35)); }
.vn .side img { height: 100%; display: block; transform-origin: 50% 100%; animation: breathe 4.2s ease-in-out infinite; }
body.in-home .vn .side { display: none; }
@media (max-width: 1400px) { .vn .side { display: none; } }
.chara { height: 84vh; right: 5vw; }
.sky { background-color: #2b2140; }
body.in-home .tint { background: linear-gradient(90deg, rgba(30,16,60,.6), rgba(30,16,60,.25) 45%, rgba(30,16,60,0) 70%); }
body.in-station .tint { background: rgba(30, 16, 60, .18); }
