:root {
  color-scheme: dark;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #08090f;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font);
  color: #fff;
}
#stage {
  position: fixed;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  overflow: hidden;
  --u: 4px;
}
#screen {
  position: absolute;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}
.screen[hidden], #touch[hidden], #pause-btn[hidden], #toast[hidden] { display: none !important; }

button {
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(#3a4060, #23273a);
  border: 2px solid #0d0e15;
  border-radius: 10px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), 0 3px 0 #0d0e15;
  padding: .45em 1em;
  min-height: 40px;
  cursor: pointer;
  font-size: clamp(12px, calc(var(--u) * 3.6), 20px);
  touch-action: manipulation;
}
button:hover { filter: brightness(1.15); }
button:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25), 0 1px 0 #0d0e15; }
button:focus-visible { outline: 3px solid #ffe04a; outline-offset: 2px; }
button.big {
  background: linear-gradient(#ff5a6a, #d01e36);
  font-size: clamp(16px, calc(var(--u) * 6), 30px);
  padding: .35em 1.6em;
  border-radius: 14px;
}
button.sub { background: linear-gradient(#4a5070, #2a2e44); }
button[aria-pressed="false"] { color: #b8bccb; background: linear-gradient(#2a2e3e, #1a1d28); }

/* ---------- タイトル ---------- */
#title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, calc(var(--u) * 2), 14px);
  padding: calc(var(--u) * 3) max(16px, env(safe-area-inset-right)) calc(var(--u) * 3) max(16px, env(safe-area-inset-left));
  text-align: center;
}
.logo {
  margin: 0;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: rotate(-3deg);
  filter: drop-shadow(0 calc(var(--u) * .8) 0 rgba(0, 0, 0, .35));
}
.logo .super {
  font-size: clamp(14px, calc(var(--u) * 5.5), 34px);
  background: #ff2e44;
  color: #fff;
  padding: .1em .6em;
  border: 3px solid #0d0e15;
  border-radius: 999px;
  margin-bottom: -.2em;
  z-index: 1;
  letter-spacing: .1em;
}
.logo .name {
  font-size: clamp(34px, calc(var(--u) * 17), 110px);
  font-weight: 900;
  color: #fff;
  letter-spacing: .02em;
  -webkit-text-stroke: calc(clamp(34px, calc(var(--u) * 17), 110px) * .09) #0d0e15;
  paint-order: stroke fill;
  text-shadow: 0 .06em 0 #ff2e44, 0 .1em 0 #0d0e15;
}
.guide {
  margin: 0;
  max-width: min(92%, 760px);
  font-size: clamp(11px, calc(var(--u) * 3.5), 18px);
  line-height: 1.5;
  font-weight: 700;
  background: rgba(13, 14, 21, .72);
  border: 2px solid rgba(255, 255, 255, .2);
  border-radius: 12px;
  padding: .5em .9em;
}
.guide.is-speaking { border-color: #ffe04a; box-shadow: 0 0 0 2px rgba(255, 224, 74, .35); }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row.small button { font-size: clamp(11px, calc(var(--u) * 3), 16px); min-height: 36px; padding: .3em .8em; }
.keys {
  margin: 0;
  font-size: clamp(9px, calc(var(--u) * 2.7), 14px);
  font-weight: 700;
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
}
.keys.touch { display: none; }
body.touch .keys.touch { display: block; }
body.touch .keys.pc { display: none; }
.back {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  top: 8px;
  color: #fff;
  font-size: clamp(11px, calc(var(--u) * 2.8), 14px);
  font-weight: 800;
  text-decoration: none;
  background: rgba(13, 14, 21, .6);
  border-radius: 999px;
  padding: .35em .9em;
}

/* ---------- マップ ---------- */
#map-ui {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
#map-ui > * { pointer-events: auto; }
.stage-name {
  display: flex;
  flex-direction: column;
  background: rgba(13, 14, 21, .78);
  border: 2px solid rgba(255, 255, 255, .25);
  border-radius: 12px;
  padding: .3em .9em;
  font-weight: 900;
}
.stage-name small { color: #ffe04a; font-size: clamp(10px, calc(var(--u) * 3), 14px); letter-spacing: .1em; }
.stage-name strong { font-size: clamp(16px, calc(var(--u) * 6), 30px); }
.stage-name em { font-style: normal; color: #8cf59c; font-size: clamp(10px, calc(var(--u) * 2.8), 14px); }
.map-buttons { display: flex; gap: 8px; align-items: center; }
body.touch .map-buttons { margin-right: calc(var(--h) * .02); }

/* ---------- ステージ紹介 ---------- */
#intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  pointer-events: none;
  text-shadow: 0 3px 0 #000;
}
#intro p { margin: .1em; }
.intro-num { color: #ffe04a; font-size: clamp(14px, calc(var(--u) * 5), 30px); letter-spacing: .2em; }
.intro-name { font-size: clamp(26px, calc(var(--u) * 11), 70px); }
.intro-lives { font-size: clamp(14px, calc(var(--u) * 5), 30px); margin-top: calc(var(--u) * 16) !important; }

/* ---------- メニュー ---------- */
#pause, #gameover, #ending {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 2);
  background: rgba(8, 9, 15, .66);
  text-align: center;
  padding: 12px;
}
#ending { background: rgba(8, 9, 15, .35); }
.screen h2 {
  margin: 0;
  font-size: clamp(26px, calc(var(--u) * 11), 64px);
  font-weight: 900;
  -webkit-text-stroke: 6px #0d0e15;
  paint-order: stroke fill;
  letter-spacing: .04em;
}
#gameover h2 { color: #ff5a6a; }
#ending h2 { color: #ffe04a; }
.screen p { margin: 0; font-weight: 800; font-size: clamp(13px, calc(var(--u) * 4), 22px); text-shadow: 0 2px 0 #000; }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ---------- 声の字幕 ---------- */
#callout {
  position: absolute;
  left: 50%;
  top: calc(var(--h) * .17);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  z-index: 3;
}
#callout b {
  font-size: clamp(20px, calc(var(--u) * 8), 48px);
  font-weight: 900;
  font-style: italic;
  color: #ffe04a;
  -webkit-text-stroke: 5px #0d0e15;
  paint-order: stroke fill;
  letter-spacing: .03em;
}
#callout span { font-size: clamp(11px, calc(var(--u) * 3.4), 18px); font-weight: 800; text-shadow: 0 2px 0 #000, 0 0 4px #000; }
#callout.show { animation: callout 1.5s ease-out forwards; }
@keyframes callout {
  0% { opacity: 0; transform: translateX(-50%) scale(.6); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.12); }
  22% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ---------- タッチ操作 ---------- */
#touch {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
}
#dpad, #btn-jump, #btn-dash {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
#dpad {
  --s: clamp(96px, calc(var(--h) * .34), 150px);
  width: var(--s);
  height: var(--s);
  left: max(14px, calc(env(safe-area-inset-left) + 6px));
  bottom: max(8px, calc(var(--h) * .03));
  background: radial-gradient(circle, rgba(255, 255, 255, .1) 0 30%, rgba(255, 255, 255, .16) 31% 64%, rgba(255, 255, 255, .07) 65%);
  border: 2px solid rgba(255, 255, 255, .35);
}
#dpad i {
  position: absolute;
  font-style: normal;
  font-size: calc(var(--s) * .2);
  color: rgba(255, 255, 255, .7);
  text-shadow: 0 1px 2px #000;
}
#dpad .l { left: 8%; top: 50%; transform: translateY(-50%); }
#dpad .r { right: 8%; top: 50%; transform: translateY(-50%); }
#dpad .d { bottom: 6%; left: 50%; transform: translateX(-50%); }
#dpad.l-on .l, #dpad.r-on .r, #dpad.d-on .d { color: #ffe04a; transform: translate(0, -50%) scale(1.25); }
#dpad.d-on .d { transform: translateX(-50%) scale(1.25); }
#btn-jump, #btn-dash {
  --s: clamp(64px, calc(var(--h) * .23), 104px);
  width: var(--s);
  height: var(--s);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: calc(var(--s) * .2);
  color: #fff;
  text-shadow: 0 1px 2px #000;
  border: 3px solid rgba(13, 14, 21, .7);
}
#btn-jump {
  right: max(14px, calc(env(safe-area-inset-right) + 6px));
  bottom: calc(max(12px, calc(var(--h) * .05)) + var(--s) * .62);
  background: radial-gradient(circle at 35% 30%, rgba(255, 140, 150, .85), rgba(208, 30, 54, .7));
}
#btn-dash {
  right: calc(max(14px, calc(env(safe-area-inset-right) + 6px)) + var(--s) * 1.12);
  bottom: max(12px, calc(var(--h) * .05));
  background: radial-gradient(circle at 35% 30%, rgba(160, 200, 255, .85), rgba(40, 80, 200, .7));
}
#btn-jump.on, #btn-dash.on { filter: brightness(1.5); transform: scale(.94); }
#pause-btn {
  position: absolute;
  z-index: 4;
  top: 6px;
  right: max(10px, calc(env(safe-area-inset-right) + 4px));
  width: 44px;
  height: 40px;
  min-height: 0;
  padding: 0;
  font-size: 18px;
  border-radius: 10px;
  background: rgba(13, 14, 21, .55);
  opacity: .85;
}
#stage:not([data-screen="play"]) #pause-btn { display: none; }
body:not(.touch) #pause-btn { top: auto; bottom: 8px; }
body.touch #pause-btn { top: auto; bottom: 8px; right: auto; left: 50%; transform: translateX(-50%); }

#toast {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  background: rgba(13, 14, 21, .9);
  border: 2px solid rgba(255, 255, 255, .3);
  border-radius: 12px;
  padding: .5em 1em;
  font-weight: 800;
  font-size: clamp(12px, calc(var(--u) * 3.6), 18px);
  z-index: 5;
  max-width: 90%;
  text-align: center;
}
.noscript { position: absolute; inset: 0; display: grid; place-items: center; }

/* WORLD EXPEDITION */
button:disabled { opacity: .42; cursor: default; filter: none; }
#title { gap: clamp(3px, calc(var(--u) * 1.3), 9px); }
#title .logo .name { font-size: clamp(30px, calc(var(--u) * 14), 88px); }
#title .guide { font-size: clamp(10px, calc(var(--u) * 2.8), 16px); max-width: min(86%, 730px); }
#title .expedition-tag { font-size: clamp(10px, calc(var(--u) * 3.1), 18px); color: #ffe69b; letter-spacing: .16em; text-shadow: 0 2px #18334a; }
.expedition-tag span { font-size: .65em; letter-spacing: 0; padding: .15em .4em; background: #203b50; border: 1px solid #83b6cf; border-radius: 4px; vertical-align: middle; }
#title .expedition-summary { font-size: clamp(10px, calc(var(--u) * 3), 17px); color: #fff4cf; }
#map-ui { inset: 0; gap: 10px; }
.stage-name { max-width: 62%; padding: .3em .7em; position: relative; z-index: 2; }
.stage-name strong { font-size: clamp(13px, calc(var(--u) * 4.5), 25px); }
.stage-name small { font-size: clamp(8px, calc(var(--u) * 2.4), 13px); }
.stage-name em { font-size: clamp(8px, calc(var(--u) * 2.4), 13px); }
.map-buttons { max-width: 35%; flex-wrap: wrap; justify-content: flex-end; position: relative; z-index: 2; gap: 5px; }
.map-buttons button { font-size: clamp(10px, calc(var(--u) * 3), 17px); min-height: 28px; padding: .3em .7em; }
.map-buttons button.big { font-size: clamp(13px, calc(var(--u) * 4), 24px); }
#map-hitboxes { position: absolute; inset: 0; pointer-events: none; }
#map-hitboxes .map-node-hit { position: absolute; border: 0; background: transparent; box-shadow: none; min-height: 0; padding: 0; pointer-events: auto; border-radius: 12px; }
#map-hitboxes .map-node-hit:focus-visible { outline: 2px solid #fff0b3; background: #ffffff12; }
#map-hitboxes .map-node-hit:hover { background: #ffffff15; }
.map-footer { position: absolute; left: 12px; right: 12px; bottom: 5px; text-align: center; pointer-events: auto; }
.map-footer p { font-size: clamp(9px, calc(var(--u) * 2.7), 14px); color: #fff2c8; padding-bottom: 4px; }
.map-footer small { font-size: clamp(8px, calc(var(--u) * 2.1), 12px); color: #d7e7ff; text-shadow: 0 1px #10243f; }
#world-tabs { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); justify-content: center; gap: 3px; max-width: 1100px; margin: 0 auto; }
#world-tabs[hidden] { display: none; }
#world-tabs button { font-size: clamp(7px, calc(var(--u) * 2), 13px); padding: .3em .15em; min-height: 25px; border-radius: 7px; white-space: nowrap; }
#world-tabs button[aria-pressed=true] { color: #ffebac; border-color: #e8bd5b; background: #23385a; }
#route-links { display: flex; gap: 4px; }
#route-links button { font-size: clamp(8px, calc(var(--u) * 2.2), 12px); padding: .1em .4em; min-height: 19px; margin-top: 3px; color: #ffe7a2; box-shadow: none; border: 1px solid #9da7b5; }
#intro .intro-name { font-size: clamp(21px, calc(var(--u) * 8), 54px); }
#intro-tip { max-width: 82%; text-align: center; font-size: clamp(10px, calc(var(--u) * 3.6), 22px); color: #c8dcec; margin-top: .7em !important; }
#intro .intro-lives { margin-top: calc(var(--u) * 10) !important; }
#field-guide { position: absolute; inset: 0; z-index: 5; background: #101d30f5; padding: 14px max(20px, calc(var(--u) * 8)); display: flex; flex-direction: column; gap: 10px; }
#field-guide header { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
#field-guide header small { color: #e3c775; letter-spacing: .15em; font-size: 10px; }
#field-guide h2 { font-size: clamp(20px, calc(var(--u) * 6), 36px); -webkit-text-stroke: 0; }
.guide-scroll { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 0 8px 12px 0; }
#field-guide p { font-size: clamp(11px, calc(var(--u) * 3), 17px); line-height: 1.7; font-weight: 500; text-shadow: none; margin-bottom: 10px; }
#gear-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
#gear-list article { display: flex; align-items: center; gap: 12px; border: 1px solid #405069; border-radius: 8px; padding: 10px; background: #1b2c44; }
#gear-list article > span { font: 900 28px monospace; min-width: 26px; text-align: center; }
#gear-list b { font-size: clamp(12px, calc(var(--u) * 3.4), 19px); }
#gear-list p { margin: 3px 0 0; font-size: clamp(10px, calc(var(--u) * 2.7), 16px); color: #c6d8e9; }
#end-progress { color: #ffe69b; }
#ending h2 { font-size: clamp(22px, calc(var(--u) * 8), 48px); }
@media (prefers-reduced-motion: reduce) { #callout.show { animation: none; opacity: 0; } }
