/* ============================================================
   あなたは何ネコ？ / Nyan Dev Lab — design tokens & components
   深夜のネコ研究所：ダーク固定テーマ（DesignSpec §2）
   ============================================================ */

:root {
  /* 背景（深夜のラボ） */
  --bg-base: #1A1B26;
  --bg-elevated: #24283B;
  --bg-panel: #2E3350;

  /* アクセント（ネオン・計器光） */
  --accent-cyan: #7DCFFF;
  --accent-mint: #9ECE6A;
  --accent-pink: #FF9EC4;
  --accent-amber: #E0AF68;
  --accent-purple: #BB9AF7;

  /* ネコを引き立てる地色 */
  --cat-spot: #F7F4EE;

  /* テキスト */
  --text-hi: #C0CAF5;
  --text-mid: #9AA5CE;
  --text-dim: #565F89;
  --text-on-accent: #1A1B26;

  /* 状態 */
  --border-soft: rgba(125, 207, 255, 0.15);
  --shadow-glow: 0 0 40px rgba(125, 207, 255, 0.25);

  /* spacing / radius / shadow */
  --radius-card: 20px;
  --radius-btn: 14px;
  --radius-pill: 999px;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --glow-cyan: 0 0 24px rgba(125, 207, 255, 0.4);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font-round: "Zen Maru Gothic", system-ui, sans-serif;
  --font-head: "Zen Kaku Gothic New", "Noto Sans JP", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-hi);
  font-family: var(--font-head);
  -webkit-font-smoothing: antialiased;
}

/* === ラボ背景：粒子＋草（contribution緑） === */
.lab-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(125, 207, 255, 0.08), transparent 60%),
    radial-gradient(900px 600px at 90% 110%, rgba(187, 154, 247, 0.07), transparent 60%),
    var(--bg-base);
}
.lab-bg::before {
  /* グリッド計器 */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(125, 207, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 207, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 40%, #000 30%, transparent 85%);
}
.lab-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent-mint);
  opacity: 0.35;
  animation: drift linear infinite;
}
@keyframes drift {
  from { transform: translateY(110vh) translateX(0); opacity: 0; }
  10% { opacity: 0.4; }
  90% { opacity: 0.4; }
  to { transform: translateY(-10vh) translateX(30px); opacity: 0; }
}

/* === アプリ枠（モバイルファースト：max 480-560 中央集約） === */
.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 40px;
}
.frame {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* === ラボ上部ステータスバー === */
.labbar {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  padding: 16px 4px 14px;
}
.labbar .rec {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-pink);
}
.labbar .rec .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-pink);
  box-shadow: 0 0 8px var(--accent-pink);
  animation: blink 1.6s var(--ease) infinite;
}
.labbar .name { color: var(--text-mid); letter-spacing: 0.16em; }
.labbar .spacer { flex: 1; }
.labbar .ver { color: var(--text-dim); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* カーソル点滅 */
.cursor::after {
  content: "_";
  color: var(--accent-cyan);
  animation: blink 1.1s steps(1) infinite;
  margin-left: 2px;
}

/* === ネコ台座（スポット＋グロー） === */
.cat-stage {
  position: relative;
  display: grid;
  place-items: center;
  margin: 6px auto;
}
.cat-glow {
  position: absolute;
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(28px);
  opacity: 0.55;
  background: radial-gradient(circle, var(--cat-spot) 0%, transparent 70%);
  z-index: 0;
}
.cat-rarity-aura {
  position: absolute;
  width: 92%;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(34px);
  opacity: 0.5;
  z-index: 0;
}
.cat-img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.45));
}
.cat-shadow {
  position: absolute;
  bottom: 6%;
  width: 52%;
  height: 14px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  filter: blur(9px);
  z-index: 1;
}

/* 浮遊 */
.float { animation: floaty 3.4s var(--ease) infinite; }
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* ぽよん登場（frame0でも可視：opacityは保つ） */
.pop-in { animation: popin 0.5s var(--ease) both; }
@keyframes popin {
  0% { transform: scale(0.82); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* === ボタン === */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  border-radius: var(--radius-btn);
  padding: 16px 20px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s;
  min-height: 52px;
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
  background: var(--accent-cyan);
  color: var(--text-on-accent);
  box-shadow: var(--glow-cyan);
}
.btn-primary:hover { box-shadow: 0 0 34px rgba(125, 207, 255, 0.6); transform: translateY(-1px); }

.btn-x {
  background: #16161e;
  color: #fff;
  border: 1.5px solid var(--accent-cyan);
  box-shadow: 0 0 20px rgba(125, 207, 255, 0.25);
  font-size: 17px;
}
.btn-x:hover { box-shadow: 0 0 30px rgba(125, 207, 255, 0.5); transform: translateY(-1px); }

.btn-follow {
  background: transparent;
  color: var(--accent-pink);
  border: 1.5px solid var(--accent-pink);
  font-size: 14.5px;
}
.btn-follow:hover { background: rgba(255, 158, 196, 0.1); }

.btn-ghost {
  background: rgba(125, 207, 255, 0.06);
  color: var(--text-mid);
  border: 1px solid var(--border-soft);
  font-weight: 600;
}
.btn-ghost:hover { color: var(--text-hi); border-color: var(--accent-cyan); }

/* === レア度バッジ === */
.rarity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.18em;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}
.rarity .stars { letter-spacing: 0.05em; }
.rarity-LEGENDARY { color: var(--accent-purple); border: 1px solid var(--accent-purple);
  background: rgba(187, 154, 247, 0.12); box-shadow: 0 0 22px rgba(187, 154, 247, 0.35); }
.rarity-EPIC { color: var(--accent-amber); border: 1px solid var(--accent-amber);
  background: rgba(224, 175, 104, 0.12); box-shadow: 0 0 18px rgba(224, 175, 104, 0.3); }
.rarity-RARE { color: var(--accent-cyan); border: 1px solid var(--accent-cyan);
  background: rgba(125, 207, 255, 0.1); }
.rarity-COMMON { color: var(--accent-mint); border: 1px solid var(--accent-mint);
  background: rgba(158, 206, 106, 0.1); }

/* 称号 pill */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  color: var(--accent-amber);
  background: rgba(224, 175, 104, 0.12);
  border: 1px solid rgba(224, 175, 104, 0.4);
}

/* === ステータスバー === */
.stat-panel {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  background: rgba(36, 40, 59, 0.6);
  padding: 16px 18px;
}
.stat-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
}
.stat-row .lbl { font-family: var(--font-head); font-weight: 700; font-size: 14px; color: var(--text-mid); }
.stat-dots { display: flex; gap: 5px; }
.stat-dots .d {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
}
.stat-dots .d.on { background: var(--accent-cyan); border-color: var(--accent-cyan); box-shadow: 0 0 8px rgba(125, 207, 255, 0.6); }
.stat-row .num { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

/* === 進捗ドット === */
.steps { display: flex; gap: 9px; align-items: center; }
.steps .s {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  transition: all 0.3s var(--ease);
}
.steps .s.done { background: var(--accent-mint); border-color: var(--accent-mint); box-shadow: 0 0 8px rgba(158, 206, 106, 0.6); }
.steps .s.cur { background: var(--accent-cyan); border-color: var(--accent-cyan); transform: scale(1.25); box-shadow: 0 0 10px rgba(125, 207, 255, 0.7); }

/* === 選択肢カード === */
.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 16px 18px;
  border-radius: var(--radius-btn);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-soft);
  color: var(--text-hi);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-head);
  font-size: 15.5px;
  line-height: 1.5;
  transition: transform 0.16s var(--ease), border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.opt:hover { border-color: var(--accent-cyan); box-shadow: var(--glow-cyan); transform: translateY(-2px); }
.opt:active, .opt.picked { transform: translateY(1px) scale(0.99); border-color: var(--accent-cyan); background: rgba(125, 207, 255, 0.08); box-shadow: var(--glow-cyan); }
.opt .key {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-cyan);
  background: rgba(125, 207, 255, 0.1);
  border: 1px solid var(--border-soft);
}

/* === ヘッドライン === */
.h-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.13em;
  color: var(--text-dim);
  text-transform: uppercase;
  white-space: nowrap;
}
.h1 { font-family: var(--font-round); font-weight: 700; font-size: 30px; line-height: 1.25; margin: 0; color: var(--text-hi); }
.h2 { font-family: var(--font-round); font-weight: 700; font-size: 22px; line-height: 1.4; margin: 0; color: var(--text-hi); }
.lead { font-size: 15px; line-height: 1.8; color: var(--text-mid); }
.dim-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); letter-spacing: 0.05em; }
.start-subtitle {
  font-family: var(--font-round);
  font-size: clamp(18px, 5.8vw, 22px);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-mid);
  white-space: nowrap;
}
.start-main-title {
  font-size: clamp(30px, 8.8vw, 34px);
  white-space: nowrap;
}

/* === 結果性格文 === */
.desc-text {
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--text-hi);
  text-wrap: pretty;
}

/* === 解析ログ === */
.analyzer-log {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--accent-mint);
  min-height: 84px;
}
.analyzer-log .ln { white-space: pre; }
.analyzer-log .ln.cy { color: var(--accent-cyan); }
.progress {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-panel);
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.progress .fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-mint), var(--accent-cyan));
  border-radius: var(--radius-pill);
  transition: width 0.2s linear;
}

/* カプセル */
.capsule {
  width: 180px; height: 180px;
  border-radius: 50%;
  display: grid; place-items: center;
  position: relative;
  background: radial-gradient(circle at 50% 35%, rgba(125, 207, 255, 0.25), rgba(36, 40, 59, 0.9) 70%);
  border: 2px solid var(--border-soft);
  box-shadow: var(--shadow-glow), inset 0 0 30px rgba(125, 207, 255, 0.2);
  animation: capspin 5s linear infinite, floaty 3s var(--ease) infinite;
}
@keyframes capspin { to { box-shadow: var(--shadow-glow), inset 0 0 40px rgba(187, 154, 247, 0.3); } }
.capsule .silh {
  width: 60%;
  filter: brightness(0) opacity(0.5);
  animation: wobble 1.4s var(--ease) infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

/* === 図鑑グリッド === */
.dex-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.dex-cell {
  aspect-ratio: 0.82;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 6px 9px;
  cursor: pointer;
  transition: transform 0.16s var(--ease), border-color 0.16s, box-shadow 0.16s;
  position: relative;
  overflow: hidden;
}
.dex-cell:hover { transform: translateY(-3px); border-color: var(--accent-cyan); box-shadow: var(--glow-cyan); }
.dex-cell .no { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-dim); align-self: flex-start; letter-spacing: 0.06em; }
.dex-cell img { width: 78%; height: auto; margin: 2px 0; }
.dex-cell .nm { font-family: var(--font-round); font-weight: 700; font-size: 10.5px; text-align: center; line-height: 1.25; color: var(--text-hi); }
.dex-cell.locked { cursor: default; }
.dex-cell.locked img { filter: brightness(0) opacity(0.32); }
.dex-cell.locked .nm { color: var(--text-dim); }
.dex-cell .lock {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -64%);
  font-size: 22px; opacity: 0.6;
}
.dex-cell .rdot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; }

/* レア度別ふち */
.cell-LEGENDARY { border-color: rgba(187, 154, 247, 0.5); }
.cell-EPIC { border-color: rgba(224, 175, 104, 0.45); }

/* === モーダル === */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 11, 18, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-back.open { display: flex; }
.modal {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px;
  max-height: 88dvh;
  overflow: auto;
  animation: popin 0.35s var(--ease) both;
}

/* === トースト === */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel);
  color: var(--text-hi);
  border: 1px solid var(--accent-cyan);
  box-shadow: var(--glow-cyan);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 紙吹雪 */
.confetti {
  position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden;
}
.confetti i {
  position: absolute;
  width: 9px; height: 14px;
  top: -20px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(108vh) rotate(640deg); opacity: 0.9; }
}

/* スクリーン切替 */
.screen { display: none; }
.screen.active { display: block; }
@keyframes fadeup { from { opacity: 0.001; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.stack { display: flex; flex-direction: column; }
.gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; }
.gap16 { gap: 16px; } .gap20 { gap: 20px; } .gap24 { gap: 24px; }
.center { text-align: center; }
.divider { height: 1px; background: var(--border-soft); border: none; margin: 4px 0; }

a.linkback {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-cyan);
  text-decoration: none;
  letter-spacing: 0.05em;
}
a.linkback:hover { text-decoration: underline; }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .float, .pop-in, .capsule, .capsule .silh, .lab-particle, .labbar .rec .dot, .cursor::after { animation: none !important; }
  .confetti { display: none !important; }
}

@media (min-width: 600px) {
  .h1 { font-size: 34px; }
  .frame { max-width: 520px; }
}
