:root {
  --system: #c0c0c0;
  --system-light: #ffffff;
  --system-mid: #777777;
  --system-dark: #303642;
  --paper: #ffffff;
  --page: #e9eef5;
  --ink: #111318;
  --muted: #4d5665;
  --navy: #1e2b4d;
  --navy-dark: #111a31;
  --shirt: #c7ddf2;
  --shirt-deep: #83acd1;
  --link: #0000cc;
  --visited: #551a8b;
  --focus: #9b001b;
  --alert: #a51d16;
  --success: #0b6b3a;
  --warm: #fff4c2;
  --rule: #9aa5b5;
  --font-ming: "PMingLiU", "新細明體", MingLiU, "細明體", "Songti TC", "Noto Serif TC", serif;
  --font-kai: "DFKai-SB", "標楷體", BiauKai, "Kaiti TC", "Noto Serif TC", serif;
  --font-ui: Tahoma, "MS Sans Serif", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: "Courier New", ui-monospace, monospace;
  --font-times: "Times New Roman", Times, serif;
  --content: 70rem;
  --reading: 45rem;
  --edge: clamp(1rem, 3vw, 2.5rem);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
  scroll-padding-top: 6.5rem;
}

body {
  margin: 0;
  min-width: 20rem;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-ming);
  font-size: 1.0625rem;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 0.075em;
  text-underline-offset: 0.14em;
}

a:visited {
  color: var(--visited);
}

a:hover {
  background: var(--warm);
  color: #000084;
  text-decoration-thickness: 0.14em;
}

a:active,
button:active {
  transform: translate(1px, 1px);
}

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

button,
select {
  min-height: 2.75rem;
  color: var(--ink);
  font: 700 0.875rem/1.2 var(--font-ui);
}

button {
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  border-radius: 0;
  background: var(--system);
  box-shadow: inset -1px -1px var(--system-mid), inset 1px 1px var(--paper);
  cursor: pointer;
}

button:active {
  border-color: var(--system-dark) var(--system-light) var(--system-light) var(--system-dark);
  box-shadow: inset 1px 1px var(--system-mid);
}

h1,
h2,
h3,
p,
ul,
ol,
blockquote,
figure {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--navy-dark);
  line-height: 1.22;
  text-wrap: balance;
}

h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
}

h3 {
  font-size: 1.35rem;
}

p,
li {
  text-wrap: pretty;
}

hr {
  clear: both;
  height: 2px;
  margin: 3rem 0;
  border: 0;
  border-top: 1px solid var(--system-dark);
  border-bottom: 1px solid var(--system-light);
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-family: var(--font-ui);
  font-weight: 700;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.preview-bar {
  position: relative;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.4rem 4rem 0.4rem 1rem;
  border-bottom: 2px solid var(--navy-dark);
  background: var(--warm);
  color: var(--ink);
  font: 700 0.8125rem/1.35 var(--font-ui);
}

.preview-bar span {
  padding: 0.1rem 0.35rem;
  background: var(--navy);
  color: #fff;
}

.preview-bar-close {
  position: absolute;
  top: 0.25rem;
  right: 0.5rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.65rem;
}

.preview-dismissed .preview-bar {
  display: none;
}

.browser-shell {
  width: min(calc(100% - 2rem), 90rem);
  margin: 1rem auto 0;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--paper);
  box-shadow: 0.65rem 0.65rem 0 rgba(30, 43, 77, 0.16);
}

.browser-chrome {
  position: sticky;
  z-index: 100;
  top: 0;
  border-bottom: 2px solid var(--system-dark);
  background: var(--system);
  font-family: var(--font-ming);
  transition: box-shadow 180ms ease;
}

.browser-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.1rem;
  padding: 0.12rem 0.22rem 0.12rem 0.48rem;
  border: 1px solid;
  border-color: #6579ad var(--navy-dark) var(--navy-dark) #6579ad;
  background: linear-gradient(90deg, #000082 0%, #083da8 55%, #1597d0 100%);
  color: #fff;
}

.wordmark,
.wordmark:visited {
  display: flex;
  align-items: center;
  gap: 0.52rem;
  min-height: 1.7rem;
  color: #fff;
  font-weight: 400;
  text-decoration: none;
}

.wordmark:hover {
  background: transparent;
  color: #fff;
  text-shadow: 1px 1px #000;
}

.wordmark-name {
  font-family: var(--font-ming);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.wordmark-field {
  color: #fff;
  font-family: var(--font-ming);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

.wordmark:hover .wordmark-field {
  color: #fff;
}

.title-pixel-star {
  position: relative;
  flex: 0 0 0.25rem;
  width: 0.25rem;
  height: 0.25rem;
  margin: 0.1rem 0.45rem 0 0.35rem;
  background: #fff600;
  box-shadow: 0 -0.5rem #fff600, 0 0.5rem #fff600, -0.5rem 0 #fff600,
    0.5rem 0 #fff600, -0.25rem -0.25rem #00ffff, 0.25rem -0.25rem #fff,
    -0.25rem 0.25rem #fff, 0.25rem 0.25rem #00ffff;
}

.titlebar-actions,
.browser-controls {
  display: flex;
  align-items: center;
}

.titlebar-actions {
  gap: 0.28rem;
}

.browser-controls {
  gap: 0.16rem;
}

.browser-controls i {
  position: relative;
  display: block;
  width: 1.55rem;
  height: 1.45rem;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  color: var(--ink);
  box-shadow: inset -1px -1px var(--system-mid), inset 1px 1px #fff;
}

.browser-controls i::after {
  position: absolute;
  right: 0.3rem;
  bottom: 0.28rem;
  left: 0.3rem;
  border-bottom: 3px solid var(--ink);
  content: "";
}

.browser-controls i:nth-child(2)::after {
  top: 0.25rem;
  border: 2px solid var(--ink);
}

.browser-controls i:nth-child(3)::before,
.browser-controls i:nth-child(3)::after {
  border: 0;
  transform: none;
}

.browser-controls i:nth-child(3)::before {
  display: none;
}

.browser-controls i:nth-child(3)::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  content: "×";
  font: 700 1rem/1 Arial, Helvetica, sans-serif;
}

.browser-toolbar {
  padding: 0 0.35rem;
  border-top: 1px solid var(--system-light);
  border-bottom: 1px solid var(--system-dark);
  background: var(--system);
}

.browser-home,
.browser-home:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 6.6rem;
  min-height: 1.65rem;
  padding: 0.05rem 0.38rem;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  color: var(--ink);
  box-shadow: inset -1px -1px var(--system-mid), inset 1px 1px #fff;
  font: 400 0.72rem/1.1 var(--font-ming);
  text-decoration: none;
}

.browser-home:hover {
  background: #d7d7d7;
  color: var(--ink);
}

.browser-home:active {
  border-color: var(--system-dark) var(--system-light) var(--system-light) var(--system-dark);
  background: #d7d7d7;
  color: var(--ink);
  box-shadow: inset 1px 1px var(--system-mid);
}

.home-icon {
  position: relative;
  flex: 0 0 1rem;
  width: 1rem;
  height: 1rem;
}

.home-icon::before {
  position: absolute;
  right: 0.18rem;
  bottom: 0;
  left: 0.18rem;
  height: 0.58rem;
  border: 1px solid #07145b;
  background: #fff;
  box-shadow: inset 0.18rem -0.12rem #00a0ff, 0.12rem 0.08rem #777;
  content: "";
}

.home-icon::after {
  position: absolute;
  top: -0.02rem;
  left: 0;
  border-right: 0.5rem solid transparent;
  border-bottom: 0.54rem solid #07145b;
  border-left: 0.5rem solid transparent;
  content: "";
  filter: drop-shadow(1px 1px 0 #00a0ff);
}

.site-nav {
  min-width: 0;
}

.site-nav ul {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav li {
  flex: 0 0 auto;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 2.7rem;
  padding: 0.12rem clamp(0.38rem, 0.8vw, 0.68rem);
  border: 0;
  color: var(--ink);
  font-family: var(--font-ming);
  font-size: 0.84rem;
  font-weight: 400;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:visited {
  color: var(--ink);
}

.site-nav a.current {
  background: transparent;
  color: #000082;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-shadow: 1px 0 #fff;
}

.site-nav a:hover {
  background: #000082;
  color: #fff;
  box-shadow: none;
  text-decoration: none;
  text-shadow: none;
}

.site-nav a:active {
  background: #000082;
  color: #fff;
  box-shadow: none;
  transform: translate(1px, 1px);
}

.nav-en {
  margin-left: 0;
  font: inherit;
}

.nav-key {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.08em;
}

.local-count {
  display: inline-flex;
  align-items: stretch;
  min-width: 0;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
}

.local-count[hidden] {
  display: none;
}

.local-count-label {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.4rem;
  background: #d40000;
  color: #fff600;
  font: 400 0.68rem/1.1 var(--font-ming);
  letter-spacing: 0.03em;
  text-shadow: 1px 1px #500;
}

.local-count-digits {
  display: inline-flex;
  align-items: stretch;
  padding: 0.12rem;
  border: 1px solid;
  border-color: #111 #8b8b8b #8b8b8b #111;
  background: #050505;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.counter-digit {
  display: inline-grid;
  place-items: center;
  width: 1.05rem;
  min-height: 1.35rem;
  border-right: 1px solid #4b4b4b;
  background: #050505;
  color: #f5ff72;
  font: 700 0.92rem/1 var(--font-mono);
  text-shadow: 0 0 2px #ff7a00;
}

.counter-digit:last-child {
  border-right: 0;
}

.browser-shell[data-compact="true"] .browser-chrome {
  box-shadow: 0 0.35rem 0 rgba(17, 26, 49, 0.18);
}

main {
  display: block;
  min-height: 60vh;
  background: var(--paper);
}

.hero {
  position: relative;
  isolation: isolate;
  min-height: min(49rem, calc(100vh - 8.5rem));
  border-bottom: 1px solid var(--navy);
  background-color: #f9fbfd;
}

.hero::before,
.hero::after {
  position: absolute;
  z-index: -1;
  content: "";
  pointer-events: none;
}

/* 四邊各是一條虛線 gradient；用 background-position 讓虛線像選取框一樣慢慢繞行。
   steps() 是刻意的：每 1.2 秒跳一格，比連續滑動更接近當年的畫法，也少掉大量重繪。 */
.hero::before {
  inset: 2rem var(--edge);
  border: 0;
  background-image:
    repeating-linear-gradient(90deg, var(--shirt-deep) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(90deg, var(--shirt-deep) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(0deg, var(--shirt-deep) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(0deg, var(--shirt-deep) 0 6px, transparent 6px 12px);
  background-repeat: no-repeat;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-size: 100% 1px, 100% 1px, 1px 100%, 1px 100%;
  animation: krx-ants 30s steps(25, end) infinite;
}

@keyframes krx-ants {
  to {
    background-position: 300px 0, -300px 100%, 0 -300px, 100% 300px;
  }
}

.hero::after {
  top: 0;
  right: 17%;
  bottom: 0;
  border-left: 1px solid #dbe4ef;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: auto 1fr auto;
  gap: clamp(1rem, 2vw, 2rem);
  width: min(100%, 82rem);
  min-height: inherit;
  margin: 0 auto;
  padding: clamp(3rem, 7vh, 6rem) var(--edge) 2rem;
}

.hero-text {
  z-index: 3;
  grid-column: 1 / 8;
  grid-row: 1;
  align-self: start;
}

.hero-eyebrow {
  display: inline-block;
  margin-bottom: 0.65rem;
  padding: 0.15rem 0.4rem;
  background: var(--navy);
  color: #fff;
  font: 400 1rem/1.4 var(--font-kai);
  letter-spacing: 0.08em;
}

.hero-blink {
  display: inline-block;
  margin: 0 0 0.65rem 0.35rem;
  padding: 0.12rem 0.3rem;
  border: 2px solid;
  border-color: #fff #640044 #640044 #fff;
  background: #f0009a;
  color: #fff600;
  box-shadow: 2px 2px 0 #640044;
  font: 700 0.66rem/1.1 var(--font-mono);
  letter-spacing: 0.04em;
  transform: rotate(-2deg);
  animation: homepage-blink 780ms steps(1, end) infinite;
}

@keyframes homepage-blink {
  0%, 48% { visibility: visible; }
  49%, 100% { visibility: hidden; }
}

.hero-name {
  display: flex;
  align-items: baseline;
  gap: clamp(0.6rem, 2vw, 1.5rem);
  margin-bottom: 1rem;
  font-family: var(--font-kai);
  font-size: clamp(3.7rem, 8vw, 7.8rem);
  font-weight: 400;
  letter-spacing: -0.08em;
  line-height: 0.95;
}

.hero-name-en {
  color: var(--muted);
  font: 400 clamp(0.8rem, 1.4vw, 1.05rem)/1.2 var(--font-times);
  letter-spacing: 0.08em;
}

.hero-roles {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-ming);
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  font-weight: 400;
}

.hero-roles li::before {
  margin-right: 0.45rem;
  color: var(--link);
  content: "■";
  font-size: 0.55em;
  vertical-align: 0.2em;
}

.hero-portrait {
  position: relative;
  z-index: 2;
  /* 人物本身放大之後，欄位一併從第 7 欄起算，才不會被欄寬先卡住 */
  grid-column: 7 / 13;
  grid-row: 1 / 4;
  align-self: end;
  justify-self: center;
  width: min(100%, 32rem);
  margin: 0;
}

.hero-doctor-frame {
  position: relative;
}

.hero-doctor {
  display: block;
  width: 100%;
  max-height: 48rem;
  height: auto;
}

.selection-frame {
  position: absolute;
  z-index: 2;
  inset: 5% -2% 1%;
  border: 1px dashed var(--navy);
  pointer-events: none;
  animation: selection-frames 900ms steps(3, end) 250ms 1 both;
}

.selection-frame::before,
.selection-frame::after {
  position: absolute;
  width: 0.55rem;
  height: 0.55rem;
  border: 1px solid #fff;
  background: var(--navy);
  content: "";
}

.selection-frame::before {
  top: -0.32rem;
  left: -0.32rem;
  box-shadow: calc(100% + 0.1rem) 0 var(--navy);
}

.selection-frame::after {
  right: -0.32rem;
  bottom: -0.32rem;
}

@keyframes selection-frames {
  0%, 33% { opacity: 0; transform: translate(3px, -2px); }
  34%, 66% { opacity: 1; transform: translate(-2px, 1px); }
  67%, 100% { opacity: 1; transform: translate(0, 0); }
}

/* ------------------------------------------------------------------
   Hero 舞台：進站顯影、環境動態與介面互動

   共通原則：**完成狀態就是預設值**，動畫只負責把它延後。
   所以 prefers-reduced-motion 的 `animation: none` 一關，畫面直接是終態；
   沒有 JS、瀏覽器不支援 @property 時也一樣看得到完整內容。
   ------------------------------------------------------------------ */

@property --krx-pct {
  syntax: "<integer>";
  inherits: false;
  initial-value: 100;
}

/* 進站顯影：十六條橫帶蓋住人物，分三遍退場。
   退場動畫只改 opacity 與水平縮放，不動遮罩幾何，舊手機才不會掉幀。

   fill 一律用 backwards，不用 both：橫帶的靜止值由下面的 `opacity: 0` 提供。
   `steps()` 在動畫區間最末端那一刻會回到前一階，forwards fill 會把那個值永久
   留住，於是隨機幾條橫帶再也清不掉。靜止值交給樣式本身就沒有這個端點問題。 */
.hero-bands {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  inset: 0;
  pointer-events: none;
}

.hero-bands i {
  flex: 0 0 auto;
  background: #f9fbfd;
  opacity: 0;
}

.krx-boot .hero-bands i {
  animation: krx-band 1ms steps(1, end) backwards;
}

@keyframes krx-band {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* 掃描間距刻意不等分：真的隔行載入不會每一條一樣厚 */
.hero-bands i:nth-child(1) { height: 6%; }
.hero-bands i:nth-child(2) { height: 9%; }
.hero-bands i:nth-child(3) { height: 4%; }
.hero-bands i:nth-child(4) { height: 7%; }
.hero-bands i:nth-child(5) { height: 11%; }
.hero-bands i:nth-child(6) { height: 5%; }
.hero-bands i:nth-child(7) { height: 8%; }
.hero-bands i:nth-child(8) { height: 3%; }
.hero-bands i:nth-child(9) { height: 10%; }
.hero-bands i:nth-child(10) { height: 6%; }
.hero-bands i:nth-child(11) { height: 4%; }
.hero-bands i:nth-child(12) { height: 9%; }
.hero-bands i:nth-child(13) { height: 7%; }
.hero-bands i:nth-child(14) { height: 5%; }
.hero-bands i:nth-child(15) { height: 3%; }
.hero-bands i:nth-child(16) { height: 3%; }

/* 第一遍：稀疏地刷過去，只看得出人形 */
.krx-boot .hero-bands i:nth-child(1) { animation-delay: 200ms; }
.krx-boot .hero-bands i:nth-child(5) { animation-delay: 285ms; }
.krx-boot .hero-bands i:nth-child(9) { animation-delay: 370ms; }
.krx-boot .hero-bands i:nth-child(13) { animation-delay: 455ms; }

/* 第二遍：補中間，密度加倍 */
.krx-boot .hero-bands i:nth-child(7) { animation-delay: 585ms; }
.krx-boot .hero-bands i:nth-child(11) { animation-delay: 670ms; }
.krx-boot .hero-bands i:nth-child(15) { animation-delay: 755ms; }
.krx-boot .hero-bands i:nth-child(2) { animation-delay: 840ms; }

/* 第三遍：由下往上填滿，眼睛那一條留到最後，補上前刻意停一拍 */
.krx-boot .hero-bands i:nth-child(16) { animation-delay: 950ms; }
.krx-boot .hero-bands i:nth-child(14) { animation-delay: 1030ms; }
.krx-boot .hero-bands i:nth-child(12) { animation-delay: 1110ms; }
.krx-boot .hero-bands i:nth-child(10) { animation-delay: 1190ms; }
.krx-boot .hero-bands i:nth-child(8) { animation-delay: 1270ms; }
.krx-boot .hero-bands i:nth-child(6) { animation-delay: 1350ms; }
.krx-boot .hero-bands i:nth-child(4) { animation-delay: 1430ms; }
.krx-boot .hero-bands i:nth-child(3) { animation-delay: 1600ms; }

/* 四條橫帶在退場前先收掉一半寬度，像一行只畫到中途就斷了。
   收合方向左右交錯，避免看起來又是同一個機械動作。

   這一組用 linear 而不是 steps：跳格寫在 keyframe 的百分比裡，時間函數本身
   沒有階梯，就不會踩到上面那個端點問題，forwards 可以安全保留半寬狀態。 */
.krx-boot .hero-bands i:nth-child(5),
.krx-boot .hero-bands i:nth-child(8),
.krx-boot .hero-bands i:nth-child(11),
.krx-boot .hero-bands i:nth-child(14) {
  animation:
    krx-band 1ms steps(1, end) backwards,
    krx-band-half 220ms linear forwards;
}

.krx-boot .hero-bands i:nth-child(5) { transform-origin: right center; animation-delay: 285ms, 65ms; }
.krx-boot .hero-bands i:nth-child(8) { transform-origin: left center; animation-delay: 1270ms, 1050ms; }
.krx-boot .hero-bands i:nth-child(11) { transform-origin: right center; animation-delay: 670ms, 450ms; }
.krx-boot .hero-bands i:nth-child(14) { transform-origin: left center; animation-delay: 1030ms, 810ms; }

@keyframes krx-band-half {
  0%, 49.9% { transform: scaleX(1); }
  50%, 100% { transform: scaleX(0.46); }
}

/* 圖還沒到位時的虛線佔位框與破圖記號 */
.hero-loadframe {
  position: absolute;
  z-index: 4;
  inset: 5% -2% 1%;
  border: 1px dashed var(--system-mid);
  opacity: 0;
  pointer-events: none;
}

.hero-loadframe::before {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  width: 0.85rem;
  height: 1rem;
  border: 1px solid var(--system-mid);
  background:
    linear-gradient(135deg, transparent 45%, var(--alert) 45%, var(--alert) 55%, transparent 55%),
    linear-gradient(45deg, transparent 45%, var(--alert) 45%, var(--alert) 55%, transparent 55%),
    var(--paper);
  content: "";
}

.krx-boot .hero-loadframe {
  animation: krx-hold-then-hide 1640ms steps(1, end) backwards;
}

@keyframes krx-hold-then-hide {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* 顯影期間才出現的選取框動作，延到人物到齊之後 */
.krx-boot .selection-frame {
  animation-delay: 1700ms;
}

/* 掃描線：每八秒一趟，用 transform 位移，不觸發版面重算 */
.hero-scan {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero-scan::before {
  position: absolute;
  right: 0;
  left: 0;
  height: 12rem;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(30, 43, 77, 0.05) 55%,
    rgba(255, 255, 255, 0) 100%
  );
  content: "";
  animation: krx-scan 8s linear 1750ms infinite;
  will-change: transform;
}

/* 顯影期間掃描線不出現：同一塊區域同時有兩個橫向移動的東西會互相拆台 */
.krx-boot .hero-scan {
  animation: krx-wait-then-show 1750ms steps(1, end) backwards;
}

@keyframes krx-scan {
  0% { transform: translateY(-14rem); }
  70%, 100% { transform: translateY(58rem); }
}

/* 人物整體的低幀位移；地面陰影不跟著動，位移才看得出來 */
#krx-figure {
  animation: krx-breathe 5200ms steps(2, end) infinite;
}

@keyframes krx-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 眼球、頭部與鏡片反光；預設值就是靜止狀態，指標裝置才由 hero-stage.js 改寫。

   這裡不設 transition：追游標的平滑由 hero-stage.js 每一幀補間，逐幀寫入變數。
   先前用 `transition: transform 120ms steps(3, end)` 補間，三階跳格加上事件本身
   的間隔，看起來就是在抖，而不是在跟著看。 */
#krx-eyes {
  transform: translate(var(--krx-eye-x, 0), var(--krx-eye-y, 0));
}

/* 頭部跟著游標做小幅度平移，幅度約為眼球的三分之一。
   單靠眼球移動在整張圖裡佔比太小，加上頭的視差才看得出人物在看你。 */
#krx-head {
  transform: translate(var(--krx-head-x, 0), var(--krx-head-y, 0));
}

#krx-glare {
  opacity: 0.45;
  transform: translateX(var(--krx-glare-x, 170px));
}

/* ------------------------------------------------------------------
   解析度倒退

   離開首屏的過程中，人物一階一階退化：取樣格變粗、色階變少、網點浮出來。
   四階是刻意的——連續縮放會像壓縮壞掉，跳階才像當年硬體換了顯示模式。
   捲回去會逐階復原，狀態列同步報出目前的模式，讓它讀起來是設計不是破圖。

   階段由 hero-stage.js 寫在 [data-lofi] 上；沒有 JS、Reduced Motion 或觸控
   裝置時屬性一直是 0，人物就是完整解析度。
   ------------------------------------------------------------------ */
.hero-portrait[data-lofi="1"] .hero-doctor { filter: url(#krx-lofi-1); }
.hero-portrait[data-lofi="2"] .hero-doctor { filter: url(#krx-lofi-2); }
.hero-portrait[data-lofi="3"] .hero-doctor { filter: url(#krx-lofi-3); }
.hero-portrait[data-lofi="4"] .hero-doctor { filter: url(#krx-lofi-4); }

/* 退到後兩階時，選取框跟著換成粗一格的虛線，整組看起來是同一台機器在降規格 */
.hero-portrait[data-lofi="3"] .selection-frame,
.hero-portrait[data-lofi="4"] .selection-frame {
  border-width: 2px;
}

.status-res {
  margin-left: 0.7rem;
  color: var(--muted);
}

/* 滑鼠指到人物時的選取框，走動速度比背景那圈快得多 */
.hero-pick {
  position: absolute;
  z-index: 3;
  inset: 5% -2% 1%;
  background-image:
    repeating-linear-gradient(90deg, var(--navy) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(90deg, var(--navy) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(0deg, var(--navy) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(0deg, var(--navy) 0 6px, transparent 6px 12px);
  background-repeat: no-repeat;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-size: 100% 1px, 100% 1px, 1px 100%, 1px 100%;
  opacity: 0;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .hero-portrait:hover .hero-pick {
    opacity: 1;
    animation: krx-ants-quick 1200ms steps(8, end) infinite;
  }
}

@keyframes krx-ants-quick {
  to {
    background-position: 96px 0, -96px 100%, 0 -96px, 100% 96px;
  }
}

/* 指到姓名時短暫換成沙漏；Safari 不吃 SVG 游標時退回系統 wait */
.hero-name.is-waiting {
  cursor: url("/assets/cursor-wait.svg") 11 11, wait;
}

/* Windows 式狀態列：閒置顯示「完成」，首頁進站時改播傳輸進度。
   sticky 貼在視窗底部，離開視窗殼之後才落回殼底，和真的視窗一樣。 */
.browser-status {
  position: sticky;
  z-index: 90;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.9rem;
  padding: 0.2rem 0.35rem;
  border-top: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  font-family: var(--font-ui);
  font-size: 0.72rem;
}

.status-line {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0.1rem 0.4rem;
  border: 1px solid;
  border-color: var(--system-mid) var(--system-light) var(--system-light) var(--system-mid);
  color: var(--ink);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-boot {
  position: absolute;
  top: 0.1rem;
  left: 0.4rem;
  opacity: 0;
}

.status-done {
  opacity: 1;
}

.krx-boot .status-boot {
  animation: krx-hold-then-hide 1660ms steps(1, end) backwards;
}

.krx-boot .status-done {
  animation: krx-wait-then-show 1660ms steps(1, end) backwards;
}

@keyframes krx-wait-then-show {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 數字與橫帶共用同一條時間軸，不會出現「100% 了圖還沒滿」 */
.status-pct::after {
  counter-reset: krx-pct var(--krx-pct);
  content: counter(krx-pct) "%";
}

.krx-boot .status-pct {
  animation: krx-count 1600ms linear backwards;
}

@keyframes krx-count {
  from { --krx-pct: 0; }
  to { --krx-pct: 100; }
}

.status-replay {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.5rem;
  padding: 0.1rem 0.5rem;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  color: var(--ink);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

.status-replay:active {
  border-color: var(--system-dark) var(--system-light) var(--system-light) var(--system-dark);
  padding: 0.15rem 0.45rem 0.05rem 0.55rem;
}

.replay-icon {
  width: 0.7rem;
  height: 0.7rem;
  border: 2px solid var(--navy);
  border-right-color: transparent;
  border-radius: 50%;
}

/* 觸控裝置不放重播鍵：24px 的目標太小，放大又會讓狀態列吃掉閱讀高度，
   而在手機上重新整理本來就會重播一次。display:none 也一併移出 Tab 順序。 */
@media (pointer: coarse) {
  .status-replay {
    display: none;
  }
}

.portal-directory {
  z-index: 4;
  grid-column: 2 / 8;
  grid-row: 2;
  align-self: end;
  max-width: 38rem;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  box-shadow: 0.45rem 0.45rem 0 rgba(30, 43, 77, 0.22);
  font-family: var(--font-ming);
}

.portal-title {
  margin: 0;
  padding: 0.28rem 0.55rem;
  background: var(--navy);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 400;
}

.portal-directory ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
}

.portal-directory li:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.portal-directory a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3.45rem;
  padding: 0.35rem 0.5rem;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: #fff;
  color: var(--link);
  font-weight: 400;
}

.portal-directory a:visited {
  color: var(--visited);
}

.portal-directory a:hover {
  background: var(--warm);
}

.portal-directory a:active {
  border-color: var(--system-dark) var(--system-light) var(--system-light) var(--system-dark);
}

.portal-icon {
  position: relative;
  flex: 0 0 1.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--navy);
  background: var(--shirt);
  box-shadow: inset 2px 2px #fff, inset -2px -2px var(--shirt-deep);
}

.portal-icon::before,
.portal-icon::after {
  position: absolute;
  content: "";
}

.portal-icon-about::before {
  top: 0.2rem;
  left: 0.42rem;
  width: 0.38rem;
  height: 0.38rem;
  border: 1px solid var(--navy);
  background: #f1c7ac;
}

.portal-icon-about::after {
  right: 0.2rem;
  bottom: 0.15rem;
  left: 0.2rem;
  height: 0.45rem;
  background: var(--navy);
}

.portal-icon-topics::before {
  top: -0.3rem;
  left: 0.12rem;
  width: 0.75rem;
  height: 0.35rem;
  border: 2px solid var(--navy);
  border-bottom: 0;
  background: var(--shirt-deep);
}

.portal-icon-articles::before {
  inset: 0.25rem 0.2rem;
  border-top: 2px solid var(--navy);
  border-bottom: 2px solid var(--navy);
}

.portal-icon-articles::after {
  top: 0.62rem;
  right: 0.2rem;
  left: 0.2rem;
  border-top: 2px solid var(--navy);
}

.portal-icon-locations::before {
  top: 0.18rem;
  left: 0.38rem;
  width: 0.5rem;
  height: 0.5rem;
  border: 2px solid var(--navy);
  border-radius: 50%;
  background: #fff;
}

.portal-icon-locations::after {
  bottom: 0.05rem;
  left: 0.48rem;
  border: 0.22rem solid transparent;
  border-top: 0.42rem solid var(--navy);
}

.portal-icon-colophon::before {
  inset: 0.2rem;
  border: 2px dotted var(--navy);
  transform: rotate(45deg);
}

.hero-utility {
  z-index: 5;
  grid-column: 1 / 8;
  grid-row: 3;
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem 1rem;
}

.hero-update {
  margin: 0;
  color: var(--muted);
  font: 0.75rem/1.4 var(--font-mono);
}

.hero-counter {
  width: fit-content;
}

.band {
  width: min(100% - (var(--edge) * 2), var(--content));
  margin-inline: auto;
  padding-block: clamp(5rem, 11vw, 10rem);
}

.band + .band {
  border-top: 1px solid #d8dee8;
}

.band-viewpoint {
  display: grid;
  grid-template-columns: minmax(11rem, 0.7fr) minmax(0, 1.6fr);
  gap: clamp(2rem, 8vw, 7rem);
  align-items: start;
}

.band-viewpoint h2 {
  font-family: var(--font-ming);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 400;
  letter-spacing: 0.08em;
}

.band-viewpoint blockquote {
  margin-bottom: 0;
  padding-left: clamp(1rem, 3vw, 2.5rem);
  border-left: 0.35rem solid var(--navy);
  font-family: var(--font-kai);
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 1.35;
}

.band-viewpoint blockquote p {
  margin-bottom: 0;
}

.band-topics {
  font-family: var(--font-kai);
}

.band-topics > p {
  max-width: 45rem;
  font-size: 1.22rem;
}

.band-topics > ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 2rem;
  padding: 1px;
  background: var(--navy);
  list-style: none;
}

.band-topics > ul li {
  padding: 1.4rem;
  background: #fff;
}

.band-articles h2,
.band-locations h2 {
  font-family: var(--font-ming);
  font-weight: 700;
}

.article-list,
.location-brief {
  margin: 2rem 0;
  padding: 0;
  list-style: none;
}

.article-list > li {
  display: grid;
  grid-template-columns: minmax(12rem, 0.9fr) minmax(9rem, 0.35fr) minmax(14rem, 1.4fr);
  gap: 1rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--rule);
}

.article-list > li:last-child {
  border-bottom: 1px solid var(--rule);
}

.article-head {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.article-title {
  font-weight: 700;
}

.article-meta {
  color: var(--muted);
  font: 0.78rem/1.6 var(--font-mono);
}

.article-summary {
  color: #27303c;
}

.tag-new {
  display: inline-block;
  padding: 0 0.25rem;
  background: var(--alert);
  color: #fff;
  font: 400 0.72rem/1.5 var(--font-ming);
  letter-spacing: 0.04em;
}

.location-brief {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5rem;
}

.location-brief li {
  padding-top: 0.75rem;
  border-top: 0.28rem solid var(--navy);
}

.location-brief strong,
.location-brief span {
  display: block;
}

.note {
  margin: 2rem 0;
  padding: 1rem 1.15rem;
  border-left: 0.3rem solid var(--shirt-deep);
  background: #eef6fd;
}

.note > :last-child {
  margin-bottom: 0;
}

.page-layout {
  width: min(100% - (var(--edge) * 2), var(--content));
  margin-inline: auto;
  padding-block: clamp(4rem, 8vw, 8rem);
}

.page-head {
  margin-bottom: clamp(2.5rem, 6vw, 5rem);
  padding-bottom: 1.2rem;
  border-bottom: 2px solid var(--navy);
}

.page-kicker {
  margin-bottom: 0.65rem;
  color: var(--navy);
  font: 700 0.76rem/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-head h1 {
  max-width: 18ch;
  margin-bottom: 0.85rem;
  font-family: var(--font-kai);
  font-size: clamp(2.7rem, 7vw, 6.5rem);
  font-weight: 400;
}

.page-lead {
  max-width: 44rem;
  margin-bottom: 0;
  color: #27303c;
  font-size: 1.2rem;
}

.page-content {
  max-width: 58rem;
}

.page-content h2 {
  clear: both;
  margin-top: 4.5rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--navy);
  font-family: var(--font-ming);
}

.page-content > h2:first-child,
.page-content > figure + h2 {
  margin-top: 0;
}

.page-content ul,
.page-content ol {
  padding-left: 1.4rem;
}

.page-content li + li {
  margin-top: 0.4rem;
}

.portrait-standing {
  float: right;
  width: clamp(11.25rem, 23vw, 17.5rem);
  margin: 0 0 3rem clamp(2rem, 6vw, 6rem);
  padding: 0.45rem;
  border: 1px solid var(--navy);
  background: #fff;
}

.portrait-standing img {
  width: 100%;
}

.portrait-standing figcaption {
  padding: 0.45rem 0.2rem 0.1rem;
  color: var(--muted);
  font: 0.76rem/1.4 var(--font-ui);
  text-align: center;
}

.page-about .page-content h2 {
  clear: none;
}

.group-title {
  margin-top: 4.5rem;
  padding: 0.4rem 0.55rem;
  background: var(--navy);
  color: #fff;
  font: 700 1rem/1.4 var(--font-ui);
}

.reading-article {
  width: min(100% - (var(--edge) * 2), var(--reading));
  margin-inline: auto;
  padding-block: clamp(3rem, 7vw, 7rem);
}

.breadcrumb {
  margin-bottom: 2.5rem;
  font: 0.78rem/1.5 var(--font-ui);
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb li + li::before {
  margin-right: 0.35rem;
  content: ">";
}

.article-headline h1 {
  max-width: 17ch;
  font-family: var(--font-ming);
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  font-weight: 700;
  letter-spacing: -0.035em;
}

.article-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 1.5rem 0 0;
  color: var(--muted);
  font: 0.78rem/1.5 var(--font-mono);
}

.article-body {
  font-size: 1.08rem;
  line-height: 1.85;
}

.article-body h2 {
  margin-top: 4.5rem;
  font-family: var(--font-ming);
  font-size: 1.8rem;
}

.article-body h3 {
  margin-top: 2.75rem;
}

.article-body blockquote {
  margin: 2.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 0.3rem solid var(--navy);
  background: #f3f6fa;
  font-family: var(--font-kai);
  font-size: 1.25rem;
}

.plain-backlinks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.45rem;
  margin: 0 0 2.5rem;
  padding: 0;
  color: var(--ink);
  font: 1rem/1.6 var(--font-ming);
}

.reading-article > .plain-backlinks {
  margin: 4rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.plain-backlinks a {
  color: var(--link);
  text-decoration: underline;
}

.human-sitemap > ul {
  margin-bottom: 4rem;
  padding: 0;
  list-style: none;
}

.human-sitemap li {
  display: grid;
  grid-template-columns: minmax(10rem, 0.7fr) minmax(0, 1.5fr);
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}

.human-sitemap li span {
  color: var(--muted);
}

.error-panel {
  position: relative;
}

.error-code {
  position: absolute;
  top: 2.5rem;
  right: 0;
  margin: 0;
  color: var(--shirt);
  font: 700 clamp(5rem, 18vw, 15rem)/1 var(--font-mono);
}

.error-panel .page-head,
.error-links {
  position: relative;
  z-index: 1;
}

.error-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  max-width: 48rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.error-links a {
  display: flex;
  align-items: center;
  min-height: 3.5rem;
  padding: 0.6rem 0.8rem;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  font-family: var(--font-ui);
  font-weight: 700;
}

.site-footer {
  width: min(calc(100% - 2rem), 90rem);
  margin: 0 auto 2rem;
  padding: clamp(2rem, 5vw, 4rem) var(--edge);
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  border-top: 0;
  background: var(--system);
  color: var(--ink);
  font-family: var(--font-ming);
}

.site-footer-inner {
  width: min(100%, var(--content));
  margin-inline: auto;
}

.footer-name {
  margin-bottom: 1rem;
  color: var(--navy-dark);
  font-weight: 700;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  margin-bottom: 1.5rem;
}

.footer-links a {
  min-height: 1.75rem;
}

.footer-note {
  max-width: 55rem;
  margin-bottom: 2rem;
  color: #28303a;
  font-size: 0.82rem;
}

.footer-resident-text {
  margin-bottom: 0.75rem;
  font: 0.78rem/1.5 var(--font-ming);
}

.footer-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--system-dark);
  font: 0.72rem/1.5 var(--font-ming);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.band-rest {
  display: grid;
  grid-template-columns: minmax(10rem, 0.6fr) minmax(0, 1.4fr);
  gap: clamp(2rem, 7vw, 6rem);
  align-items: center;
}

.band-rest h2 {
  margin: 0;
  font-family: var(--font-kai);
  font-weight: 400;
}

.band-rest p {
  margin: 0;
  padding: 1.25rem;
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  font-family: var(--font-ming);
}

.portal-icon-rest::before {
  top: 0.3rem;
  left: 0.18rem;
  width: 0.35rem;
  height: 0.35rem;
  background: var(--alert);
  box-shadow: 0.45rem 0 var(--navy), 0.22rem 0.42rem var(--success);
}

.page-rest .page-content {
  max-width: none;
}

.minesweeper {
  margin-top: 4rem;
  padding: clamp(1rem, 3vw, 2rem);
  border: 2px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  background: var(--system);
  box-shadow: 0.55rem 0.55rem 0 rgba(30, 43, 77, 0.2);
  font-family: var(--font-ui);
}

.minesweeper > h2 {
  margin: calc(clamp(1rem, 3vw, 2rem) * -1) calc(clamp(1rem, 3vw, 2rem) * -1) 1rem;
  padding: 0.35rem 0.6rem;
  border: 0;
  background: var(--navy);
  color: #fff;
  font: 700 1rem/1.4 var(--font-ui);
}

.game-intro,
.game-nojs {
  max-width: 48rem;
  font-size: 0.9rem;
}

.game-nojs {
  padding: 0.65rem;
  border: 2px solid var(--alert);
  background: var(--warm);
  font-weight: 700;
}

.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 1.5rem 0 0.75rem;
}

.difficulty-label {
  font-size: 0.82rem;
  font-weight: 700;
}

.game-toolbar select,
.game-toolbar button {
  min-height: 2.75rem;
  padding: 0.4rem 0.7rem;
}

.mode-controls {
  display: inline-flex;
  gap: 2px;
}

.mode-controls button[aria-pressed="true"] {
  border-color: var(--system-dark) var(--system-light) var(--system-light) var(--system-dark);
  background: var(--navy);
  color: #fff;
  box-shadow: inset 1px 1px var(--navy-dark);
}

.game-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(7rem, 1fr));
  gap: 2px;
  margin: 0.75rem 0;
}

.game-readout p {
  min-height: 2.25rem;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border: 2px solid;
  border-color: var(--system-dark) var(--system-light) var(--system-light) var(--system-dark);
  background: var(--navy-dark);
  color: #fff;
  font: 700 0.82rem/1.4 var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.game-readout output,
.game-readout time {
  color: #9ff5bf;
}

.board-scroll {
  max-width: 100%;
  padding: 0.45rem;
  overflow-x: auto;
  border: 2px solid;
  border-color: var(--system-dark) var(--system-light) var(--system-light) var(--system-dark);
  background: #9ca4af;
  scrollbar-color: var(--navy) var(--system);
}

.minesweeper-grid {
  display: grid;
  width: max-content;
  margin: 0 auto;
  touch-action: manipulation;
}

.minesweeper-grid[data-difficulty="beginner"] {
  grid-template-columns: repeat(9, 2rem);
}

.minesweeper-grid[data-difficulty="intermediate"] {
  grid-template-columns: repeat(16, 2rem);
}

.mine-cell {
  display: grid;
  place-items: center;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  min-height: 2rem;
  padding: 0;
  border-width: 2px;
  font: 700 0.86rem/1 var(--font-mono);
  touch-action: manipulation;
}

.mine-cell[data-revealed="true"] {
  border: 1px solid var(--system-mid);
  background: #e4e7eb;
  box-shadow: none;
  cursor: default;
}

.mine-cell[data-flagged="true"] {
  background: var(--warm);
  color: var(--alert);
}

.mine-cell[data-mine="true"] {
  background: var(--alert);
  color: #fff;
}

.mine-cell[data-count="1"] { color: #0000cc; }
.mine-cell[data-count="2"] { color: #0b6b3a; }
.mine-cell[data-count="3"] { color: #a51d16; }
.mine-cell[data-count="4"],
.mine-cell[data-count="5"],
.mine-cell[data-count="6"],
.mine-cell[data-count="7"],
.mine-cell[data-count="8"] { color: #551a8b; }

.game-status {
  min-height: 2.5rem;
  margin: 0.75rem 0;
  padding: 0.45rem 0.6rem;
  border-left: 0.3rem solid var(--navy);
  background: #fff;
  font-weight: 700;
}

.game-instructions {
  margin-top: 1.5rem;
  font-size: 0.85rem;
}

.game-instructions h3 {
  margin-bottom: 0.5rem;
  font: 700 0.88rem/1.4 var(--font-ui);
}

.game-instructions ul {
  margin-bottom: 0;
}

.under-construction {
  position: relative;
  margin-top: clamp(5rem, 10vw, 9rem);
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border: 3px dashed var(--navy);
  background: #fbfcff;
  font-family: var(--font-ui);
}

.under-construction h2 {
  max-width: 22ch;
  margin-top: 1.2rem;
  border: 0;
  font: 700 clamp(1.7rem, 4vw, 3.3rem)/1.15 var(--font-ui);
}

.construction-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.2rem 0.45rem;
  background: var(--warm);
  color: var(--alert);
  font: 700 0.78rem/1.4 var(--font-mono);
}

.construction-icon {
  position: relative;
  flex: 0 0 1.4rem;
  width: 1.4rem;
  height: 1.4rem;
}

.construction-icon::before {
  position: absolute;
  top: 0;
  left: 0.3rem;
  border-right: 0.4rem solid transparent;
  border-bottom: 1rem solid #ff5200;
  border-left: 0.4rem solid transparent;
  content: "";
  filter: drop-shadow(1px 1px 0 #6f2100);
  transform: rotate(-3deg);
}

.construction-icon::after {
  position: absolute;
  right: 0;
  bottom: 0.08rem;
  left: 0;
  height: 0.3rem;
  border: 1px solid #111;
  background: #fff600;
  box-shadow: inset 0 -0.1rem #ff5200;
  content: "";
}

.footer-creature-line {
  display: flex;
  align-items: center;
  min-height: 2rem;
  margin-bottom: 0.75rem;
  font: 0.78rem/1.5 var(--font-ming);
}

.footer-creature-trigger {
  position: relative;
  z-index: 2;
  display: inline-grid;
  flex: 0 0 1.75rem;
  place-items: center;
  width: 1.75rem;
  min-width: 1.75rem;
  height: 1.75rem;
  min-height: 1.75rem;
  margin-right: 0.35rem;
  padding: 0;
  transform: translateX(calc(var(--creature-step, 0) * 1em));
  transition: none;
}

.footer-creature-trigger[hidden] {
  display: none;
}

.footer-creature-trigger span {
  position: relative;
  width: 0.8rem;
  height: 0.65rem;
  background: var(--navy);
  box-shadow: -0.22rem 0.18rem var(--shirt-deep), 0.35rem 0.18rem var(--system-dark), 0.15rem -0.22rem var(--navy);
}

.footer-creature-trigger span::before {
  position: absolute;
  right: -0.2rem;
  bottom: -0.25rem;
  width: 0.2rem;
  height: 0.2rem;
  background: var(--alert);
  box-shadow: -0.65rem 0 var(--alert);
  content: "";
}

.footer-creature-trigger.is-step-b span {
  transform: translateY(-2px) skewX(-8deg);
}

.footer-creature-trigger.has-flag span::after {
  position: absolute;
  top: -0.7rem;
  right: -0.35rem;
  width: 0.45rem;
  height: 0.35rem;
  border-left: 2px solid var(--navy-dark);
  background: var(--success);
  content: "";
}

.creature-character {
  display: inline-block;
  min-width: 1em;
  text-align: center;
}

.creature-character.is-eaten {
  visibility: hidden;
}

.creature-dialog {
  width: min(calc(100% - 2rem), 24rem);
  padding: 1rem;
  border: 3px solid;
  border-color: var(--system-light) var(--system-dark) var(--system-dark) var(--system-light);
  border-radius: 0;
  background: var(--system);
  color: var(--ink);
  font-family: var(--font-ming);
  box-shadow: 0.6rem 0.6rem 0 rgba(17, 26, 49, 0.35);
}

.creature-dialog::backdrop {
  background: rgba(17, 26, 49, 0.68);
}

.creature-clear {
  margin: -1rem -1rem 1rem;
  padding: 0.35rem 0.6rem;
  background: var(--navy);
  color: #fff;
  font: 700 1.1rem/1.4 var(--font-ming);
  letter-spacing: 0.12em;
}

.creature-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.creature-dialog-actions button {
  padding: 0.45rem 0.8rem;
  font-family: var(--font-ming);
}

@media (max-width: 60rem) {
  .site-nav ul {
    justify-content: flex-start;
  }

  .hero-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .hero-text {
    grid-column: 1 / 6;
  }

  .hero-portrait {
    grid-column: 5 / 9;
  }

  .portal-directory {
    grid-column: 1 / 6;
  }

  .hero-utility {
    grid-column: 1 / 6;
  }

  .article-list > li {
    grid-template-columns: minmax(12rem, 1fr) minmax(8rem, 0.5fr);
  }

  .article-summary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 47.5rem) {
  html {
    scroll-padding-top: 5.5rem;
  }

  body {
    font-size: 1rem;
  }

  .browser-shell,
  .site-footer {
    width: 100%;
    margin: 0;
    border-right: 0;
    border-left: 0;
    box-shadow: none;
  }

  .browser-shell {
    border-top: 0;
  }

  .site-nav ul {
    display: flex;
    justify-content: flex-start;
    gap: 0;
  }

  .site-nav a {
    justify-content: flex-start;
    width: auto;
    min-height: 3rem;
    padding: 0.2rem 0.12rem 0.12rem;
    font-size: clamp(0.62rem, 2.8vw, 0.8rem);
    line-height: 1.1;
    text-align: left;
  }

  .nav-en {
    margin-left: 0;
    font: inherit;
  }

  .browser-shell[data-compact="true"] .browser-titlebar {
    display: none;
  }

  .browser-shell[data-compact="true"] .site-nav a {
    padding-inline: 0.12rem;
    font-size: clamp(0.62rem, 2.8vw, 0.68rem);
  }

  .hero {
    min-height: auto;
  }

  .hero::before {
    inset: 1rem;
  }

  .hero::after {
    right: 34%;
  }

  .hero-grid {
    /* 人物欄一併加寬；姓名字級同步收一格，窄畫面才不會被擠到換行 */
    grid-template-columns: minmax(0, 1fr) minmax(8rem, 38vw);
    grid-template-rows: auto auto auto;
    min-height: 0;
    padding: 2.75rem 1rem 1.25rem;
  }

  .hero-text {
    grid-column: 1;
    grid-row: 1;
  }

  .hero-name {
    display: block;
    font-size: clamp(3rem, 15vw, 5rem);
  }

  .hero-name-en {
    display: block;
    margin-top: 0.7rem;
    letter-spacing: 0.02em;
  }

  .hero-roles {
    font-size: 0.98rem;
  }

  .hero-portrait {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: start;
    width: 100%;
    margin-top: 2.5rem;
  }

  /* 人物自 R015 起是內嵌 SVG，不再是 <img>；選擇器一併更正，否則手機版沒有上限 */
  .hero-doctor {
    max-height: 26rem;
  }

  /* 選取框、佔位框與 hover 選取框在桌機刻意比人物寬一點；窄畫面沒有那個餘裕，
     負的左右 inset 會頂出 2–3px 的水平捲動，改成切齊人物邊界。 */
  .selection-frame {
    inset: 4% 0 0;
  }

  .hero-pick,
  .hero-loadframe {
    inset-inline: 0;
  }

  .portal-directory {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 1.5rem;
  }

  .portal-directory ul {
    grid-template-columns: 1fr;
  }

  .portal-directory li:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .portal-directory a {
    min-height: 3rem;
  }

  .hero-utility {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .band {
    padding-block: 5.5rem;
  }

  .band-viewpoint,
  .band-topics > ul,
  .band-rest,
  .location-brief,
  .human-sitemap li,
  .error-links {
    grid-template-columns: 1fr;
  }

  .band-viewpoint {
    gap: 1rem;
  }

  .band-viewpoint blockquote {
    font-size: clamp(2rem, 10vw, 3.3rem);
  }

  .article-list > li {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .article-summary {
    grid-column: auto;
  }

  .game-readout {
    grid-template-columns: 1fr;
  }

  .minesweeper {
    margin-inline: calc(var(--edge) * -0.35);
  }

  .under-construction {
    margin-top: 5rem;
  }

  .portrait-standing {
    float: none;
    width: min(65vw, 15rem);
    margin: 0 auto 3rem;
  }

  .page-head h1 {
    font-size: clamp(2.7rem, 14vw, 4.7rem);
  }

  .footer-meta {
    display: grid;
  }
}

@media (max-width: 25rem) {
  .site-nav a {
    font-size: 0.68rem;
  }

  .wordmark {
    gap: 0.45rem;
  }

  .wordmark-name {
    font-size: 0.95rem;
  }

  .wordmark-field {
    display: none;
  }

  .browser-titlebar {
    padding-left: 0.3rem;
  }

  .browser-home,
  .browser-home:visited {
    min-width: 5.75rem;
    padding-inline: 0.25rem;
  }

  .browser-controls i {
    width: 1.4rem;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr) 8rem;
  }

  .hero-name {
    font-size: 3rem;
  }

  .hero-eyebrow {
    font-size: 0.72rem;
  }

  .hero-roles {
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }

  .selection-frame {
    transform: none;
  }

  /* Hero 的完成狀態本來就是預設值，動畫關掉即是終態；
     只有掃描線沒有可接受的靜止樣子，整條移除。 */
  .hero-scan {
    display: none;
  }

  .footer-creature-trigger,
  .creature-dialog {
    display: none !important;
  }

  .creature-character.is-eaten {
    visibility: visible;
  }
}

@media print {
  body {
    background: #fff;
  }

  .preview-bar,
  .browser-toolbar,
  .browser-status,
  .site-footer,
  .portal-directory,
  .selection-frame,
  .hero-bands,
  .hero-loadframe,
  .hero-pick,
  .hero-scan {
    display: none;
  }

  .browser-shell {
    width: 100%;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .browser-chrome {
    position: static;
  }
}
