/* 見た目の土台：仕様§7（画面ごとの表示管理・UI寸法・フォント）。8pxグリッド。 */
:root {
  --ink: #1B1B20;
  --paper: #F4F0E8;
  --btn-bg: rgba(255, 255, 255, 0.72);
  --btn-ink: #1B1B20;
  --ring: #1B1B20;
  --btn-edge: transparent;
  --hint-bg: rgba(255, 255, 255, 0.72);
  --hint-ink: #1B1B20;
  --coral: #FF7A59;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo UI", "Noto Sans JP", sans-serif;
}
:root[data-theme="dark"] {
  --ink: #F4F0E8;
  --btn-bg: rgba(27, 36, 64, 0.8);
  --btn-ink: #F4F0E8;
  --ring: #F4F0E8;
  --btn-edge: rgba(244, 240, 232, 0.35);
  --hint-bg: rgba(27, 36, 64, 0.8);
  --hint-ink: #F4F0E8;
}
* { box-sizing: border-box; margin: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: linear-gradient(#CFE8F2, #F6EBD9);
  font-family: var(--font);
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
.nb { display: inline-block; white-space: nowrap; } /* 文節の泣き別れを防ぐ */

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#vignette {
  --vig: 0.2;
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(10, 14, 26, 0) 55%, rgba(10, 14, 26, var(--vig)) 100%);
}

/* タイトル：左上 16px・20px Black（サイズ階層 20/16/13） */
#title {
  position: fixed; left: 16px; top: calc(16px + env(safe-area-inset-top)); z-index: 6;
  font-size: 20px; font-weight: 900; line-height: 1.3; letter-spacing: 0.02em;
  color: var(--ink); white-space: nowrap; pointer-events: none;
  transition: color 0.6s, opacity 0.4s;
}

/* 下中央の3ボタン：48×48・間隔16・端16 */
#dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; gap: 16px; z-index: 6;
  transition: opacity 0.4s;
}
#dock button {
  width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--btn-bg); color: var(--btn-ink);
  box-shadow: inset 0 0 0 1px var(--btn-edge);
  transition: transform 0.18s, background 0.6s, color 0.6s;
}
#dock button:hover { transform: scale(1.06); }
#dock button:active { transform: scale(0.96); }
#dock button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
#dock svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#dock #btn-pause svg path[d^="M8 5.5l"] { fill: currentColor; }

/* 初回ヒント：ボタンの上 24px・13px Bold・1行 */
#hint {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + 48px + 24px + env(safe-area-inset-bottom));
  z-index: 6; font-size: 13px; font-weight: 700; line-height: 1.6;
  padding: 8px 16px; border-radius: 999px; white-space: nowrap;
  background: var(--hint-bg); color: var(--hint-ink);
  opacity: 0; pointer-events: none; transition: opacity 0.8s;
}
#hint.show { opacity: 1; }

/* ダッシュ中はUIを薄く（没入） */
body.dash #dock, body.dash #title { opacity: 0.35; }

/* 吹き出し：ダーヤの頭上・16px Bold・1行・1.4秒 */
#bubble {
  position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none;
  font-size: 16px; font-weight: 700; line-height: 1.6; white-space: nowrap;
  padding: 0 16px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.95); color: #1B1B20;
  opacity: 0; transition: opacity 0.2s;
}
#bubble.in { opacity: 1; }
#bubble.out { opacity: 0; transition: opacity 0.35s; }
#bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px;
  background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}

/* S0 読み込み中：空色の背景・中央の「よみこみ中」と細い進捗線 */
#loading {
  position: fixed; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 16px;
  background: linear-gradient(#CFE8F2, #F6EBD9); color: #1B1B20;
  font-size: 13px; font-weight: 700; transition: opacity 0.6s; 
}
#loading.gone { opacity: 0; pointer-events: none; }
#loading .track { width: 160px; height: 4px; border-radius: 2px; background: rgba(27, 27, 32, 0.12); overflow: hidden; }
#loading #bar { display: block; height: 100%; width: 0; background: var(--coral); transition: width 0.3s; }
#fade {
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(#CFE8F2, #F6EBD9); opacity: 1; transition: opacity 1.4s ease-out;
}
#fade.gone { opacity: 0; }

/* S4 3D非対応・失敗：メッセージのみ */
#unsupported {
  position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px; text-align: center;
  font-size: 16px; font-weight: 700; line-height: 1.6; color: #1B1B20;
  background: linear-gradient(#CFE8F2, #F6EBD9);
  text-wrap: balance;
}
#unsupported[hidden] { display: none; }
#hint[hidden], #dock[hidden], #bubble[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  #fade, #loading, #hint, #bubble, #dock button { transition: none; }
}
