/* 落ち着いた清潔な見た目。字体は端末に入っている物だけを使う（外から読み込まない） */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #5f6b76;
  --line: #e3e1da;
  --accent: #2e6b6e;
  --accent-ink: #ffffff;
  --accent-soft: #e4efee;
  --stat: #2e6b6e;
  --nostat: #8a7a5c;
  --nostat-soft: #f2ede2;
  --warn: #b0603a;
  --warn-soft: #e7b9a1;
  --help: #c9a227;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191d;
    --surface: #1e2429;
    --ink: #e8ebee;
    --muted: #9aa5ae;
    --line: #2d353c;
    --accent: #6fb3b5;
    --accent-ink: #10181a;
    --accent-soft: #233436;
    --stat: #6fb3b5;
    --nostat: #c9b48a;
    --nostat-soft: #2d2a22;
    --warn: #e09a74;
    --warn-soft: #6b4636;
    --help: #e0c25a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
.top, main, .foot { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 16px; padding-bottom: 6px; }
.brand { margin: 0; font-size: 12px; letter-spacing: .12em; color: var(--muted); }
.name { margin: 2px 0 0; font-size: 22px; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
body[data-screen="screen-play"] .top { display: none; }
body[data-screen="screen-end"] .stage { display: none; }
body[data-screen="screen-start"] .clock { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 10px 0;
}
.hidden { display: none !important; }
.small { font-size: 13px; color: var(--muted); }
h2 { font-size: 19px; margin: 0; line-height: 1.4; }
h3 { font-size: 16px; margin: 0 0 6px; }
h3.sec { font-size: 14px; margin: 0 0 8px; }
h3.sec small { font-weight: normal; color: var(--muted); font-size: 12px; margin-left: 6px; }

.big-number { font-size: 18px; font-weight: 600; margin: 0 0 8px; line-height: 1.5; }
.big-number em { font-style: normal; color: var(--accent); font-size: 32px; }
.credit-line { font-size: 11px; color: var(--muted); margin: 6px 0; line-height: 1.5; }

.actions { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
button, .button {
  font: inherit;
  font-size: 16px;
  border-radius: 12px;
  padding: 13px 16px;
  border: 1px solid var(--accent);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  width: 100%;
}
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary.big { font-size: 18px; padding: 16px; }
.secondary { background: transparent; color: var(--accent); }
button:active, .button:active { transform: translateY(1px); }
button:focus-visible, .button:focus-visible, select:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
select {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}

/* ---- 絵（季節で変わる空・2つの会社・5人） ---- */
.stage {
  position: relative; height: 168px; margin: 10px 0 0; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line);
  --sky1: #cfe6f2; --sky2: #f7eef0; --fallc: #f2b8c6; --sun: #ffd98a; --gnd: #b9d39a;
}
.stage .sky { position: absolute; inset: 0; background: linear-gradient(180deg, var(--sky1), var(--sky2)); }
.stage.season-summer { --sky1: #8fcbe8; --sky2: #e3f4f9; --fallc: transparent; --sun: #ffc94a; --gnd: #8fc27a; }
.stage.season-autumn { --sky1: #f2c9a0; --sky2: #f8eadb; --fallc: #d9793e; --sun: #ffb36b; --gnd: #c9b07a; }
.stage.season-winter { --sky1: #b9c7d6; --sky2: #eef2f6; --fallc: #ffffff; --sun: #f4f1e0; --gnd: #e8edf0; }
.stage.night { --sky1: #1d2740; --sky2: #3a4566; --sun: #f2efd0; --gnd: #3c4a3a; }
.stage.night .win { background: #ffe9a8; }
.sun { position: absolute; top: 16px; right: 22px; width: 34px; height: 34px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 18px var(--sun); }
.ground { position: absolute; left: 0; right: 0; bottom: 0; height: 34px; background: var(--gnd); }
.bld { position: absolute; bottom: 34px; display: grid; gap: 5px; padding: 8px; border-radius: 3px 3px 0 0; }
.bld-a { left: 8%; width: 30%; height: 92px; grid-template-columns: repeat(3, 1fr); background: #7d8f97; }
.bld-b { right: 8%; width: 24%; height: 70px; grid-template-columns: repeat(2, 1fr); background: #a2928a; }
.win { background: #dfe9ee; border-radius: 2px; transition: background .6s; }
.fall i {
  position: absolute; top: -10px; width: 7px; height: 7px; border-radius: 50% 0 50% 0; background: var(--fallc);
  animation: fall 6s linear infinite; opacity: .9;
}
.season-winter .fall i { border-radius: 50%; }
.fall i:nth-child(1) { left: 6%; animation-delay: 0s; }
.fall i:nth-child(2) { left: 16%; animation-delay: 2.2s; animation-duration: 7s; }
.fall i:nth-child(3) { left: 27%; animation-delay: 4.1s; }
.fall i:nth-child(4) { left: 38%; animation-delay: 1.3s; animation-duration: 5.4s; }
.fall i:nth-child(5) { left: 49%; animation-delay: 3.4s; }
.fall i:nth-child(6) { left: 58%; animation-delay: .7s; animation-duration: 6.6s; }
.fall i:nth-child(7) { left: 67%; animation-delay: 2.8s; }
.fall i:nth-child(8) { left: 76%; animation-delay: 5s; animation-duration: 5.8s; }
.fall i:nth-child(9) { left: 86%; animation-delay: 1.8s; }
.fall i:nth-child(10) { left: 94%; animation-delay: 3.9s; animation-duration: 7.4s; }
@keyframes fall {
  0% { transform: translate(0, 0) rotate(0); }
  100% { transform: translate(-24px, 190px) rotate(300deg); }
}
/* 人: 最初の会社の前（左）に並び、辞めたら次の会社の前（右）へ歩いて移る */
.fig {
  position: absolute; bottom: 22px; width: 20px; height: 38px;
  left: calc(9% + var(--slot, 0) * 24px);
  transition: left 1.4s ease-in-out;
  display: flex; flex-direction: column; align-items: center;
  animation: bob 1.6s ease-in-out infinite;
}
.fig.moved { left: calc(60% + var(--slot, 0) * 16px); }
.fig.me .tag { top: -14px; font-weight: 700; color: #2e6b6e; }
.fig .head { width: 12px; height: 12px; border-radius: 50%; background: #f1d3b8; border: 2px solid #4b5560; }
.fig .body { width: 16px; height: 16px; border-radius: 7px 7px 3px 3px; background: #6c7a86; margin-top: 1px; }
.fig.me .body { background: #2e6b6e; }
.fig.me .head { border-color: #2e6b6e; }
.fig .tag { position: absolute; top: 38px; font-size: 10px; line-height: 1; color: #2b333a; white-space: nowrap; }
.stage.night .fig .tag { color: #eef; }
.fig:nth-of-type(odd) { animation-delay: .4s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.clock {
  position: absolute; left: 10px; top: 10px; background: rgba(255,255,255,.86); color: #1f2933;
  border-radius: 10px; padding: 4px 10px; display: flex; flex-direction: column; line-height: 1.3;
}
#clock-main { font-weight: 700; font-size: 17px; }
#clock-sub { font-size: 11px; color: #5f6b76; }
@media (prefers-reduced-motion: reduce) {
  .fall i, .fig { animation: none; }
  .fig { transition: none; }
}

/* ---- 進みの画面 ---- */
.controls { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; flex-wrap: wrap; }
.controls button { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 999px; }
.pause { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.speeds { display: flex; gap: 4px; }
.speed { background: transparent; color: var(--accent); }
.speed.on { background: var(--accent-soft); font-weight: 700; }
.pause-note { font-size: 12px; color: var(--warn); font-weight: 600; }
.hud { padding: 10px 16px; }
.hud-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 2px 0; }
.hud-row .k { color: var(--muted); white-space: nowrap; }
.hud-row .k small { font-size: 11px; }
.hud-row .v { text-align: right; font-weight: 600; }
.hud-row .v.pay { font-variant-numeric: tabular-nums; font-size: 16px; }
.meter { display: inline-block; width: 140px; height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; vertical-align: middle; }
.meter span { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.meter span.low { background: var(--warn); }

/* 人生マス */
.lifegrid { display: flex; flex-direction: column; gap: 5px; }
.grid-row { display: flex; align-items: center; gap: 8px; }
.grid-label { font-size: 11px; color: var(--muted); width: 3.4em; flex: none; }
.grid-cells { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; flex: 1; }
.cell { aspect-ratio: 1; border-radius: 4px; background: var(--line); position: relative; }
.cell.lived.season-spring { background: #9cc9c1; }
.cell.lived.season-summer { background: #5fa9a2; }
.cell.lived.season-autumn { background: #c99a6a; }
.cell.lived.season-winter { background: #8ea4b5; }
.cell.now { outline: 2px solid var(--accent); outline-offset: 1px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.cell.mk-quit { background: var(--warn) !important; }
.cell.mk-help::after, .cell.mk-decide::after, .cell.mk-raise::after, .cell.mk-start::after {
  content: ""; position: absolute; inset: 30%; border-radius: 50%; background: #fff;
}
.cell.mk-help::after { background: var(--help); inset: 25%; }
.cell.mk-decide::after { border-radius: 1px; transform: rotate(45deg); }
.lanes-title { margin-top: 12px !important; }
.lanes { display: flex; flex-direction: column; gap: 4px; }
.lane { display: flex; align-items: center; gap: 8px; }
.lane-name { font-size: 11px; color: var(--muted); width: 3.4em; flex: none; }
.lane-cells { display: grid; grid-template-columns: repeat(36, 1fr); gap: 1px; flex: 1; }
.lc { height: 8px; background: var(--line); border-radius: 1px; }
.lc.lived { background: #8fb7b3; }
.lc.quit { background: var(--warn); }
.lc.moved { background: var(--warn-soft); }
.legend { font-size: 11px; color: var(--muted); margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; }
.lg.lived { background: #8fb7b3; } .lg.quit { background: var(--warn); } .lg.moved { background: var(--warn-soft); }
.lg.help { background: var(--help); border-radius: 50%; }

/* 知らせ */
.feed { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 5.6em 1fr auto; gap: 2px 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; animation: evin .5s ease-out; }
.ev:first-child { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }
@keyframes evin { from { transform: translateY(-6px); } to { transform: none; } }
.ev-when { font-size: 11px; color: var(--muted); padding-top: 2px; white-space: nowrap; }
.ev-peer .ev-text::before { content: "同期 "; font-size: 11px; font-weight: 700; color: var(--warn); }
.ev-help .ev-text { color: var(--accent); font-weight: 600; }
.ev-decide .ev-text { font-weight: 600; }
.src-link { font-size: 11px; color: var(--accent); white-space: nowrap; padding-top: 2px; }
.ev-nostat { font-size: 10px; color: var(--nostat); white-space: nowrap; padding-top: 3px; }

/* 止まる窓 */
.sheet {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(20, 26, 30, .38); padding: 12px;
  animation: fadein .25s ease-out;
}
.sheet.night { background: rgba(10, 14, 30, .62); }
.sheet-card {
  background: var(--surface); border-radius: 18px; padding: 18px 16px 12px; width: 100%; max-width: 528px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25);
  animation: up .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes fadein { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.scene-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; margin-top: 2px; }
.badge.stat { background: var(--accent-soft); color: var(--stat); }
.badge.nostat { background: var(--nostat-soft); color: var(--nostat); }
.lines p { margin: 0 0 8px; }
.lines p.note { font-size: 13px; color: var(--muted); }
.sh-src { font-size: 11px; margin: 4px 0 0; }
.sh-src a { color: var(--muted); }

.helper { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 4px; }
.avatar {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; border: 2px solid var(--accent);
}
.bubble { background: var(--accent-soft); border-radius: 4px 14px 14px 14px; padding: 10px 12px; flex: 1; }
.bubble p { margin: 0; }
.helper-name { font-size: 12px; color: var(--muted); }
.helper-say { font-weight: 600; margin: 2px 0 6px !important; }
.helper-next { font-size: 14px; }

/* 終わりの演出 */
.finale {
  position: fixed; inset: 0; z-index: 30; background: #12171b; color: #eef1f3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
  cursor: pointer; outline: none;
}
.fin-card { max-width: 440px; width: 100%; opacity: 0; transform: translateY(12px); }
.fin-card.in { opacity: 1; transform: none; transition: opacity .8s ease, transform .8s ease; }
.fin-kicker { font-size: 13px; letter-spacing: .1em; color: #9fb7b8; margin: 0 0 6px; }
.fin-title { font-size: 26px; margin: 0 0 16px; line-height: 1.4; }
.fin-card.result .fin-title { font-size: 30px; color: #8fd0d2; }
.fin-line { font-size: 16px; margin: 0 0 12px; color: #d9dfe3; }
.fin-src { font-size: 11px; color: #8a979f; margin-top: 18px; }
.fin-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin: 0 0 16px; background: #2a3238; }
.fin-bar span { display: block; height: 100%; }
.fin-bar .q { background: #6b4636; }
.fin-bar .s { flex: 1; background: #24474a; }
.fin-bar .me.q { background: #e09a74; }
.fin-bar .me.s { background: #6fb3b5; }
.fin-foot { position: absolute; bottom: 24px; left: 0; right: 0; display: flex; justify-content: center; gap: 14px; font-size: 13px; color: #8a979f; margin: 0; }

/* 終わりの画面 */
.result h2 { font-size: 22px; margin-top: 2px; }
.side { color: var(--accent); font-weight: 600; margin: 4px 0 8px; }
.mini-grid { display: grid; grid-template-columns: repeat(36, 1fr); gap: 2px; margin: 8px 0 12px; }
.mc { height: 14px; border-radius: 2px; background: #8fb7b3; position: relative; }
.mc.quit { background: var(--warn); }
.mc.moved { background: var(--warn-soft); }
.mc.help::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--help); }
.rs-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.rs-list dt { color: var(--muted); }
.rs-list dd { margin: 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: normal; }
tr.me td { font-weight: 600; }
td:first-child, td:last-child, th:last-child { white-space: nowrap; }

/* 共有の窓 */
.share-dialog {
  border: none; border-radius: 18px; padding: 16px; width: calc(100% - 24px); max-width: 528px;
  background: var(--surface); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.share-dialog::backdrop { background: rgba(20, 26, 30, .5); }
.share-dialog img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }

/* 出典 */
.sources { font-size: 13px; }
.credits { padding-left: 18px; margin: 4px 0; }
.credits li { margin-bottom: 4px; }
.sources a { color: var(--accent); word-break: break-all; }
details summary { cursor: pointer; color: var(--accent); margin-top: 6px; }
.src-table { width: 100%; font-size: 12px; margin: 8px 0; }
.src-table td, .src-table th { padding: 4px; }
.how { padding-left: 18px; }
.foot { color: var(--muted); font-size: 12px; padding-bottom: 32px; }
.src-table td + td, .src-table th + th { white-space: nowrap; text-align: right; }
