/* スマートフォンの表示はここで一元管理。PC用HUDを縮小して流用しない。 */
[hidden], body #mobile-controller-zone[hidden] { display: none !important; }
.mobile-start-label, #mobile-hud, #mobile-notice { display: none; }
#pause-menu {
  margin: auto; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 24px);
  padding: 20px; overflow: auto; overscroll-behavior: contain; touch-action: pan-y pinch-zoom;
  background: #101c2a; color: #f1f5f9; border: 2px solid #fbbf24; border-radius: 16px;
  font: 16px/1.5 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}
#pause-menu::backdrop { background: #030712bb; }
.pause-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.pause-heading p, .pause-note { color: #cbd5e1; }
.pause-heading h2 { font-size: 24px; color: #fbbf24; }
#pause-stats { margin: 12px 0; }
.pause-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#pause-menu button { min-height: 48px; padding: 8px 12px; border: 1px solid #718096; border-radius: 8px; background: #243448; color: #fff; font: inherit; font-weight: bold; cursor: pointer; }
#pause-menu #mobile-resume { background: #9f2525; border-color: #fca5a5; white-space: nowrap; }
.pause-note { margin-top: 12px; }
body.mobile-landscape { position: fixed; inset: 0; width: var(--play-width, 100vw); height: var(--play-height, 100dvh); min-height: 0; }
body.mobile-landscape #game-container {
  position: fixed; inset: 0; display: block; width: var(--play-width, 100vw); height: var(--play-height, 100dvh);
  max-width: none; max-height: none; padding: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none;
}
body.mobile-landscape #canvas-wrapper {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; border: 0; border-radius: 0; aspect-ratio: auto; flex: none;
}
body.mobile-landscape #gameCanvas { display: block; width: 100%; height: 100%; object-fit: fill; touch-action: none; }
body.mobile-landscape #ui-header { display: none !important; }
body.mobile-landscape #mobile-hud {
  display: flex; position: absolute; z-index: 35; top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: calc(env(safe-area-inset-left, 0px) + 12px); right: calc(env(safe-area-inset-right, 0px) + 12px);
  align-items: flex-start; justify-content: space-between; pointer-events: none; gap: 12px;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000;
}
.mobile-vitals { width: 174px; padding: 6px 8px; background: #0b1522e8; border: 1px solid #66788b; border-radius: 8px; }
.mobile-health { display: flex; align-items: center; gap: 6px; font-size: 14px; line-height: 18px; }
#mobile-level { margin-left: auto; color: #fbbf24; }
.mobile-meter { height: 6px; background: #3b4555; border-radius: 3px; overflow: hidden; margin-top: 4px; }
#mobile-hp-fill { height: 100%; background: #4ade80; }
#mobile-hp-fill.low { background: #fb7185; }
.mobile-exp-meter { height: 3px; margin-top: 3px; background: #3b4555; }
#mobile-exp-fill { height: 100%; background: #38bdf8; }
.mobile-clock { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 4px 8px; min-height: 30px; background: #0b1522de; border-radius: 6px; }
.mobile-clock span { display: block; font-size: 11px; line-height: 16px; color: #e2e8f0; white-space: nowrap; }
.mobile-clock strong { display: block; font-size: 16px; line-height: 20px; white-space: nowrap; }
/* 神社の最上段では中央のキャラを隠さず、一時停止の隣へ寄せる。 */
#mobile-hud.shrine-view .mobile-clock { left: auto; right: 60px; transform: none; }
#mobile-pause { width: 48px; height: 48px; pointer-events: auto; background: #0b1522ec; border: 1px solid #94a3b8; border-radius: 10px; color: #fff; font-size: 24px; cursor: pointer; }
body.mobile-landscape #mobile-notice {
  display: block; position: absolute; z-index: 34; top: calc(env(safe-area-inset-top, 0px) + 64px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 70%; padding: 6px 12px; background: #0b1522e8; border-left: 3px solid #fbbf24;
  border-radius: 4px; color: #fde68a; font-size: 14px; line-height: 1.4; text-align: center; pointer-events: none;
}
body.mobile-landscape #mobile-controller-zone {
  position: absolute; inset: 0; z-index: 40; display: block; width: 100%; height: 100%; background: none;
  border: 0; padding: 0; pointer-events: none;
}
body.mobile-landscape #joystick-zone {
  position: absolute; width: 104px; height: 104px; margin: 0; right: calc(env(safe-area-inset-right, 0px) + 20px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); pointer-events: auto; touch-action: none; opacity: .72;
}
body.mobile-landscape #joystick-zone.is-dragging { opacity: 1; }
body.mobile-landscape #joystick-base { width: 100%; height: 100%; background: #13233899; border: 2px solid #fbbf24bb; box-shadow: none; }
body.mobile-landscape #joystick-knob { width: 46px; height: 46px; border-width: 2px; box-shadow: none; }
body.mobile-landscape .knob-icon { font-size: 22px; }
body.mobile-landscape .controller-guide-text, body.mobile-portrait #mobile-controller-zone { display: none; }
body.mobile-landscape .overlay { padding: 8px calc(env(safe-area-inset-right, 0px) + 12px) 8px calc(env(safe-area-inset-left, 0px) + 12px); backdrop-filter: none; }
body.mobile-landscape .overlay-card { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y pinch-zoom; }
body.mobile-landscape .start-button, body.mobile-landscape .sub-action-button { min-height: 48px; padding: 10px 16px; font-size: 16px; }
body.mobile-landscape #title-overlay { background-image: none; }
body.mobile-landscape #title-overlay::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(#080c10aa, #080c10cc), url('assets/title_bg.webp?v=20260929_webp_lightweight_v1') center / cover;
}
body.mobile-landscape .title-art {
  display: block; position: absolute; z-index: 1;
  top: 8px; left: calc(env(safe-area-inset-left, 0px) + 12px);
  width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px);
  height: calc(100% - max(12px, env(safe-area-inset-bottom, 0px)) - 72px);
  object-fit: contain; object-position: center; pointer-events: none;
}
body.mobile-landscape .sfc-start-hitbox { top: auto; bottom: max(12px, env(safe-area-inset-bottom, 0px)); left: 50%; width: 220px; height: 52px; transform: translateX(-50%); border: 2px solid #fde68a; border-radius: 10px; background: #9f2525; animation: none; }
body.mobile-landscape .mobile-start-label { display: block; color: white; font-size: 20px; font-weight: 900; }
body.mobile-landscape #result-overlay .overlay-card { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: auto auto auto auto auto; column-gap: 20px; width: min(100%, 900px); max-width: none; padding: 14px 18px; }
body.mobile-landscape .result-title { grid-column: 2; font-size: 18px; line-height: 1.3; margin: 0; }
body.mobile-landscape .stars { grid-column: 2; font-size: 18px; line-height: 20px; margin: 0; }
body.mobile-landscape .result-rank-title { grid-column: 2; font-size: 14px; line-height: 20px; padding: 2px 6px; margin: 0; }
body.mobile-landscape .ending-banner { grid-column: 1; grid-row: 1 / 6; margin: 0; width: 100%; align-self: center; }
body.mobile-landscape .ending-banner img { max-height: calc(var(--play-height) - 70px); object-fit: contain; }
body.mobile-landscape .result-stats { grid-column: 2; margin: 6px 0; padding: 6px 10px; gap: 2px; }
body.mobile-landscape .stat-row { font-size: 14px; line-height: 20px; padding: 0; color: #cbd5e1; }
body.mobile-landscape #restart-btn { grid-column: 2; width: 100%; font-size: 16px; margin: 0; }
@media (max-height: 330px) { #pause-menu { padding: 12px 16px; } .pause-note { font-size: 14px; } body.mobile-landscape #joystick-zone { width: 96px; height: 96px; bottom: max(8px, env(safe-area-inset-bottom, 0px)); } }

body.mobile-portrait #game-container { width: 100vw; max-width: 100vw; overflow: hidden; }
body.mobile-portrait #ui-header { display: none !important; }

/* 平和時間だけ表示。移動スティックと反対側に置く、PC・スマホ共通の操作。 */
#skip-peace {
  position: absolute; z-index: 36;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  min-height: 48px; padding: 10px 16px; border: 1px solid #fde68a; border-radius: 10px;
  background: #9f2525; color: #fff; font: bold 16px/1.4 sans-serif;
  cursor: pointer; touch-action: manipulation;
}
#skip-peace:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#skip-peace:active { background: #7f1d1d; }

#event-continue {
  position: absolute; z-index: 46; right: calc(env(safe-area-inset-right, 0px) + 16px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  min-height: 48px; min-width: 148px; padding: 10px 16px; border: 2px solid #fde68a;
  border-radius: 8px; background: #9f2525; color: #fff; font: bold 16px/1.4 sans-serif;
  white-space: nowrap; cursor: pointer; touch-action: manipulation;
}
#event-continue:disabled { opacity: .55; cursor: default; }
.pause-actions #mobile-title { grid-column: 1 / -1; }

/* 文字込みの生成画像を1枚ずつ大きく表示する遊び方。 */
#tutorial-overlay {
  margin: auto; padding: 0; width: min(960px, calc(100vw - 16px)); max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px); overflow: auto;
  color: #fff9e8; background: #101c2a; border: 2px solid #fbbf24; border-radius: 12px;
  font: 16px/1.5 'Noto Sans JP', 'Hiragino Sans', Meiryo, sans-serif;
  touch-action: pan-y pinch-zoom; overscroll-behavior: contain;
}
#tutorial-overlay::backdrop { background: #030712e8; }
.guide-shell { display: flex; flex-direction: column; gap: 8px; padding: 12px; max-height: calc(100dvh - 20px); }
.guide-header { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-height: 24px; flex: none; }
#guide-title { font-size: 18px; line-height: 24px; color: #fff9e8; margin: 0; }
#guide-page { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; color: #fbbf24; }
.guide-content { min-height: 0; overflow: auto; touch-action: pan-y pinch-zoom; }
.guide-art {
  position: relative; overflow: hidden; aspect-ratio: 2 / 1; margin: 0 auto;
  width: min(100%, 900px, calc((100dvh - 144px) * 2)); min-width: min(100%, 344px);
  background: #082032;
}
#guide-image { position: absolute; width: 200%; height: 200%; max-width: none; left: var(--guide-x, 0%); top: var(--guide-y, 0%); pointer-events: none; user-select: none; }
.guide-pc-tip { text-align: center; color: #dce8f1; font-size: 16px; margin: 8px 0 0; }
.guide-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.guide-actions button {
  min-width: 64px; min-height: 48px; padding: 8px 14px; font: inherit; font-weight: 700;
  color: #f1f5f9; background: #243448; border: 1px solid #94a3b8; border-radius: 8px;
  cursor: pointer; touch-action: manipulation;
}
.guide-actions .guide-next { margin-left: auto; min-width: 144px; background: #9f2525; border-color: #fde68a; }
.guide-actions .guide-close { background: transparent; }
.guide-actions button:disabled { opacity: .45; cursor: default; }
.guide-actions button:focus-visible { outline: 3px solid #38bdf8; outline-offset: 2px; }
.guide-actions button:not(:disabled):active { filter: brightness(1.2); }
.guide-fallback { font-size: 24px; line-height: 1.6; max-width: 680px; padding: 20px; margin: auto; }
.guide-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-height: 360px) {
  #tutorial-overlay { max-height: calc(100dvh - 8px); }
  .guide-shell { padding: 6px; gap: 4px; max-height: calc(100dvh - 12px); }
  .guide-art { width: min(100%, 900px, calc((100dvh - 104px) * 2)); }
}
@media (max-height: 240px) {
  .guide-shell { max-height: none; }
  .guide-content { overflow: visible; }
}
@media (max-width: 380px) {
  .guide-shell { padding: 6px; }
  .guide-actions button { padding-inline: 10px; }
  .guide-actions .guide-next { min-width: 128px; }
}
