:root {
  --ink: #17122a;
  --panel: #2c2050;
  --cyan: #55f8e7;
  --pink: #ff4f9a;
  --yellow: #fff45f;
  --violet: #8d5cff;
  color: var(--yellow);
  background: var(--ink);
  font-family: "Courier New", monospace;
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgb(85 248 231 / .045) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(rgb(85 248 231 / .045) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(circle at 78% 12%, #55225f 0 2px, transparent 3px),
    linear-gradient(145deg, #100b22, #1f1238 52%, #101731);
}
button { font: inherit; }

#app { width: min(calc(100% - 2rem), 1120px); margin: 0 auto; padding: 1rem 0 2rem; }
.pixel-panel { border: 4px solid var(--cyan); background: linear-gradient(145deg, #33215b, var(--panel)); box-shadow: 8px 8px 0 var(--pink), -3px -3px 0 var(--violet); padding: 1.15rem; }
.pixel-button { border: 3px solid var(--yellow); background: var(--pink); color: var(--ink); cursor: pointer; padding: .65rem .9rem; font-weight: 900; box-shadow: 4px 4px 0 #0d0920; text-transform: none; }
.pixel-button:hover { background: var(--cyan); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #0d0920; }
.pixel-button:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.scene { min-height: min(76vh, 760px); display: grid; place-items: center; margin-top: 1.25rem; }
.hud { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; justify-content: space-between; }
.hud-scores, .audio-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.hud-scores span { border-left: 4px solid var(--pink); padding-left: .65rem; letter-spacing: .08em; }
.hud-audio-button { border: 2px solid var(--cyan); background: #17122a; color: var(--yellow); cursor: pointer; padding: .42rem .6rem; font-size: .78rem; font-weight: 800; }
.hud-audio-button:hover { border-color: var(--yellow); color: var(--cyan); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-scene, .dialogue-scene, .transition-scene { width: min(100%, 620px); }
.map-scene { width: min(100%, 820px); }
.scene-title { margin: 0 0 1rem; color: var(--cyan); font-family: system-ui, sans-serif; font-size: clamp(1.45rem, 4vw, 2.45rem); font-weight: 950; letter-spacing: .04em; text-shadow: 3px 3px 0 #762462; }
.dialogue { margin: 0 0 1rem; color: #fff; font-family: system-ui, sans-serif; font-size: 1.05rem; line-height: 1.7; }
.dialogue-success { color: var(--yellow); font-weight: 700; }
.login-form { display: grid; gap: .75rem; }
.field-label { color: var(--cyan); font-weight: 700; }
.name-input { width: 100%; border: 3px solid var(--cyan); background: var(--ink); color: #fff; padding: .7rem; font: inherit; }
.field-hint { margin: -.25rem 0 0; color: #c8c1dd; font-family: system-ui, sans-serif; font-size: .86rem; }
.form-error { min-height: 1.5em; margin: 0; color: var(--pink); font-family: system-ui, sans-serif; }
.world-map { position: relative; min-height: 430px; overflow: hidden; margin: 1rem 0; border: 4px solid var(--cyan); background: linear-gradient(rgb(255 255 255 / .035) 2px, transparent 2px) 0 0 / 24px 24px, linear-gradient(90deg, rgb(255 255 255 / .035) 2px, transparent 2px) 0 0 / 24px 24px, linear-gradient(#32656b 0 34%, #245550 34% 100%); box-shadow: inset 0 0 0 5px #15132b; }
.world-map::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 48% 48%, transparent 0 37%, rgb(10 12 36 / .2) 70%), linear-gradient(145deg, transparent 0 48%, rgb(85 248 231 / .08) 49% 52%, transparent 53%); pointer-events: none; }
.map-route { position: absolute; left: 8%; top: 8%; width: 72%; height: 72%; border-left: 12px dotted #f4d582; border-top: 12px dotted #f4d582; border-right: 12px dotted #f4d582; border-radius: 48% 55% 28% 42%; rotate: 8deg; opacity: .8; }
.map-building { --map-x: 0%; --map-y: 0%; position: absolute; z-index: 3; left: var(--map-x); top: var(--map-y); width: 142px; min-height: 82px; translate: -50% -50%; border: 4px solid #7e7891; background: #28243e; color: #aaa4b6; padding: .42rem; cursor: pointer; box-shadow: 5px 5px 0 #111022; text-align: center; transition: filter 160ms steps(2), left 720ms steps(8), top 720ms steps(8); }
.map-building::before { content: ''; position: absolute; left: 20%; right: 20%; top: -17px; height: 14px; border: 4px solid currentColor; border-bottom: 0; background: #30274b; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.map-building:disabled { cursor: not-allowed; filter: grayscale(.7) brightness(.72); }
.map-building:not(:disabled):hover { filter: brightness(1.22); translate: -50% calc(-50% - 3px); }
.map-building.is-active { border-color: var(--yellow); color: var(--yellow); background: #49315d; animation: map-beacon 1.3s steps(2) infinite; }
.map-building.is-lit { border-color: var(--cyan); color: var(--cyan); background: #243f50; box-shadow: 0 0 18px rgb(85 248 231 / .65), 5px 5px 0 #111022; }
.map-building-rooftop { width: 160px; }
.map-building-icon, .map-building-title, .map-building-objective { display: block; }
.map-building-icon { font-size: 1.35rem; line-height: 1; }
.map-building-title { margin-top: .2rem; font-family: system-ui, sans-serif; font-size: .95rem; }
.map-building-objective { margin-top: .18rem; color: #fff; font-family: system-ui, sans-serif; font-size: .72rem; }
.map-player { --map-x: 0%; --map-y: 0%; position: absolute; z-index: 6; left: var(--map-x); top: var(--map-y); width: 36px; height: 40px; display: grid; place-items: center; translate: -50% 44px; border: 4px solid #121026; background: var(--pink); color: var(--yellow); font-size: 1.2rem; font-weight: 900; box-shadow: 3px 3px 0 #121026; transition: left 720ms steps(8), top 720ms steps(8); }
.map-player::after { content: '▂ ▂'; position: absolute; bottom: -13px; color: var(--cyan); font-size: .75rem; letter-spacing: .2rem; }
.map-player.is-walking { animation: map-walk 180ms steps(2) 4; }
.map-walk-status { position: absolute; z-index: 7; left: .6rem; bottom: .5rem; margin: 0; color: #fff; font-family: system-ui, sans-serif; font-size: .78rem; }
.map-pond { position: absolute; left: 4%; top: 25%; width: 118px; height: 62px; display: grid; place-items: center; border: 4px solid #7ef0ff; border-radius: 45%; background: #24629a; color: #baf8ff; rotate: -8deg; }
.map-tree, .map-lamp { position: absolute; z-index: 1; color: #a9ff65; font-size: 2rem; text-shadow: 3px 3px 0 #17352a; }
.map-tree-one { left: 7%; top: 53%; }
.map-tree-two { left: 62%; top: 74%; }
.map-tree-three { right: 5%; top: 24%; }
.map-lamp { color: var(--yellow); font-size: 1.2rem; animation: lamp-twinkle 1.4s steps(2) infinite; }
.map-lamp-one { left: 36%; top: 43%; }
.map-lamp-two { right: 24%; top: 42%; }
.quest-log { margin: 0 0 1rem; border: 3px dashed var(--pink); background: #160f2c; padding: .75rem .9rem; }
.quest-log-title { margin: 0 0 .55rem; color: var(--yellow); font-size: .9rem; letter-spacing: .08em; }
.quest-log-items { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.quest-log-entry { color: #fff; font-family: system-ui, sans-serif; font-size: .92rem; line-height: 1.45; }
.quest-log-entry::before { content: '▸ '; color: var(--cyan); font-weight: 900; }
.transition-scene { text-align: center; }
.message-scene { width: min(100%, 760px); }
.story-progress, .jump-progress { display: flex; gap: .55rem; justify-content: center; margin: 1rem 0; }
.story-progress-dot, .jump-progress-block { width: 28px; height: 12px; border: 3px solid #77718d; background: #231c3a; }
.story-progress-dot.is-current, .jump-progress-block.is-current { border-color: var(--yellow); }
.story-progress-dot.is-read, .jump-progress-block.is-landed { border-color: var(--cyan); background: var(--pink); box-shadow: 0 0 8px var(--cyan); }
.message-transcript { display: grid; gap: .5rem; max-height: 170px; overflow: auto; margin: 0 0 .8rem; padding: 0; list-style: none; }
.message-transcript-entry { border-left: 4px solid var(--pink); padding: .35rem .65rem; background: rgb(12 9 32 / .45); font-family: system-ui, sans-serif; font-size: .83rem; line-height: 1.4; }
.message-transcript-line, .message-transcript-reply { display: block; }
.message-transcript-line { color: #bdb6d5; }
.message-transcript-reply { margin-top: .2rem; color: var(--cyan); }
.message-card { min-height: 235px; border: 3px solid var(--pink); background: #17122a; padding: 1rem; box-shadow: inset 0 0 0 4px #2e244a; }
.message-counter { margin: 0 0 .7rem; color: var(--pink); font-size: .82rem; letter-spacing: .08em; }
.message-line, .message-reply, .message-restored { font-family: system-ui, sans-serif; line-height: 1.65; }
.message-line { margin: 0 0 1rem; color: #fff; font-size: 1.15rem; font-weight: 750; }
.message-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.message-choice { min-height: 54px; border: 3px solid var(--cyan); background: #302651; color: var(--yellow); cursor: pointer; padding: .6rem; }
.message-choice:hover:not(:disabled) { background: var(--cyan); color: var(--ink); }
.message-choice:disabled { opacity: .55; }
.message-reply { min-height: 3.2em; margin: .8rem 0; color: var(--cyan); }
.message-continue { display: block; margin-left: auto; }
.message-continue[hidden] { display: none; }
.message-exit { margin-top: .8rem; }
.message-restored-label { color: var(--pink); font-weight: 900; text-align: center; }
.message-restored { color: var(--yellow); font-size: 1.15rem; text-align: center; }

.jump-scene { width: min(100%, 820px); }
.jump-stage { position: relative; min-height: 410px; overflow: hidden; border: 4px solid var(--cyan); background: linear-gradient(rgb(88 72 119 / .14) 2px, transparent 2px) 0 0 / 30px 30px, linear-gradient(90deg, rgb(88 72 119 / .14) 2px, transparent 2px) 0 0 / 30px 30px, #fff8e8; color: var(--ink); box-shadow: inset 0 0 0 5px #2b2144; }
.jump-stage::before, .jump-stage::after { content: ''; position: absolute; border: 5px solid var(--pink); opacity: .5; }
.jump-stage::before { left: 6%; top: 43%; width: 28px; height: 28px; rotate: 18deg; }
.jump-stage::after { right: 7%; top: 28%; width: 42px; height: 18px; border-color: var(--cyan); border-radius: 50%; }
.jump-prompt { position: relative; z-index: 2; width: min(88%, 610px); margin: 1rem auto .6rem; color: #35264d; font-family: system-ui, sans-serif; font-size: clamp(1rem, 2.5vw, 1.35rem); font-weight: 900; line-height: 1.45; text-align: center; }
.jump-bubble { position: relative; z-index: 2; width: min(82%, 560px); min-height: 72px; margin: 0 auto; border: 4px solid #35264d; background: #fff; padding: .7rem 1rem; color: #35264d; font-family: system-ui, sans-serif; line-height: 1.45; text-align: center; box-shadow: 5px 5px 0 var(--pink); }
.jump-bubble::after { content: ''; position: absolute; left: calc(50% - 10px); bottom: -14px; width: 16px; height: 16px; border-right: 4px solid #35264d; border-bottom: 4px solid #35264d; background: #fff; rotate: 45deg; }
.jump-avatar { --jump-x: 50%; position: absolute; z-index: 4; left: var(--jump-x); top: 49%; width: 46px; height: 46px; display: grid; place-items: center; translate: -50% -50%; border: 4px solid #35264d; border-radius: 50%; background: var(--yellow); font-size: 1.4rem; font-weight: 900; box-shadow: 4px 4px 0 var(--pink); transition: left 360ms steps(5); }
.jump-avatar.is-jumping { animation: platform-jump 430ms steps(6); }
.jump-platforms { position: absolute; z-index: 3; left: 3%; right: 3%; bottom: 24px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5%; align-items: end; }
.jump-platform { min-height: 82px; border: 4px solid #35264d; background: var(--cyan); color: #231838; cursor: pointer; padding: .5rem; font-weight: 900; box-shadow: 0 9px 0 #35264d; }
.jump-platform-2 { translate: 0 -16px; background: var(--yellow); }
.jump-platform-3 { translate: 0 7px; background: #ff9cc7; }
.jump-platform:hover:not(:disabled), .jump-platform.is-selected { filter: brightness(1.1); box-shadow: 0 9px 0 #35264d, 0 0 15px var(--pink); }
.jump-platform:disabled { cursor: default; }
.jump-finish-platform { grid-column: 1 / -1; border: 4px solid var(--pink); background: #35264d; color: var(--yellow); padding: 1rem; text-align: center; }
.jump-continue { display: block; margin: .9rem auto 0; }
.jump-continue[hidden] { display: none; }
.jump-exit { margin-top: .8rem; }

.station-scene { width: min(100%, 820px); }
.station-content { min-height: 310px; display: grid; align-content: center; }
.station-step-title { margin: 0 0 1.1rem; color: var(--yellow); font-family: system-ui, sans-serif; font-size: clamp(1.1rem, 3vw, 1.5rem); }
.station-ticket-grid, .station-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.station-ticket { min-height: 112px; border: 4px solid var(--cyan); background: repeating-linear-gradient(135deg, #241642 0 10px, #34215e 10px 20px); color: var(--yellow); cursor: pointer; font-weight: 900; font-size: 1.1rem; box-shadow: inset 0 0 0 4px #17122a, 5px 5px 0 var(--pink); }
.station-ticket::before { content: 'TICKET\A'; white-space: pre; color: var(--pink); font-size: .72rem; letter-spacing: .12em; }
.station-ticket:hover { border-color: var(--yellow); transform: translateY(-4px); }
.station-summary, .station-restored { color: #fff; font-family: system-ui, sans-serif; line-height: 1.65; }
.station-restored { min-height: 1.7em; color: var(--yellow); font-weight: 800; text-align: center; }
.station-platform { position: relative; height: 145px; overflow: hidden; border: 4px solid var(--cyan); background: linear-gradient(#17112e 0 56%, #54335f 56% 61%, #211638 61%); }
.station-platform::after { content: ''; position: absolute; inset: auto 0 20px; height: 5px; background: repeating-linear-gradient(90deg, var(--yellow) 0 30px, transparent 30px 46px); }
.pixel-person { position: absolute; top: 72px; z-index: 1; width: 42px; height: 46px; display: grid; place-items: center; border: 4px solid #0c0920; font-size: 1.55rem; transition: left 650ms steps(5), right 650ms steps(5); }
.pixel-person::after { content: ''; position: absolute; top: -22px; width: 24px; height: 22px; background: inherit; border: 4px solid #0c0920; }
.pixel-person-one { left: 10%; background: var(--pink); color: var(--yellow); }
.pixel-person-two { right: 10%; background: var(--cyan); color: var(--ink); }
.station-platform.is-meeting .pixel-person-one { left: calc(50% - 50px); }
.station-platform.is-meeting .pixel-person-two { right: calc(50% - 50px); }
.station-sign { position: absolute; top: 12px; left: 50%; translate: -50% 0; border: 3px solid var(--pink); background: #100a21; color: var(--yellow); padding: .35rem .6rem; font-weight: 900; white-space: nowrap; }
.station-depart { justify-self: center; min-width: 180px; }
.station-exit { margin-top: .85rem; }

.finale-scene { position: relative; width: min(100%, 820px); overflow: hidden; border-color: #9ad8ff; background: linear-gradient(#171934 0 45%, #312547 45%); box-shadow: 8px 8px 0 #6e4a79; }
.rooftop-skyline { height: 92px; margin: -1.15rem -1.15rem 1rem; border-bottom: 5px solid #9ad8ff; background: linear-gradient(175deg, #392a61, #18162f 70%); opacity: .75; }
.rooftop-skyline::after { content: '✦　　　·　　　　✧　　　　　·　　　✦'; display: block; padding: 1rem; color: #fff8b0; letter-spacing: .1em; text-align: center; }
.finale-content { position: relative; }
.finale-scenario { border-left: 4px solid #9ad8ff; margin: 0 0 1rem; padding: .7rem .8rem; background: rgb(9 8 28 / .45); color: #e8e2f6; font-family: system-ui, sans-serif; line-height: 1.6; }
.finale-question { margin: 1.25rem 0; color: #fff; font-family: system-ui, sans-serif; font-size: clamp(1.25rem, 3vw, 1.75rem); font-weight: 900; line-height: 1.45; text-align: center; }
.final-actions { position: relative; min-height: 120px; border: 3px dashed #73688f; }
.final-actions > .finale-accept, .final-actions > .finale-refuse { position: absolute; top: 34px; width: min(42%, 220px); }
.final-actions > .finale-accept { left: 7%; }
.final-actions > .finale-refuse { transition: left 170ms steps(2), right 170ms steps(2), top 170ms steps(2), background 130ms steps(2); }
.finale-appeal, .finale-ending-copy { color: #fff; font-family: system-ui, sans-serif; font-size: 1.12rem; line-height: 1.75; text-align: center; }
.appeal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.finale-decline-stable { background: #8d87a2; }
.finale-hint { color: #c9c4da; font-family: system-ui, sans-serif; text-align: center; }
.finale-return { display: block; margin: 1rem auto 0; }
.pixel-fireworks { color: var(--yellow); font-size: clamp(2rem, 7vw, 4.5rem); text-align: center; text-shadow: -12px 5px 0 var(--pink), 13px -6px 0 var(--cyan); animation: firework-pop 800ms steps(4) infinite alternate; }

@keyframes rooftop-pulse { 50% { filter: brightness(1.28); } }
@keyframes map-beacon { 50% { box-shadow: 0 0 20px var(--yellow), 5px 5px 0 #111022; } }
@keyframes map-walk { 50% { translate: -50% 38px; } }
@keyframes lamp-twinkle { 50% { opacity: .4; } }
@keyframes platform-jump { 0% { translate: -50% -50%; } 45% { translate: -50% -145%; } 100% { translate: -50% -50%; } }
@keyframes firework-pop { from { scale: .92; } to { scale: 1.06; } }

@media (max-width: 520px) {
  #app { width: min(100% - 1rem, 900px); }
  .hud { align-items: stretch; flex-direction: column; }
  .hud-scores, .audio-controls { justify-content: space-between; }
  .hud-audio-button { flex: 1; }
  .pixel-button { width: 100%; }
  .world-map { min-height: 520px; }
  .map-building { width: 112px; min-height: 74px; }
  .map-building-title { font-size: .82rem; }
  .map-building-objective { font-size: .64rem; }
  .message-choices { grid-template-columns: 1fr; }
  .jump-stage { min-height: 470px; }
  .jump-platforms { left: 2%; right: 2%; gap: 2%; }
  .jump-platform { min-height: 100px; padding: .25rem; font-size: .75rem; }
  .station-ticket-grid, .station-detail-grid { grid-template-columns: 1fr; }
  .station-ticket { min-height: 70px; }
  .appeal-actions { grid-template-columns: 1fr; }
  .station-content { min-height: 0; }
}

@media (min-width: 700px) and (max-height: 800px) {
  .jump-stage { min-height: 350px; }
  .scene { min-height: 66vh; }
  .station-content { min-height: 250px; }
}

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