/* ==========================================================================
   《你的秘密，正在被保存》— CeQureX 後量子互動體驗
   Brand: CeQureX (Indigo / Violet / Blue / Cyan) · 警示：Warning orange
   字型全部為本機檔案（assets/fonts），無外部 CDN。
   ========================================================================== */

/* ---------- 本機字型 ---------- */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("assets/fonts/inter-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("assets/fonts/inter-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Roboto"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("assets/fonts/roboto-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Roboto"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("assets/fonts/roboto-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* 繁體中文：Noto Sans TC 子集（只含本遊戲用到的字）。
   新增文案若出現子集外的字，瀏覽器會自動改用系統中文字型顯示該字。 */
@font-face {
  font-family: "Noto Sans TC"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("assets/fonts/noto-sans-tc-400-subset.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans TC"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("assets/fonts/noto-sans-tc-700-subset.woff2") format("woff2");
}

/* ---------- Design tokens ---------- */
:root {
  --indigo: #1B1E3C;
  --indigo-2: #252A50;
  --indigo-3: #2E3463;
  --indigo-deep: #15183A;
  --violet: #5A4FD6;
  --blue: #2560FF;
  --blue-hover: #1E4FD6;
  --blue-pressed: #1A44B8;
  --cyan: #00B8D9;
  --charcoal: #1A1B23;
  --slate: #3A3F54;
  --gray: #6B7280;
  --line: #E6E8EF;
  --bg-subtle: #F7F8FB;
  --violet-tint: #E8E6FA;
  --blue-tint: #E9EFFF;
  --cyan-tint: #E0F7FA;
  --warn: #D68A0C;
  --warn-bright: #F2A53C;
  --warn-tint: #FCF1DF;

  --font-display: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --font-body: "Roboto", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;

  --radius-card: 12px;
  --radius-btn: 6px;
  --pad-x: calc(1rem + env(safe-area-inset-left));
  --pad-x-r: calc(1rem + env(safe-area-inset-right));
}

[data-theme="dark"] {
  --bg: var(--indigo);
  --fg: #FFFFFF;
  --fg-2: rgba(255, 255, 255, .80);
  --muted: rgba(255, 255, 255, .62);
  --line-c: rgba(255, 255, 255, .14);
  --surface: var(--indigo-2);
  --accent: var(--cyan);
  --hl: var(--cyan);
  --heading: #FFFFFF;
  --eyebrow: var(--cyan);
  --focus: var(--cyan);
  --btn2-border: rgba(255, 255, 255, .42);
  --btn2-hover: rgba(255, 255, 255, .08);
}
[data-theme="light"] {
  --bg: #FFFFFF;
  --fg: var(--charcoal);
  --fg-2: var(--slate);
  --muted: var(--gray);
  --line-c: var(--line);
  --surface: #FFFFFF;
  --accent: var(--violet);
  --hl: var(--violet);
  --heading: var(--indigo);
  --eyebrow: var(--violet);
  --focus: var(--blue);
  --btn2-border: #C9CCD8;
  --btn2-hover: var(--bg-subtle);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  /* 以視窗寬高共同縮放：1920×1080 ≈ 20px，筆電 / 手機 16px */
  font-size: clamp(16px, min(1.05vw, 1.95vh), 22px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
  background: var(--indigo);
}
html[data-theme="light"] { background: #FFFFFF; }

body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  line-height: 1.65;
  letter-spacing: .02em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

p { margin: 0; }
h1, h2, h3 { margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--blue); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 1.25rem; height: 1.25rem; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

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

:focus-visible { outline: 3px solid var(--focus, var(--blue)); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }

em.hl { font-style: normal; color: var(--hl); }

/* ---------- App shell ---------- */
.app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  background: var(--bg); color: var(--fg);
  transition: background-color .5s ease, color .5s ease;
}

.topbar {
  flex: none;
  display: flex; align-items: center; gap: 1rem;
  min-height: 3.5rem;
  padding: calc(.375rem + env(safe-area-inset-top)) var(--pad-x-r) .375rem var(--pad-x);
  border-bottom: 1px solid var(--line-c);
  background: var(--bg);
  transition: background-color .5s ease, border-color .5s ease;
  position: relative; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: .5rem; white-space: nowrap; color: var(--heading); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; letter-spacing: -.01em; }
.brand-zh { font-size: .8125rem; color: var(--muted); }
.brand-logo { height: 1.75rem; width: auto; display: block; }

.progress {
  flex: 1; display: flex; justify-content: center; align-items: center; gap: .5rem;
  list-style: none; margin: 0; padding: 0; min-width: 0;
}
.pg-step { display: flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.pg-bar { display: block; width: 1.75rem; height: 4px; border-radius: 2px; background: var(--line-c); }
.pg-step.is-done .pg-bar { background: var(--accent); opacity: .55; }
.pg-step.is-current .pg-bar { background: var(--accent); }
.pg-step.is-current .pg-label { color: var(--fg); font-weight: 500; }

.btn-home { margin-left: auto; }

.stage { flex: 1; min-height: 0; position: relative; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--bg); color: var(--fg);
}
.screen.is-entering { animation: screen-in .45s ease both; }
.screen.is-locked { overflow: hidden; }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.screen-body {
  position: relative;
  flex: 1 0 auto;
  width: 100%; max-width: 92rem; margin: 0 auto;
  padding: 1.25rem var(--pad-x-r) 1.5rem var(--pad-x);
}

.cta-bar {
  flex: none;
  position: sticky; bottom: 0; z-index: 6;
  display: flex; justify-content: center; gap: .75rem;
  padding: .75rem var(--pad-x-r) calc(.75rem + env(safe-area-inset-bottom)) var(--pad-x);
  background: var(--bg);
  border-top: 1px solid var(--line-c);
}

/* ---------- Typography ---------- */
.display {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.5rem, 4.8vw, 5.5rem); line-height: 1.12; letter-spacing: 0;
  color: var(--heading);
}
.h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.75rem, 3vw, 3.25rem); line-height: 1.28; color: var(--heading); }
.h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.375rem, 2.2vw, 2.375rem); line-height: 1.35; color: var(--heading); }
.h3 { font-family: var(--font-body); font-weight: 500; font-size: 1.0625rem; line-height: 1.4; color: var(--fg); }
.eyebrow {
  font-family: var(--font-body); font-weight: 700; font-size: .8125rem;
  letter-spacing: .12em; color: var(--eyebrow);
  margin-bottom: .5rem;
}
.lead { font-size: clamp(1.125rem, 1.7vw, 1.875rem); color: var(--fg-2); margin: 1.25rem 0 2rem; line-height: 1.55; }
.fine { font-size: .8125rem; color: var(--muted); margin-top: 1rem; line-height: 1.6; }
.title-bar { width: 70px; height: 4px; border-radius: 2px; background: var(--violet); margin: .75rem 0 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3rem; padding: .625rem 1.375rem;
  border-radius: var(--radius-btn); border: 1px solid transparent;
  font-family: var(--font-body); font-weight: 500; font-size: 1rem; line-height: 1.3;
  text-align: center; text-decoration: none; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
.btn .icon { width: 1.25em; height: 1.25em; }
.btn-primary { background: var(--blue); color: #FFFFFF; }
.btn-primary:active:not(:disabled) { background: var(--blue-pressed); }
.btn-secondary { background: transparent; color: var(--fg); border-color: var(--btn2-border); }
.btn-ghost { background: transparent; color: var(--fg); border-color: transparent; }
.btn-sm { min-height: 2.75rem; padding: .375rem .875rem; font-size: .9375rem; }
.btn-lg { min-height: 3.5rem; padding: .75rem 1.75rem; font-size: 1.125rem; }
.btn-xl { min-height: 4rem; padding: .875rem 2.5rem; font-size: 1.375rem; font-weight: 700; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
  .btn-secondary:hover:not(:disabled), .btn-ghost:hover:not(:disabled) { background: var(--btn2-hover); }
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem; border-radius: var(--radius-btn);
  border: 1px solid var(--line-c); background: transparent; color: var(--fg); cursor: pointer;
}

/* ---------- Brand motif: soft "X" bands ---------- */
.motif-x { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.motif-x::before, .motif-x::after {
  content: ""; position: absolute; top: -35%; left: 64%;
  width: 24%; height: 170%; border-radius: 16px;
  background: linear-gradient(180deg, var(--violet), var(--blue));
  opacity: .16; transform: rotate(45deg);
}
.motif-x::after { transform: rotate(-45deg); opacity: .1; }
.motif-x-sm::before, .motif-x-sm::after { left: 58%; width: 34%; opacity: .14; }
.motif-x-sm::after { opacity: .09; }

/* ==========================================================================
   1. 首頁
   ========================================================================== */
.home-grid {
  z-index: 1;
  display: grid; gap: 2rem; align-content: center;
  padding-top: 2rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}
.home-copy { max-width: 46rem; }
.home-actions { display: flex; flex-wrap: wrap; gap: 1rem; }
.notice {
  display: flex; gap: .875rem; align-items: flex-start;
  margin-top: 2rem; padding: 1rem 1.25rem; max-width: 42rem;
  border: 1px solid rgba(242, 165, 60, .5); border-left: 4px solid var(--warn-bright);
  border-radius: 8px; background: rgba(214, 138, 12, .1);
}
.notice-icon { color: var(--warn-bright); width: 1.5rem; height: 1.5rem; margin-top: .1rem; }
.notice-title { font-weight: 700; color: var(--warn-bright); font-size: 1.0625rem; }
.notice-body { margin-top: .25rem; color: var(--fg-2); font-size: .9375rem; }
.home-meta { margin-top: 1rem; color: var(--muted); font-size: .875rem; }

.home-visual { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.vault-art { width: min(100%, 22rem); height: auto; overflow: visible; }
.home-visual-cap { font-size: .8125rem; letter-spacing: .12em; color: var(--muted); }
.va-body { fill: var(--indigo-2); stroke: rgba(255, 255, 255, .18); stroke-width: 2; }
.va-door { fill: #20244A; stroke: rgba(0, 184, 217, .5); stroke-width: 2; }
.va-hinge { fill: var(--indigo-3); }
.va-ring { fill: none; stroke: url(#grad-violet-blue); stroke-width: 10; }
.va-dial { fill: var(--indigo); stroke: rgba(255, 255, 255, .22); stroke-width: 2; }
.va-ticks path { fill: none; stroke: rgba(255, 255, 255, .5); stroke-width: 3; stroke-linecap: round; }
.va-handle { transform-box: view-box; transform-origin: 210px 180px; animation: dial-turn 16s ease-in-out infinite; }
.va-handle path { fill: none; stroke: #FFFFFF; stroke-width: 8; stroke-linecap: round; }
.va-handle circle { fill: var(--cyan); }
.va-display { fill: var(--indigo); stroke: var(--cyan); stroke-width: 2; }
.va-digits { fill: var(--cyan); font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: 4px; }
.va-eye circle:first-child { fill: rgba(214, 138, 12, .16); stroke: var(--warn-bright); stroke-width: 2; }
.va-eye path { fill: none; stroke: var(--warn-bright); stroke-width: 2; }
.va-eye circle:last-child { fill: var(--warn-bright); }
.va-scan { fill: var(--cyan); opacity: .55; animation: scan 4s ease-in-out infinite; }
@keyframes scan { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(298px); } }
@keyframes dial-turn { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(120deg); } }

/* ==========================================================================
   2. 1A2B 猜密碼
   ========================================================================== */
.screen-game .screen-body {
  display: flex; flex-direction: column; gap: .75rem;
  flex: 1 1 auto; min-height: 33rem;
  padding-top: .875rem;
  padding-bottom: calc(.875rem + env(safe-area-inset-bottom));
  max-width: 84rem;
}
.game-head .eyebrow { margin-bottom: .25rem; }
.game-sub { color: var(--fg-2); font-size: .9375rem; margin-top: .125rem; }

.game-status { display: flex; align-items: stretch; gap: .625rem; }
.stat {
  display: flex; align-items: center; gap: .625rem;
  padding: .375rem .875rem .375rem .5rem;
  border: 1px solid var(--line-c); border-radius: 10px; background: var(--surface);
}
.timer-ring { width: 2.75rem; height: 2.75rem; transform: rotate(-90deg); flex: none; }
.tr-track { fill: none; stroke: rgba(255, 255, 255, .12); stroke-width: 5; }
.tr-bar {
  fill: none; stroke: var(--cyan); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 0;
  transition: stroke-dashoffset .3s linear, stroke .3s ease;
}
.stat-text { display: flex; flex-direction: column; line-height: 1.15; }
.stat-label { font-size: .75rem; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: 1.625rem; font-variant-numeric: tabular-nums; }
.stat-value small { font-family: var(--font-body); font-size: .75rem; font-weight: 500; margin-left: .2rem; color: var(--fg-2); }
.stat-timer.is-warn .tr-bar { stroke: var(--warn-bright); }
.stat-timer.is-warn .stat-value { color: var(--warn-bright); }
.stat-timer.is-paused .stat-value { color: var(--muted); }
.stat-tries { padding-left: .875rem; }
.pips { display: flex; gap: 4px; }
.pip { width: .5rem; height: 1.75rem; border-radius: 2px; background: var(--cyan); transition: background-color .3s ease; }
.pip.is-used { background: rgba(255, 255, 255, .16); }
.btn-rules { margin-left: auto; align-self: center; }

.game-main {
  position: relative;
  flex: 1; min-height: 0;
  display: grid; gap: .75rem;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(4.75rem, 1fr) auto;
  grid-template-areas: "vault" "history" "pad";
}
.vault-panel { grid-area: vault; }
.history-panel { grid-area: history; }
.pad-area { grid-area: pad; --key-h: clamp(3rem, 7.4vh, 5.5rem); }

/* 規則面板（覆蓋於遊戲區上方，倒數不暫停） */
.rules-panel {
  position: absolute; z-index: 25; top: 0; right: 0;
  width: min(100%, 34rem); max-height: 100%; overflow-y: auto;
  padding: 1rem 1.25rem 1.25rem;
  border-radius: var(--radius-card); border: 1px solid var(--cyan);
  background: var(--indigo-deep);
}
.rules-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.rules-list { margin: 0; padding-left: 1.25rem; display: grid; gap: .25rem; font-size: .9375rem; color: var(--fg-2); }
.rules-list li::marker { color: var(--cyan); }
.rules-example {
  margin-top: .75rem; padding: .625rem .875rem; border-radius: 8px;
  background: rgba(0, 184, 217, .1); font-size: .9375rem; color: var(--fg);
}

.vault-panel {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: .75rem 1rem .625rem;
  border: 1px solid var(--line-c); border-radius: var(--radius-card); background: var(--surface);
}
.vault-head { display: flex; align-items: center; gap: .5rem; color: var(--fg-2); font-size: .875rem; }
.vault-lock { color: var(--cyan); }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: .625rem; width: min(100%, 22rem); }
.slot {
  display: flex; align-items: center; justify-content: center;
  height: clamp(3.25rem, 9vh, 7.25rem);
  border-radius: 10px; border: 2px solid rgba(255, 255, 255, .18); background: var(--indigo);
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.75rem, 5.4vh, 4.25rem);
  font-variant-numeric: tabular-nums; color: #FFFFFF; line-height: 1;
  transition: border-color .15s ease, color .2s ease, background-color .2s ease;
}
.slot:empty::after { content: ""; width: 28%; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .22); }
.slot.is-filled { border-color: rgba(255, 255, 255, .45); }
.slot.is-active { border-color: var(--cyan); }
.slot.is-answer { border-color: var(--cyan); color: var(--cyan); background: rgba(0, 184, 217, .08); }
.slots.is-shake { animation: shake .36s ease; }
.slots:focus { outline: none; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

.game-msg { min-height: 1.6em; font-size: .9375rem; text-align: center; color: var(--fg-2); }
.game-msg.is-error { color: var(--warn-bright); }
.game-msg.is-result { color: var(--cyan); font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem; letter-spacing: .06em; }

.history-panel {
  display: flex; flex-direction: column; min-height: 0;
  padding: .625rem .875rem;
  border: 1px solid var(--line-c); border-radius: var(--radius-card); background: var(--surface);
}
.history-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .125rem .75rem; margin-bottom: .375rem; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .375rem; font-size: .75rem; color: var(--muted); }
.legend .lg + span { margin-right: .375rem; }
.lg { display: inline-block; width: .625rem; height: .625rem; border-radius: 50%; }
.lg-a { background: var(--cyan); }
.lg-b { border: 2px solid var(--cyan); }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: .375rem; align-content: start; overflow-y: auto; min-height: 0; }
.h-item {
  display: grid; grid-template-columns: 1.75rem 1fr auto auto; align-items: center; gap: .75rem;
  padding: .3rem .625rem; border-radius: 8px; background: rgba(255, 255, 255, .05);
}
.h-item.is-new { animation: item-in .35s ease; }
.h-idx { font-family: var(--font-display); font-weight: 600; font-size: .8125rem; color: var(--muted); }
.h-guess { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.h-res { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.h-res .ra { color: var(--cyan); }
.h-dots { display: flex; gap: 3px; }
.dot { width: .625rem; height: .625rem; border-radius: 50%; background: rgba(255, 255, 255, .14); }
.dot-a { background: var(--cyan); }
.dot-b { background: transparent; border: 2px solid var(--cyan); }
.history-empty { color: var(--muted); font-size: .875rem; }
@keyframes item-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.keypad {
  display: grid; gap: .5rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, var(--key-h));
}
.key {
  display: flex; align-items: center; justify-content: center; gap: .375rem;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, .14);
  background: var(--indigo-2); color: #FFFFFF;
  font-family: var(--font-display); font-weight: 600; font-size: clamp(1.375rem, 3.4vh, 2.375rem); line-height: 1;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .12s ease, border-color .12s ease, transform .08s ease;
}
.key-fn { font-family: var(--font-body); font-weight: 500; font-size: .9375rem; color: var(--fg-2); }
.key-submit { grid-column: 4; grid-row: 3 / span 2; background: var(--blue); border-color: var(--blue); color: #FFFFFF; font-family: var(--font-body); font-weight: 700; font-size: 1.125rem; }
.key-zero { grid-column: 1 / span 3; grid-row: 4; }
.key:active:not(:disabled), .key.is-pressed { background: var(--blue); border-color: var(--blue); color: #FFFFFF; transform: scale(.97); }
.key-submit:active:not(:disabled), .key-submit.is-pressed { background: var(--blue-pressed); }
.key:disabled { opacity: .35; cursor: not-allowed; }
@media (hover: hover) {
  .key:hover:not(:disabled) { background: var(--indigo-3); }
  .key-submit:hover:not(:disabled) { background: var(--blue-hover); }
}

.game-end {
  display: flex; flex-direction: column; justify-content: center; gap: .5rem; text-align: center;
  min-height: calc(var(--key-h) * 4 + 1.5rem);
  padding: 1rem 1.25rem;
  border: 1px solid var(--line-c); border-radius: var(--radius-card); background: var(--surface);
  animation: item-in .4s ease;
}
.end-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.5rem, 2.4vw, 2.25rem); }
.end-title.is-win { color: var(--cyan); }
.end-body { color: var(--fg-2); margin-bottom: .5rem; }

/* 開局說明 */
.game-intro {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem var(--pad-x-r) calc(1rem + env(safe-area-inset-bottom)) var(--pad-x);
  overflow-y: auto;
  background: rgba(21, 24, 58, .92);
}
.intro-card {
  width: min(100%, 36rem); margin: auto;
  padding: 1.5rem 1.5rem 1.25rem;
  border-radius: 16px; border: 1px solid var(--line-c); background: var(--indigo-2);
}
.intro-card .h2 { margin-bottom: .875rem; }
.intro-note { margin: 1rem 0; font-size: .875rem; color: var(--muted); }

/* ==========================================================================
   3. 輸入紀錄揭曉
   ========================================================================== */
.reveal-grid { display: grid; gap: 1.25rem; align-content: start; grid-template-areas: "head" "rec" "copy"; }
.reveal-head { grid-area: head; }
.recorder { grid-area: rec; }
.reveal-copy { grid-area: copy; }
.reveal-copy .callout-dark { margin-top: 0; }
.callout-dark {
  display: flex; gap: .875rem; align-items: flex-start;
  margin-top: 1.5rem; padding: 1.125rem 1.25rem;
  border-radius: var(--radius-card); background: var(--indigo-2); border-left: 4px solid var(--cyan);
}
.callout-dark .icon { color: var(--cyan); width: 1.5rem; height: 1.5rem; margin-top: .15rem; }
.callout-strong { font-weight: 700; font-size: 1.125rem; margin-bottom: .375rem; }

.recorder {
  padding: 1rem 1.125rem;
  border: 1px solid var(--line-c); border-radius: var(--radius-card); background: var(--indigo-deep);
}
.recorder-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line-c); }
.rec-dot { width: .75rem; height: .75rem; border-radius: 50%; background: var(--warn-bright); animation: blink 1.4s steps(2, jump-none) infinite; }
.rec-tag { font-family: var(--font-display); font-weight: 700; font-size: .8125rem; letter-spacing: .14em; color: var(--warn-bright); }
.recorder-titles { flex: 1; min-width: 9rem; }
.recorder-sub { font-size: .8125rem; color: var(--muted); }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: .25; } }

.replay-list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .5rem; }
.rp-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .875rem;
  padding: .625rem .875rem; border-radius: 8px;
  background: rgba(255, 255, 255, .04); border: 1px solid transparent;
  transition: opacity .3s ease, border-color .3s ease;
}
.rp-item.is-pending { opacity: .28; }
.rp-item.is-playing { border-color: var(--cyan); }
.rp-meta { display: flex; flex-direction: column; line-height: 1.35; font-size: .8125rem; color: var(--muted); min-width: 0; }
.rp-meta strong { color: var(--fg); font-weight: 500; font-size: .9375rem; }
.rp-digits { display: flex; gap: .375rem; }
.rp-digit {
  width: 2.25rem; height: 2.75rem; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid rgba(255, 255, 255, .16); background: var(--indigo);
  font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; color: transparent;
  transition: color .15s ease, border-color .15s ease;
}
.rp-digit.is-shown { color: #FFFFFF; border-color: var(--cyan); }
.rp-res { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; min-width: 3.25rem; text-align: right; opacity: 0; transition: opacity .2s ease; }
.rp-res.is-shown { opacity: 1; }
.rp-res .ra { color: var(--cyan); }
.replay-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .375rem; padding: 2rem 1rem 1.5rem; }
.replay-empty .icon { width: 2rem; height: 2rem; color: var(--cyan); }
.replay-empty-title { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.replay-empty-sub { color: var(--muted); font-size: .9375rem; }
.recorder-count { margin-top: .75rem; font-size: .8125rem; color: var(--muted); text-align: right; }

/* ==========================================================================
   4. 加密資料被保存
   ========================================================================== */
.harvest-body { display: flex; flex-direction: column; }
.scene-banner {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; margin-bottom: 1rem;
  border-radius: 999px; border: 1px solid var(--cyan);
  background: rgba(0, 184, 217, .1); color: var(--cyan);
  font-weight: 700; font-size: 1rem;
  animation: item-in .5s ease;
}

.flow {
  display: grid; gap: .875rem; margin: 1.25rem 0 .5rem;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "sender" "channel" "observer";
}
.flow-sender { grid-area: sender; display: flex; flex-direction: column; gap: .5rem; }
.flow-channel { grid-area: channel; display: flex; align-items: center; gap: .75rem; }
.flow-observer { grid-area: observer; display: flex; flex-direction: column; align-items: stretch; }

.node-label, .flow-receiver { display: inline-flex; align-items: center; gap: .375rem; font-size: .875rem; color: var(--fg-2); }
.flow-receiver { flex: none; flex-direction: column; gap: .125rem; font-size: .8125rem; }
.flow-receiver .icon { width: 1.75rem; height: 1.75rem; color: var(--fg); }

.msg-card {
  position: relative;
  padding: 1rem 1.125rem .875rem; border-radius: var(--radius-card);
  background: #FFFFFF; color: var(--charcoal);
}
.msg-tag { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .06em; color: var(--violet); }
.msg-text { font-size: 1.125rem; line-height: 1.6; margin: .25rem 0 .5rem; }
.msg-lock {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .2rem .625rem; border-radius: 999px;
  background: var(--cyan-tint); color: #006E82; font-size: .8125rem; font-weight: 700;
  opacity: 0; transform: translateY(4px); transition: opacity .35s ease, transform .35s ease;
}
.msg-lock .icon { width: 1rem; height: 1rem; }
.st-1 .msg-lock { opacity: 1; transform: none; }

.track { position: relative; flex: 1; height: 3.5rem; }
.track-line { position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed rgba(255, 255, 255, .3); }
.packet {
  position: absolute; top: 50%; left: 0; transform: translate(0, -50%);
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .4rem .7rem; border-radius: 8px;
  border: 1px solid var(--cyan); background: var(--indigo-2); color: var(--fg);
  font-family: var(--font-mono); font-size: .8125rem; letter-spacing: .04em; white-space: nowrap;
  opacity: 0;
  transition: left 1.6s ease-in-out, transform 1.6s ease-in-out, opacity .3s ease;
}
.packet .icon { width: 1rem; height: 1rem; color: var(--cyan); }
.st-2 .packet { opacity: 1; }
.st-3 .packet { left: 100%; transform: translate(-100%, -50%); }

.observer {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .875rem 1rem; border-radius: var(--radius-card);
  border: 1px solid rgba(242, 165, 60, .5); background: rgba(214, 138, 12, .07);
  opacity: .3; transition: opacity .5s ease;
}
.st-3 .observer { opacity: 1; }
.observer-eye { width: 1.75rem; height: 1.75rem; color: var(--warn-bright); margin-top: .1rem; }
.observer-label { font-size: .8125rem; color: var(--fg-2); }
.observer-hex { font-family: var(--font-mono); font-size: .9375rem; letter-spacing: .06em; color: var(--fg); word-break: normal; overflow-wrap: anywhere; margin: .125rem 0; }
.observer-note { font-size: .8125rem; color: var(--warn-bright); font-weight: 700; }

.copy-arrow {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 3rem; color: var(--warn-bright); font-size: .8125rem; font-weight: 700;
  opacity: .25; transition: opacity .4s ease;
}
.copy-arrow::before { content: ""; position: absolute; left: 50%; top: .25rem; bottom: .5rem; border-left: 2px dashed currentColor; }
.copy-arrow::after {
  content: ""; position: absolute; left: calc(50% - 6px); bottom: 0;
  border-style: solid; border-width: 9px 6px 0 6px; border-color: currentColor transparent transparent transparent;
}
.copy-arrow span { position: relative; z-index: 1; padding: .125rem .5rem; background: var(--bg); }
.st-4 .copy-arrow { opacity: 1; }

.archive {
  padding: .75rem 1rem; border-radius: var(--radius-card);
  border: 1px dashed rgba(255, 255, 255, .32); background: var(--indigo-deep);
}
.archive-head { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.archive-head .icon { color: var(--warn-bright); }
.archive-count { margin-left: auto; font-size: .8125rem; font-weight: 500; color: var(--muted); }
.archive-slot { min-height: 2.75rem; margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.saved-packet {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .35rem .65rem; border-radius: 8px;
  border: 1px solid var(--cyan); background: var(--indigo-2);
  font-family: var(--font-mono); font-size: .8125rem; color: var(--fg-2);
  animation: drop-in .5s ease both;
}
.saved-packet .icon { width: 1rem; height: 1rem; color: var(--cyan); }
@keyframes drop-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

.key-msg {
  margin-top: 1.25rem; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.375rem, 2.6vw, 2.75rem); line-height: 1.4;
  opacity: 0; transform: translateY(8px); transition: opacity .5s ease, transform .5s ease;
}
.st-5 .key-msg { opacity: 1; transform: none; }
.fine-center { text-align: center; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .375rem; }
.sim-chip {
  display: inline-block; padding: .05rem .5rem; border-radius: 4px;
  border: 1px solid var(--line-c); font-size: .75rem; font-weight: 700; color: var(--fg-2);
}

/* ==========================================================================
   5. 未來量子威脅
   ========================================================================== */
.quantum-body { display: flex; flex-direction: column; }
.sim-badge {
  position: sticky; top: .5rem; z-index: 7;
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .45rem .875rem; margin-bottom: 1rem;
  border-radius: 6px; border: 1px solid rgba(255, 255, 255, .4);
  background: var(--indigo-2); color: #FFFFFF;
  font-size: .9375rem; font-weight: 700;
}
.sim-badge .icon { color: var(--cyan); }
.quantum-title { max-width: 60rem; }

.timeline { list-style: none; margin: 1.5rem 0 1.25rem; padding: 0; display: grid; gap: 1.25rem; }
.tl-step {
  position: relative;
  display: grid; grid-template-columns: 2.75rem minmax(0, 1fr);
  grid-template-areas: "dot text" "dot visual";
  gap: .25rem .875rem;
  opacity: .32; transition: opacity .5s ease;
}
.tl-step.is-on { opacity: 1; }
.tl-step::before {
  content: ""; position: absolute; left: calc(1.375rem - 1px); top: 2.75rem; bottom: -1.25rem;
  border-left: 2px solid rgba(255, 255, 255, .2); transition: border-color .5s ease;
}
.tl-step:last-child::before { display: none; }
.tl-step.is-done::before { border-color: var(--cyan); }
.tl-dot {
  grid-area: dot; position: relative; z-index: 1;
  width: 2.75rem; height: 2.75rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--cyan); color: var(--cyan); background: var(--indigo);
}
.tl-dot-warn { border-color: var(--warn-bright); color: var(--warn-bright); }
.tl-text { grid-area: text; }
.tl-label { font-family: var(--font-display); font-weight: 700; font-size: 1.1875rem; }
.tl-desc { color: var(--fg-2); font-size: .9375rem; margin-top: .125rem; }
.tl-visual { grid-area: visual; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .5rem; }
.mini-packet {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .3rem .6rem; border-radius: 6px;
  border: 1px solid var(--cyan); background: var(--indigo-2);
  font-family: var(--font-mono); font-size: .75rem; color: var(--fg-2);
}
.mini-packet .icon { width: 1rem; height: 1rem; color: var(--cyan); }
.mini-packet-warn { border-color: var(--warn-bright); }
.mini-packet-warn .icon { color: var(--warn-bright); }
.tl-chip { font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--line-c); color: var(--fg-2); }
.tl-chip-warn { border-color: var(--warn-bright); color: var(--warn-bright); }
.stack { position: relative; display: inline-block; width: 4.5rem; height: 2.25rem; }
.stack span {
  position: absolute; left: 0; width: 3.5rem; height: 1.25rem; border-radius: 4px;
  border: 1px solid var(--cyan); background: var(--indigo-2);
  opacity: 0; transform: translateY(-6px); transition: opacity .35s ease, transform .35s ease;
}
.stack span:nth-child(1) { top: 1rem; left: 0; }
.stack span:nth-child(2) { top: .5rem; left: .5rem; transition-delay: .25s; }
.stack span:nth-child(3) { top: 0; left: 1rem; transition-delay: .5s; }
.tl-step.is-on .stack span { opacity: 1; transform: none; }

.quantum-bottom { display: grid; gap: 1rem; }
.exposure {
  padding: 1rem 1.125rem; border-radius: var(--radius-card);
  border: 1px solid rgba(255, 255, 255, .14); background: var(--indigo-deep);
  transition: border-color .5s ease;
}
.exposure.is-risk { border-color: var(--warn-bright); }
.exposure-tag { display: flex; align-items: center; gap: .375rem; font-size: .8125rem; font-weight: 700; color: var(--muted); transition: color .5s ease; }
.exposure.is-risk .exposure-tag { color: var(--warn-bright); }
.exposure-text { margin-top: .5rem; font-size: 1.125rem; line-height: 1.8; word-break: break-all; }
.ch { display: inline-block; min-width: .5em; transition: color .4s ease, background-color .4s ease; }
.ch.is-masked { color: transparent; background: rgba(255, 255, 255, .16); border-radius: 2px; margin: 0 1px; }
.ch.is-exposed { color: var(--warn-bright); background: transparent; }
.hndl {
  padding: 1rem 1.25rem; border-radius: var(--radius-card);
  background: var(--indigo-2); border-left: 4px solid var(--warn-bright);
}
.hndl-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; }
.hndl-en { font-family: var(--font-body); font-weight: 500; font-size: .8125rem; letter-spacing: .08em; color: var(--warn-bright); text-transform: uppercase; }
.hndl-body { margin-top: .375rem; font-size: 1.0625rem; color: var(--fg); }
.hndl .fine { margin-top: .625rem; }

/* ==========================================================================
   6. 選擇防護方式（白色品牌畫布）
   ========================================================================== */
.defense-grid { display: grid; gap: 1.5rem; align-content: start; }
.screen-defense .h2 { color: var(--indigo); }
.options { display: grid; gap: .75rem; margin-top: 1.5rem; }
.opt {
  display: flex; align-items: center; gap: 1rem; width: 100%;
  min-height: 4rem; padding: .875rem 1.25rem;
  border-radius: 10px; border: 2px solid var(--line); background: #FFFFFF; color: var(--charcoal);
  font-family: var(--font-body); font-weight: 500; font-size: 1.125rem; line-height: 1.45; text-align: left;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, background-color .2s ease;
}
.opt-key {
  flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--violet-tint); color: var(--violet);
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
}
.opt-text { flex: 1; }
.opt-mark { flex: none; width: 1.5rem; height: 1.5rem; }
.opt.is-tried { background: var(--bg-subtle); color: var(--slate); }
.opt.is-tried .opt-key { background: var(--line); color: var(--gray); }
.opt.is-tried .opt-mark { color: var(--gray); }
.opt.is-correct { border-color: var(--violet); background: var(--violet-tint); }
.opt.is-correct .opt-key { background: var(--violet); color: #FFFFFF; }
.opt.is-correct .opt-mark { color: var(--violet); }
.opt:disabled { cursor: default; }
.opt:disabled:not(.is-correct) { opacity: .5; }
@media (hover: hover) { .opt:hover:not(:disabled) { border-color: var(--blue); } }

.quiz-feedback { margin-top: 1rem; }
.fb { display: flex; gap: .75rem; align-items: flex-start; padding: .875rem 1rem; border-radius: 10px; background: var(--blue-tint); color: var(--charcoal); animation: item-in .3s ease; }
.fb .icon { color: var(--blue); width: 1.5rem; height: 1.5rem; }
.fb-tag { font-weight: 700; color: var(--blue); }
.fb-ok { background: var(--violet-tint); }
.fb-ok .icon, .fb-ok .fb-tag { color: var(--violet); }
.quiz-explain { margin-top: 1rem; padding: 1.25rem 1.5rem; border-radius: var(--radius-card); background: var(--bg-subtle); border-left: 4px solid var(--violet); animation: item-in .4s ease; }
.quiz-explain-tag { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; font-weight: 700; color: var(--violet); }
.quiz-explain-tag .icon { width: 1.375rem; height: 1.375rem; }
.quiz-explain-main { font-size: 1.0625rem; color: var(--charcoal); }
.quiz-explain-sub { margin-top: .5rem; color: var(--slate); font-size: .9375rem; }

.shield-panel {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  min-height: 19rem; padding: 2rem 1.5rem; text-align: center;
  border-radius: 16px; background: var(--indigo); color: #FFFFFF;
}
.shield-panel::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%);
  opacity: 0; transition: opacity .9s ease;
}
.shield-panel.is-upgraded::before { opacity: 1; }
.shield-panel > :not(.motif-x) { position: relative; }
.shield-art { width: min(55%, 14rem); height: auto; overflow: visible; }
.sh-outline { fill: none; stroke: rgba(255, 255, 255, .4); stroke-width: 4; stroke-dasharray: 12 9; transition: stroke .5s ease; }
.sh-fill { fill: url(#grad-violet-blue); opacity: 0; transform-box: view-box; transform-origin: 120px 130px; transform: scale(.82); transition: opacity .6s ease, transform .7s ease; }
.sh-broken rect, .sh-broken path { fill: none; stroke: var(--warn-bright); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.sh-broken { transition: opacity .4s ease; }
.sh-ok path { fill: none; stroke: #FFFFFF; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 130; stroke-dashoffset: 130; transition: stroke-dashoffset .6s ease .45s; }
.sh-pqc { fill: #FFFFFF; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: 3px; opacity: 0; transition: opacity .4s ease .8s; }
.is-upgraded .sh-outline { stroke: #FFFFFF; stroke-dasharray: none; }
.is-upgraded .sh-fill { opacity: 1; transform: scale(1); }
.is-upgraded .sh-broken { opacity: 0; }
.is-upgraded .sh-ok path { stroke-dashoffset: 0; }
.is-upgraded .sh-pqc { opacity: 1; }
.shield-tag {
  display: inline-block; padding: .2rem .7rem; border-radius: 999px;
  border: 1px solid var(--warn-bright); color: var(--warn-bright);
  font-size: .8125rem; font-weight: 700; letter-spacing: .06em;
}
.is-upgraded .shield-tag { border-color: #FFFFFF; color: #FFFFFF; }
.shield-title { margin-top: .5rem; font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; }
.shield-sub { margin-top: .25rem; color: rgba(255, 255, 255, .8); font-size: .9375rem; }

/* ==========================================================================
   7. 結果與產品介紹（白色品牌畫布）
   ========================================================================== */
.result-body { display: flex; flex-direction: column; gap: 1.75rem; }
.result-top { display: grid; gap: 1.5rem; align-items: center; }
.result-card {
  position: relative; overflow: hidden;
  padding: 1.5rem 1.5rem 1.25rem; border-radius: 16px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--violet) 100%); color: #FFFFFF;
}
.result-card > :not(.motif-x) { position: relative; }
.rc-head { display: flex; align-items: center; gap: 1rem; }
.rc-emblem { width: 3.5rem; height: 3.5rem; flex: none; fill: none; stroke: #FFFFFF; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow-on-dark { color: rgba(255, 255, 255, .8); margin-bottom: .25rem; }
.rc-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.75rem, 3vw, 3rem); line-height: 1.2; }
.rc-stats-title { margin: 1.25rem 0 .5rem; font-size: .875rem; color: rgba(255, 255, 255, .8); }
.rc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 0; }
.rc-stats > div { padding: .75rem 1rem; border-radius: 10px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); }
.rc-stats dt { font-size: .8125rem; color: rgba(255, 255, 255, .8); }
.rc-stats dd { margin: .125rem 0 0; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.3; }
.rc-stats dd small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .8125rem; line-height: 1.3; opacity: .85; }
.rc-disclaimer { margin-top: .875rem; font-size: .8125rem; color: rgba(255, 255, 255, .82); }
.rc-brand { margin-top: .75rem; font-family: var(--font-display); font-size: .75rem; color: rgba(255, 255, 255, .62); }

.result-message { display: flex; flex-direction: column; gap: .5rem; }
.key-statement { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.5rem, 2.7vw, 2.875rem); line-height: 1.38; color: var(--indigo); }
.bridge { font-size: clamp(1.0625rem, 1.4vw, 1.5rem); color: var(--slate); }
.share-slot { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: .75rem; }
.share-msg { font-size: .875rem; color: var(--violet); }

.products { list-style: none; margin: .25rem 0 0; padding: 0; display: grid; gap: .875rem; grid-template-columns: minmax(0, 1fr); }
.product {
  position: relative; --pc: var(--blue); --pc-tint: var(--blue-tint); --pc-ink: var(--blue);
  display: flex; flex-direction: column; gap: .5rem;
  padding: 1.125rem 1.25rem; border-radius: 10px; border: 2px solid var(--pc); background: #FFFFFF;
}
.product[data-color="cyan"] { --pc: var(--cyan); --pc-tint: var(--cyan-tint); --pc-ink: #00879F; }
.product[data-color="blue"] { --pc: var(--blue); --pc-tint: var(--blue-tint); --pc-ink: var(--blue); }
.product[data-color="violet"] { --pc: var(--violet); --pc-tint: var(--violet-tint); --pc-ink: var(--violet); }
.product[data-color="indigo"] { --pc: var(--indigo); --pc-tint: var(--line); --pc-ink: var(--indigo); }
.p-head { display: flex; align-items: center; gap: .75rem; }
.p-icon { width: 2.75rem; height: 2.75rem; flex: none; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--pc-tint); color: var(--pc-ink); }
.p-icon .icon { width: 1.5rem; height: 1.5rem; }
.p-step { font-size: .75rem; font-weight: 700; letter-spacing: .1em; color: var(--violet); }
.p-name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1.25; color: var(--indigo); letter-spacing: 0; }
.p-name sup { font-size: .55em; font-weight: 600; margin-left: .05em; }
.p-desc { color: var(--slate); font-size: .9375rem; }
.p-link { font-size: .875rem; font-weight: 500; }
.website { font-size: .9375rem; margin-top: .75rem; }
.website a { display: inline-flex; align-items: center; gap: .375rem; color: var(--blue); font-weight: 500; text-decoration: none; }
.website a .icon { width: 1rem; height: 1rem; }
.cta-bar-split .btn { flex: 1 1 0; max-width: 18rem; }

/* ==========================================================================
   雙人連線
   ========================================================================== */
.duo-hint { margin-top: .75rem; font-size: .875rem; color: var(--muted); }
.lobby-body { display: flex; justify-content: center; align-items: flex-start; }
.lobby-card {
  position: relative; width: min(100%, 40rem); margin: 0 auto;
  padding: 1.5rem; border-radius: 16px; border: 1px solid var(--line-c); background: var(--indigo-2);
}
.lobby-panel { margin-top: 1rem; }
.lobby-intro { color: var(--fg-2); font-size: 1.0625rem; }
.lobby-sub { color: var(--fg-2); }
.consent {
  margin-top: 1rem; padding: 1rem 1.125rem; border-radius: 10px;
  background: var(--indigo-deep); border-left: 4px solid var(--warn-bright);
}
.consent-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--warn-bright); }
.consent-list { margin: .5rem 0 0; padding-left: 1.25rem; display: grid; gap: .25rem; font-size: .9375rem; color: var(--fg-2); }
.consent-check {
  display: flex; align-items: center; gap: .75rem; margin-top: .875rem;
  min-height: 3rem; padding: .5rem .75rem; border-radius: 8px; border: 1px solid var(--line-c);
  cursor: pointer; font-weight: 500;
}
.consent-check input { width: 1.375rem; height: 1.375rem; margin: 0; flex: none; accent-color: var(--cyan); }
.lobby-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; }
.lobby-actions .btn { flex: 1 1 12rem; }
.join-form { margin-top: 1rem; }
.join-label { display: block; margin-bottom: .375rem; font-size: .875rem; color: var(--fg-2); }
.join-row { display: flex; gap: .75rem; }
.code-input {
  flex: 1; min-width: 0; min-height: 3.5rem; padding: 0 1rem;
  border-radius: 8px; border: 2px solid rgba(255, 255, 255, .3); background: var(--indigo); color: #FFFFFF;
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; letter-spacing: .3em; text-transform: uppercase;
}
.code-input::placeholder { color: rgba(255, 255, 255, .28); }
.code-input:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; border-color: var(--cyan); }
.lobby-msg { min-height: 1.5em; margin-top: .75rem; font-size: .9375rem; color: var(--warn-bright); }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin-top: 1rem; }
.qr { width: min(66vw, 15rem); aspect-ratio: 1 / 1; padding: .625rem; border-radius: 12px; background: #FFFFFF; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr-dark { fill: var(--indigo); }
.room-code { display: flex; flex-direction: column; align-items: center; }
.room-code-label { font-size: .8125rem; color: var(--muted); }
.room-code-value { padding-left: .3em; font-family: var(--font-display); font-weight: 700; font-size: 2.25rem; letter-spacing: .3em; color: var(--cyan); }
.lobby-hint { margin-top: 1rem; text-align: center; font-size: .875rem; color: var(--muted); }
.qr-scope { margin-top: .75rem; padding: .625rem .875rem; border-radius: 8px; border: 1px solid rgba(0, 184, 217, .45); background: rgba(0, 184, 217, .08); font-size: .875rem; color: var(--fg-2); }
.qr-scope.is-warn { border-color: rgba(242, 165, 60, .6); background: rgba(214, 138, 12, .1); color: var(--warn-bright); }
.lobby-status { display: flex; align-items: center; justify-content: center; gap: .625rem; margin-top: 1rem; font-weight: 700; }
.pulse { width: .75rem; height: .75rem; border-radius: 50%; background: var(--cyan); animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .25; } }
.paired-title { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; color: var(--cyan); }
.paired-title .icon { width: 1.5rem; height: 1.5rem; }
#lp-paired .rules-list { margin: .875rem 0; }
.ready-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.ready-chip { display: inline-flex; align-items: center; gap: .375rem; padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line-c); font-size: .875rem; color: var(--fg-2); }
.ready-chip[data-state="yes"] { border-color: var(--cyan); color: var(--cyan); }
.big-count { margin: 1rem 0; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: clamp(5rem, 18vw, 9rem); line-height: 1; color: var(--cyan); font-variant-numeric: tabular-nums; }
.err-title { display: flex; align-items: center; gap: .5rem; margin-bottom: .375rem; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.err-title .icon { color: var(--warn-bright); }
.conn-note { margin-top: 1rem; font-size: .875rem; color: var(--warn-bright); }
.lobby-cancel { margin-top: .75rem; color: var(--fg-2); text-decoration: underline; padding-inline: .5rem; }

.game-status { flex-wrap: wrap; }
.opp-chip {
  flex-basis: 100%;
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .75rem; border-radius: 8px;
  border: 1px solid rgba(242, 165, 60, .45); background: rgba(214, 138, 12, .08);
  font-size: .875rem;
}
.opp-chip .icon { width: 1.125rem; height: 1.125rem; color: var(--warn-bright); }
.opp-label { font-weight: 700; color: var(--warn-bright); }
.opp-text { color: var(--fg); font-variant-numeric: tabular-nums; }

.reveal-mine {
  margin-top: 1rem; padding: .75rem 1rem; border-radius: 10px;
  border: 1px dashed rgba(242, 165, 60, .55); font-size: .9375rem; color: var(--fg-2);
}
.reveal-mine strong { color: var(--warn-bright); font-weight: 700; }
.mine-guess { font-family: var(--font-display); font-weight: 700; letter-spacing: .12em; color: #FFFFFF; white-space: nowrap; }
.recorder-note { margin-top: .75rem; font-size: .875rem; color: var(--warn-bright); }
.rc-opp { grid-column: 1 / -1; }

/* ==========================================================================
   對話框
   ========================================================================== */
.dlg {
  --focus: var(--blue);
  width: min(92vw, 28rem); padding: 1.5rem; margin: auto;
  border: 0; border-radius: 14px;
  background: #FFFFFF; color: var(--charcoal);
}
.dlg::backdrop { background: rgba(21, 24, 58, .74); }
.dlg-title { font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; color: var(--indigo); }
.dlg-body { margin: .5rem 0 1.25rem; color: var(--slate); font-variant-numeric: tabular-nums; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.dlg-actions .btn { flex: 1 1 8rem; }
.dlg .btn-secondary { background: #FFFFFF; color: var(--indigo); border-color: #C9CCD8; }
@media (hover: hover) { .dlg .btn-secondary:hover { background: var(--bg-subtle); } }
.dlg.is-fallback { position: fixed; inset: 0; z-index: 100; height: fit-content; }

.noscript { position: fixed; inset: auto 0 0 0; padding: 1rem; background: var(--warn); color: #FFFFFF; text-align: center; z-index: 200; }

/* ==========================================================================
   Responsive
   ========================================================================== */
/* 手機（主要檢查範圍 360～430px） */
@media (max-width: 599px) {
  .topbar { min-height: 3.25rem; gap: .5rem; }
  .brand-zh { display: none; }
  .progress { gap: .3rem; }
  .pg-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .pg-bar { width: 1rem; }
  .btn-home { padding-inline: .625rem; }

  .home-grid { padding-top: 1.5rem; gap: 1.5rem; }
  .home-visual { order: -1; }
  .vault-art { width: min(64vw, 13rem); }
  .home-visual-cap { display: none; }
  .lead { margin: .875rem 0 1.5rem; }
  .home-actions .btn { width: 100%; }
  .notice { margin-top: 1.5rem; }

  .game-head .eyebrow { display: none; }
  .stat-label { white-space: nowrap; }
  .btn-rules { width: 2.75rem; padding: 0; }
  .btn-rules span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .pad-area { --key-h: clamp(3rem, 6.6vh, 3.75rem); }
  .scene-banner { font-size: .9375rem; padding: .45rem .875rem; }
  .game-head .h2 { font-size: 1.25rem; }
  .game-sub { font-size: .8125rem; }
  .stat { padding: .25rem .625rem .25rem .375rem; gap: .5rem; }
  .stat-tries { padding-left: .625rem; }
  .timer-ring { width: 2.25rem; height: 2.25rem; }
  .stat-value { font-size: 1.375rem; }
  .pip { height: 1.375rem; width: .4375rem; }
  .history-head .legend { display: none; }
  .h-item { gap: .5rem; padding: .25rem .5rem; }
  .h-guess { font-size: 1.125rem; letter-spacing: .14em; }
  .vault-panel { padding: .5rem .75rem .375rem; gap: .375rem; }
  .vault-head { font-size: .8125rem; }

  .cta-bar .btn { width: 100%; }
  .cta-bar .btn-lg { font-size: 1.0625rem; padding-inline: .75rem; }
  .cta-bar-split .btn { width: auto; max-width: none; padding-inline: .75rem; }

  .rp-item { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "meta res" "digits digits"; gap: .5rem .75rem; }
  .rp-meta { grid-area: meta; flex-direction: row; flex-wrap: wrap; gap: 0 .625rem; align-items: baseline; }
  .rp-digits { grid-area: digits; }
  .rp-res { grid-area: res; }
  .rp-digit { width: 2.5rem; height: 2.75rem; }

  .key-msg { margin-top: 1rem; }
  .flow { margin-top: .75rem; }
  .sim-badge { font-size: .8125rem; }
  .opt { font-size: 1.0625rem; min-height: 3.75rem; padding: .75rem 1rem; gap: .75rem; }
  .result-card { padding: 1.25rem 1.125rem 1rem; }
  .lobby-card { padding: 1.125rem; }
  .lobby-actions .btn { flex-basis: 100%; }
  .room-code-value { font-size: 2rem; }
  .rc-emblem { width: 2.75rem; height: 2.75rem; }
}

@media (max-width: 399px) {
  .cta-bar:not(.cta-bar-split) .btn .icon { display: none; }
}
@media (max-width: 374px) {
  .h-dots { display: none; }
}
/* 矮的手機畫面（如 360×640）：保留完整鍵盤 */
@media (max-width: 599px) and (max-height: 700px) {
  .game-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .vault-head { display: none; }
  .slot { height: 3rem; font-size: 1.75rem; }
  .screen-game .screen-body { gap: .5rem; padding-top: .625rem; min-height: 30rem; }
  .game-main { gap: .5rem; grid-template-rows: auto minmax(4.25rem, 1fr) auto; }
  .pad-area { --key-h: 3rem; }
  .keypad { gap: .4rem; }
  .opp-chip { padding: .15rem .625rem; font-size: .8125rem; }
}
/* 手機與直向平板：防護盾牌改為頂部橫幅，選擇後立即看到升級動畫 */
@media (max-width: 1023px) {
  .shield-panel { order: -1; flex-direction: row; justify-content: flex-start; text-align: left; gap: 1rem; min-height: 0; padding: 1rem 1.25rem; }
  .shield-art { width: 4.75rem; flex: none; }
  .shield-status { min-width: 0; }
  .shield-title { font-size: 1.125rem; margin-top: .375rem; }
  .shield-sub { font-size: .875rem; }
}

/* 平板 */
@media (min-width: 600px) {
  .screen-body { padding-left: calc(2rem + env(safe-area-inset-left)); padding-right: calc(2rem + env(safe-area-inset-right)); }
  .cta-bar { padding-left: calc(2rem + env(safe-area-inset-left)); padding-right: calc(2rem + env(safe-area-inset-right)); }
  .screen-game .screen-body { max-width: 46rem; }
  .flow-observer { flex-direction: row; align-items: stretch; }
  .observer { flex: 1 1 0; }
  .archive { flex: 1 1 0; }
  .copy-arrow { min-width: 5rem; min-height: 0; }
  .copy-arrow::before { left: .25rem; right: .75rem; top: 50%; bottom: auto; border-left: 0; border-top: 2px dashed currentColor; }
  .copy-arrow::after { left: auto; right: 0; bottom: auto; top: calc(50% - 5px); border-width: 6px 0 6px 9px; border-color: transparent transparent transparent currentColor; }
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quantum-bottom { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
}

/* 時間軸水平 */
@media (min-width: 900px) {
  .timeline { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem; }
  .tl-step { grid-template-columns: minmax(0, 1fr); grid-template-areas: "dot" "text" "visual"; justify-items: start; gap: .625rem; }
  .tl-step::before { left: 3rem; right: -1.75rem; top: calc(1.375rem - 1px); bottom: auto; border-left: 0; border-top: 2px solid rgba(255, 255, 255, .2); }
  .tl-step.is-done::before { border-top-color: var(--cyan); }
}

/* 桌面 / 展場 */
@media (min-width: 1024px) {
  .topbar { min-height: 4rem; padding-left: calc(2.5rem + env(safe-area-inset-left)); padding-right: calc(2.5rem + env(safe-area-inset-right)); }
  .brand-name { font-size: 1.25rem; }
  .screen-body { padding: 2.25rem calc(4rem + env(safe-area-inset-right)) 2.25rem calc(4rem + env(safe-area-inset-left)); }
  .cta-bar { padding-top: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }

  .home-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); align-items: center; padding-top: 2rem; }
  .vault-art { width: min(100%, 30rem); }

  .screen-game .screen-body {
    max-width: 84rem;
    flex: 1 0 auto;
    display: grid; gap: 1.25rem 2.5rem;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    grid-template-rows: auto auto;
    grid-template-areas: "head status" "main main";
    align-content: center;
    padding-top: 1.5rem; padding-bottom: 1.75rem;
    min-height: 0;
  }
  .game-head { grid-area: head; }
  .game-status { grid-area: status; align-self: end; justify-content: flex-end; }
  .btn-rules { margin-left: .5rem; }
  .game-main {
    grid-area: main;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    grid-template-rows: auto auto;
    grid-template-areas: "vault history" "pad history";
    gap: 1.25rem 2.5rem;
  }
  .vault-panel { padding: 1.25rem 1.5rem 1rem; gap: .75rem; }
  .slots { width: min(100%, 30rem); gap: 1rem; }
  /* 歷次猜測不撐高版面，超出時於面板內捲動 */
  .history-panel { padding: 1.25rem 1.5rem; contain: size; min-height: 14rem; }
  .history { gap: .625rem; }
  .h-item { padding: .625rem 1rem; gap: 1.25rem; grid-template-columns: 2.5rem 1fr auto auto; }
  .h-guess { font-size: 1.75rem; }
  .h-res { font-size: 1.5rem; }
  .dot { width: .8125rem; height: .8125rem; }
  .keypad { gap: .625rem; }
  .game-msg { font-size: 1.0625rem; }

  .reveal-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-rows: auto auto; grid-template-areas: "head rec" "copy rec"; gap: 1.5rem 4rem; align-items: center; align-content: center; }
  .reveal-head { align-self: end; }
  .reveal-copy { align-self: start; }
  .callout-dark { padding: 1.5rem 1.75rem; }
  .recorder { padding: 1.5rem 1.75rem; }
  .rp-item { padding: .625rem 1.25rem; }
  .rp-digit { width: 2.625rem; height: 3rem; font-size: 1.625rem; }

  .flow { grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); grid-template-areas: "sender channel" ". observer"; gap: 1.25rem 2rem; align-items: center; margin-top: 1.75rem; }
  .msg-card { padding: 1.25rem 1.5rem 1rem; }
  .msg-text { font-size: 1.25rem; }
  .packet { font-size: .9375rem; padding: .5rem .875rem; }
  .flow-receiver .icon { width: 2.25rem; height: 2.25rem; }

  .lobby-body { align-items: center; }
  .lobby-card { padding: 2rem 2.25rem; }
  .qr { width: 17rem; }
  .defense-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 4rem; align-items: stretch; align-content: center; }
  .shield-panel { min-height: 26rem; }

  .result-body { gap: 2rem; justify-content: center; padding-top: 2rem; padding-bottom: 2rem; }
  .result-top { grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 4rem; }
  .result-card { padding: 1.75rem 2rem 1.5rem; }
  .result-message { gap: .75rem; }
}

@media (min-width: 1200px) {
  .products { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.5rem; }
  .product:not(:last-child)::after {
    content: ""; position: absolute; top: 50%; right: calc(-1.5rem - 2px); width: 1.5rem;
    border-top: 2px dotted var(--pc);
  }
}

/* 較矮的桌面 / 筆電（如 1366×768、1280×720） */
@media (min-width: 1024px) and (max-height: 820px) {
  .screen-body { padding-top: 1.25rem; padding-bottom: 1.25rem; }
  .screen-game .screen-body { padding-top: 1rem; padding-bottom: 1rem; gap: .75rem 2rem; }
  .game-sub { display: none; }
  .vault-panel { padding: .75rem 1rem .5rem; gap: .5rem; }
  .history-panel { padding: .875rem 1.125rem; }
  .h-item { padding: .375rem .875rem; }
  .h-guess { font-size: 1.375rem; }
  .h-res { font-size: 1.25rem; }
  .timeline { margin: 1rem 0; }
  .shield-panel { min-height: 20rem; }
  .scene-banner { margin-bottom: .5rem; }
  .flow { margin-top: 1rem; gap: 1rem 2rem; }
  .key-msg { margin-top: .75rem; }
}

/* 手機橫向 */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 1023px) {
  .screen-game .screen-body { max-width: none; min-height: 0; }
  .game-head { display: none; }
  .game-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "vault pad" "history pad"; }
  .pad-area { --key-h: clamp(2.75rem, 15vh, 3.5rem); }
  .slot { height: 2.75rem; font-size: 1.625rem; }
}

/* ---------- 減少動畫 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
    transition-duration: .001ms !important; transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
  transition-duration: .001ms !important; transition-delay: 0s !important;
}
