/* 撃退シミュ。色・形はきんちゃんのアプリのデザインシステム（app/lib/core/theme/tokens.dart）と同じ値。
   字体は Zen Maru Gothic を自分のサイトから配る（外の字体配信に閲覧者の情報を送らない）。
   fonts/ はゲームの文字だけに絞った部分セット（tools/subset_fonts.py で作る）。無い字は端末の字体になる */
@font-face {
  font-family: "Zen Maru Gothic";
  src: url("fonts/zmg-500.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}
@font-face {
  font-family: "Zen Maru Gothic";
  src: url("fonts/zmg-700.woff2") format("woff2");
  font-weight: 600 900;
  font-display: swap;
}

:root {
  --pink-500: #ff2e78;
  --pink-400: #ff4d8d;
  --pink-300: #ff6fa3;
  --pink-200: #ff8fb4;
  --pink-100: #ffc2d8;
  --pink-050: #ffdcea;
  --bg-base: #ffffff;
  --bg-tint-1: #fff6fa;
  --bg-tint-2: #ffeaf3;
  --text-main: #3a2836;
  --text-sub: #c0adb7;
  --text-soft: rgba(58, 40, 54, .64);
  --gold-1: #ffc65a;
  --gold-2: #ff9a3d;
  --danger: #e5327a;
  --success: #8de05a;
  --info: #3a8dff;
  --border-hair: #f2dbe5;
  --grad-cta: linear-gradient(135deg, #ff6fa3, #ff2e78);
  --grad-soft: linear-gradient(180deg, #fff6fa, #fff);
  --shadow-card: 0 6px 16px rgba(255, 46, 120, .10);
  --shadow-float: 0 12px 30px rgba(255, 46, 120, .18);
  --shadow-cta: 0 10px 24px rgba(255, 46, 120, .28);
  --font: "Zen Maru Gothic", -apple-system, BlinkMacSystemFont, "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-tint-1);
  color: var(--text-main);
  font-family: var(--font);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.8;
  -webkit-text-size-adjust: 100%;
}
button, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: 100%; background: var(--bg-base); position: relative; }
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.is-active { display: flex; flex-direction: column; }

/* ---------- 始め ---------- */
.start { padding: 40px 20px 32px; text-align: center; background: var(--grad-soft); flex: 1; }
.start-kicker { margin: 0; color: var(--pink-500); font-weight: 700; letter-spacing: .1em; }
.start-title { margin: 4px 0 20px; font-size: 28px; line-height: 1.4; font-weight: 900; }
.start-phone { margin: 0 auto 24px; max-width: 320px; }
.notif {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--bg-base); border-radius: 18px; padding: 12px 16px;
  box-shadow: var(--shadow-float); text-align: left; animation: buzz .6s ease 1s 2;
}
.notif-from { font-weight: 700; font-size: 13px; }
.notif-body { color: var(--text-soft); font-size: 14px; }
@keyframes buzz { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.start-lead { margin: 0 0 12px; }
.start-rule { margin: 0 0 28px; font-size: 17px; }
.start-rule b { color: var(--pink-500); }
.fine { color: var(--text-soft); font-size: 12px; margin: 16px 0 0; }

.btn-cta {
  display: block; width: 100%; min-height: 52px; border: 0; border-radius: 30px;
  background: var(--grad-cta); color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: var(--shadow-cta);
}
.btn-cta:active { transform: translateY(1px); }
.btn-ghost {
  display: block; width: 100%; min-height: 48px; margin-top: 10px; border-radius: 30px;
  background: var(--bg-base); border: 1.5px solid var(--pink-100); color: var(--text-main); font-weight: 700;
}
.btn-text { border: 0; background: none; color: var(--pink-500); font-weight: 700; padding: 8px 4px; min-height: 44px; }

/* ---------- トーク ---------- */
.chat-head {
  position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg-base); border-bottom: 1px solid var(--border-hair);
}
.chat-name { font-weight: 700; font-size: 17px; }
.chat-clock { color: var(--text-soft); font-variant-numeric: tabular-nums; }

.gauges {
  position: sticky; top: 52px; z-index: 3; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 8px 12px; background: var(--bg-tint-1); border-bottom: 1px solid var(--border-hair);
}
.gauge { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; }
.gauge-label { font-size: 12px; font-weight: 700; }
.gauge-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; height: 8px; }
.gauge-bar i { border-radius: 4px; background: var(--pink-050); transition: background .3s; }
/* 帯の色は予報のセマンティックカラー（DS §6-2）: 良い = success・ふつう = pink・悪い = danger。金は夢専用なので使わない */
.gauge .gauge-bar i.on { background: var(--pink-300); }
.gauge.is-good .gauge-bar i.on { background: var(--success); }
.gauge.is-low .gauge-bar i.on { background: var(--danger); }
.gauge-word { grid-column: 1 / -1; font-size: 12px; color: var(--text-soft); line-height: 1.4; }
.gauge.bump { animation: bump .4s ease; }
@keyframes bump { 50% { transform: scale(1.04); } }

.talk { flex: 1; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.stamp { align-self: center; font-size: 12px; color: var(--text-soft); background: var(--bg-tint-1); border-radius: 30px; padding: 2px 12px; }
.row { display: flex; align-items: flex-end; gap: 6px; animation: rise .22s ease both; }
.row.them { justify-content: flex-start; }
.row.me { justify-content: flex-end; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.meta { font-size: 11px; color: var(--text-sub); line-height: 1.3; white-space: nowrap; }
.row.me .meta { text-align: right; }

.bubble { margin: 0; max-width: 78%; padding: 9px 14px; border-radius: 18px; overflow-wrap: anywhere; line-height: 1.6; }
.bubble.them { background: var(--bg-tint-2); border-top-left-radius: 6px; }
.bubble.me { background: var(--pink-500); color: #fff; border-top-right-radius: 6px; }
.bubble.kin { background: var(--bg-base); border: 1.5px solid var(--pink-100); }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--pink-200); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { opacity: .3; transform: translateY(-2px); } }
.chip { align-self: flex-end; font-size: 11px; color: var(--text-soft); background: var(--bg-tint-1); border-radius: 8px; padding: 1px 8px; margin-top: -4px; }
.sys { align-self: center; text-align: center; font-size: 13px; color: var(--text-soft); max-width: 90%; }

.dock { position: sticky; bottom: 0; z-index: 3; background: var(--bg-base); border-top: 1px solid var(--border-hair); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  text-align: left; padding: 10px 14px; min-height: 44px; border-radius: 12px;
  background: var(--bg-base); border: 1.5px solid var(--pink-100); line-height: 1.55; font-size: 14px;
}
.choice:active { background: var(--pink-050); }
.dock.is-wait .choices, .dock.is-wait .free { opacity: .4; pointer-events: none; }
.dock-prompt { margin: 0 0 8px; font-weight: 700; text-align: center; }
.free { margin-top: 4px; text-align: center; }
.free-box { text-align: left; }
.free-note { margin: 0 0 6px; font-size: 12px; color: var(--danger); }
.free-row { display: flex; gap: 8px; align-items: flex-end; }
.free-row textarea {
  flex: 1; resize: none; border-radius: 12px; border: 1.5px solid var(--pink-100); padding: 8px 12px; line-height: 1.5; background: var(--bg-tint-1);
}
.free-row textarea:focus { outline: 2px solid var(--pink-300); outline-offset: 0; }
.btn-send { border: 0; border-radius: 30px; background: var(--grad-cta); color: #fff; font-weight: 700; padding: 0 18px; min-height: 44px; }

/* ---------- 値が崩れた瞬間のきんちゃん（入口） ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(58, 40, 54, .35); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body {
  width: 100%; max-width: 480px; background: var(--bg-base); border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-float); animation: up .25s ease both;
  max-height: 92vh; overflow-y: auto;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.kin-row { display: flex; gap: 10px; align-items: flex-start; }
.kin-face { flex: 0 0 auto; }
.kin-say { background: var(--bg-tint-2); border-radius: 18px; padding: 8px 14px; line-height: 1.9; }
.kin-say p { margin: 0; }
.kin-name { font-size: 11px; color: var(--pink-500); font-weight: 700; }
.cue-sub { margin-top: 6px !important; font-size: 14px; color: var(--pink-500); font-weight: 700; }
.cue-go { margin-top: 16px; }

/* ---------- 結果 ---------- */
.result { padding: 28px 20px 40px; background: var(--grad-soft); flex: 1; }
.r-kicker { margin: 0; text-align: center; font-size: 13px; color: var(--text-soft); }
.r-name { margin: 0; text-align: center; font-size: 15px; color: var(--pink-500); font-weight: 700; }
.r-title { margin: 0 0 12px; text-align: center; font-size: 28px; line-height: 1.4; font-weight: 900; }
.r-kin { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.r-kin img { flex: 0 0 auto; }
.r-kin .kin-say { flex: 1; }
.r-kin.is-serious .kin-say { background: var(--danger); color: #fff; }
.r-kin.is-serious .kin-name { color: #fff; }
.r-last { margin: 0 0 16px; }
.card { background: var(--bg-base); border-radius: 18px; padding: 16px 20px; box-shadow: var(--shadow-card); margin-bottom: 16px; }
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card p { margin: 0; }
.sos { border: 2px solid var(--danger); }
.sos-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border-hair); }
.sos-line:last-of-type { border-bottom: 0; }
.sos-line b { font-size: 22px; }
.sos-line a { flex: 0 0 auto; color: #fff; background: var(--danger); border-radius: 30px; padding: 6px 16px; text-decoration: none; font-weight: 700; }
.sos-src { font-size: 12px; color: var(--text-soft); margin-top: 6px !important; }
.r-gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.r-gauges .gauge-word { font-size: 14px; color: var(--text-main); font-weight: 700; }
.stats { display: flex; justify-content: space-around; text-align: center; font-size: 12px; color: var(--text-soft); }
.stats b { display: block; font-size: 24px; color: var(--text-main); line-height: 1.3; }
.pick-head { margin: 16px 0 0; font-size: 15px; }
.free-note + .pick-head { margin-top: 12px; }
.card .free-note { margin-top: 10px; }
.picks { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pick { display: block; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--border-hair); background: var(--bg-base); }
.pick.is-on { border-color: var(--pink-500); background: var(--bg-tint-1); }
.pick-q { display: block; font-size: 12px; color: var(--text-soft); line-height: 1.5; }
.pick-a { display: block; font-size: 14px; line-height: 1.6; }
.pick-n { display: block; font-size: 12px; color: var(--pink-500); line-height: 1.5; margin-top: 2px; }
.card-preview { display: block; width: 100%; border-radius: 12px; box-shadow: var(--shadow-card); margin: 12px 0; background: var(--bg-tint-1); aspect-ratio: 4 / 5; }
.share-row { display: grid; gap: 8px; }
.btn-x { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 30px; background: var(--text-main); color: #fff; text-decoration: none; font-weight: 700; }
.door { text-align: center; }
.door p { margin-bottom: 12px; }
.door a.btn-cta { text-decoration: none; display: flex; align-items: center; justify-content: center; }
.door .site-link { display: inline-block; margin-top: 10px; color: var(--info); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 20;
  background: var(--text-main); color: #fff; padding: 8px 16px; border-radius: 30px; font-size: 13px; max-width: 90%;
}

/* ---------- 今夜の記録 ---------- */
.r-line { margin: -4px 0 18px; text-align: center; font-size: 15px; color: var(--text-soft); }
.note { margin: 0 0 10px !important; font-size: 12px; color: var(--text-soft); line-height: 1.6; }

/* 1通ずつのマス。左半分 = 売上・右半分 = 安全。色は予報のセマンティックカラー（DS §6-2） */
.map { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.sq { position: relative; display: flex; aspect-ratio: 1; border-radius: 6px; overflow: hidden; padding: 0; border: 0; background: none; gap: 2px; }
.sq .h { flex: 1; display: block; }
.sq.is-empty { border: 1.5px dashed var(--pink-100); }
.h.up { background: var(--success); }
.h.flat { background: var(--text-sub); }
.h.down { background: var(--danger); }
.map.is-big { gap: 6px; margin-bottom: 26px; }
.map.is-big .sq { overflow: visible; }
.map.is-big .sq .h:first-child { border-radius: 6px 0 0 6px; }
.map.is-big .sq .h:nth-child(2) { border-radius: 0 6px 6px 0; }
.map.is-big .sq.is-on { outline: 2px solid var(--text-main); outline-offset: 2px; border-radius: 6px; }
.sq-time { position: absolute; left: 50%; top: calc(100% + 4px); transform: translateX(-50%); font-size: 10px; color: var(--text-soft); line-height: 1; white-space: nowrap; }
.map.is-small { gap: 2px; }
.map.is-small .sq { border-radius: 3px; gap: 1px; }
.map.is-small .sq.is-empty { border-width: 1px; }
.map-detail { margin-top: 10px !important; font-size: 13px; line-height: 1.6; min-height: 2.6em; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-soft); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend .h { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

/* 2本の値の線（売上 = pink-500・安全 = info。2色は色覚の違いでも見分けられることを検査済み） */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border-hair); stroke-width: 1; }
.chart .axis { font-size: 10px; fill: var(--text-soft); }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.uri, .chart .dot.uri { stroke: var(--pink-500); }
.chart .ln.anzen, .chart .dot.anzen { stroke: var(--info); }
.chart .dot { fill: var(--bg-base); stroke-width: 2; }
.chart .saisoku { fill: var(--text-sub); stroke: var(--bg-base); stroke-width: 2; }
.chart .lab { font-size: 11px; font-weight: 700; fill: var(--text-main); }
.ln-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.ln-key.uri { background: var(--pink-500); }
.ln-key.anzen { background: var(--info); }
.ln-key.saisoku { width: 8px; height: 8px; border-radius: 50%; background: var(--text-sub); }

/* 同じ夜の5人 */
.peers { display: flex; flex-direction: column; gap: 8px; }
.peer { display: grid; grid-template-columns: 84px 1fr; grid-template-areas: "who map" "who end"; align-items: center; gap: 2px 8px; padding: 6px 8px; border-radius: 12px; }
.peer .peer-who { grid-area: who; }
.peer .map { grid-area: map; }
.peer.is-me { background: var(--bg-tint-1); border: 1.5px solid var(--pink-100); }
.peer-who { display: flex; flex-direction: column; line-height: 1.3; }
.peer-who b { font-size: 14px; }
.peer-who span { font-size: 10px; color: var(--text-soft); }
.peer-end { grid-area: end; font-size: 11px; font-weight: 700; line-height: 1.3; color: var(--text-soft); }
.peer.is-me .peer-end { color: var(--pink-500); }
.rank { margin-top: 10px !important; text-align: center; font-weight: 700; }
