/* COSMIC EATER - styles */

:root {
  --bg: #05040f;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-line: rgba(255, 255, 255, 0.14);
  --text: #eef0ff;
  --muted: #9aa2cf;
  --accent: #9b6bff;
  --hp: #ff5d6c;
  --mass: #5cc9ff;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

#game-canvas {
  position: fixed; inset: 0;
  display: block;
  touch-action: none;
  z-index: 0;
}

/* WebGL(#game-canvas)の上に重ねる2Dオーバーレイ。HPバー・浮遊ダメージ数・
   彗星の尾アップグレードの軌跡・色調ワッシュ・流れ星などの画面に張り付く
   表現を描く。クリック等はすべて下のWebGLキャンバスへ通す。 */
#overlay-canvas {
  position: fixed; inset: 0;
  display: block;
  pointer-events: none;
  z-index: 1;
}

/* 薄いビネット（写真的な周辺減光）。毎フレームのcanvas再描画コストを避けるため
   常時表示のCSSオーバーレイとして重ねている（GPU合成のみでコストがほぼ0）。 */
#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.38) 100%);
}

/* ───────── HUD ───────── */
#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10;
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
}

#hud-top {
  display: flex; align-items: center; gap: 10px;
  max-width: 720px; margin: 0 auto;
}

#stage-badge {
  flex: none;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 66px;
}
#stage-name { font-weight: 800; color: var(--text); font-size: 13px; white-space: nowrap; }
#stage-level { font-size: 10px; }
#stage-level b { color: var(--text); }

#bars { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bar {
  position: relative;
  height: 15px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--panel-line);
  overflow: hidden;
}
.bar i {
  display: block; height: 100%; width: 0%;
  border-radius: 8px 0 0 8px;
  transition: width .25s ease;
}
.hp-bar i { background: linear-gradient(90deg,#ff8a8a,var(--hp)); }
.mass-bar i { background: linear-gradient(90deg,#7ee0ff,var(--mass)); }
.bar span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  letter-spacing: .02em;
}

#hud-time {
  flex: none;
  font-size: 11px; color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 5px 8px;
  white-space: nowrap;
}

#btn-menu {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  pointer-events: auto;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

/* ロックオン表示 */
#lockon {
  position: fixed; left: 12px; top: 78px;
  width: 168px;
  background: rgba(10, 6, 26, .55);
  border: 1px solid rgba(255,120,120,.4);
  border-radius: 10px;
  padding: 7px 9px;
  pointer-events: none;
}
#lockon.hidden { display: none; }
.lockon-name { font-size: 12px; font-weight: 800; color: #ffb3ba; margin-bottom: 4px; }
.lockon-bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.lockon-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg,#ff8a8a,#ff4d5e); }
.lockon-sub { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* モードバッジ（メニューボタンの下、右上） */
#mode-badge {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 40px);
  right: 12px;
  font-size: 9.5px; color: var(--muted);
  background: rgba(10,6,26,.5);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 3px 7px;
  pointer-events: none;
  z-index: 10;
}

/* 保有衛星（ロックオンパネルの下、左上に積む） */
#satellite-hud {
  position: fixed; left: 12px; top: 78px;
  font-size: 12px; font-weight: 800; color: #8fe3c9;
  background: rgba(10,6,26,.55);
  border: 1px solid rgba(140,230,190,.4);
  border-radius: 10px;
  padding: 5px 9px;
  pointer-events: none;
  z-index: 10;
}
#lockon:not(.hidden) ~ #satellite-hud { top: 152px; }
#satellite-hud.hidden { display: none; }

/* エンドレスモード統計（左上のスタックに積む。実際の上下位置は他パネルの表示状態に
   応じて game.js が動的に top を設定する） */
#endless-hud {
  position: fixed; left: 12px; top: 78px;
  font-size: 11px; font-weight: 700; color: #c9a2ff;
  background: rgba(10,6,26,.55);
  border: 1px solid rgba(155,107,255,.4);
  border-radius: 10px;
  padding: 5px 9px;
  pointer-events: none;
  z-index: 10;
  line-height: 1.5;
}
#endless-hud.hidden { display: none; }

/* 捕獲ボタン（スマホ向け） */
#btn-capture {
  position: fixed;
  right: 12px;
  bottom: max(18px, env(safe-area-inset-bottom));
  pointer-events: auto;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 2px solid rgba(140,230,190,.5);
  background: rgba(10,6,26,.6);
  color: #8fe3c9;
  font-size: 24px;
  opacity: 0.45;
  transition: opacity .15s ease, transform .1s ease, box-shadow .15s ease;
}
#btn-capture.ready {
  opacity: 1;
  box-shadow: 0 0 18px rgba(140,230,190,.6);
  border-color: #8fe3c9;
}
#btn-capture:active { transform: scale(.94); }
#btn-capture.hidden { display: none; }

#lockon.capturable { border-color: rgba(140,230,190,.65); }
#lockon.capturable .lockon-sub { color: #8fe3c9; }

.btn-fast { opacity: 0.85; }

/* 取得アップグレード一覧 */
#upgrade-list {
  position: fixed; right: 8px; top: 78px;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 60vh; overflow: hidden;
}
.upg-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: rgba(10,6,26,.55);
  border: 1px solid var(--panel-line);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  position: relative;
}
.upg-icon .lv {
  position: absolute; right: -3px; bottom: -3px;
  font-size: 9px; font-weight: 800;
  background: var(--accent); color: #100826;
  border-radius: 99px; padding: 0 4px;
  line-height: 1.4;
}

/* ───────── モーダル共通 ───────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 2, 10, .82);
  backdrop-filter: blur(6px);
  padding: 20px;
  pointer-events: auto;
}
.modal.hidden { display: none; }

.modal-inner {
  width: min(100%, 460px);
  background: linear-gradient(160deg, #171233, #0b081d);
  border: 1px solid var(--panel-line);
  border-radius: 20px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-inner h1 { font-size: clamp(24px, 6vw, 34px); margin: 0 0 12px; background: linear-gradient(90deg,#b98bff,#5cc9ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.modal-inner h2 { margin: 0 0 6px; font-size: 22px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.title-desc { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 0 0 22px; }
.title-hint { color: var(--muted); font-size: 11.5px; margin-top: 22px; }

.btn {
  border: 0; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 800;
  cursor: pointer; width: 100%; transition: transform .1s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(90deg,#9b6bff,#5cc9ff); color: #0a0716; }
.btn-ghost { background: rgba(255,255,255,.08); border: 1px solid var(--panel-line); color: var(--text); }
.title-buttons, .pause-buttons { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }

/* アップグレードカード */
.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--panel-line);
  background: rgba(255,255,255,.04);
  padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.card.rare { border-color: rgba(92,201,255,.5); box-shadow: 0 0 22px rgba(92,201,255,.12) inset; }
.card.epic { border-color: rgba(255,196,92,.55); box-shadow: 0 0 22px rgba(255,196,92,.14) inset; }
.card-icon { font-size: 26px; flex: none; width: 40px; text-align: center; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.card-rarity { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 99px; letter-spacing: .04em; }
.card-rarity.common { background: rgba(255,255,255,.1); color: var(--muted); }
.card-rarity.rare { background: rgba(92,201,255,.18); color: #8fd8ff; }
.card-rarity.epic { background: rgba(255,196,92,.2); color: #ffd18f; }
.card-desc { font-size: 12.5px; color: var(--muted); margin: 5px 0 10px; line-height: 1.5; }
.card-pick { border: 0; border-radius: 10px; padding: 8px; font-size: 13px; font-weight: 800; cursor: pointer; background: linear-gradient(90deg,#9b6bff,#5cc9ff); color: #0a0716; width: 100%; }
.card-pick:active { transform: scale(.97); }

/* トースト */
.toast {
  position: fixed; left: 50%; top: 30%; transform: translate(-50%,-50%);
  z-index: 60; pointer-events: none; text-align: center;
  background: rgba(10,6,26,.75); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 14px 20px; font-size: 14px; font-weight: 700;
}
.toast.hidden { display: none; }

/* リザルト */
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.result-stats div { background: rgba(255,255,255,.05); border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; gap: 3px; }
.result-stats span { font-size: 10px; color: var(--muted); }
.result-stats b { font-size: 17px; }

@media (min-width: 720px) {
  #hud-top { max-width: 820px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
