:root {
  --bg: #f5f4ee;
  --panel: #fffefa;
  --panel-2: #eef5ed;
  --line: #e3e2d8;
  --ink: #20231f;
  --ink-dim: #657067;
  --accent: #32965a;
  --accent-2: #237b48;
  --accent-ink: #1d7946;
  --pink: #df8d97;
  --btn-grad: linear-gradient(90deg, #188047, #1a7a43);
  --good: #2c9656;
  --warn: #e0556e;
  --gold: #e0a93b;
  --radius: 20px;
  --shadow: 0 8px 28px rgba(49, 65, 49, 0.08), 0 1px 3px rgba(49, 65, 49, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  background:
    radial-gradient(900px 520px at 72% -10%, rgba(255, 250, 226, 0.9), transparent 68%),
    radial-gradient(700px 440px at 8% 12%, rgba(214, 232, 211, 0.45), transparent 68%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 0;
  width: calc(100% - 40px);
  max-width: 1540px;
  min-height: calc(100vh - 40px);
  margin: 20px auto 42px;
  overflow: hidden;
  background: rgba(255, 254, 250, 0.88);
  border: 1px solid rgba(213, 214, 204, 0.9);
  border-radius: 28px;
  box-shadow: 0 18px 60px rgba(50, 59, 48, 0.12);
  backdrop-filter: blur(14px);
  align-items: start;
}

/* ===== 入力パネル ===== */
.panel.inputs {
  background: linear-gradient(180deg, #fffefa 0%, #f7faf4 100%);
  border-radius: 0;
  padding: 22px 18px 28px;
  box-shadow: none;
  border-right: 1px solid var(--line);
  position: relative;
  height: auto;
  max-height: none;
  overflow: visible;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 2px 0 21px;
  border-bottom: 1px solid var(--line);
}
.sidebar-brand > div { flex: 1; min-width: 0; text-align: center; }
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 15px 15px 19px 19px;
  background: linear-gradient(145deg, #e4f2e2, #cfe5cf);
  box-shadow: inset 0 0 0 1px rgba(35, 123, 72, 0.12);
  overflow: hidden;
}
.brand-mark img { width: 40px; height: 40px; display: block; }
.brand-name { margin: 0; font-size: 23px; font-weight: 900; letter-spacing: 0.005em; white-space: nowrap; }
.brand-note { margin: 5px 0 0; color: var(--ink-dim); font-size: 13px; letter-spacing: 0.02em; }
.sidebar-heading {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 8px;
  padding: 14px 14px 10px;
}
.sidebar-heading-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e3eee2;
  color: var(--accent-ink);
  margin-top: 0;
  flex: 0 0 auto;
}
.sidebar-heading-icon svg { width: 19px; height: 19px; fill: currentColor; }
.panel.inputs h2 { margin: 0; font-size: 18px; }
.sidebar-heading p { margin: 4px 0 0; color: var(--ink-dim); font-size: 12px; line-height: 1.55; }

fieldset {
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  margin: 10px 0 0;
  background: rgba(232, 241, 230, 0.62);
}
legend { padding: 0; color: var(--accent-ink); font-size: 14px; font-weight: 800; }

.field { margin: 13px 0; }
.field label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #3f4942;
  margin-bottom: 8px;
}
.field output { color: var(--ink); font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }

.field.highlight {
  background: rgba(232, 241, 230, 0.72);
  border-radius: 14px;
  padding: 13px 14px;
  margin: 5px 0 10px;
}
.badge {
  font-size: 12px;
  background: var(--accent-2);
  color: #fff;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
}
.hint { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: var(--ink-dim); }
.pension-actual {
  margin: 8px 0 0;
  padding: 8px 11px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-dim);
}
.pension-actual b {
  color: var(--accent-ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.pension-actual .pa-note { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-dim); }

/* select は OS 標準のグラデを消し、単色＋自前の矢印で見やすく */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235b6b60' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px !important;   /* 矢印ぶんの余白 */
  color: var(--ink);
  cursor: pointer;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
/* ドロップダウンの選択肢自体（OSにより効く範囲は異なる） */
select option { background: var(--panel); color: var(--ink); }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-2);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
input[type="range"]::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent-2); cursor: pointer;
}

.total { margin: 10px 0 0; font-size: 13px; color: var(--ink-dim); }
.total strong { color: var(--gold); font-size: 18px; }

.btn-reset {
  margin-top: 18px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.btn-reset:hover { background: var(--line); }

/* ===== ダッシュボード ===== */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 26px 26px 38px;
  background:
    radial-gradient(700px 300px at 35% 0%, rgba(255, 250, 225, 0.68), transparent 75%),
    #fbfaf5;
}

.dashboard-intro {
  min-height: 138px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: visible;
  padding: 6px 410px 4px 6px;
}
.intro-copy { position: relative; z-index: 2; }
.eyebrow {
  margin: 0 0 8px;
  color: #839187;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
}
.dashboard-intro h1 {
  margin: 0;
  font-size: clamp(24px, 2.25vw, 36px);
  line-height: 1.28;
  letter-spacing: 0.01em;
}
.dashboard-intro h1 strong { color: var(--accent); }
.intro-break { display: none; }
.dashboard-intro p:last-child { margin: 9px 0 0; color: var(--ink-dim); font-size: 14px; }
.intro-illustration {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: -18px;
  width: 420px;
  max-height: 230px;
  object-fit: contain;
  object-position: center bottom;
}

.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 124px;
  padding: 24px 42% 24px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(221, 219, 207, 0.9);
  transition: border-color 0.4s, background 0.4s;
  color: var(--ink);
  background: var(--panel);
  position: relative;
  overflow: hidden;
}
.hero.good { background: #fdf9ee; }
.hero.warn { background: #fdf9ee; border-color: #ecd0d0; }
.hero-icon {
  flex: 0 0 auto;
  font-size: 31px;
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #43af70, #219354);
  box-shadow: 0 8px 18px rgba(42, 151, 87, 0.22);
}
.hero.warn .hero-icon { background: linear-gradient(145deg, #ef7d85, #d94f62); }
.hero-text { position: relative; z-index: 2; }
.hero-headline { margin: 0; font-size: clamp(19px, 1.7vw, 27px); font-weight: 900; }
.hero-detail { margin: 7px 0 0; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }
.hero-landscape {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  width: 48%;
  height: 100%;
  object-fit: cover;
  object-position: 64% 64%;
  opacity: 0.98;
}

.metrics-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(210px, 1fr); gap: 14px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card {
  background: var(--panel);
  border-radius: 14px;
  min-height: 130px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(226, 224, 214, 0.9);
  position: relative;
  overflow: hidden;
}
.card-label { font-size: 14px; color: var(--ink-dim); }
.card-figure { margin-top: 9px; line-height: 1; position: relative; z-index: 2; }
.card-value {
  font-size: clamp(26px, 2.2vw, 38px); font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.card-value.neg { color: var(--warn); }
.card-unit { font-size: 13px; color: var(--ink-dim); }
.card-sub { margin-top: 4px; font-size: 13px; color: var(--accent-ink); font-weight: 700; }
.card-sub:empty { display: none; }
.card-art {
  position: absolute;
  right: 10px;
  bottom: 5px;
  width: 70px;
  height: 70px;
  object-fit: contain;
  object-position: center bottom;
  opacity: 0.96;
}
.card-art-pig { width: 76px; height: 70px; }
.card-art-chart { width: 70px; height: 68px; }
.card-art-plant { width: 62px; height: 82px; right: 14px; bottom: 1px; }

/* 安心度ゲージ */
.gauge-wrap {
  background: var(--panel);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 224, 214, 0.9);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
}
.gauge-label { font-size: 14px; color: var(--ink); font-weight: 700; white-space: nowrap; }
.gauge {
  height: 14px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--warn), var(--gold), var(--good));
  transition: width 0.6s cubic-bezier(.22,1,.36,1);
}
.gauge-value {
  min-height: 42px;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 5px;
  padding: 1px 1px 0;
}
.gauge-score { font-size: 32px; font-weight: 900; text-align: right; line-height: 1; }
.gauge-max { color: var(--ink-dim); font-size: 11px; white-space: nowrap; }

.chart-box {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 224, 214, 0.9);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.chart-box h3 { margin: 0 0 10px; font-size: 17px; }
.chart-box h3 small { color: var(--ink-dim); font-size: 12px; font-weight: 500; }
.chart-box canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  max-height: 280px;
}
.section-kicker {
  display: block;
  margin-bottom: 5px;
  color: #87948a;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

/* 年表 */
.year-table {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 4px 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 224, 214, 0.9);
}
.year-table summary {
  cursor: pointer;
  padding: 18px 0;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  list-style: none;
}
.year-table summary::-webkit-details-marker { display: none; }
.year-table summary span { display: flex; flex-direction: column; gap: 4px; }
.year-table summary small { color: #87948a; font-size: 9px; letter-spacing: 0.16em; }
.year-table summary b {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent-ink);
  font-size: 11px;
}
.year-table[open] summary b { background: var(--accent-2); color: #fff; }
.table-scroll { max-height: 360px; overflow: auto; }
#year-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
#year-table th, #year-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); }
#year-table th { position: sticky; top: 0; background: var(--panel); color: var(--ink-dim); }
#year-table tr.neg td { color: var(--warn); }
#year-table tr.pension-start td { background: rgba(46,158,87,0.12); }

/* 投稿ボックス */
.post-box {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(120deg, rgba(46,158,87,0.12), rgba(124,196,127,0.10));
  border: 1px solid var(--line);
}
.post-box h3 { margin: 0 0 4px; font-size: 16px; }
.post-box .hint { font-size: 13px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; }
#pen-name {
  width: 100%; margin: 10px 0; padding: 9px 11px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.btn-post {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  background: var(--btn-grad);
  color: #fff; font-weight: 800; font-size: 15px; cursor: pointer;
}
.btn-post:hover { filter: brightness(1.08); }
.btn-post:disabled { opacity: 0.5; cursor: default; }
.post-msg { margin: 8px 0 0; font-size: 12px; min-height: 16px; }
.post-msg.ok { color: var(--good); }
.post-msg.ng { color: var(--warn); }

/* みんなのギャラリー */
.gallery {
  width: calc(100% - 40px);
  max-width: 1500px;
  margin: 20px auto 0;
  padding: 28px;
  background: rgba(255, 254, 250, 0.88);
  border: 1px solid rgba(213, 214, 204, 0.9);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.gallery-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.gallery-head h2 { margin: 0; font-size: 23px; }
.sorts { display: flex; gap: 8px; }
.sort-btn {
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim);
}
.sort-btn.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }

.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.muted { color: var(--ink-dim); }
.plan-card {
  background: var(--panel); border-radius: 18px; padding: 18px;
  box-shadow: 0 5px 18px rgba(49, 65, 49, 0.07); border: 1px solid var(--line);
  border-top: 4px solid var(--good);
  position: relative; transition: transform 0.15s;
}
.plan-card:hover { transform: translateY(-3px); }
.plan-card.depleted { border-top-color: var(--warn); }
.plan-card.mine::after {
  content: "あなた"; position: absolute; top: 12px; right: 12px;
  font-size: 10px; background: var(--accent-2); color: #fff;
  padding: 2px 8px; border-radius: 999px;
}
.plan-name { font-weight: 800; font-size: 16px; margin: 0 0 8px; }
.plan-verdict { font-size: 14px; font-weight: 700; margin: 0 0 10px; }
.plan-verdict.good { color: var(--good); }
.plan-verdict.warn { color: var(--warn); }
.plan-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; }
.plan-stats span { color: var(--ink-dim); }
.plan-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.plan-actions { margin-top: 12px; display: flex; gap: 8px; }
.plan-actions button {
  flex: 1; padding: 7px; border-radius: 8px; cursor: pointer; font-size: 12px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}
.plan-actions .del { color: var(--warn); border-color: #5a2330; }

/* Before/After ゴースト案内 */
.ghost-note { margin: 0 0 8px; font-size: 12px; color: var(--gold); min-height: 0; max-height: 0; overflow: hidden; transition: max-height 0.3s; }
.ghost-note.show { max-height: 30px; }

/* みんなとの相対位置 */
.relative-box { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; color: var(--ink-dim); padding: 0 4px; }
.relative-box:empty { display: none; }
.relative-box b { color: var(--accent-ink); }

/* イベント */
.events-box .event-presets, .events-box .event-list { display: flex; flex-direction: column; gap: 6px; }
.event-presets { flex-direction: row !important; flex-wrap: wrap; margin: 8px 0; }
.event-presets button {
  padding: 7px 11px; border-radius: 999px; cursor: pointer; font-size: 11px;
  border: 1px solid #b9d6bd; background: #f8fbf5; color: var(--accent-ink);
}
.event-presets button:hover { background: #e1efdf; }
.event-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  background: rgba(255,255,255,0.72); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 12px;
}
.event-row .ev-meta { color: var(--ink-dim); font-size: 11px; }
.event-row button { border: none; background: none; color: var(--warn); cursor: pointer; font-size: 16px; line-height: 1; }
.small { font-size: 11px; }

/* 暴落 */
.crash-toggle-label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; margin: 6px 0; }
.crash-controls { display: flex; gap: 8px; margin: 6px 0; }
.crash-controls select {
  flex: 1; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
  background-color: var(--bg); color: var(--ink); font-size: 12px;
}
.crash-controls select:disabled { opacity: 0.45; }

/* 年表のイベント/暴落ハイライト */
#year-table tr.has-event td { background: rgba(251,191,36,0.10); }
#year-table tr.crashed td { background: rgba(251,113,133,0.16); }

/* 投稿フォームの属性 */
.attr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.attr-grid select {
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background-color: var(--bg); color: var(--ink); font-size: 14px; width: 100%;
}
#post-pass {
  width: 100%; margin: 4px 0 14px; padding: 10px 12px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-size: 14px;
}

/* プランカードの属性チップ */
.plan-attrs { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 8px; }
.plan-attrs .chip {
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
  background: rgba(46,158,87,0.14); color: var(--ink); border: 1px solid var(--line);
}
.plan-actions .edit { color: var(--accent-ink); border-color: var(--accent-ink); }

/* 同類比較フィルタ（トレンド） */
.trends-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.trends-head h2 { margin: 0; }
.cohort-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cohort-label { font-size: 12px; color: var(--ink-dim); }
.cohort-filter select {
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
  background-color: var(--panel); color: var(--ink); font-size: 13px;
}
.cohort-filter .co-mine {
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 700;
  border: 1px solid var(--accent-2); background: rgba(46,158,87,0.12); color: var(--ink);
}
.cohort-filter .co-mine:hover { background: var(--accent-2); }
.cohort-filter .co-clear {
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-dim);
}
.cohort-note { margin: 0 0 12px; font-size: 13px; color: var(--gold); min-height: 16px; }
.cohort-note:empty { display: none; }

/* 子への贈与 */
.gift-controls { margin: 6px 0; }
.gift-controls .field { margin: 8px 0; }
.gift-range { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.gift-range select {
  flex: 1; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
  background-color: var(--bg); color: var(--ink); font-size: 13px;
}
.gift-range select:disabled { opacity: 0.45; }

/* 60歳時点のローン */
.loan-controls { margin: 6px 0; }
.loan-controls .field { margin: 8px 0; }
.loan-controls .field input:disabled { opacity: 0.45; }
.loan-payment {
  margin: 10px 0 0;
  padding: 8px 11px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-dim);
}
.loan-payment b { color: var(--accent-ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.gift-range span { color: var(--ink-dim); font-size: 14px; }

/* チャート見出し（バンドトグル付き） */
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chart-head h3 { margin: 0; }
.band-toggle { font-size: 13px; color: var(--ink-dim); display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* 逆算ゴールシーク */
.goalseek {
  min-height: 245px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  background: linear-gradient(120deg, #fffefa 0%, #f4f8ed 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.gs-content { position: relative; z-index: 2; }
.gs-head { margin-bottom: 15px; }
.gs-title { display: block; font-size: 20px; font-weight: 900; }
.gs-sub { display: block; font-size: 13px; color: var(--ink-dim); margin-top: 4px; }
.gs-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; align-items: center;
}
.gs-row { display: grid; grid-template-columns: 82px 1fr; gap: 8px; align-items: center; margin: 4px 0; }
.gs-row > label { font-size: 13px; color: var(--ink-dim); }
.gs-row select {
  padding: 6px 9px; border-radius: 9px; border: 1px solid var(--line);
  background-color: var(--bg); color: var(--ink); font-size: 14px; width: 100%;
}
.gs-age { display: flex; align-items: center; gap: 8px; }
.gs-age input[type="range"] { flex: 1; }
.gs-age output { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.gs-run {
  width: 100%; margin-top: 14px; padding: 11px; border: none; border-radius: 999px;
  background: var(--btn-grad);
  color: #fff; font-weight: 800; font-size: 14px; cursor: pointer;
}
.gs-run:hover { filter: brightness(1.08); }
.gs-result { margin-top: 12px; font-size: 14px; }
.gs-result:empty { display: none; }
.gs-ok { margin: 0; color: var(--ink); line-height: 1.6; }
.gs-ok b { color: var(--gold); font-size: 18px; }
.gs-ng { color: var(--warn); font-size: 13px; line-height: 1.6; }
.gs-apply { margin-top: 10px; }
.gs-apply button {
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 700;
  border: 1px solid var(--accent); background: rgba(124,196,127,0.16); color: var(--ink);
}
.gs-apply button:hover { background: var(--accent-ink); color: #fff; }
.gs-apply:empty { display: none; }
.gs-illustration {
  position: absolute;
  z-index: 1;
  right: -25px;
  bottom: -56px;
  width: 355px;
  height: 300px;
  object-fit: contain;
  object-position: center bottom;
}

.planning-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.25fr) minmax(260px, 0.85fr);
  gap: 16px;
  align-items: stretch;
}
.chart-box-main { min-width: 0; }
.chart-box-main canvas { max-height: 315px; }
.event-card {
  min-width: 0;
  margin: 0;
  padding: 20px;
  border-radius: var(--radius);
  background: linear-gradient(165deg, #fffefa 0%, #eef5e9 100%);
  border: 1px solid rgba(226, 224, 214, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.event-heading { margin: 0 0 4px; }
.event-heading span {
  display: block;
  margin-bottom: 5px;
  color: #87948a;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
}
.event-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
}
.event-lead { margin: 0; color: var(--ink-dim); font-size: 13px; line-height: 1.65; }
.event-illustration {
  display: block;
  width: calc(100% + 10px);
  height: 128px;
  margin: 3px -5px -2px;
  object-fit: contain;
}
.event-card .event-presets { margin-top: 10px; }
.event-card .event-list:empty { display: none; }
.details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.flow-card canvas { max-height: 260px; }

/* トレンド */
.trends {
  width: calc(100% - 40px);
  max-width: 1500px;
  margin: 20px auto 0;
  padding: 28px;
  background: rgba(255, 254, 250, 0.88);
  border: 1px solid rgba(213, 214, 204, 0.9);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.trends h2 { font-size: 23px; margin: 0 0 14px; }
.trend-summary { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.trend-stat {
  background: var(--panel); border-radius: 16px; padding: 16px 20px;
  border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; min-width: 120px;
}
.trend-num { font-size: 28px; font-weight: 800; color: var(--accent-ink); }
.trend-stat span:last-child { font-size: 11px; color: var(--ink-dim); }
.trend-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.trend-charts canvas { max-height: 220px; }

.foot { text-align: center; color: var(--ink-dim); font-size: 12px; padding: 26px 28px 32px; }

/* ===== 初回ウェルカム ===== */
body.welcome-open { overflow: hidden; }
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 45, 34, 0.46);
  backdrop-filter: blur(8px);
}
.welcome-overlay[hidden] { display: none; }
.welcome-card {
  width: min(940px, 100%);
  min-height: 530px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(330px, 0.95fr);
  overflow: hidden;
  background: #fffefa;
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 28px;
  box-shadow: 0 28px 90px rgba(20, 42, 27, 0.3);
  animation: welcome-in 0.45s cubic-bezier(.2,.75,.25,1);
}
.welcome-copy {
  z-index: 2;
  min-width: 0;
  padding: 50px 20px 40px 52px;
}
.welcome-kicker {
  margin: 0 0 12px;
  color: #859489;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
}
.welcome-card h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 45px);
  line-height: 1.3;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}
.welcome-card h2 strong { color: var(--accent); }
.welcome-lead {
  max-width: 480px;
  margin: 18px 0 24px;
  color: var(--ink-dim);
  font-size: 15px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.welcome-points {
  display: grid;
  gap: 11px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  font-size: 14px;
  font-weight: 700;
}
.welcome-points li { display: flex; align-items: center; gap: 11px; }
.welcome-points span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e5f1e3;
  color: var(--accent-ink);
  font-size: 11px;
}
.welcome-start {
  width: min(360px, 100%);
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--btn-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(26, 122, 67, 0.2);
}
.welcome-start:hover { filter: brightness(1.06); }
.welcome-start:focus-visible { outline: 3px solid rgba(46,158,87,0.3); outline-offset: 3px; }
.welcome-skip {
  width: min(360px, 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  color: var(--ink-dim);
  font-size: 12px;
  cursor: pointer;
}
.welcome-visual {
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: #fffefa;
}
.welcome-couple {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 500px;
  max-width: 125%;
  transform: translate(-50%, -50%);
}
@keyframes welcome-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== ゲームモード ===== */
.game-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.game-bar-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-toggle {
  padding: 9px 16px; border: none; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 800; white-space: nowrap;
  background: linear-gradient(90deg, var(--pink), var(--accent-2));
  color: #fff; box-shadow: 0 4px 14px rgba(46,158,87,0.30);
}
.game-toggle:hover { filter: brightness(1.08); }
.game-tip { font-size: 13px; color: var(--ink-dim); }
.game-timer { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; justify-content: flex-end; }
.game-clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; color: var(--accent-ink); white-space: nowrap; }
.game-clock small { font-size: 12px; color: var(--ink-dim); margin-left: 2px; }
.game-bar-track { flex: 1; max-width: 360px; height: 10px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.game-bar-fill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--good), var(--gold)); transition: width 0.9s linear; }
.game-timer.danger .game-clock { color: var(--warn); animation: pulse 0.8s ease-in-out infinite; }
.game-timer.danger .game-bar-fill { background: linear-gradient(90deg, var(--warn), var(--gold)); }
.game-quit {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-size: 12px; background: var(--panel-2); color: var(--ink-dim); white-space: nowrap;
}
.game-quit:hover { background: var(--line); color: var(--ink); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* プレイ中はヒーローに枠でゲーム中だと分かるように */
.dashboard.game-on .hero { outline: 2px dashed rgba(46,158,87,0.5); outline-offset: 3px; }

/* 失敗時の爆発: 画面シェイク＋赤フラッシュ */
.dashboard.boom { animation: shake 0.55s cubic-bezier(.36,.07,.19,.97); }
.dashboard.boom::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background: radial-gradient(circle at center, rgba(251,113,133,0.45), rgba(251,113,133,0));
  animation: flash 0.6s ease-out forwards;
}
@keyframes shake {
  10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); }
  30%,50%,70% { transform: translateX(-8px); } 40%,60% { transform: translateX(8px); }
}
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* 結果オーバーレイ */
.game-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(20,40,28,0.45);
  backdrop-filter: blur(3px);
}
.game-overlay[hidden] { display: none; }
.game-result {
  background: var(--panel); border-radius: 20px; padding: 32px 36px;
  text-align: center; max-width: 420px; width: 88%;
  box-shadow: 0 20px 60px rgba(20,60,35,0.25);
  animation: pop 0.35s cubic-bezier(.18,.89,.32,1.28);
}
.game-result.win { border: 2px solid var(--good); }
.game-result.lose { border: 2px solid var(--warn); }
.game-result-icon { font-size: 64px; line-height: 1; }
.game-result.win .game-result-icon { animation: bounce 0.6s ease; }
.game-result.lose .game-result-icon { animation: shake 0.55s; }
.game-result-title { margin: 12px 0 6px; font-size: 24px; font-weight: 800; }
.game-result.win .game-result-title { color: var(--good); }
.game-result.lose .game-result-title { color: var(--warn); }
.game-result-msg { margin: 0 0 20px; font-size: 14px; color: var(--ink-dim); line-height: 1.6; }
.game-result-btn {
  padding: 11px 28px; border: none; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 800; color: #fff;
  background: var(--btn-grad);
}
.game-result-btn:hover { filter: brightness(1.08); }
@keyframes pop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-16px); } 60% { transform: translateY(-6px); } }

/* 端末がアニメ削減希望なら抑制 */
@media (prefers-reduced-motion: reduce) {
  .dashboard.boom, .game-result, .game-result-icon, .game-timer.danger .game-clock, .welcome-card { animation: none; }
  .dashboard.boom::after { animation: none; opacity: 0; }
}

/* ===== レスポンシブ ===== */
@media (max-width: 1180px) {
  .goalseek { grid-template-columns: minmax(0, 1fr) 240px; }
  .gs-illustration { right: -45px; width: 300px; }
  .planning-grid { grid-template-columns: 1fr; }
  .event-card {
    display: grid;
    grid-template-columns: minmax(220px, 0.65fr) minmax(0, 1fr);
    column-gap: 18px;
  }
  .event-heading, .event-lead { grid-column: 1; }
  .event-illustration { grid-column: 1; grid-row: 3 / 5; height: 150px; }
  .event-card .event-presets, .event-card .event-list { grid-column: 2; }
  .details-grid { grid-template-columns: 1fr; }
}

/* タブレット以下: 1カラム化・横余白を詰める */
@media (max-width: 880px) {
  .welcome-card {
    min-height: 0;
    grid-template-columns: 1fr;
  }
  .welcome-copy { padding: 38px 38px 30px; }
  .welcome-visual { min-height: 250px; }
  .welcome-couple { top: 50%; width: 430px; }

  .trend-charts { grid-template-columns: 1fr; }
  .layout {
    grid-template-columns: 1fr;
    width: calc(100% - 24px);
    margin: 12px auto 28px;
    border-radius: 22px;
  }
  .panel.inputs {
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .dashboard { padding: 22px 20px 32px; }
  .dashboard-intro { min-height: 126px; padding-right: 315px; }
  .intro-illustration { width: 320px; max-height: 205px; }
  .metrics-row { grid-template-columns: 1fr; }
  .goalseek { grid-template-columns: 1fr; padding-right: 210px; }
  .gs-body { grid-template-columns: 1fr; }
  .gs-illustration { right: -54px; width: 270px; opacity: 0.9; }
  .gauge-wrap {
    display: grid;
    grid-template-columns: auto minmax(160px, 1fr) auto auto;
    align-items: center;
  }
  .gauge-value { min-height: 0; }
  .gallery, .trends { padding-left: 16px; padding-right: 16px; }
  .foot { padding-left: 16px; padding-right: 16px; }

  /* モバイル再配置（JS=initResponsiveLayout が DOM を移動し is-relocated を付与）。
     .layout 直下に来た .dashboard-intro と、.gallery 直前に来た .post-box の見栄えを整える。 */
  /* 最上部へ移動したイントロ。モバイルでは画面占有を抑えるためイラストは出さず、
     見出し＋一文だけのコンパクトな帯にする（イラスト分の下余白を作らない）。 */
  .dashboard-intro.is-relocated {
    margin: 0;
    border-radius: 0;                    /* layout 上端に密着 */
    overflow: hidden;
    padding: 16px 16px 14px;             /* 縦をぎゅっと圧縮 */
    min-height: 0;
  }
  .dashboard-intro.is-relocated .intro-illustration { display: none; }
  .post-box.is-relocated {
    margin: 24px 16px 4px;               /* gallery と同じ横余白に揃える */
  }
}

/* スマホ: 縦積み・文字とパディングを縮小・はみ出し対策 */
@media (max-width: 560px) {
  .welcome-overlay { align-items: start; padding: 12px; overflow-y: auto; }
  .welcome-card { width: 100%; max-width: calc(100vw - 24px); border-radius: 22px; }
  .welcome-copy { padding: 30px 22px 24px; }
  .welcome-card h2 { max-width: 310px; font-size: 30px; }
  .welcome-lead { max-width: 310px; margin: 14px 0 18px; font-size: 14px; }
  .welcome-points { margin-bottom: 22px; font-size: 13px; }
  .welcome-visual {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .welcome-couple {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    height: 210px;
    max-width: none;
    padding: 12px 12px 0;
    object-fit: contain;
    object-position: center;
    transform: none;
  }

  .layout { width: 100%; margin: 0; border: 0; border-radius: 0; }
  .panel.inputs {
    height: auto;
    max-height: min(68vh, 620px);
    padding: 16px;
    overflow-y: auto;
    box-shadow: 0 10px 26px rgba(44, 72, 48, 0.08);
  }
  .dashboard { padding: 20px 12px 28px; }
  .gallery, .trends { padding-left: 12px; padding-right: 12px; }

  /* 指標カードは1列 */
  .cards { grid-template-columns: 1fr; }
  .card-value { font-size: 26px; }

  .dashboard-intro {
    min-height: 220px;
    align-items: flex-start;
    padding: 4px 4px 115px;
  }
  .dashboard-intro h1 { font-size: 26px; }
  .intro-break { display: block; }
  .dashboard-intro p:last-child { line-height: 1.7; }
  .dashboard-intro p { max-width: 100%; overflow-wrap: anywhere; }
  .intro-illustration {
    right: 50%;
    bottom: -38px;
    width: 310px;
    transform: translateX(50%);
  }

  /* ヒーローはイラストを背景に残して縦方向へ圧縮 */
  .hero { min-height: 190px; align-items: flex-start; gap: 12px; padding: 18px 18px 90px; text-align: left; }
  .hero-icon { width: 52px; height: 52px; font-size: 34px; }
  .hero-headline { font-size: 19px; }
  .hero-landscape { width: 100%; height: 105px; object-position: 65% 68%; }

  /* 縦積みに戻す。align-items は 880px の center が残ると
     列フレックスでバー(.gauge)が幅0に潰れて見えなくなるので stretch へ戻す。 */
  .gauge-wrap { display: flex; flex-direction: column; align-items: stretch; }
  .gauge-value { width: 100%; justify-content: flex-start; }

  /* 逆算プランナーは1列に戻す */
  .goalseek { min-height: 450px; padding: 20px 18px 190px; }
  .gs-body { grid-template-columns: 1fr; }
  .gs-row { grid-template-columns: 72px 1fr; }
  .gs-illustration {
    right: 50%;
    bottom: -58px;
    width: 300px;
    height: 260px;
    transform: translateX(50%);
  }

  .event-card { display: block; }
  .event-illustration { height: 135px; }
  .chart-box { padding: 16px 14px; }
  .chart-head { align-items: flex-start; flex-wrap: wrap; gap: 8px 10px; }
  .chart-head > div { min-width: 0; }
  .band-toggle { width: 100%; white-space: normal; }

  .trends, .gallery {
    width: calc(100% - 24px);
    padding: 20px 16px;
    border-radius: 20px;
  }

  /* 年表は横スクロールで溢れさせる */
  .table-scroll { overflow-x: auto; }
  #year-table { min-width: 560px; }

  /* ギャラリーのカードは最小幅を下げて1〜2列 */
  .cards-grid { grid-template-columns: 1fr; }
  .gallery-head h2, .trends h2 { font-size: 18px; }

  /* トレンドの統計タイルは横スクロールせず折返し */
  .trend-stat { min-width: 0; flex: 1 1 calc(50% - 8px); padding: 12px; }
  .trend-num { font-size: 24px; }

  /* チャートの高さをやや抑える */
  .chart-box canvas { max-height: 240px; }
  .trend-charts canvas { max-height: 200px; }

  /* ゲームバーは縦積み */
  .game-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .game-timer { width: 100%; }
}
