/* ============ 大水槽 UI ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #dcecf5;
  --dim: #8fb4c7;
  --glass: rgba(6, 24, 38, 0.62);
  --glass-line: rgba(140, 200, 235, 0.18);
  --accent: #6fd3ff;
}

html, body, #app { width: 100%; height: 100%; overflow: hidden; }

body {
  background: #04121f;
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#stage:active { cursor: grabbing; }

/* 水中らしい周辺減光(擬似ポストエフェクト) */
#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(2, 10, 20, 0.42) 100%),
    linear-gradient(to bottom, rgba(90, 180, 220, 0.05), transparent 30%);
}

/* ---- タイトル ---- */
#hud-title {
  position: absolute; top: 22px; left: 26px; pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 10, 20, 0.8);
}
#hud-title h1 {
  font-size: 26px; font-weight: 700; letter-spacing: 0.14em;
}
#hud-title h1 span {
  font-size: 11px; letter-spacing: 0.42em; color: var(--dim);
  display: block; margin-top: 2px; font-weight: 400;
}
#hud-title .hint { margin-top: 10px; font-size: 11.5px; color: var(--dim); letter-spacing: 0.04em; }

/* ---- 左下コントロール ---- */
#hud-left {
  position: absolute; left: 26px; bottom: 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.ctl {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(8px); border-radius: 10px; padding: 8px 14px;
}
.ctl label { font-size: 12px; color: var(--dim); white-space: nowrap; }
.ctl input[type="range"] { width: 130px; accent-color: var(--accent); }
/* ボタンが増えても、ラベルの途中で折り返さないこと。
   幅が足りないときは行を増やして逃がす(「えさを/まく」と割れると読めない) */
.ctl-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--glass); border: 1px solid var(--glass-line); color: var(--ink);
  backdrop-filter: blur(8px); border-radius: 10px; padding: 8px 14px;
  font-size: 12.5px; cursor: pointer; transition: background 0.15s;
  white-space: nowrap; flex: 0 0 auto;
}
/* .chip は display を指定していないので既定の hidden が効くが、
   flex アイテムとして扱われる場面もあるため明示しておく */
.chip[hidden] { display: none; }
.chip:hover { background: rgba(20, 60, 90, 0.7); }
.chip.on { border-color: var(--accent); color: var(--accent); }
/* 餌やりだけは押してほしいボタンなので、少し前に出す。
   撒いたあとは短いあいだ沈んで、次に撒けるまでを見せる */
.chip.feed { border-color: rgba(255, 176, 96, 0.55); color: #ffd0a0; }
.chip.feed:hover { background: rgba(120, 70, 20, 0.55); }
.chip.feed.cooling { opacity: 0.45; pointer-events: none; }
#fps { font-size: 10px; color: rgba(140, 180, 200, 0.55); padding-left: 4px; }

/* ---- ポータルへ戻る ----
   以前はここに水槽のタブを横並びにしていた。5つで既に画面から
   はみ出していて、増えるほど横スクロールが伸びる形だった。
   行き先を選ぶのはポータルエリアの仕事にして、UI には
   「戻る」1つだけを残す。水槽が増えてもこのボタンは増えない */
#hubBtn {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  z-index: 20; cursor: pointer; font-family: inherit;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); border-radius: 14px;
  padding: 10px 18px; font-size: 13px; color: var(--ink);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: background 0.18s;
}
#hubBtn[hidden] { display: none; }
#hubBtn .hi { font-size: 16px; }
#hubBtn:hover { background: rgba(30, 78, 108, 0.6); }

/* ---- 図鑑パネル ---- */
#panelToggle {
  position: absolute; top: 22px; right: 24px; z-index: 20;
  background: var(--glass); border: 1px solid var(--glass-line); color: var(--ink);
  backdrop-filter: blur(8px); border-radius: 12px; padding: 10px 16px;
  font-size: 14px; cursor: pointer;
}
#panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 320px; z-index: 15;
  background: linear-gradient(to left, rgba(4, 16, 28, 0.92), rgba(4, 16, 28, 0.78));
  border-left: 1px solid var(--glass-line); backdrop-filter: blur(14px);
  padding: 76px 18px 16px; overflow-y: auto;
  transform: translateX(105%); transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
#panel.open { transform: translateX(0); }
#panel h2 { font-size: 15px; letter-spacing: 0.2em; color: var(--dim); margin-bottom: 14px; }
#panel footer { margin-top: 14px; font-size: 10.5px; color: rgba(140, 180, 200, 0.5); text-align: center; }

.card {
  background: rgba(12, 36, 56, 0.55); border: 1px solid var(--glass-line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.card:hover { background: rgba(18, 52, 78, 0.7); }
.card.active { border-color: var(--accent); background: rgba(20, 62, 92, 0.75); }
.card .row { display: flex; align-items: baseline; gap: 8px; }
.card .icon { font-size: 20px; }
.card .name { font-size: 14.5px; font-weight: 700; }
.card .sci { font-size: 10px; color: var(--dim); font-style: italic; }
.card .desc { margin-top: 7px; font-size: 11.5px; line-height: 1.65; color: #b9d4e2; }
.card .eco { margin-top: 6px; font-size: 10.5px; color: var(--accent); opacity: 0.85; }

/* ---- 追跡中の解説ポップ ---- */
#infoPop {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%);
  max-width: 520px; text-align: center; pointer-events: none;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); border-radius: 14px; padding: 12px 22px;
  font-size: 12.5px; line-height: 1.7; color: #cfe4ef;
  transition: opacity 0.4s;
}
#infoPop b { color: var(--accent); font-size: 13.5px; }
.hidden { opacity: 0; visibility: hidden; }

/* ---- ハッチをくぐるときの覆い ----
   UI より前、遊び方の動画より後ろ。中身は毎フレーム JS が塗るので、
   ここでは重ね順とクリックの素通しだけ決める。
   transition は付けない——JS 側が時間を持っているので、
   CSS にも補間させると二重にかかって遅れる */
#warp {
  position: fixed; inset: 0; z-index: 35;
  pointer-events: none; opacity: 0;
}

/* ---- 遊び方の動画 ---- */
#guide {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 10, 18, 0.78); backdrop-filter: blur(6px);
  transition: opacity 0.25s;
}
#guide.hidden { pointer-events: none; }
#guideBox {
  /* 縦長(540×1170)の動画なので、幅ではなく高さで収まりを決める。
     幅だけで決めると、横長の画面では画面外へ突き抜ける。 */
  width: min(92vw, 430px, calc((100vh - 130px) * 540 / 1170));
  background: rgba(4, 16, 28, 0.94); border: 1px solid var(--glass-line);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  transform: scale(0.97); transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
#guide:not(.hidden) #guideBox { transform: scale(1); }
#guideHead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 12px 18px;
  font-size: 13px; letter-spacing: 0.18em; color: var(--dim);
}
#guideClose {
  background: transparent; border: 1px solid var(--glass-line); color: var(--ink);
  border-radius: 9px; width: 32px; height: 32px; font-size: 13px; cursor: pointer;
}
#guideClose:hover { background: rgba(20, 60, 90, 0.7); }
#guideVideo { display: block; width: 100%; aspect-ratio: 540 / 1170; background: #04101c; }

@media (max-width: 720px) {
  #panel { width: 86%; }
  #hud-title h1 { font-size: 20px; }
  #hud-title .hint { display: none; }
  /* 狭い画面では上に3つ並べる余裕がないので、戻るボタンは最下段へ。
     1つしかないので、もう横スクロールは要らない */
  #hubBtn { top: auto; bottom: 16px; padding: 9px 16px; font-size: 12px; }
  #hud-left { left: 16px; right: 16px; bottom: 74px; }
  #hud-left .ctl input[type="range"] { width: 100%; }
  #fps { display: none; }
  /* 追跡中の解説も、コントロールの上へ逃がす */
  #infoPop {
    left: 16px; right: 16px; bottom: 176px; transform: none;
    max-width: none; font-size: 11.5px; padding: 10px 14px;
  }
  /* 指で押しやすい大きさに。3つ並べても折り返らない範囲で詰める */
  .chip { padding: 10px 13px; font-size: 12.5px; }
  #panelToggle { padding: 12px 18px; }
}
