/* 做隻貓
   只用貓看得清楚的顏色：藍、黃、灰。貓分不太出紅和綠，所以這裡沒有紅色。
   黃色是「注意」：你的命運、等你決定的時候、快撐不住的數值、值得記得的事。
   字型是像素體「俐方體 11 號」，大小用 12 的倍數，像素才不會糊掉。 */

@font-face {
  font-family: 'Cubic 11';
  src: url('fonts/Cubic_11.woff2') format('woff2');
  font-display: swap;
}

:root {
  --mist: #E4E9EE;
  --paper: #F1F4F7;
  --rule: #C3CCD7;
  --dusk: #9AA7B9;
  --slate: #55637A;
  --ink: #1E2A42;
  --ink-deep: #121A2E;
  --night: #18213A;
  --night-2: #222D4C;
  --night-3: #2E3B62;
  --term: #DCE3EA;
  --term-dim: #8391AB;
  --eye: #E8C547;
  --eye-dim: #B9A55A;
  --eye-wash: #EFDF9E;
  --cool: #A9C2E8;
  --spring: #C8D190;
  --summer: #E2BD45;
  --autumn: #B0A27C;
  --winter: #8A9DBD;

  --px: 'Cubic 11', 'PingFang TC', 'Hiragino Sans', 'Noto Sans CJK TC', 'Microsoft JhengHei', sans-serif;
  --s: 12px;
  --m: 24px;
  --l: 36px;

  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  background: var(--mist);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--px);
  font-size: var(--m);
  line-height: 1.5;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

::selection { background: var(--eye-wash); color: var(--ink); }

button, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--eye);
  outline-offset: 3px;
}

canvas.px {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 像素邊框：四個角缺一格 */
.btn,
.card,
.stage-wrap,
.console {
  box-shadow:
    0 -4px 0 0 var(--ink-deep),
    0 4px 0 0 var(--ink-deep),
    -4px 0 0 0 var(--ink-deep),
    4px 0 0 0 var(--ink-deep);
}

/* ───── 按鈕 ───── */

.btn {
  margin: 4px;
  padding: 10px 24px;
  background: var(--eye);
  color: var(--ink-deep);
  border: 0;
  cursor: pointer;
  font-size: var(--m);
}
.btn-quiet { background: var(--paper); }
.btn:active { transform: translate(0, 2px); }

.btn-text {
  padding: 4px 0;
  background: none;
  border: 0;
  color: var(--slate);
  font-size: 18px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

/* ───── 開頭 ───── */

.title {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px 20px;
}

.langs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
}
.lang {
  padding: 2px 10px;
  background: none;
  border: 0;
  color: var(--slate);
  font-size: var(--m);
  cursor: pointer;
}
.lang[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.title-book { text-align: center; }
.title-book.vertical {
  writing-mode: vertical-rl;
  text-align: start;
}
.title-name {
  margin: 0 0 16px;
  font-size: 96px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: .08em;
}
.title-book.vertical .title-name {
  margin: 0;
  margin-block-end: 32px;
}
.title-poem p { margin: 0; line-height: 1.75; }

.title-cat { width: 120px; height: 80px; }

.title-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.past { width: min(100%, 40rem); }
.past h2 {
  margin: 0 0 8px;
  font-size: var(--m);
  font-weight: 400;
  text-align: center;
}
.past ol {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--slate);
}
.past li {
  padding: 6px 0;
  border-bottom: 2px dotted var(--rule);
}

.fine {
  margin: 0;
  max-width: 34em;
  color: var(--slate);
  text-align: center;
}

/* ───── 投胎 ───── */

.reveal {
  width: min(100% - 40px, 40rem);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 40px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.fates {
  list-style: none;
  margin: 0 0 40px;
  padding: 0;
  font-size: 48px;
  line-height: 1.5;
  color: var(--rule);
}
.fates li {
  width: fit-content;
  background-image: linear-gradient(var(--eye), var(--eye));
  background-repeat: no-repeat;
  background-position: 0 90%;
  background-size: 0% 30%;
}
.fates li.on { color: var(--ink); }
.fates.settled li { color: var(--dusk); }
.fates.settled li.chosen {
  color: var(--ink);
  background-size: 100% 30%;
  transition: background-size .5s steps(8);
}

.reveal-body {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}
.reveal-body p { margin: 0 0 10px; }
.reveal-body .reveal-line { margin-bottom: 24px; color: var(--slate); }
.reveal-cat {
  flex: none;
  width: 144px;
  height: 132px;
}

/* ───── 這一生 ───── */

.game {
  display: grid;
  grid-template-columns: 656px minmax(400px, 720px);
  justify-content: center;
  align-items: start;
  gap: 36px;
  padding: 28px 28px 40px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.stage-wrap {
  display: flex;
  justify-content: center;
  align-self: center;
  justify-self: center;
  width: fit-content;
  margin: 4px;
  background: var(--ink-deep);
  line-height: 0;
}

.card {
  margin: 4px;
  padding: 18px 22px 20px;
  background: var(--paper);
}
.cat-name {
  margin: 0;
  font-size: var(--l);
  font-weight: 400;
  line-height: 1.2;
}
.cat-name.unnamed { color: var(--slate); }
.cat-desc,
.cat-where {
  margin: 6px 0 0;
  color: var(--slate);
}
.cat-where {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.stats {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 6px 14px;
  margin-top: 16px;
}
.stat { display: contents; }
.stat-k { color: var(--slate); }
.blocks { display: flex; gap: 3px; }
.blocks i {
  width: 12px;
  height: 12px;
  background: var(--rule);
}
.blocks i.on { background: var(--ink); }
.stat-v { width: fit-content; }
.stat.low .blocks i.on { background: var(--eye); }
.stat.low .stat-v { background: var(--eye-wash); }

.life h2 {
  margin: 0 0 12px;
  font-size: var(--m);
  font-weight: 400;
}

.grid {
  display: grid;
  grid-template-columns: 2em repeat(12, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  max-width: 420px;
}
.yr {
  padding-right: 6px;
  font-size: var(--s);
  color: var(--slate);
  text-align: right;
}
.cell {
  position: relative;
  display: block;
  aspect-ratio: 1;
}
.cell.spring { background: var(--spring); }
.cell.summer { background: var(--summer); }
.cell.autumn { background: var(--autumn); }
.cell.winter { background: var(--winter); }
.cell.future { box-shadow: inset 0 0 0 2px var(--rule); }
.cell.pre { background: repeating-linear-gradient(45deg, var(--rule) 0 2px, transparent 2px 5px); }
.cell.none { visibility: hidden; }
.cell.mark::after {
  content: '';
  position: absolute;
  inset: 30%;
  background: var(--ink);
}
.cell.now { box-shadow: 0 0 0 2px var(--mist), 0 0 0 5px var(--ink); }
.cell.last { background: var(--ink); }
.cell.last.mark::after { background: var(--mist); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 12px 0 0;
  font-size: var(--s);
  color: var(--slate);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { width: 12px; height: 12px; }
.legend .cell.plain { background: var(--rule); }

.side-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
  color: var(--slate);
}
.lang-pick { display: inline-flex; align-items: center; gap: 8px; }
.lang-pick select {
  padding: 2px 6px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 0;
}

/* ───── 終端機 ───── */

.console {
  position: sticky;
  top: 32px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  min-height: 420px;
  margin: 4px;
  background: var(--night);
  color: var(--term);
}

.term {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 12px;
  scrollbar-color: var(--night-3) transparent;
  overscroll-behavior: contain;
}
.term:focus-visible { outline-offset: -4px; }
.term p { margin: 0 0 6px; }

.t-month {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px dashed var(--night-2);
}
.t-head { color: var(--term-dim); }
.t-note { color: var(--term-dim); }
.t-note::before { content: '· '; }
.t-act { color: var(--eye); }
.t-act::before { content: '› '; }
.t-act.auto { color: var(--eye-dim); }
.t-delta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
  color: var(--term-dim);
  font-size: 18px;
}
.t-delta .up { color: var(--cool); }
.t-mark {
  width: fit-content;
  padding: 0 8px;
  background: var(--eye);
  color: var(--ink-deep);
}
.t-mark::before { content: '★ '; }
.t-sys { color: var(--eye); }
.t-end { color: var(--paper); }

.t-prompt {
  margin: -6px 0 16px;
}
.t-q { color: var(--eye); }
.t-q::before { content: '? '; }
.t-prompt ol {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.t-choice {
  display: flex;
  gap: 14px;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: 0;
  color: var(--term);
  text-align: left;
  cursor: pointer;
}
.t-key { flex: none; color: var(--eye); }
.t-key::before { content: '['; }
.t-key::after { content: ']'; }
.t-choice:focus-visible {
  outline: 0;
  background: var(--eye);
  color: var(--ink-deep);
}
.t-choice:focus-visible .t-key { color: var(--ink-deep); }
@media (hover: hover) {
  .t-choice:hover { background: var(--eye); color: var(--ink-deep); }
  .t-choice:hover .t-key { color: var(--ink-deep); }
}

.t-review { margin: 8px 0 20px; }

.t-cursor {
  display: inline-block;
  width: 12px;
  height: 24px;
  vertical-align: middle;
  background: var(--term-dim);
  animation: blink 1s steps(1) infinite;
}
.console.waiting .t-cursor { background: var(--eye); }
@keyframes blink { 50% { opacity: 0; } }

.bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--ink-deep);
  color: var(--term-dim);
  font-size: 18px;
}
.bar-btn {
  padding: 4px 12px;
  background: var(--night-3);
  border: 0;
  color: var(--term);
  cursor: pointer;
}
.bar-btn:disabled { opacity: .4; cursor: default; }
.bar-state { margin-left: auto; }
.console.waiting .bar-state { color: var(--eye); }
.bar-tick {
  position: absolute;
  inset: -4px 0 auto 0;
  height: 4px;
}
.bar-tick i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--eye);
}
@keyframes fill { from { width: 0; } to { width: 100%; } }

/* ───── 貓生回顧 ───── */

.review {
  width: min(100% - 40px, 760px);
  margin: 0 auto;
  padding: 36px 0 72px;
}
.rv-kicker {
  margin: 28px 0 4px;
  color: var(--slate);
}
.rv-title {
  margin: 0;
  font-size: 48px;
  font-weight: 400;
  line-height: 1.25;
}
.rv-title:focus { outline: none; }
.rv-who { margin: 8px 0 0; color: var(--slate); }

.rv-epitaph { margin: 28px 0; }
.rv-epitaph p { margin: 0 0 12px; }
.rv-epitaph .rv-line { color: var(--slate); }

.rv-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 24px;
  margin: 0 0 40px;
  padding: 20px 0;
  border-top: 4px solid var(--ink);
  border-bottom: 2px solid var(--rule);
}
.rv-facts div { display: contents; }
.rv-facts dt { color: var(--slate); }
.rv-facts dd { margin: 0; }

.review h2 {
  margin: 0 0 14px;
  font-size: var(--m);
  font-weight: 400;
}
.rv-years ol {
  list-style: none;
  margin: 0 0 40px;
  padding: 0;
}
.rv-years li {
  display: grid;
  grid-template-columns: 7em 1fr;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 2px dotted var(--rule);
}
.rv-y { color: var(--slate); }
.rv-years p { margin: 0 0 4px; }
.rv-act::before { content: '› '; color: var(--slate); }
.rv-mark { width: fit-content; background: var(--eye-wash); }
.rv-mark::before { content: '★ '; }
.rv-quiet { color: var(--slate); }

.rv-life { margin-bottom: 40px; }
.grid.big { max-width: 520px; }
.rv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

/* ───── 小螢幕 ───── */

@media (max-width: 1160px) {
  .game {
    grid-template-columns: minmax(0, 720px);
    gap: 20px;
    padding: 16px 14px 32px;
  }
  .side { display: contents; }
  .stage-wrap { order: 1; }
  .card { order: 2; }
  .console {
    order: 3;
    position: static;
    height: 62vh;
    min-height: 340px;
  }
  .life { order: 4; }
  .side-foot { order: 5; }
}

@media (max-width: 560px) {
  body { font-size: 18px; }
  .btn, .lang { font-size: 18px; }
  .title-name { font-size: 72px; }
  .title-poem { font-size: 18px; }
  .fates { font-size: 36px; }
  .reveal-body { flex-direction: column; }
  .cat-name { font-size: var(--m); }
  .card { padding: 14px 16px; }
  .stats { gap: 4px 10px; }
  .blocks i { width: 9px; height: 9px; }
  .term { padding: 14px 14px 8px; }
  .rv-title { font-size: var(--l); }
  .rv-years li { grid-template-columns: 4.5em 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .t-cursor { animation: none; }
  .fates.settled li.chosen { transition: none; }
}
