/* 千に一つ - スタイルシート（画像を一切使わず、CSSのみで表現する） */

:root {
  --bg: #0f1117;
  --bg2: #161a24;
  --bg3: #1e2330;
  --line: #2c3242;
  --text: #eef0f5;
  --text-dim: #9aa3b5;
  --gold: #d8b45c;
  --gold-dim: #8a733a;
  --good: #4fd18b;
  --bad: #e2596b;
  --warn: #e2b34f;
  --info: #5aa7e0;
  --purple: #a37de0;
  --hp: #e2596b;
  --sp: #5aa7e0;
  --int: #7fd1e0;
  --cha: #e0a95a;
  --cred: #9adf7a;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  overflow-x: hidden;
}
button { font-family: inherit; }
h1, h2, h3, p { margin: 0; }

.app { position: relative; min-height: 100vh; }
.screen { min-height: 100vh; }
[hidden] { display: none !important; }

/* ============ ボタン共通 ============ */
.btn {
  display: inline-block;
  padding: 0.85em 1.6em;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #f0d48a);
  color: #241d0d;
  box-shadow: 0 4px 16px rgba(216,180,92,0.35);
}
.btn-primary:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
}
.link-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 0.85rem; cursor: pointer; text-decoration: underline;
  padding: 0.4em;
}
.icon-btn {
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 2.4em; height: 2.4em;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============ タイトル画面 ============ */
.title-screen {
  display: flex; align-items: center; justify-content: center;
  position: relative;
  background: radial-gradient(ellipse at 30% 20%, #1c2233 0%, #0f1117 60%);
  padding: 2rem 1rem;
}
.title-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.seed-dot {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold-dim); opacity: 0.5;
  animation: floatUp 14s linear infinite;
}
.seed-dot.d1 { left: 10%; animation-duration: 16s; animation-delay: -2s; }
.seed-dot.d2 { left: 25%; animation-duration: 20s; animation-delay: -6s; }
.seed-dot.d3 { left: 45%; animation-duration: 13s; animation-delay: -1s; }
.seed-dot.d4 { left: 62%; animation-duration: 18s; animation-delay: -9s; }
.seed-dot.d5 { left: 78%; animation-duration: 15s; animation-delay: -4s; }
.seed-dot.d6 { left: 90%; animation-duration: 22s; animation-delay: -11s; }
@keyframes floatUp {
  0% { transform: translateY(110vh) scale(0.6); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-10vh) scale(1.2); opacity: 0; }
}
.title-card {
  position: relative; z-index: 1;
  max-width: 480px; width: 100%;
  text-align: center;
  background: rgba(22,26,36,0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.4rem 1.8rem;
  backdrop-filter: blur(6px);
}
.title-logo {
  font-size: 3.2rem; letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--gold), #fff2c8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 0 0 0.6rem;
}
.title-logo-small { font-size: 1.6rem; }
.title-copy { color: var(--text-dim); font-size: 1rem; margin-bottom: 1.4rem; }
.title-desc { font-size: 0.92rem; line-height: 1.9; color: var(--text-dim); margin-bottom: 1.8rem; }
.title-desc strong { color: var(--gold); }
.title-buttons { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1.2rem; }
.title-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 1rem; margin-bottom: 1rem; }
.title-foot { font-size: 0.72rem; color: #5a6070; }

/* ============ ゲーム画面：全体レイアウト ============ */
/* モバイル（〜767px）：上から下へ自然に流れる1カラム。ログは適度な高さで内部スクロールし、
   行動パネルの下に「人生・実績・図鑑・記録」タブを続けて表示する（下部の大ボタンが行動選択の主役）。 */
.game-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.statbar { position: sticky; top: 0; z-index: 5; flex: 0 0 auto; order: 0; }
.logpane { flex: 0 1 auto; max-height: 34vh; overflow-y: auto; order: 1; }
.actionpane { flex: 0 0 auto; order: 2; }
.sidepane {
  display: flex; flex-direction: column;
  border-left: none; border-top: 6px solid var(--bg);
  flex: 0 0 auto; order: 3;
}
.sidepane-body { max-height: 60vh; }

/* ---- ステータスバー ---- */
.statbar {
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-bottom: 1px solid var(--line);
  padding: 0.6rem 0.8rem 0.5rem;
}
.statbar-row1 { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.statbar-age { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.statbar-turn { font-weight: 400; font-size: 0.78rem; color: var(--text-dim); }
.statbar-job {
  flex: 1; text-align: center; font-size: 0.85rem; color: var(--gold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid var(--gold-dim); border-radius: 999px; padding: 0.25em 0.8em;
}
.statbar-row2 { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.stat-pill {
  display: flex; align-items: baseline; gap: 0.4em;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.28em 0.85em; font-size: 0.82rem;
}
.stat-pill.money .stat-value { color: var(--gold); font-weight: 700; }
.stat-pill.debt .stat-value { color: var(--bad); font-weight: 700; }
.stat-pill.luck .stat-value { color: var(--purple); font-weight: 700; }
.stat-label { color: var(--text-dim); font-size: 0.75rem; }
.statbar-bars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; }
.bar-wrap { display: flex; flex-direction: column; gap: 0.15rem; }
.bar-icon { font-size: 0.62rem; color: var(--text-dim); text-align: center; }
.bar-track { height: 7px; border-radius: 999px; background: var(--bg3); overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.bar-hp { background: linear-gradient(90deg, #b23a4a, var(--hp)); }
.bar-sp { background: linear-gradient(90deg, #2f6fa8, var(--sp)); }
.bar-int { background: linear-gradient(90deg, #3b9aa8, var(--int)); }
.bar-cha { background: linear-gradient(90deg, #a3782f, var(--cha)); }
.bar-cred { background: linear-gradient(90deg, #5a9a3a, var(--cred)); }

/* ---- ログ ---- */
.logpane { overflow-y: auto; padding: 0.8rem; background: var(--bg); }
.log-list { display: flex; flex-direction: column; gap: 0.55rem; max-width: 720px; margin: 0 auto; }
.log-entry {
  background: var(--bg2); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 10px; padding: 0.6rem 0.8rem; font-size: 0.88rem; line-height: 1.6;
  animation: logIn 0.25s ease;
}
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.log-entry.tag-turn { border-left-color: var(--line); color: var(--text-dim); font-size: 0.8rem; }
.log-entry.tag-good { border-left-color: var(--good); }
.log-entry.tag-bad { border-left-color: var(--bad); }
.log-entry.tag-neutral { border-left-color: var(--info); }
.log-entry.tag-lifeevent { border-left-color: var(--gold); background: #201c14; }
.log-entry .log-title { font-weight: 700; margin-right: 0.4em; }
.log-entry .log-delta { display: inline-block; margin-top: 0.3em; font-size: 0.78rem; color: var(--text-dim); }
.log-delta .d-up { color: var(--good); }
.log-delta .d-down { color: var(--bad); }
.log-flash-cash { animation: flashGold 0.6s ease; }
@keyframes flashGold { 0% { background: rgba(216,180,92,0.25);} 100% { background: transparent; } }

/* ---- 行動パネル ---- */
.actionpane {
  background: var(--bg2); border-top: 1px solid var(--line);
  padding: 0.6rem 0.7rem calc(0.7rem + env(safe-area-inset-bottom));
}
.action-hint { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.72rem; color: var(--text-dim); margin-bottom: 0.4rem; }
.kbd-hint { display: none; }
.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-bottom: 0.6rem; }
.action-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.55rem 0.2rem; color: var(--text);
  min-height: 4.6rem;
  cursor: pointer;
}
.action-btn .action-num {
  position: absolute; top: 3px; left: 6px; font-size: 0.62rem; color: var(--text-dim);
}
.action-btn.selected { border-color: var(--gold); background: #2a2412; box-shadow: 0 0 0 2px rgba(216,180,92,0.35) inset; }
.action-btn .action-name { font-size: 0.74rem; }
.action-btn:disabled { opacity: 0.35; cursor: default; }
.btn-confirm { width: 100%; }

/* 行動アイコン（画像なし・CSS図形のみ） */
.action-icon { width: 26px; height: 26px; position: relative; }
.act-work { background: linear-gradient(135deg, #7fa3d1, #4a6a9a); border-radius: 4px; }
.act-study { background: var(--int); clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%); }
.act-exercise { background: var(--hp); border-radius: 50%; }
.act-exercise::after { content:""; position:absolute; inset:6px; border:2px solid rgba(255,255,255,0.6); border-radius:50%; }
.act-meet { background: var(--cha); border-radius: 50% 50% 50% 4px; }
.act-invest { background: linear-gradient(45deg, var(--good), #2e7a52); clip-path: polygon(0 100%, 20% 60%, 40% 80%, 65% 30%, 85% 45%, 100% 0%, 100% 100%); }
.act-rest { background: var(--sp); border-radius: 50% 50% 0 0 / 60% 60% 0 0; }
.act-bet { background: var(--purple); transform: rotate(45deg); border-radius: 4px; }
.act-family { background: var(--gold); border-radius: 50% 50% 6px 6px; }

/* ---- サイドパネル（人生・実績・図鑑・記録タブ） ---- */
.sidepane { background: var(--bg2); overflow: hidden; }
.sidepane-tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab-btn { flex: 1; padding: 0.7rem 0.3rem; background: none; border: none; color: var(--text-dim); font-size: 0.82rem; cursor: pointer; border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.sidepane-body { overflow-y: auto; padding: 0.8rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.career-block { margin-bottom: 1.1rem; }
.career-block h3 { font-size: 0.85rem; color: var(--gold); margin-bottom: 0.4rem; }
.career-line { font-size: 0.8rem; color: var(--text-dim); line-height: 1.7; }
.career-line b { color: var(--text); }

.list-grid { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
.list-item {
  display: flex; gap: 0.6rem; align-items: flex-start;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
}
.list-item.locked { opacity: 0.4; }
.list-item .li-mark { flex-shrink: 0; width: 1.3em; text-align: center; }
.list-item.done .li-mark { color: var(--good); }
.list-item .li-name { font-weight: 700; display: block; }
.list-item .li-desc { color: var(--text-dim); }
.progress-line { font-size: 0.74rem; color: var(--text-dim); margin: 0.6rem 0; }

/* ============ モーダル共通 ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,7,11,0.78);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50; padding: 0;
  backdrop-filter: blur(3px);
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 1.4rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px;
  max-height: 86vh; overflow-y: auto;
  animation: modalUp 0.22s ease;
}
@keyframes modalUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-box h3 { color: var(--gold); font-size: 1rem; margin-bottom: 0.8rem; }
.modal-row { margin-bottom: 1rem; }
.modal-row label { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 0.4rem; }
.modal-row input[type="range"] { width: 100%; }
.modal-row input[type="number"] { width: 100%; padding: 0.5em; border-radius: 8px; border: 1px solid var(--line); background: var(--bg3); color: var(--text); }
.modal-choice-group { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.6rem 0 1rem; }
.modal-choice-btn {
  text-align: left; background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 0.7rem 0.9rem; font-size: 0.88rem; cursor: pointer;
}
.modal-choice-btn:hover, .modal-choice-btn:focus { border-color: var(--gold); }
.modal-target-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.7rem; }
.modal-target-tabs button {
  flex: 1; padding: 0.5em; border-radius: 8px; border: 1px solid var(--line); background: var(--bg3); color: var(--text-dim); cursor: pointer;
}
.modal-target-tabs button.active { border-color: var(--gold); color: var(--gold); }
.modal-buttons { display: flex; gap: 0.6rem; justify-content: flex-end; }
.modal-quick { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }
.modal-quick button { background: var(--bg3); border: 1px solid var(--line); color: var(--text-dim); border-radius: 999px; padding: 0.3em 0.8em; font-size: 0.76rem; cursor: pointer; }

.choice-box .choice-flavor { font-size: 0.88rem; color: var(--text-dim); line-height: 1.7; margin-bottom: 1rem; }
.choice-box .choice-title { color: var(--gold); font-weight: 700; margin-bottom: 0.4rem; }

.menu-box ul { padding-left: 1.2rem; margin: 0.4rem 0 1rem; font-size: 0.85rem; color: var(--text-dim); line-height: 1.8; }
.menu-box .menu-section { margin-bottom: 1rem; }
.menu-box h4 { color: var(--gold); font-size: 0.88rem; margin-bottom: 0.3rem; }

/* ============ トースト ============ */
.toast-layer {
  position: fixed; top: env(safe-area-inset-top); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding-top: 0.6rem; z-index: 80; pointer-events: none;
}
.toast {
  background: linear-gradient(135deg, #2a2412, #1c1a10);
  border: 1px solid var(--gold-dim); color: var(--gold);
  padding: 0.55rem 1.1rem; border-radius: 999px; font-size: 0.8rem;
  box-shadow: var(--shadow);
  animation: toastPop 3.2s ease forwards;
}
@keyframes toastPop {
  0% { transform: translateY(-10px); opacity: 0; }
  10% { transform: translateY(0); opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============ エンディング画面 ============ */
.ending-screen {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: #06070b; padding: 1.5rem;
  overflow-y: auto;
}
.ending-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.ending-flash.play { animation: endFlash 0.9s ease; }
@keyframes endFlash { 0% { opacity: 0.9; } 100% { opacity: 0; } }
.ending-card {
  position: relative; max-width: 560px; width: 100%; text-align: center;
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.2rem 1.6rem; animation: modalUp 0.4s ease;
}
.ending-label { font-size: 0.8rem; color: var(--text-dim); letter-spacing: 0.2em; margin-bottom: 0.6rem; }
.ending-name {
  font-size: 2rem; margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--gold), #fff2c8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ending-text { font-size: 0.92rem; line-height: 1.9; color: var(--text-dim); margin-bottom: 1.4rem; }
.ending-stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 0.5rem; margin-bottom: 1.2rem; text-align: left; }
.ending-stats div { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.7rem; font-size: 0.78rem; }
.ending-stats div b { display: block; color: var(--gold); font-size: 0.95rem; }
.ending-newAch { margin-bottom: 1.2rem; font-size: 0.8rem; color: var(--good); }
.ending-buttons { display: flex; flex-direction: column; gap: 0.6rem; }

/* ============ 破滅演出（画面暗転） ============ */
.doom-overlay {
  position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 70;
}
.doom-overlay.play { animation: doomFlash 1.1s ease; }
@keyframes doomFlash { 0% { opacity: 0; } 30% { opacity: 0.85; } 100% { opacity: 0; } }

/* ============ タブレット 768px〜 : 2カラム ============ */
@media (min-width: 768px) {
  .game-screen {
    display: grid;
    height: 100vh;
    height: 100dvh;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "stat stat"
      "log side"
      "action action";
    overflow: hidden;
  }
  .statbar { position: static; grid-area: stat; }
  .logpane { grid-area: log; max-height: none; overflow-y: auto; }
  .actionpane { grid-area: action; }
  .sidepane {
    display: flex; flex-direction: column; grid-area: side;
    border-left: 1px solid var(--line); border-top: none;
  }
  .sidepane-body { flex: 1; }
  .action-grid { grid-template-columns: repeat(8, 1fr); }
  .statbar-bars { grid-template-columns: repeat(5, minmax(0,1fr)); max-width: 620px; margin: 0 auto; }
  .statbar-row2 { justify-content: center; }
}

/* ============ PC 1024px〜 : 3カラム・キーボード操作 ============ */
@media (min-width: 1024px) {
  .game-screen {
    display: grid;
    grid-template-columns: 300px 1fr 340px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "stat stat stat"
      "charpane log side";
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .sidepane { grid-area: side; }
  .logpane { grid-area: log; }
  .statbar { display: flex; align-items: center; gap: 1.5rem; padding: 0.7rem 1.4rem; }
  .statbar-row1, .statbar-row2, .statbar-bars { margin: 0; }
  .statbar-row1 { gap: 1rem; }
  .actionpane {
    grid-area: charpane;
    border-top: none; border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
  }
  .action-grid { grid-template-columns: repeat(2, 1fr); flex: 1; align-content: start; }
  .kbd-hint { display: block; margin-top: 0.2rem; }
  .action-hint { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
  .logpane { padding: 1.2rem; }
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 18px; }
}

/* ============ アニメーション：数値のカウントアップ演出用ハイライト ============ */
.stat-value.pulse-up { animation: pulseUp 0.5s ease; }
.stat-value.pulse-down { animation: pulseDown 0.5s ease; }
@keyframes pulseUp { 0% { color: var(--good); transform: scale(1.25);} 100% { transform: scale(1);} }
@keyframes pulseDown { 0% { color: var(--bad); transform: scale(1.25);} 100% { transform: scale(1);} }

/* ============ アクセシビリティ：フォーカス ============ */
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ============ スクロールバー（控えめ） ============ */
* { scrollbar-color: #3a4256 var(--bg2); scrollbar-width: thin; }
