/* おひさしぶりです！（誰！？） 共通スタイル
   トークン: インク / 紙 / チラシの黄 / 赤面ピンク / 空色 / 警報赤 */
:root {
  --ink: #1E2340;
  --paper: #FFFFFF;
  --flyer: #FFE14D;
  --blush: #FF6F91;
  --sky: #7CC8FF;
  --alarm: #FF3B30;
  --ok: #2BB673;
  --muted: #5B6180;
  --font-display: "Dela Gothic One", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-body: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  --line: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  height: 100vh; height: 100dvh;
  overflow: hidden; overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--ink);
  /* チラシの網点 */
  background-color: var(--flyer);
  background-image: radial-gradient(rgba(30, 35, 64, .12) 1.2px, transparent 1.4px);
  background-size: 14px 14px;
  font-family: var(--font-body);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
#app { position: relative; width: 100%; height: 100%; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* ---- ボタン（漫画のコマ風: 太い線とずらした影） ---- */
.btn {
  min-height: 48px; padding: .6rem 1.2rem; border: var(--line); border-radius: 14px;
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
  font: 800 1rem/1.3 var(--font-body); cursor: pointer; touch-action: manipulation;
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--blush); color: var(--paper); text-shadow: 0 1px 0 rgba(30, 35, 64, .35); }
.btn[disabled] { opacity: .45; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border: var(--line); border-radius: 12px; background: var(--paper);
  color: var(--ink); font-size: 1rem; cursor: pointer; touch-action: manipulation; box-shadow: 2px 2px 0 var(--ink);
}
.muted { color: var(--muted); font-size: .9rem; }
.center-text { text-align: center; }

/* ---- タイトル ---- */
/* 背景: Stage 1 のスーパーを黄色いチラシ色で薄め、右下からおばちゃんがこっちを見ている（絵が無くても文字だけで成り立つ） */
#screen-title {
  background:
    linear-gradient(rgba(255, 225, 77, .62), rgba(255, 225, 77, .82)),
    url("../assets/stage01/bg.jpg") center / cover no-repeat,
    var(--flyer);
  overflow: hidden;
}
.title-art { position: absolute; inset: 0; pointer-events: none; }
.title-char {
  position: absolute; right: -16%; bottom: -5%; width: min(80vw, 420px); aspect-ratio: 1;
  background: url("../assets/stage01/char_normal.png") center / contain no-repeat;
}
/* 音あり / 音なし（2026-11-02 BGM）: 始める前に消せるよう、タイトルの右上に */
.sound-toggle {
  position: absolute; top: max(.75rem, env(safe-area-inset-top)); right: max(.75rem, env(safe-area-inset-right)); z-index: 2;
  min-height: 44px; padding: .4rem .9rem; border: var(--line); border-radius: 99px; background: var(--paper); color: var(--ink);
  font: 800 .9rem var(--font-body); box-shadow: 2px 2px 0 var(--ink); cursor: pointer; touch-action: manipulation;
}
.sound-toggle[aria-pressed="false"] { background: var(--muted); color: var(--paper); }
.sound-toggle:focus-visible { outline: 3px solid var(--blush); outline-offset: 2px; }
#screen-title .back-link { background: rgba(255, 255, 255, .9); border-radius: 99px; padding: .45rem .9rem; } /* おばちゃんの髪に重なっても読める */
.title-bubble { display: none; } /* 縦画面ではボタンと重なるので出さない（PC だけ。css/wide.css） */
.title-wrap {
  position: relative; /* 絵より手前 */
  margin: auto; width: min(100%, 440px); padding: 1.5rem 1.25rem; overflow-y: auto; max-height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem; text-align: center;
}
.badge {
  font: .8rem var(--font-display); background: var(--ink); color: var(--flyer);
  padding: .2rem .7rem; border-radius: 99px; letter-spacing: .1em;
}
.logo { display: block; width: min(100%, 420px); line-height: 1; font-weight: normal; }
/* タイトルロゴ（2026-11-04）: 明るい「おひさしぶりです！」の吹き出しに、心の声「（誰！？）」の爆発が突っ込んでくる */
.logo-svg { display: block; width: 100%; height: auto; overflow: visible; }
.logo-hello { font: 60px var(--font-display); fill: var(--ink); letter-spacing: -1px; }
.logo-desu { fill: var(--blush); }
.logo-who { font: 64px var(--font-display); letter-spacing: -4px; fill: var(--paper); stroke: var(--ink); stroke-width: 7px; paint-order: stroke fill; stroke-linejoin: round; }
.logo-burst { transform-box: fill-box; }
.logo-burst > * { transform-origin: 0 0; }
.logo-burst polygon, .logo-burst text { animation: burst-in .45s .35s cubic-bezier(.3, 1.6, .5, 1) both, burst-shake 2.6s 1.2s infinite; transform-box: fill-box; transform-origin: center; }
.logo-sweat { animation: sweat-in .3s .7s ease-out both; }
@keyframes burst-in { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1) rotate(0); } }
@keyframes burst-shake { 0%, 88%, 100% { translate: 0 0; } 91% { translate: 3px -1px; } 94% { translate: -3px 1px; } 97% { translate: 2px 0; } }
@keyframes sweat-in { from { opacity: 0; translate: 0 -8px; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { .logo-burst polygon, .logo-burst text, .logo-sweat { animation: none; } }
.lead { font-weight: 800; line-height: 1.7; background: var(--paper); border: var(--line); border-radius: 18px; padding: .8rem 1rem; box-shadow: var(--shadow); }
.menu { display: flex; flex-direction: column; gap: .8rem; width: min(100%, 280px); }
.back-link { color: var(--ink); font-weight: 800; font-size: .9rem; padding: .6rem; }

/* ---- 汎用ページ（選択・図鑑・設定・結果） ---- */
.page-head { flex: none; display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; width: min(100%, 560px); margin: 0 auto; }
.page-head h2 { font: 1.3rem var(--font-display); font-weight: normal; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; width: min(100%, 560px); margin: 0 auto; padding: .25rem 1rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

.stage-list { list-style: none; display: flex; flex-direction: column; gap: .8rem; }
.stage-card {
  width: 100%; display: grid; grid-template-columns: 2.8rem 1fr; align-items: center; column-gap: .75rem; row-gap: .3rem; text-align: left;
  padding: .75rem .9rem; border: var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow);
  font: inherit; color: inherit; cursor: pointer; touch-action: manipulation;
}
.stage-card[disabled] { background: #EDEEF3; cursor: default; box-shadow: none; }
.stage-no { font: 1.6rem var(--font-display); text-align: center; grid-row: span 2; }
.stage-title { font-weight: 800; }
.stage-meta { font-size: .8rem; color: var(--muted); }
.stage-badges { grid-column: 2; display: flex; align-items: center; gap: .5rem; font-size: .85rem; white-space: nowrap; }
.stars { letter-spacing: .05em; color: #F5A400; -webkit-text-stroke: .5px var(--ink); }
.stars .off { color: #D6D8E2; }
.s-mark { font: .75rem var(--font-display); background: var(--alarm); color: var(--paper); padding: .05rem .45rem; border-radius: 6px; }

.panel { background: var(--paper); border: var(--line); border-radius: 18px; padding: 1rem; box-shadow: var(--shadow); }
.panel h3 { font: 1rem var(--font-display); font-weight: normal; margin-bottom: .5rem; }

/* 結果 */
.result { justify-content: safe center; } /* safe: 中身が高いとき、上にはみ出した見出しにスクロールで届かなくなるのを防ぐ（ux-review F1） */
.result-head { text-align: center; font: clamp(1.8rem, 9vw, 2.6rem) var(--font-display); color: var(--paper); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--ink); }
.result-head.bad { color: var(--sky); }
.result-head.s { color: var(--alarm); }
.result-sub { text-align: center; font-weight: 800; }
.result-text { line-height: 1.8; }
.result-text .mono { color: var(--muted); font-size: .9rem; display: block; margin-top: .4rem; }
.checks { list-style: none; display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.checks li::before { content: "—  "; color: var(--muted); }
.checks li.ok::before { content: "★ "; color: #F5A400; }
.result-actions { display: flex; flex-direction: column; gap: .7rem; }
.checks + .muted { margin-top: .7rem; }
.cause { display: flex; flex-direction: column; gap: .35rem; font-weight: 800; padding: .7rem 1rem; }
.cause .muted { font-weight: 800; }

/* 図鑑 */
.zukan-summary { display: flex; justify-content: space-around; text-align: center; font-weight: 800; }
.zukan-summary b { display: block; font: 1.5rem var(--font-display); font-weight: normal; }
.zukan-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.zukan-item { width: 100%; min-height: 44px; text-align: left; padding: .5rem .75rem; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); font: inherit; font-weight: 800; color: inherit; cursor: pointer; touch-action: manipulation; }
.zukan-item[disabled] { color: var(--muted); background: #EDEEF3; border-style: dashed; cursor: default; }
.zukan-item.unknown { color: var(--muted); background: #EDEEF3; border-style: dashed; }
.detail-text { line-height: 1.8; text-align: left; }

/* 設定 */
.setting-row { display: flex; flex-direction: column; gap: .5rem; }
.setting-row label { font-weight: 800; }
.setting-row input[type=range] { width: 100%; height: 44px; accent-color: var(--blush); }

/* ---- モーダル ---- */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: rgba(30, 35, 64, .55);
}
.overlay[hidden] { display: none; }
.dialog {
  width: min(100%, 360px); max-height: 100%; overflow-y: auto; padding: 1.4rem; border: var(--line); border-radius: 20px;
  background: var(--paper); box-shadow: 6px 6px 0 var(--ink); text-align: center; display: flex; flex-direction: column; gap: 1rem;
}
.dialog-title { font: 1.15rem var(--font-display); }
/* 遊び方 */
.help-dialog { width: min(100%, 520px); max-height: min(100%, 720px); }
.help-body { overflow-y: auto; min-height: 0; text-align: left; display: flex; flex-direction: column; gap: .9rem; }
.help-sec h3 { font: 1rem var(--font-display); font-weight: normal; margin-bottom: .3rem; }
.help-sec p { line-height: 1.7; font-weight: 800; font-size: .95rem; }
.dialog .actions { display: flex; flex-direction: column; gap: .75rem; }

#rotate { display: none; z-index: 40; }
@media (orientation: landscape) and (max-height: 500px) {
  body[data-orientation="portrait"] #rotate { display: flex; }
}

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

/* ステージ選択の章見出し */
.chapter-head { font: 1rem var(--font-display); margin-top: .4rem; padding-left: .2rem; }
/* 最終ステージの結末 */
.finale { display: flex; flex-direction: column; gap: .7rem; text-align: center; }
.finale-line { font-weight: 800; line-height: 1.8; }
.staff-roll { height: 260px; overflow: hidden; position: relative; -webkit-mask: linear-gradient(transparent, #000 15%, #000 85%, transparent); mask: linear-gradient(transparent, #000 15%, #000 85%, transparent); }
.staff-roll-inner { animation: staff-roll 40s linear forwards; padding-top: 120px; }
.staff-roll-inner p { line-height: 2; }
.staff-roll-inner .staff-head { font: 1rem var(--font-display); margin-top: 1.2rem; }
@keyframes staff-roll { to { transform: translateY(-100%); } }
@media (prefers-reduced-motion: reduce) { .staff-roll { height: auto; overflow: visible; -webkit-mask: none; mask: none; } .staff-roll-inner { animation: none; padding-top: 0; } }

/* 設定のチェックボックス行 */
.check-row { display: flex; gap: 10px; align-items: center; font-weight: 800; cursor: pointer; }
.check-row input { flex: none; width: 26px; height: 26px; margin: 0; accent-color: var(--accent, #ff6b8a); }

/* ステージ開放（2026-11-04） */
.result-open { align-self: center; font-weight: 800; background: var(--flyer); border: var(--line); border-radius: 99px; padding: .35rem 1rem; box-shadow: 2px 2px 0 var(--ink); animation: open-pop .5s .35s both; }
@keyframes open-pop { from { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .result-open { animation: none; } }

/* セーブデータを消す確認（2026-11-04） */
.reset-actions { display: flex; flex-direction: column; gap: 1.4rem; } /* 「はい」は「いいえ」から離して下に */
.btn.danger { background: var(--alarm); color: var(--paper); }
.btn.danger[disabled] { opacity: .5; }
