/* ============================================================
   虚無の鼓動 / Pulse of the Void — Stylesheet
   前衛的: モノクロ基調 + 単色アクセント + ノイズ + 揺らぎ
   ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: #06060a;
  color: #e8e6df;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  letter-spacing: 0.02em;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* 背景: 動くノイズ + 漸進グラデ */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(180, 60, 60, 0.10), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(60, 80, 140, 0.10), transparent 55%),
    linear-gradient(180deg, #07070b 0%, #0a0a0f 100%);
  z-index: -2;
}
body::after {
  content: "";
  position: fixed; inset: -50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  pointer-events: none;
  z-index: -1;
  animation: drift 18s linear infinite;
  opacity: 0.55;
}
@keyframes drift {
  from { transform: translate(0,0); }
  to   { transform: translate(-80px,-60px); }
}

/* レイアウト */
#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%; height: 100vh; height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
}

/* ── ヘッダー ── */
header.top {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(4px);
}
.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.game-title {
  font-size: 20px;
  letter-spacing: 0.25em;
  font-weight: 400;
  margin: 0;
  color: #f5f1e6;
  text-shadow: 0 0 12px rgba(220, 80, 80, 0.15);
}
.game-title .sub {
  display: block;
  font-size: 10px;
  letter-spacing: 0.4em;
  color: #8d8a82;
  margin-top: 2px;
}
.reset-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: #b8b3a6;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  letter-spacing: 0.2em;
  font-family: inherit;
  border-radius: 0;
  transition: all .2s;
}
.reset-btn:hover, .reset-btn:active { background: rgba(220,80,80,0.18); color:#fff; }

.chapter-row { margin-top: 10px; }
.ch-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: #c7c2b3;
}
.ch-label .next { color: #8d8a82; font-size: 10px; }
.ch-bar {
  margin-top: 4px;
  height: 2px;
  background: rgba(255,255,255,0.08);
  position: relative;
  overflow: hidden;
}
.ch-bar > div {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #c33, #e9b86b);
  transition: width .4s ease;
}

/* ── メイン ── */
main.center {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow: hidden;
  position: relative;
}

/* 左: コア + リソース */
.left-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-right: 1px solid rgba(255,255,255,0.05);
  position: relative;
  min-height: 0;
}

.resources {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}
.coin-amount {
  font-size: 36px;
  letter-spacing: 0.04em;
  color: #f5f1e6;
  text-shadow: 0 0 18px rgba(220, 80, 80, 0.22);
  font-feature-settings: "tnum";
}
.coin-name {
  font-size: 11px;
  letter-spacing: 0.4em;
  color: #b8b3a6;
  margin-top: 2px;
}
.sub-stats {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: #8d8a82;
}
.sub-stats span b { color:#d8d3c3; font-weight:400; }

/* コア(タップ対象) */
.core-wrap {
  position: relative;
  width: 220px; height: 220px;
  display: flex; align-items: center; justify-content: center;
}
#core {
  position: relative;
  width: 200px; height: 200px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,210,180,0.20), transparent 50%),
    radial-gradient(circle at 50% 50%, #1a0e10 0%, #06060a 70%);
  border: 1px solid rgba(220, 80, 80, 0.35);
  box-shadow:
    0 0 60px rgba(220, 80, 80, 0.18),
    inset 0 0 40px rgba(220, 80, 80, 0.18);
  cursor: pointer;
  transition: transform .08s ease;
  display:flex; align-items:center; justify-content:center;
}
#core::before {
  content: "";
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 1px dashed rgba(255,255,255,0.06);
  animation: spin 60s linear infinite;
}
#core::after {
  content: "鼓動";
  font-size: 13px;
  letter-spacing: 0.6em;
  color: rgba(245, 241, 230, 0.75);
  text-shadow: 0 0 10px rgba(220,80,80,0.4);
  padding-left: 0.6em;
}
#core.pulse {
  animation: corePulse 0.45s ease-out;
}
@keyframes corePulse {
  0%   { transform: scale(1.0); box-shadow: 0 0 60px rgba(220, 80, 80, 0.18), inset 0 0 40px rgba(220, 80, 80, 0.18); }
  30%  { transform: scale(0.94); box-shadow: 0 0 90px rgba(220, 80, 80, 0.45), inset 0 0 60px rgba(220, 80, 80, 0.4); }
  100% { transform: scale(1.0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* フローティング数字 */
#floatLayer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 50;
}
.float-num {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #f5d6a0;
  text-shadow: 0 0 8px rgba(245,214,160,0.6);
  animation: floatUp 1s ease-out forwards;
  letter-spacing: 0.05em;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1.05); }
}

/* 右: タブ(ストーリー / ショップ) */
.right-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #8d8a82;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.3em;
  padding: 12px 0;
  cursor: pointer;
  position: relative;
  transition: color .2s;
}
.tab-btn.active { color: #f5f1e6; }
.tab-btn.active::after {
  content: "";
  position: absolute; bottom: -1px; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #c33, transparent);
}
.tab-pane {
  display: none;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px;
  min-height: 0;
}
.tab-pane.active { display: block; }
.tab-pane::-webkit-scrollbar { width: 4px; }
.tab-pane::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

/* ストーリー */
.story-line {
  font-size: 13px;
  line-height: 1.85;
  margin: 0 0 10px;
  color: #d8d3c3;
  animation: storyFade 0.9s ease;
  border-left: 1px solid rgba(220, 80, 80, 0.25);
  padding-left: 10px;
}
.story-line .story-ch {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.3em;
  color: #8d8a82;
  margin-right: 6px;
  vertical-align: 2px;
}
@keyframes storyFade {
  from { opacity: 0; transform: translateY(8px); filter: blur(2px); }
  to   { opacity: 1; transform: none; filter: none; }
}
/* 章ごとのアクセント色 */
.story-line.ch-0 { border-color: rgba(180,180,180,0.3); }
.story-line.ch-1 { border-color: rgba(200,160,120,0.4); }
.story-line.ch-2 { border-color: rgba(120,180,200,0.4); }
.story-line.ch-3 { border-color: rgba(220,120,120,0.45); }
.story-line.ch-4 { border-color: rgba(220,200,140,0.5); }
.story-line.ch-5 { border-color: rgba(200,140,220,0.5); }
.story-line.ch-6 { border-color: rgba(140,200,220,0.5); }
.story-line.ch-7 { border-color: rgba(245,245,245,0.6); color: #f5f1e6; }
.story-line.ch-8 { border-color: rgba(160,220,160,0.55); }
.story-line.ch-9 { border-color: rgba(245,180,80,0.7); }
.story-line.ch-10 { border-color: rgba(245,90,90,0.85); color: #f5e1d8; }

/* ショップ */
.shop-section-title {
  font-size: 10px;
  letter-spacing: 0.4em;
  color: #8d8a82;
  margin: 6px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
}
.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.shop-item {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.08);
  color: #c7c2b3;
  text-align: left;
  padding: 10px 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 0;
  transition: all .15s;
}
.shop-item:disabled { opacity: 0.6; cursor: not-allowed; }
.shop-item.can {
  border-color: rgba(220, 80, 80, 0.5);
  background: rgba(220, 80, 80, 0.06);
  color: #f5f1e6;
}
.shop-item.can:hover { background: rgba(220, 80, 80, 0.14); }
.shop-item.bought { opacity: 0.4; cursor: default; }
.shop-item.click { border-style: solid; border-left-width: 3px; border-left-color: rgba(245, 200, 120, 0.5); }
.si-row { display: flex; justify-content: space-between; align-items: baseline; }
.si-name { font-size: 13px; letter-spacing: 0.1em; }
.si-owned { font-size: 10px; color: #8d8a82; letter-spacing: 0.2em; }
.si-desc { font-size: 11px; color: #8d8a82; margin: 4px 0 6px; line-height: 1.5; }
.si-cost { font-size: 11px; letter-spacing: 0.15em; color: #e9b86b; text-align: right; }

/* タブバー(下部) — モバイル時のみ表示 */
nav.bottom {
  display: none;
}

/* トースト */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast-item {
  background: rgba(20,18,22,0.92);
  color: #f5f1e6;
  padding: 10px 18px;
  border: 1px solid rgba(220, 80, 80, 0.4);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-align: center;
  animation: toastIn 0.3s ease;
  backdrop-filter: blur(6px);
}
.toast-item.out { animation: toastOut 0.4s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

/* ────────────────── モバイル対応 ────────────────── */
@media (max-width: 760px) {
  main.center {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .left-pane {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 10px;
  }
  .core-wrap { width: 180px; height: 180px; }
  #core { width: 170px; height: 170px; }
  .coin-amount { font-size: 30px; }
  .game-title { font-size: 16px; letter-spacing: 0.2em; }
  .game-title .sub { font-size: 9px; }
  .right-pane { min-height: 0; }
  .tab-pane { padding: 10px; }
  .story-line { font-size: 12.5px; }
}

@media (max-width: 380px) {
  .core-wrap { width: 150px; height: 150px; }
  #core { width: 140px; height: 140px; }
  .coin-amount { font-size: 26px; }
  .sub-stats { font-size: 9px; gap: 8px; }
}

/* セーフエリア(iPhone notch) */
@supports (padding: env(safe-area-inset-top)) {
  header.top { padding-top: calc(12px + env(safe-area-inset-top)); }
  #app { padding-bottom: env(safe-area-inset-bottom); }
}

/* PWAスタンドアロン時の調整 */
@media (display-mode: standalone) {
  body { background: #06060a; }
}
