:root {
  --bg: #05060d;
  --fg: #eceef3;
  --muted: #9aa0ab;
  --accent: #ffd35c;
}

* { box-sizing: border-box; }

/* Safari 26 の上下バーの色は html の背景から取られる。body と同じ色にしておく */
html { background-color: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 画面の端に置くものはセーフエリアの分だけ内側に。高さは 100vh ではなく 100dvh */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bar__title { margin: 0; font-size: 18px; }
.bar__actions { display: flex; gap: 8px; }
.pill {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  touch-action: manipulation;   /* ダブルタップ拡大を止める */
  min-height: 0;
}
.credit { text-align: center; font-size: 12px; color: var(--muted); }
.credit a { color: inherit; }
.credit a + a { margin-left: 4px; }

/* 全画面のオーバーレイは opacity ではなく display: none で隠す */

#scene {
  position: absolute;
  inset: 0;
}
#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* OrbitControls がドラッグ・ピンチを扱う */
}

.hud {
  position: absolute;
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud--top { top: max(8px, env(safe-area-inset-top)); }

.search {
  position: relative;
}
#search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 11, 20, 0.72);
  color: var(--fg);
  font-size: 16px; /* iOS の自動ズームを避ける */
  backdrop-filter: blur(4px);
}
#search-input.is-invalid {
  border-color: #ff6b6b;
  color: #ffb4b4;
}
.search__msg {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: #ffb4b4;
  background: rgba(10, 4, 4, 0.78);
}

.hud__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hud__buttons .pill {
  background: rgba(10, 11, 20, 0.72);
  backdrop-filter: blur(4px);
}

.stats {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 2;
  font-size: 11px;
  color: var(--muted);
  background: rgba(10, 11, 20, 0.55);
  padding: 4px 8px;
  border-radius: 8px;
  pointer-events: none;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  max-height: 45%;
  display: flex;
  flex-direction: column;
  background: rgba(8, 9, 16, 0.92);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px 14px 0 0;
  padding: 10px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
}
.sheet__path {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.sheet__close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}
.sheet__list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet__list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
}
.sheet__list .meaning {
  color: var(--muted);
  text-align: right;
}
