:root {
    --parchment: #fbf5e6;
    --parchment-deep: #efe3c8;
    --gold: #c8963e;
    --gold-bright: #f7d97e;
    --gold-dark: #7a5216;
    --emerald: #14532d;
    --emerald-mid: #1e6b43;
    --crimson: #8f1d21;
    --crimson-bright: #dc2626;
    --navy: #142038;
    --ink: #231b12;
    --muted: #655744;
    --serif: "Noto Serif TC", "PMingLiU", "DFKai-SB", Georgia, serif;
    --sans: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  }

  /* 三段字級：直接切換根元素 html 的字級，全站所有 rem（電腦＋手機）一次連動放大 */
  html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  html.fs-lg { font-size: 118%; }
  html.fs-xl { font-size: 134%; }

  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

  html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background: #101622;
    color: var(--ink);
    font-family: var(--sans);
    overflow-x: hidden;
  }
  body { font-size: 1rem; }

  button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), filter 0.16s ease, box-shadow 0.16s ease;
  }
  button:active { transform: scale(0.96); }

  .hidden { display: none !important; }

  /* =========================================================
     1. 商業級全螢幕電影感開場標題畫面 (Title Screen)
  ========================================================= */
  #titleScreen {
    position: fixed;
    inset: 0;
    min-height: 100dvh;
    z-index: 50;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 36px 20px max(28px, env(safe-area-inset-bottom));
    background: #0e1621;
  }

  .title-bg {
    position: absolute;
    inset: -4%;
    background: url("../assets_art/title_keyart.webp") center center / cover no-repeat;
    animation: kenBurns 22s ease-in-out infinite alternate;
    filter: brightness(0.92) saturate(1.06);
  }

  @keyframes kenBurns {
    0% { transform: scale(1.0) translate(0, 0); }
    100% { transform: scale(1.08) translate(-1.5%, -1%); }
  }

  .title-vignette {
    position: absolute;
    inset: 0;
    background:
      radial-gradient(circle at 50% 42%, transparent 25%, rgba(12, 18, 28, 0.68) 100%),
      linear-gradient(180deg, rgba(12, 18, 28, 0.55) 0%, transparent 32%, transparent 62%, rgba(12, 18, 28, 0.88) 100%);
    pointer-events: none;
  }

  #ambientCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
  }

  .title-crest-wrap {
    position: relative;
    z-index: 4;
    text-align: center;
    margin-top: 2vh;
    padding: 20px 38px 22px;
    border-radius: 22px;
    background: radial-gradient(ellipse at center, rgba(16, 26, 44, 0.72) 0%, rgba(16, 26, 44, 0.36) 65%, transparent 100%);
    backdrop-filter: blur(3px);
  }

  .title-edition-ribbon {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, #14532d, #8f1d21);
    color: #fff9db;
    border: 2px solid var(--gold-bright);
    padding: 6px 20px;
    border-radius: 999px;
    font-weight: 900;
    font-size: 0.9rem;
    letter-spacing: 2px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    margin-bottom: 12px;
  }

  .game-logo {
    font-family: var(--serif);
    font-size: clamp(2.3rem, 5.4vw, 4.2rem);
    font-weight: 900;
    margin: 0;
    letter-spacing: 5px;
    color: #fff6cf;
    text-shadow:
      0 3px 0 #7a4b0b,
      0 6px 0 #3b2004,
      0 10px 26px rgba(0, 0, 0, 0.92),
      0 0 28px rgba(247, 217, 126, 0.65);
    line-height: 1.18;
  }

  .game-subtitle {
    margin: 10px 0 0;
    font-family: var(--serif);
    font-size: clamp(1.05rem, 2.2vw, 1.48rem);
    color: #fef3c7;
    letter-spacing: 5px;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95), 0 0 14px rgba(0, 0, 0, 0.8);
  }

  .title-menu {
    position: relative;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 440px;
  }

  .btn-storybook-primary {
    width: 100%;
    background: linear-gradient(180deg, #f6d57a 0%, #c88d2c 55%, #9a6516 100%);
    color: #221404;
    border: 2.5px solid #fff7d6;
    border-radius: 14px;
    padding: 15px 28px;
    font-family: var(--serif);
    font-size: 1.26rem;
    font-weight: 900;
    letter-spacing: 2px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.75);
  }
  .btn-storybook-primary:hover {
    transform: translateY(-3px) scale(1.02);
    filter: brightness(1.08);
    box-shadow: 0 12px 34px rgba(247, 217, 126, 0.38);
  }

  .title-sub-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }

  .btn-storybook-glass {
    background: rgba(18, 28, 44, 0.78);
    backdrop-filter: blur(8px);
    color: #fef3c7;
    border: 1.5px solid rgba(247, 217, 126, 0.65);
    border-radius: 12px;
    padding: 11px 14px;
    font-weight: 800;
    font-size: 0.96rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  }
  .btn-storybook-glass:hover {
    background: rgba(30, 58, 95, 0.88);
    border-color: #fff7d6;
    transform: translateY(-2px);
  }
  /* 封面「重新開始」按第一下：變紅色提醒，再按一次才清除進度 */
  .btn-storybook-glass.armed,
  .btn-storybook-glass.armed:hover {
    background: rgba(153, 27, 27, 0.92);
    border-color: #fecaca;
    color: #fff;
  }

  .title-credit {
    position: relative;
    z-index: 4;
    color: rgba(254, 243, 199, 0.85);
    font-size: 0.88rem;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
    text-align: center;
  }

  /* =========================================================
     2. 商業繪本 HUD & 手繪互動大世界地圖 (Overworld Map)
  ========================================================= */
  #mapScreen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at 50% 0%, #24334a 0%, #101723 100%);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .studio-hud {
    background: linear-gradient(180deg, rgba(20, 30, 48, 0.97) 0%, rgba(14, 22, 36, 0.95) 100%);
    border-bottom: 2.5px solid var(--gold);
    padding: 8px 16px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .studio-hud-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .hero-hud-card {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .hero-avatar-mini {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2.5px solid var(--gold-bright);
    object-fit: cover;
    object-position: center 15%;
    box-shadow: 0 0 14px rgba(247, 217, 126, 0.45);
    background: #fbf5e6;
    flex-shrink: 0;
  }

  .hud-lv-line {
    font-family: var(--serif);
    color: var(--gold-bright);
    font-weight: 900;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .hud-bars-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 3px;
    flex-wrap: wrap;
  }

  .bar-mini-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #e2e8f0;
    font-size: 0.84rem;
    font-weight: 800;
  }

  .bar-mini-track {
    width: 86px;
    height: 9px;
    background: #0b111c;
    border: 1px solid rgba(247, 217, 126, 0.45);
    border-radius: 999px;
    overflow: hidden;
  }
  .bar-mini-fill { height: 100%; transition: width 0.35s ease; }

  .hud-relic-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(200, 150, 62, 0.16);
    border: 1px solid rgba(247, 217, 126, 0.5);
    color: #fef3c7;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 800;
  }
  .hud-relic-pill img { width: 20px; height: 20px; object-fit: contain; }

  .hud-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .hud-btn {
    background: rgba(255, 250, 235, 0.1);
    color: #fef3c7;
    border: 1px solid rgba(247, 217, 126, 0.45);
    border-radius: 10px;
    padding: 6px 11px;
    font-size: 0.88rem;
    font-weight: 800;
  }
  .hud-btn:hover { background: rgba(247, 217, 126, 0.22); }
  .hud-btn.gold {
    background: linear-gradient(180deg, #f6d57a, #c88d2c);
    color: #231504;
    border-color: #fff6d1;
  }

  /* 大世界地圖畫框 */
  .overworld-shell {
    max-width: 1240px;
    width: 100%;
    margin: 12px auto 26px;
    padding: 0 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .quest-scroll-bar {
    background: linear-gradient(90deg, #fbf5e6 0%, #f3e4c3 100%);
    border: 2.5px solid var(--gold);
    border-radius: 14px;
    padding: 9px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.7);
  }

  .quest-scroll-text {
    font-weight: 800;
    color: #2b1d0c;
    font-size: 1.02rem;
  }

  .map-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 18px;
    overflow: hidden;
    border: 4px solid var(--gold);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), inset 0 0 0 2px rgba(255, 248, 220, 0.5);
    background: #1a2d24;
  }

  .map-bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    user-select: none;
    pointer-events: none;
  }

  .map-sunlight-layer {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 22% 14%, rgba(255, 244, 200, 0.22), transparent 55%);
    pointer-events: none;
  }

  .map-paths-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
  }

  .quest-path-line {
    fill: none;
    stroke: rgba(255, 245, 205, 0.85);
    stroke-width: 4;
    stroke-dasharray: 10 8;
    stroke-linecap: round;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.65));
    animation: marchPath 22s linear infinite;
  }
  @keyframes marchPath {
    to { stroke-dashoffset: -360; }
  }

  /* 地圖可點選據點（帶商業角色頭像徽章） */
  .map-node {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    padding: 0;
  }

  .node-ring {
    position: relative;
    width: clamp(54px, 6.2vw, 82px);
    height: clamp(54px, 6.2vw, 82px);
    border-radius: 50%;
    border: 3.5px solid var(--gold-bright);
    background: #fbf5e6;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(20, 32, 56, 0.55);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .map-node:hover .node-ring {
    transform: scale(1.12) translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.72), 0 0 22px rgba(247, 217, 126, 0.9);
  }

  .map-node.active-quest .node-ring {
    animation: beaconPulse 1.8s infinite;
  }

  @keyframes beaconPulse {
    0%, 100% { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(253, 224, 71, 0.85); }
    65% { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6), 0 0 0 15px rgba(253, 224, 71, 0); }
  }

  .map-node.cleared .node-ring {
    border-color: #4ade80;
    filter: saturate(0.85);
  }

  .map-node.final-boss .node-ring {
    width: clamp(64px, 7.2vw, 96px);
    height: clamp(64px, 7.2vw, 96px);
    border-color: #fca5a5;
    box-shadow: 0 10px 26px rgba(143, 29, 33, 0.85), 0 0 24px rgba(239, 68, 68, 0.8);
  }

  .node-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
  }

  .node-status-tag {
    position: absolute;
    top: -16px;
    z-index: 4;
    background: linear-gradient(180deg, #ef4444, #991b1b);
    color: #fff;
    border: 1.5px solid #fef08a;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: clamp(0.72rem, 0.95vw, 0.84rem);
    font-weight: 900;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.58);
    white-space: nowrap;
  }
  .map-node.cleared .node-status-tag {
    background: linear-gradient(180deg, #16a34a, #14532d);
    border-color: #bbf7d0;
  }
  /* 最終關上鎖：前五關都過才開放 */
  .map-node.locked .node-ring {
    border-color: #94a3b8;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    filter: grayscale(0.9) brightness(0.72);
  }
  .map-node.locked .node-status-tag {
    background: linear-gradient(180deg, #64748b, #334155);
    border-color: #cbd5e1;
  }

  .node-label {
    margin-top: 5px;
    background: linear-gradient(180deg, rgba(251, 245, 230, 0.96), rgba(235, 220, 186, 0.96));
    color: #241709;
    border: 1.5px solid var(--gold-dark);
    border-radius: 8px;
    padding: 2px 9px;
    font-weight: 900;
    font-size: clamp(0.76rem, 1.05vw, 0.92rem);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
  }

  /* 3D 寶箱圖釘 */
  .map-chest {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 5;
    background: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .map-chest::before {
    content: "";
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(254, 240, 138, 0.72) 0%, rgba(245, 158, 11, 0.25) 55%, transparent 75%);
    animation: chestAura 2s ease-in-out infinite;
    pointer-events: none;
  }
  .map-chest.opened::before { display: none; }
  @keyframes chestAura {
    0%, 100% { transform: scale(0.92); opacity: 0.75; }
    50% { transform: scale(1.25); opacity: 1; }
  }

  .map-chest img {
    position: relative;
    z-index: 1;
    width: clamp(40px, 4.5vw, 56px);
    height: clamp(40px, 4.5vw, 56px);
    object-fit: contain;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.72)) drop-shadow(0 0 12px rgba(253, 224, 71, 0.85));
    animation: floatChest 2.4s ease-in-out infinite;
    transition: transform 0.2s ease, opacity 0.3s ease;
  }
  .map-chest:hover img { transform: scale(1.2); }
  .map-chest.opened img {
    animation: none;
    filter: grayscale(0.9) opacity(0.55);
  }

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

  /* 主角在地圖上平滑移動的精緻棋子 */
  .map-hero-token {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 9;
    pointer-events: none;
    transition: left 0.85s cubic-bezier(0.25, 0.9, 0.3, 1), top 0.85s cubic-bezier(0.25, 0.9, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .map-hero-token img {
    width: clamp(46px, 5vw, 64px);
    height: clamp(46px, 5vw, 64px);
    border-radius: 50%;
    border: 3.5px solid #38bdf8;
    object-fit: cover;
    object-position: center 15%;
    box-shadow: 0 0 0 3px #fff, 0 8px 20px rgba(0, 0, 0, 0.75);
    animation: heroHover 1.6s ease-in-out infinite;
    background: #fbf5e6;
  }

  @keyframes heroHover {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
  }

  .map-hero-badge {
    margin-top: 3px;
    background: linear-gradient(180deg, #0284c7, #0369a1);
    color: #fff;
    border: 1.5px solid #e0f2fe;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.72rem;
    font-weight: 900;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
  }

  .map-toast {
    position: absolute;
    top: 12px;
    left: 14px;
    transform: translateY(-10px);
    z-index: 20;
    background: linear-gradient(180deg, rgba(20, 32, 56, 0.94), rgba(12, 20, 34, 0.94));
    color: var(--gold-bright);
    border: 2px solid var(--gold-bright);
    border-radius: 999px;
    padding: 7px 16px;
    font-weight: 900;
    font-size: 0.92rem;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.58);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    white-space: nowrap;
    max-width: 48%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .map-toast.show { opacity: 1; transform: translateY(0); }

  /* =========================================================
     3. 商業級 JRPG 劇院戰鬥舞台 (Ni no Kuni × Ace Attorney × Hearthstone)
  ========================================================= */
  #battleScreen {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    flex-direction: column;
    background: #0c121e;
    overflow-y: auto;
  }
  #battleScreen.open { display: flex; }

  .battle-bg {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(0.74) saturate(1.08);
    z-index: 0;
  }
  .battle-bg-shade {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, rgba(10, 15, 28, 0.72) 0%, rgba(10, 15, 28, 0.22) 38%, rgba(10, 15, 28, 0.88) 100%);
    z-index: 1;
    pointer-events: none;
  }

  #vfxCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 25;
  }

  .battle-inner {
    position: relative;
    z-index: 5;
    max-width: 1120px;
    width: 100%;
    margin: auto;
    padding: 10px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .battle-inner.hit-shake {
    animation: stageShake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97);
  }
  @keyframes stageShake {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-10px, 5px); }
    35% { transform: translate(10px, -5px); }
    55% { transform: translate(-6px, -3px); }
    75% { transform: translate(6px, 3px); }
  }

  /* 格鬥遊戲級雙層延遲血條 */
  .battle-bars-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    align-items: center;
  }

  .combatant-bar-box {
    background: linear-gradient(180deg, rgba(20, 30, 48, 0.88), rgba(12, 18, 30, 0.92));
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 10px 14px;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
  }
  .combatant-bar-box.boss { border-color: #f87171; }

  .cb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 900;
    color: #fef3c7;
    font-size: 1rem;
  }

  .dual-hp-track {
    position: relative;
    height: 16px;
    background: #090d16;
    border-radius: 999px;
    overflow: hidden;
    border: 1.5px solid rgba(255, 245, 205, 0.45);
    margin-top: 6px;
  }
  .dual-hp-ghost {
    position: absolute;
    inset: 0 auto 0 0;
    background: #fef08a;
    transition: width 0.85s ease 0.25s;
  }
  .dual-hp-main {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(90deg, #16a34a, #4ade80);
    transition: width 0.22s ease;
  }
  .combatant-bar-box.boss .dual-hp-main {
    background: linear-gradient(90deg, #b91c1c, #f97316);
  }

  .round-emblem {
    background: linear-gradient(180deg, #f6d57a, #b4771e);
    color: #231404;
    border: 2px solid #fff7d6;
    border-radius: 14px;
    padding: 7px 14px;
    text-align: center;
    font-family: var(--serif);
    font-weight: 900;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  }

  /* 雙人高畫質手繪立繪對峙區 */
  .portraits-stage {
    display: grid;
    grid-template-columns: 1fr 140px 1fr;
    align-items: end;
    gap: 10px;
    min-height: 220px;
  }

  .portrait-frame {
    position: relative;
    margin: 0 auto;
    width: clamp(180px, 21vw, 240px);
    height: clamp(210px, 23vw, 272px);
    border-radius: 20px;
    padding: 6px;
    background: linear-gradient(145deg, #fce397 0%, #b57c25 45%, #fce397 100%);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.72);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), filter 0.3s ease;
    animation: breatheCard 3.6s ease-in-out infinite;
  }

  @keyframes breatheCard {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
  }

  .portrait-frame.speaking {
    filter: brightness(1.08) drop-shadow(0 0 22px rgba(247, 217, 126, 0.55));
    z-index: 3;
  }
  .portrait-frame.dimmed {
    filter: brightness(0.76) saturate(0.85);
  }
  .portrait-frame.lunge-right {
    animation: none;
    transform: translateX(48px) scale(1.06) rotate(2deg) !important;
  }
  .portrait-frame.hit-flash {
    animation: bossRecoil 0.42s ease !important;
    filter: brightness(2.2) contrast(1.2) !important;
  }

  @keyframes bossRecoil {
    0% { transform: translateX(0); }
    25% { transform: translateX(26px) rotate(5deg); }
    55% { transform: translateX(-14px) rotate(-3deg); }
    100% { transform: translateX(0); }
  }

  .portrait-inner {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    background: #fbf5e6;
    border: 2px solid #4a2e0b;
  }

  .portrait-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 14%;
    display: block;
  }

  .portrait-nameplate {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, transparent, rgba(16, 22, 34, 0.92) 38%);
    color: #fef3c7;
    padding: 18px 10px 8px;
    text-align: center;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1rem;
    letter-spacing: 1px;
  }

  .vs-medallion {
    align-self: center;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .vs-medallion-orb {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(254, 240, 138, 0.28) 0%, rgba(20, 32, 56, 0.72) 68%, rgba(20, 32, 56, 0.9) 100%);
    border: 2px solid rgba(247, 217, 126, 0.75);
    box-shadow: 0 0 28px rgba(247, 217, 126, 0.38), inset 0 0 14px rgba(254, 240, 138, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .vs-medallion img {
    width: 82px;
    height: 82px;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.85));
    animation: floatChest 2.8s ease-in-out infinite;
  }
  .vs-relic-tag {
    background: rgba(16, 24, 40, 0.86);
    color: var(--gold-bright);
    border: 1px solid rgba(247, 217, 126, 0.65);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 1px;
    white-space: nowrap;
  }

  /* 繪本羊皮紙劇院對話框 */
  .storybook-dialogue {
    background: linear-gradient(180deg, #fffdf7 0%, #f4e6c8 100%);
    color: var(--ink);
    border: 3px solid var(--gold);
    border-radius: 16px;
    padding: 11px 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55), inset 0 0 0 2px rgba(255, 255, 255, 0.8);
    position: relative;
  }

  .dlg-speaker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(90deg, #8f1d21, #b91c1c);
    color: #fff;
    border: 1.5px solid #fde047;
    padding: 3px 13px;
    border-radius: 999px;
    font-weight: 900;
    font-size: 0.9rem;
    margin-bottom: 6px;
  }
  .dlg-speaker.hero { background: linear-gradient(90deg, #14532d, #15803d); }
  .dlg-speaker.mentor { background: linear-gradient(90deg, #1e3a8a, #2563eb); }

  .dlg-text {
    font-size: 1.14rem;
    font-weight: 800;
    line-height: 1.6;
    color: #24180b;
  }

  /* 商業收藏級 3D 雷射光澤法規必殺技卡牌 */
  .spell-hand {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    perspective: 900px;
  }

  .foil-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(160deg, #fffdf5 0%, #f3e4c3 100%);
    color: #23180b;
    border: 3px solid var(--gold);
    border-radius: 16px;
    padding: 12px 14px 11px;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.55), inset 0 0 0 2px rgba(255, 255, 255, 0.8);
    transform-style: preserve-3d;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  }

  .foil-card::after {
    content: "";
    position: absolute;
    inset: -60%;
    background: linear-gradient(115deg, transparent 36%, rgba(255, 255, 255, 0.65) 50%, rgba(247, 217, 126, 0.35) 56%, transparent 68%);
    transform: translateX(-85%) rotate(12deg);
    transition: transform 0.55s ease;
    pointer-events: none;
  }

  .foil-card:hover:not(:disabled) {
    transform: translateY(-9px) scale(1.025);
    border-color: #fff6c9;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.65), 0 0 24px rgba(247, 217, 126, 0.65);
  }
  .foil-card:hover:not(:disabled)::after {
    transform: translateX(85%) rotate(12deg);
  }

  .foil-card.tier-emerald { border-color: #16a34a; }
  .foil-card.tier-amethyst { border-color: #9333ea; }
  .foil-card.card-win {
    background: linear-gradient(160deg, #dcfce7, #bbf7d0);
    border-color: #15803d;
  }
  .foil-card.card-fail {
    background: linear-gradient(160deg, #fee2e2, #fecaca);
    border-color: #b91c1c;
    opacity: 0.62;
  }

  .fc-name {
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1.1rem;
    color: #14532d;
  }

  .fc-law-pill {
    display: inline-block;
    background: #142038;
    color: var(--gold-bright);
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
    margin-top: 4px;
  }
  .fc-law-pill.revealed-ok { background: #14532d; color: #dcfce7; }
  .fc-law-pill.revealed-fail { background: #991b1b; color: #fee2e2; }

  .fc-desc {
    font-size: 0.96rem;
    color: #3a2b1a;
    font-weight: 700;
    line-height: 1.5;
  }

  .battle-bottom-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  /* =========================================================
     4. 「法規奧義」必殺技特寫 Cut-in 演出層
  ========================================================= */
  #cutinOverlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    pointer-events: none;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 16, 28, 0.45);
  }
  #cutinOverlay.active { display: flex; }

  .cutin-band {
    width: 112%;
    height: 210px;
    transform: rotate(-4deg);
    background: linear-gradient(90deg, #0b3620 0%, #166534 30%, #ca8a04 68%, #fef08a 100%);
    border-top: 5px solid #fffbe0;
    border-bottom: 5px solid #fffbe0;
    box-shadow: 0 0 60px rgba(247, 217, 126, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 26px;
    overflow: hidden;
    position: relative;
    /* 停留時間由 triggerCutin 依 ms 同步設定（預設 2.5 秒）：前 14% 滑入、停住、最後 14% 淡出 */
    animation: cutinSlide 2.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  @keyframes cutinSlide {
    0% { opacity: 0; transform: rotate(-4deg) translateX(-45%) scaleY(0.4); }
    14% { opacity: 1; transform: rotate(-4deg) translateX(0) scaleY(1); }
    86% { opacity: 1; transform: rotate(-4deg) translateX(0) scaleY(1); }
    100% { opacity: 0; transform: rotate(-4deg) translateX(25%) scaleY(0.85); }
  }
  /* 系統開啟「減少動態效果」：不滑入，只停留後淡出 */
  @keyframes cutinFade {
    0%, 90% { opacity: 1; transform: rotate(-4deg); }
    100% { opacity: 0; transform: rotate(-4deg); }
  }
  @media (prefers-reduced-motion: reduce) {
    .cutin-band { animation-name: cutinFade; }
  }

  .cutin-portrait {
    height: 245px;
    width: 190px;
    object-fit: cover;
    object-position: center 12%;
    border: 4px solid #fffbe0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.65);
    flex-shrink: 0;
  }

  .cutin-text-group {
    color: #fff;
    text-shadow: 0 4px 0 #1f1406, 0 8px 22px rgba(0, 0, 0, 0.75);
  }
  .cutin-kicker {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 900;
    color: #fef08a;
    letter-spacing: 5px;
  }
  .cutin-title {
    font-family: var(--serif);
    font-size: clamp(1.5rem, 3.6vw, 2.7rem);
    font-weight: 900;
    line-height: 1.15;
  }

  /* =========================================================
     5. 典藏彈出視窗（聖物館、移交清冊、法典與榮譽證書）
  ========================================================= */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(8, 13, 24, 0.78);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
  }
  .modal-backdrop.open { display: flex; }

  .storybook-modal {
    background: linear-gradient(180deg, #fffdf7 0%, #f5e9ce 100%);
    color: var(--ink);
    border: 3.5px solid var(--gold);
    border-radius: 20px;
    max-width: 900px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 28px 65px rgba(0, 0, 0, 0.7);
  }

  .sm-head {
    background: linear-gradient(135deg, #14532d 0%, #1e3a5f 100%);
    color: #fef3c7;
    padding: 14px 20px;
    border-bottom: 2.5px solid var(--gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1.16rem;
  }

  .sm-body {
    padding: 18px 20px;
    overflow-y: auto;
  }

  /* 🔒 最終決戰還沒開放（前五關都過才開） */
  .final-lock-modal { max-width: 500px; }
  .final-lock-lead { margin: 0 0 12px; font-weight: 800; font-size: 1.02rem; line-height: 1.65; }
  .final-lock-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
  .final-lock-go {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: linear-gradient(95deg, #fffdf7 0%, #f3e4c3 100%);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 9px 12px;
    color: #241709;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  }
  .final-lock-go b { display: block; font-family: var(--serif); font-weight: 900; color: #14532d; }
  .final-lock-go small { display: block; margin-top: 2px; font-size: 0.86rem; font-weight: 700; color: #5c4d3c; }
  .final-lock-go .final-lock-cta {
    flex-shrink: 0;
    background: linear-gradient(180deg, #ef4444, #991b1b);
    color: #fff;
    border: 1.5px solid #fef08a;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 0.86rem;
    font-weight: 900;
    white-space: nowrap;
  }
  .final-lock-note { margin: 0 0 12px; font-size: 0.92rem; font-weight: 700; color: #5c4d3c; line-height: 1.6; }
  .final-lock-actions { display: flex; justify-content: flex-end; }

  .relic-showcase-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
  }

  .relic-studio-card {
    background: radial-gradient(circle at 50% 35%, #24344d 0%, #101827 100%);
    color: #fef3c7;
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 12px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  }
  .relic-studio-card img {
    width: 118px;
    height: 118px;
    object-fit: contain;
    filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.6));
  }

  .ledger-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
    margin: 10px 0 16px;
  }

  .ledger-item {
    background: #fff;
    border: 2px solid #d6c5a3;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.94rem;
    line-height: 1.5;
  }
  .ledger-item.got {
    background: #ecfdf5;
    border-color: #16a34a;
  }

  .cert-frame {
    background: linear-gradient(180deg, #fffdf5, #f6e7c1);
    border: 8px double #a6721f;
    border-radius: 16px;
    padding: 26px 22px;
    text-align: center;
    position: relative;
  }

  /* 封面字級按鈕橫跨整列 */
  .title-font-btn { grid-column: 1 / -1; }

  /* 放大字級換行時平均分行，避免第二行只剩單一個字 */
  .game-logo, .game-subtitle, .title-edition-ribbon, .btn-storybook-glass,
  .portrait-nameplate, .mob-qc-zone, .sm-head span, .sop-title, .cutin-title, .cutin-kicker {
    text-wrap: balance;
  }

  /* =========================================================
     7. 六大移交清冊・互動點交核對卡（20 秒快問快答）
  ========================================================= */
  .ledger-modal { max-width: 660px; }
  .lc-hero {
    display: flex;
    align-items: center;
    gap: 12px;
    background: radial-gradient(circle at 18% 30%, #2a3c58 0%, #101827 100%);
    color: #fef3c7;
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 10px 14px;
  }
  .lc-hero img {
    width: 76px;
    height: 76px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 10px rgba(253, 224, 71, 0.6));
  }
  .lc-hero-title { font-family: var(--serif); font-weight: 900; font-size: 1.14rem; color: var(--gold-bright); }
  .lc-hero-desc { font-size: 0.92rem; line-height: 1.55; color: #e2e8f0; margin-top: 4px; }
  .lc-reward-tag {
    display: inline-block;
    margin-top: 6px;
    background: rgba(22, 163, 74, 0.22);
    border: 1px solid #4ade80;
    color: #dcfce7;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.82rem;
    font-weight: 900;
  }
  .lc-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin: 14px 0 8px;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1.04rem;
    color: #14532d;
  }
  .lc-progress-pill {
    font-family: var(--sans);
    background: #142038;
    color: var(--gold-bright);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
  .lc-check-list { display: grid; gap: 8px; }
  .lc-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 2px dashed #c8a96a;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.5;
    color: #2b1d0c;
  }
  .lc-check:hover:not(:disabled) { border-color: var(--gold); background: #fffaf0; }
  .lc-check:disabled { cursor: default; }
  .lc-box {
    flex-shrink: 0;
    width: 1.55em;
    height: 1.55em;
    margin-top: 0.05em;
    border-radius: 7px;
    border: 2px solid #a6721f;
    background: #fffdf5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
  }
  .lc-check.done { background: #ecfdf5; border-style: solid; border-color: #16a34a; }
  .lc-check.done .lc-box { background: #16a34a; border-color: #15803d; color: #fff; }

  .lc-quiz {
    margin-top: 14px;
    background: linear-gradient(180deg, #fff8e3 0%, #fbe9bd 100%);
    border: 2.5px solid var(--gold);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
  }
  .lc-quiz.locked {
    background: #f3ede0;
    border-style: dashed;
    color: #7a6a52;
    text-align: center;
    font-weight: 800;
    line-height: 1.55;
  }
  .lc-timer-row { display: flex; align-items: center; gap: 10px; }
  .lc-timer-num {
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1.3rem;
    color: #8f1d21;
    min-width: 4.4em;
    white-space: nowrap;
  }
  .lc-timer-track {
    flex: 1;
    height: 12px;
    background: #e9dcc0;
    border: 1px solid #c8a96a;
    border-radius: 999px;
    overflow: hidden;
  }
  .lc-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #dc2626 0%, #f59e0b 45%, #16a34a 100%);
    transition: width 0.2s linear;
  }
  .lc-question { margin: 10px 0 8px; font-weight: 900; font-size: 1.06rem; line-height: 1.6; color: #231b12; }
  .lc-options { display: grid; gap: 8px; }
  .lc-option {
    width: 100%;
    text-align: left;
    background: #fffdf7;
    border: 2px solid #d6c5a3;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.5;
    color: #2b1d0c;
  }
  .lc-option:hover:not(:disabled) { border-color: var(--gold); background: #fff4d6; }
  .lc-option:disabled { cursor: default; }
  .lc-option.right { background: #dcfce7; border-color: #15803d; color: #14532d; }
  .lc-option.wrong { background: #fee2e2; border-color: #b91c1c; color: #7f1d1d; }
  .lc-result {
    margin-top: 10px;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.6;
  }
  .lc-result.ok { background: #ecfdf5; border: 2px solid #16a34a; color: #14532d; }
  .lc-result.ng { background: #fef2f2; border: 2px solid #dc2626; color: #7f1d1d; }
  .lc-law {
    display: inline-block;
    margin-top: 6px;
    background: #142038;
    color: var(--gold-bright);
    border-radius: 999px;
    padding: 1px 10px;
    font-size: 0.8rem;
    font-weight: 800;
  }
  .lc-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
  .lc-actions .hud-btn { padding: 9px 14px; font-size: 0.94rem; }
  .lc-actions .hud-btn:not(.gold) { background: #142038; }
  .lc-stamp {
    display: inline-block;
    margin: 8px 0 2px;
    padding: 4px 14px;
    border: 3px double #b91c1c;
    border-radius: 10px;
    color: #b91c1c;
    background: rgba(255, 255, 255, 0.6);
    font-family: var(--serif);
    font-weight: 900;
    letter-spacing: 3px;
    transform: rotate(-6deg);
    animation: stampIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
  }
  @keyframes stampIn {
    0% { opacity: 0; transform: rotate(-6deg) scale(2.4); }
    100% { opacity: 1; transform: rotate(-6deg) scale(1); }
  }

  /* 最終魔王戰：清冊加成橫幅、清冊佐證排除牌、合法點交大陣 Cut-in */
  .ledger-bonus-banner {
    background: linear-gradient(90deg, rgba(20, 83, 45, 0.95), rgba(30, 58, 95, 0.95));
    color: #fef3c7;
    border: 2px solid var(--gold-bright);
    border-radius: 12px;
    padding: 7px 12px;
    font-weight: 900;
    font-size: 0.94rem;
    line-height: 1.5;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  }
  .ledger-bonus-banner.none { background: rgba(72, 24, 26, 0.92); border-color: #fca5a5; }
  .ledger-bonus-banner.perfect {
    background: linear-gradient(90deg, #7a5216 0%, #b4771e 40%, #14532d 100%);
    animation: perfectGlow 1.6s ease-in-out infinite;
  }
  @keyframes perfectGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.65), 0 8px 20px rgba(0, 0, 0, 0.45); }
    50% { box-shadow: 0 0 0 7px rgba(253, 224, 71, 0), 0 8px 20px rgba(0, 0, 0, 0.45); }
  }
  .foil-card.card-struck { opacity: 0.5; filter: grayscale(0.8); border-style: dashed; }
  .foil-card.card-struck .fc-law-pill { background: #475569; color: #f1f5f9; }

  .cutin-band.ledger-array {
    background: linear-gradient(90deg, #3b2004 0%, #9a6516 32%, #14532d 70%, #1e3a5f 100%);
    animation-duration: 2.8s;
  }
  .cutin-band.ledger-array .cutin-portrait {
    object-fit: contain;
    background: radial-gradient(circle, rgba(254, 240, 138, 0.6) 0%, rgba(20, 32, 56, 0.92) 72%);
  }

  /* 證書：完美清冊制霸印記 */
  .cert-ledger-seal {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    width: 9.6em;
    height: 9.6em;
    border-radius: 50%;
    border: 5px double #b91c1c;
    color: #b91c1c;
    background: rgba(254, 226, 226, 0.35);
    font-family: var(--serif);
    font-weight: 900;
    font-size: 0.92rem;
    line-height: 1.35;
    letter-spacing: 2px;
    transform: rotate(-10deg);
  }
  .cert-ledger-seal b { font-size: 1.45em; letter-spacing: 1px; }

  /* =========================================================
     8. 選務全流程時間軸 SOP 總圖（聖物館與法典）
  ========================================================= */
  .sop-progress {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    margin: 6px 0 10px;
  }
  .sop-seg {
    position: relative;
    padding-top: 16px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 900;
    color: #8a7a5f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sop-seg::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 0;
    right: 0;
    height: 9px;
    border-radius: 999px;
    background: #e3d6b8;
  }
  .sop-seg.lit { color: #7a5216; }
  .sop-seg.lit::before { background: linear-gradient(90deg, #f6d57a, #c88d2c); box-shadow: 0 0 8px rgba(247, 217, 126, 0.85); }
  .sop-tip { margin: 0 0 10px; font-size: 0.86rem; line-height: 1.55; color: #6b5d48; }
  .sop-timeline {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 4px 0 16px;
  }
  .sop-stage {
    position: relative;
    background: #f4eedf;
    border: 2px solid #d3c4a2;
    border-radius: 14px;
    padding: 10px 12px 12px;
    color: #5f5240;
    font-size: 0.9rem;
    line-height: 1.55;
  }
  .sop-stage.lit {
    background: linear-gradient(180deg, #fffbea 0%, #fdefc0 100%);
    border-color: var(--gold);
    color: #2b1d0c;
    box-shadow: 0 0 0 2px rgba(247, 217, 126, 0.55), 0 8px 18px rgba(200, 150, 62, 0.3);
  }
  .sop-head { display: flex; align-items: center; gap: 8px; }
  .sop-no {
    flex-shrink: 0;
    width: 2em;
    height: 2em;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #cbbf9f;
    color: #fff;
    font-weight: 900;
    font-size: 0.92rem;
  }
  .sop-stage.lit .sop-no { background: linear-gradient(180deg, #16a34a, #14532d); box-shadow: 0 0 10px rgba(74, 222, 128, 0.7); }
  .sop-title { font-family: var(--serif); font-weight: 900; font-size: 1.02rem; line-height: 1.35; color: #14532d; }
  .sop-stage:not(.lit) .sop-title { color: #6b5d48; }
  .sop-time {
    display: inline-block;
    margin-top: 6px;
    background: #8f1d21;
    color: #fff;
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1.45;
  }
  .sop-stage:not(.lit) .sop-time { background: #9b8f78; }
  .sop-list { margin: 6px 0 0; padding-left: 1.15em; }
  .sop-list li { margin: 3px 0; }
  .sop-law { margin-top: 6px; font-size: 0.8rem; font-weight: 800; color: #7a5216; }
  .sop-lock {
    margin-top: 6px;
    font-size: 0.86rem;
    font-weight: 800;
    color: #8a7a5f;
    background: rgba(255, 255, 255, 0.55);
    border: 1px dashed #c8b998;
    border-radius: 8px;
    padding: 4px 8px;
  }

  /* 手機專屬元件（電腦版隱藏） */
  .map-scroll-wrap {
    width: 100%;
    position: relative;
  }
  .mobile-swipe-hint, .mobile-adventure-deck {
    display: none;
  }

  @media (max-width: 860px) {
    .spell-hand, .relic-showcase-grid { grid-template-columns: 1fr; }
    .sop-timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .portraits-stage { grid-template-columns: 1fr 1fr; min-height: 0; }
    .vs-medallion { display: none; }
    .cutin-band { height: 145px; gap: 12px; }
    .cutin-portrait { height: 155px; width: 120px; }
  }

  /* =========================================================
     6. 手機直立專項優化（<= 760px，電腦版完全不受影響）
  ========================================================= */
  @media (max-width: 760px) {
    /* 手機封面：全螢幕滿版 9:16 專用繪本原畫（帥氣男主角與奇幻城堡滿版完整同框！） */
    #titleScreen {
      padding: 26px 16px max(22px, env(safe-area-inset-bottom));
      justify-content: space-between;
      gap: 10px;
    }
    .title-bg {
      background-image: url("../assets_art/title_keyart_mobile.webp");
      background-position: center center;
      filter: brightness(0.95) saturate(1.06);
      animation: kenBurns 22s ease-in-out infinite alternate;
    }
    .title-vignette {
      background:
        linear-gradient(180deg, rgba(10, 18, 32, 0.58) 0%, rgba(10, 18, 32, 0.12) 28%, transparent 56%, rgba(10, 18, 32, 0.82) 100%);
    }
    .title-crest-wrap { margin-top: 1vh; padding: 14px 16px 16px; width: 100%; max-width: 360px; }
    .title-edition-ribbon { font-size: 0.84rem; padding: 5px 14px; letter-spacing: 1px; margin-bottom: 8px; }
    .game-logo { font-size: clamp(2.05rem, 9.2vw, 2.65rem); letter-spacing: 3px; }
    .game-subtitle { font-size: 1rem; letter-spacing: 2px; margin-top: 6px; }
    .title-menu { margin-top: auto; margin-bottom: 4px; gap: 9px; max-width: 390px; }
    .btn-storybook-primary { padding: 13px 18px; font-size: 1.14rem; }
    .title-credit { font-size: 0.8rem; line-height: 1.5; }

    /* 大地圖頂部 HUD 緊湊化 */
    .studio-hud { padding: 7px 10px; }
    .studio-hud-inner { gap: 7px; }
    .hero-avatar-mini { width: 40px; height: 40px; }
    .hud-lv-line { font-size: 0.94rem; }
    .bar-mini-track { width: 60px; }
    .hud-relic-pill { font-size: 0.8rem; padding: 2px 7px; }
    .hud-btn-group { width: 100%; display: flex; flex-wrap: wrap; gap: 5px; }
    .hud-btn { flex: 1 1 auto; text-align: center; padding: 6px 7px; font-size: 0.82rem; white-space: nowrap; }

    /* 任務橫幅緊湊化 */
    .overworld-shell { margin: 8px auto 18px; padding: 0 10px; gap: 8px; }
    .quest-scroll-bar { padding: 8px 11px; gap: 7px; border-width: 2px; }
    .quest-scroll-text { font-size: 0.94rem; line-height: 1.5; }

    /* 可左右滑動不重疊的手繪大地圖 */
    .mobile-swipe-hint {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      color: #fde68a;
      font-size: 0.86rem;
      font-weight: 800;
      text-align: center;
      padding: 2px 0;
    }
    .map-scroll-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      border-radius: 15px;
      border: 3px solid var(--gold);
      box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
      background: #1a2d24;
    }
    .map-viewport {
      width: 780px;
      min-width: 780px;
      height: 410px;
      aspect-ratio: auto;
      border: none;
      border-radius: 0;
      box-shadow: none;
    }
    .node-ring { width: 48px; height: 48px; border-width: 3px; }
    .map-node.final-boss .node-ring { width: 56px; height: 56px; }
    .node-status-tag { top: -15px; font-size: 0.7rem; padding: 1px 7px; }
    .node-label { font-size: 0.76rem; padding: 2px 7px; margin-top: 3px; }
    .map-hero-token img { width: 42px; height: 42px; border-width: 3px; }
    .map-chest img { width: 38px; height: 38px; }
    .map-toast { left: 10px; top: 10px; max-width: 340px; font-size: 0.84rem; padding: 5px 12px; }

    /* 手機專屬：大按鈕六大據點冒險清單 ＋ 六座寶箱列 */
    .mobile-adventure-deck {
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-top: 4px;
    }
    .mob-section-title {
      font-family: var(--serif);
      color: var(--gold-bright);
      font-weight: 900;
      font-size: 1.04rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 2px;
    }
    .mob-quest-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .mob-quest-card {
      width: 100%;
      background: linear-gradient(95deg, #fffdf7 0%, #f3e4c3 100%);
      border: 2.5px solid var(--gold);
      border-radius: 14px;
      padding: 9px 11px;
      display: flex;
      align-items: center;
      gap: 10px;
      text-align: left;
      color: #241709;
      box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
    }
    .mob-quest-card.is-next {
      border-color: #fde047;
      box-shadow: 0 0 0 2px rgba(253, 224, 71, 0.55), 0 8px 18px rgba(0, 0, 0, 0.45);
    }
    .mob-quest-card.is-cleared {
      background: linear-gradient(95deg, #f0fdf4 0%, #dcfce7 100%);
      border-color: #22c55e;
    }
    .mob-quest-card.is-final {
      border-color: #f87171;
    }
    .mob-qc-avatar {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      border: 2.5px solid var(--gold-dark);
      object-fit: cover;
      object-position: center 14%;
      flex-shrink: 0;
      background: #fbf5e6;
    }
    .mob-qc-info { flex: 1; min-width: 0; }
    .mob-qc-zone { font-family: var(--serif); font-weight: 900; font-size: 1.04rem; color: #14532d; }
    .mob-qc-boss { font-size: 0.88rem; color: #5c4d3c; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .mob-qc-cta {
      background: linear-gradient(180deg, #ef4444, #991b1b);
      color: #fff;
      border: 1.5px solid #fef08a;
      border-radius: 999px;
      padding: 5px 11px;
      font-size: 0.86rem;
      font-weight: 900;
      flex-shrink: 0;
      white-space: nowrap;
    }
    .mob-quest-card.is-cleared .mob-qc-cta {
      background: linear-gradient(180deg, #16a34a, #14532d);
      border-color: #bbf7d0;
    }
    .mob-quest-card.is-locked {
      background: linear-gradient(95deg, #f1f5f9 0%, #e2e8f0 100%);
      border-color: #94a3b8;
    }
    .mob-quest-card.is-locked .mob-qc-avatar { filter: grayscale(0.9); opacity: 0.8; }
    .mob-quest-card.is-locked .mob-qc-boss { white-space: normal; overflow: visible; color: #475569; }
    .mob-quest-card.is-locked .mob-qc-cta {
      background: linear-gradient(180deg, #64748b, #334155);
      border-color: #cbd5e1;
    }

    .mob-chest-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 7px;
    }
    .mob-chest-btn {
      background: linear-gradient(180deg, rgba(30, 44, 68, 0.94), rgba(16, 25, 42, 0.96));
      border: 1.8px solid rgba(247, 217, 126, 0.65);
      border-radius: 12px;
      padding: 8px 9px;
      display: flex;
      align-items: center;
      gap: 7px;
      color: #fef3c7;
      text-align: left;
    }
    .mob-chest-btn.opened {
      border-color: #4ade80;
      background: rgba(20, 83, 45, 0.48);
    }
    .mob-chest-btn img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
    .mob-chest-btn.opened img { filter: grayscale(0.5); }
    .mob-chest-txt { font-size: 0.86rem; font-weight: 800; line-height: 1.35; }

    /* 戰鬥舞台手機緊湊單屏化（從 993px 壓縮至 ~780px 內） */
    .battle-inner {
      padding: 8px 10px max(12px, env(safe-area-inset-bottom));
      gap: 7px;
      margin: 0 auto;
    }
    .battle-bars-top {
      grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
      gap: 6px;
    }
    .combatant-bar-box { min-width: 0; padding: 6px 8px; border-radius: 11px; border-width: 1.8px; }
    /* 手機：名稱與 HP 上下兩行，HP 數字永遠完整顯示不被截斷 */
    .cb-header { font-size: 0.8rem; gap: 0; flex-direction: column; align-items: stretch; line-height: 1.3; }
    .combatant-bar-box.boss .cb-header { flex-direction: column-reverse; text-align: right; }
    .cb-header span:first-child, .cb-header span:last-child {
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
    }
    #bHeroHpLabel, #bBossHpLabel { overflow: visible; text-overflow: clip; }
    .dual-hp-track { height: 10px; margin-top: 4px; }
    .round-emblem { padding: 4px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
    .round-emblem div { white-space: nowrap; }
    .round-emblem .re-label { font-size: 0.68rem !important; letter-spacing: 0.5px !important; }
    #bRoundText { font-size: 0.92rem !important; }
    .round-emblem .round-stars { font-size: 0.74rem; }

    .portraits-stage { gap: 8px; }
    .portrait-frame {
      width: 100%;
      max-width: 162px;
      height: 142px;
      padding: 4px;
      border-radius: 14px;
    }
    .portrait-inner { border-radius: 10px; }
    .portrait-nameplate { font-size: 0.84rem; padding: 12px 6px 5px; letter-spacing: 0; }

    .storybook-dialogue { padding: 8px 11px; border-radius: 13px; border-width: 2.5px; }
    .dlg-speaker { font-size: 0.84rem; padding: 2px 10px; margin-bottom: 4px; }
    .dlg-text { font-size: 0.98rem; line-height: 1.55; }

    .spell-hand { gap: 7px; }
    .foil-card { padding: 9px 11px; border-radius: 13px; border-width: 2.5px; gap: 4px; }
    .fc-name { font-size: 1rem; }
    .fc-law-pill { font-size: 0.76rem; padding: 1px 8px; margin-top: 2px; }
    .fc-desc { font-size: 0.9rem; line-height: 1.48; }

    .battle-bottom-bar { gap: 7px; }
    .battle-bottom-bar .hud-btn { font-size: 0.9rem; padding: 8px 11px; }
    #battleProceedSlot { width: 100%; }
    #battleProceedSlot .btn-storybook-primary { width: 100% !important; font-size: 1rem !important; padding: 11px 14px !important; }

    /* 清冊點交卡、魔王清冊加成、SOP 總圖：手機直立版 */
    .sm-head .hud-btn { flex: 0 0 auto; }
    .mob-section-title > span:last-child { white-space: nowrap; flex-shrink: 0; }
    .cutin-kicker { font-size: 1.02rem; letter-spacing: 2px; }
    .modal-backdrop { padding: 10px; }
    .storybook-modal { max-height: 92vh; max-height: 92dvh; }
    .sm-head { padding: 11px 14px; font-size: 1.04rem; gap: 8px; }
    .sm-body { padding: 14px 13px; }
    .lc-hero { padding: 9px 11px; gap: 10px; }
    .lc-hero img { width: 58px; height: 58px; }
    .lc-check, .lc-option { padding: 10px 11px; }
    .lc-actions .hud-btn { flex: 1 1 auto; text-align: center; }
    .ledger-bonus-banner { font-size: 0.86rem; padding: 6px 10px; }
    .sop-timeline { grid-template-columns: 1fr; }
    .sop-seg { font-size: 0.72rem; }
    .cert-ledger-seal { font-size: 0.84rem; }
  }

  /* =========================================================
     8. 卡牌對決演出：卡牌外觀、蓋牌／翻牌、飛牌、擊破章、法規卡冊
  ========================================================= */
  .tcg-card {
    min-height: 228px;
    padding: 8px 10px 10px;
    gap: 6px;
  }
  .tcg-titlebar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #142038, #1e3a8a);
    border: 1.5px solid rgba(253, 230, 138, 0.75);
    border-radius: 9px;
    padding: 5px 8px;
  }
  .tcg-card .fc-name {
    color: #fef3c7;
    font-size: 1.12rem;
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.3;
  }
  .tcg-art {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 74px;
    border-radius: 10px;
    overflow: hidden;
    background: radial-gradient(circle at 50% 38%, #fffbea 0%, #f7d97e 48%, #b57c25 100%);
    border: 2px solid #7a5216;
    box-shadow: inset 0 0 18px rgba(122, 82, 22, 0.45);
  }
  .tcg-art-icon {
    font-size: 2.6rem;
    line-height: 1;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
  }
  .tcg-card.tier-emerald .tcg-art {
    background: radial-gradient(circle at 50% 38%, #f0fdf4 0%, #86efac 48%, #15803d 100%);
    border-color: #14532d;
  }
  .tcg-card.tier-amethyst .tcg-art {
    background: radial-gradient(circle at 50% 38%, #faf5ff 0%, #d8b4fe 48%, #7e22ce 100%);
    border-color: #581c87;
  }
  .tcg-card .fc-law-pill { align-self: center; margin-top: 0; }
  .tcg-card .fc-desc {
    flex: 1;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(122, 82, 22, 0.35);
    border-radius: 8px;
    padding: 7px 9px;
  }
  .tcg-card.card-win .tcg-titlebar { background: linear-gradient(90deg, #14532d, #15803d); }
  .tcg-card.card-win { box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.55), 0 14px 30px rgba(0, 0, 0, 0.55); }

  /* 蓋牌：只露出卡背 */
  .tcg-card.is-facedown > * { visibility: hidden; }
  .tcg-card.is-facedown { border-color: var(--gold-bright); }
  .tcg-card.is-facedown::before,
  .cb-card.locked::before {
    content: "";
    position: absolute;
    inset: 7px;
    border-radius: 10px;
    border: 2px solid rgba(247, 217, 126, 0.75);
    background:
      url("../assets_art/relic_seal_3d.webp") center / auto 58% no-repeat,
      repeating-linear-gradient(45deg, rgba(247, 217, 126, 0.17) 0 2px, transparent 2px 14px),
      repeating-linear-gradient(-45deg, rgba(247, 217, 126, 0.17) 0 2px, transparent 2px 14px),
      radial-gradient(circle at 50% 45%, #1e3a8a 0%, #142038 72%);
  }

  /* 飛向魔王的分身牌 */
  .card-ghost {
    position: fixed !important;
    z-index: 70;
    margin: 0 !important;
    pointer-events: none;
    box-sizing: border-box;
  }
  .foil-card.is-flying { opacity: 0.22; }
  .foil-card.fx-lock { transition: none !important; }

  .tcg-collected {
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 2;
    font-size: 0.76rem;
    font-weight: 900;
    color: #14532d;
    background: #fef9c3;
    border: 1.5px solid #ca8a04;
    border-radius: 999px;
    padding: 1px 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    animation: stampIn 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  }

  /* 魔王擊破章 */
  .portrait-frame.boss-ko {
    animation: koShake 0.6s ease 1 !important;
    filter: grayscale(1) brightness(0.85) !important;
  }
  .portrait-frame.boss-ko::after {
    content: "擊破";
    position: absolute;
    left: 10%;
    right: 10%;
    top: 34%;
    z-index: 5;
    text-align: center;
    font-family: var(--serif);
    font-weight: 900;
    font-size: clamp(1.8rem, 4.6vw, 3rem);
    letter-spacing: 6px;
    color: #dc2626;
    background: rgba(255, 251, 235, 0.88);
    border: 5px double #dc2626;
    border-radius: 14px;
    padding: 2px 0;
    animation: stampIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) 0.25s both;
  }
  @keyframes koShake {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    20% { transform: translate(-12px, 4px) rotate(-4deg); }
    40% { transform: translate(12px, -4px) rotate(4deg); }
    60% { transform: translate(-8px, 2px) rotate(-2deg); }
    80% { transform: translate(6px, -2px) rotate(1deg); }
  }

  /* 📖 法規卡冊 */
  .cb-summary {
    background: #fef3c7;
    border-left: 5px solid var(--gold);
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 800;
    line-height: 1.7;
    margin-bottom: 6px;
  }
  .cb-section { margin: 14px 0 4px; }
  .cb-section-title {
    font-family: var(--serif);
    font-weight: 900;
    color: #14532d;
    font-size: 1.05rem;
    margin: 0 0 8px;
  }
  .cb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
  }
  .cb-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: linear-gradient(160deg, #fffdf5 0%, #f3e4c3 100%);
    border: 2.5px solid var(--gold);
    border-radius: 13px;
    padding: 9px 10px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  }
  .cb-top { display: flex; align-items: center; gap: 8px; }
  .cb-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    border-radius: 9px;
    background: radial-gradient(circle at 50% 38%, #fffbea 0%, #f7d97e 52%, #b57c25 100%);
    border: 1.5px solid #7a5216;
  }
  .cb-name { font-family: var(--serif); font-weight: 900; color: #14532d; font-size: 1.04rem; line-height: 1.3; }
  .cb-round { font-size: 0.76rem; font-weight: 800; color: #6b5a43; }
  .cb-law {
    align-self: flex-start;
    font-size: 0.78rem;
    font-weight: 800;
    background: #14532d;
    color: #dcfce7;
    border-radius: 999px;
    padding: 1px 9px;
  }
  .cb-desc { font-size: 0.92rem; font-weight: 700; line-height: 1.55; color: #3a2b1a; }
  .cb-card details {
    font-size: 0.88rem;
    line-height: 1.65;
    color: #14532d;
    background: rgba(20, 83, 45, 0.07);
    border-radius: 8px;
    padding: 5px 8px;
  }
  .cb-card summary { cursor: pointer; font-weight: 900; }
  .cb-review {
    align-self: flex-start;
    font-size: 0.76rem;
    font-weight: 900;
    color: #9a3412;
    background: #ffedd5;
    border: 1px solid #fdba74;
    border-radius: 999px;
    padding: 1px 8px;
  }
  .cb-card.locked {
    min-height: 118px;
    align-items: center;
    justify-content: flex-end;
    border-color: var(--gold-bright);
    background: #142038;
  }
  .cb-lock-text {
    position: relative;
    z-index: 1;
    font-size: 0.82rem;
    font-weight: 900;
    color: #fef3c7;
    background: rgba(15, 23, 42, 0.82);
    border-radius: 999px;
    padding: 2px 10px;
    text-align: center;
  }

  /* 手機與窄螢幕：三張牌直排，改成橫式精簡卡 */
  @media (max-width: 860px) {
    .tcg-card {
      display: grid;
      grid-template-columns: 54px minmax(0, 1fr);
      grid-template-areas: "art title" "art pill" "art desc";
      column-gap: 9px;
      row-gap: 4px;
      align-items: start;
      min-height: 0;
      padding: 8px 10px;
    }
    .tcg-art { grid-area: art; height: 100%; min-height: 62px; }
    .tcg-art-icon { font-size: 1.75rem; }
    .tcg-titlebar { grid-area: title; justify-content: flex-start; padding: 3px 8px; }
    .tcg-card .fc-name { font-size: 1rem; text-align: left; letter-spacing: 0.5px; }
    .tcg-card .fc-law-pill { grid-area: pill; justify-self: start; }
    .tcg-card .fc-desc { grid-area: desc; padding: 4px 8px; }
    .tcg-collected { top: auto; bottom: 6px; right: 8px; }
    .cb-grid { grid-template-columns: 1fr; }
  }

  /* =========================================================
     9. 新題型：🔍 找碴（抓廢票）、⚖️ 合法／違規快判、🔢 數字牌、🔑 重點、星等
  ========================================================= */
  .spell-hand.mode-spot, .spell-hand.mode-judge { display: block; }

  .round-howto {
    background: rgba(16, 24, 40, 0.88);
    color: #fef3c7;
    border: 1.5px solid rgba(247, 217, 126, 0.7);
    border-radius: 12px;
    padding: 8px 12px;
    font-weight: 800;
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 16px;
  }

  /* 🔍 找碴：選票 */
  .ballot-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px 12px;
  }
  .ballot {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fffef7;
    color: #2b2116;
    border: 2px solid #c9b48a;
    border-radius: 6px;
    padding: 13px 9px 8px;
    text-align: left;
    font-family: var(--serif);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5);
  }
  .ballot:hover:not(:disabled) {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(247, 217, 126, 0.75);
  }
  .ballot:disabled { cursor: default; }
  .ballot-tag {
    position: absolute;
    top: -12px;
    left: 8px;
    background: #142038;
    color: var(--gold-bright);
    border: 1.5px solid var(--gold-bright);
    border-radius: 999px;
    padding: 0 10px;
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 900;
  }
  .ballot-head {
    display: block;
    text-align: center;
    font-weight: 900;
    font-size: 0.8rem;
    line-height: 1.35;
    border-bottom: 1.5px solid #8a6d3b;
    padding-bottom: 4px;
    margin-bottom: 3px;
  }
  .ballot-head small { display: block; font-size: 0.7rem; font-weight: 700; color: #6b5a43; }
  .ballot-row {
    display: grid;
    grid-template-columns: 24px 16px minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    min-height: 26px;
    border-bottom: 1px dashed #d8c9a6;
    font-size: 0.9rem;
    font-weight: 800;
  }
  .ballot-mark { position: relative; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; }
  .ballot-no { font-family: var(--sans); font-size: 0.74rem; color: #6b5a43; text-align: center; }
  .ballot-name { display: block; min-width: 0; line-height: 1.2; }
  .ring {
    position: relative;
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2.6px solid #1d4ed8;
    transform: rotate(-8deg);
  }
  .ring.pencil { border-color: #a1a1aa; border-width: 2px; box-shadow: 0 0 0 1px rgba(161, 161, 170, 0.4); }
  .pencil-tip { position: absolute; right: -9px; top: -7px; font-size: 0.82rem; }
  .ring.altered::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 4px;
    background: repeating-linear-gradient(135deg, #1d4ed8 0 2px, transparent 2px 4px);
    opacity: 0.92;
  }
  .ballot-note {
    display: block;
    font-family: "DFKai-SB", "BiauKai", "標楷體", var(--serif);
    color: #1d4ed8;
    font-size: 0.76rem;
    font-weight: 700;
    transform: rotate(-3deg);
    transform-origin: left center;
  }
  .ballot-stamps { display: flex; justify-content: space-between; align-items: flex-end; gap: 6px; margin-top: 7px; }
  .stamp-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .stamp-cap { font-family: var(--sans); font-size: 0.64rem; font-weight: 800; color: #8a7a5c; }
  .stamp {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #c81e1e;
    border: 2px solid #c81e1e;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 0.62rem;
    line-height: 1.12;
    opacity: 0.88;
  }
  .stamp.cu { width: 40px; height: 40px; border-radius: 4px; transform: rotate(-5deg); }
  .stamp.sup { width: 30px; height: 30px; border-radius: 50%; transform: rotate(8deg); }
  .stamp.missing { border: 1.5px dashed #c8b991; opacity: 1; transform: none; }
  /* 作廢章蓋在票頭（社名、屆次那一塊），不遮住圈選處與印章，方便改判時還看得到證據 */
  .ballot.marked { border-color: #dc2626; }
  .ballot.marked::after {
    content: attr(data-stamp);
    position: absolute;
    left: 16%;
    right: 16%;
    top: 3px;
    text-align: center;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1.32rem;
    line-height: 1.2;
    letter-spacing: 6px;
    color: #dc2626;
    background: rgba(255, 251, 235, 0.92);
    border: 4px double #dc2626;
    border-radius: 10px;
    pointer-events: none;
    animation: voidStampIn 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  }
  @keyframes voidStampIn {
    0% { opacity: 0; transform: rotate(-6deg) scale(2.2); }
    100% { opacity: 1; transform: rotate(-6deg) scale(1); }
  }
  .ballot.hint-glow { animation: spotGlow 1.1s ease-in-out infinite; }
  @keyframes spotGlow {
    0%, 100% { box-shadow: 0 0 0 3px #fde047, 0 10px 22px rgba(0, 0, 0, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(253, 224, 71, 0.35), 0 10px 22px rgba(0, 0, 0, 0.5); }
  }
  .ballot-verdict {
    display: block;
    position: relative;
    z-index: 2;
    margin-top: 7px;
    border-radius: 8px;
    padding: 4px 7px;
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 900;
    line-height: 1.45;
  }
  .ballot-verdict.ok { background: #dcfce7; color: #14532d; border: 1.5px solid #16a34a; }
  .ballot-verdict.bad { background: #fee2e2; color: #7f1d1d; border: 1.5px solid #dc2626; }
  .bv-law { display: block; font-size: 0.72rem; font-weight: 800; opacity: 0.85; }

  /* 🔍 找碴：文件卡（申請書、名冊、選務紀錄、罷免案、清冊欄位）；外框沿用 .ballot */
  .doc-head {
    background: #fffdf5;
    color: #3a2b1a;
    border: 2px dashed #b4771e;
    border-radius: 10px;
    padding: 6px 12px;
    margin: -6px 0 16px;
    text-align: center;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 0.92rem;
    line-height: 1.5;
  }
  .doc-head small { display: block; font-family: var(--sans); font-weight: 700; font-size: 0.78rem; color: #6b5a43; }
  .doc-card { padding-top: 16px; }
  .doc-title {
    display: block;
    font-weight: 900;
    font-size: 1rem;
    color: #14532d;
    border-bottom: 1.5px solid #8a6d3b;
    padding: 2px 0 4px;
    margin-bottom: 2px;
    line-height: 1.35;
  }
  .doc-line {
    display: block;
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.45;
    padding: 4px 0;
    border-bottom: 1px dashed #d8c9a6;
  }
  /* 文件卡的章蓋在右上角，不遮住任何一行內容 */
  .ballot.doc-card.marked::after {
    left: auto;
    right: -8px;
    top: -14px;
    padding: 0 8px;
    font-size: 1.08rem;
    letter-spacing: 3px;
  }
  .spot-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
  .spot-msg { max-width: 760px; text-align: center; font-weight: 900; font-size: 0.98rem; line-height: 1.6; border-radius: 10px; }
  .spot-msg:empty { display: none; }
  .spot-msg.ng { background: #fef2f2; color: #7f1d1d; border: 2px solid #dc2626; padding: 7px 12px; }
  .spot-msg.ok { background: #ecfdf5; color: #14532d; border: 2px solid #16a34a; padding: 7px 12px; }
  .spot-submit { width: auto; padding: 11px 26px; font-size: 1.05rem; letter-spacing: 1px; }

  /* ⚖️ 合法／違規快判 */
  .judge-panel {
    max-width: 760px;
    margin: 0 auto;
    background: linear-gradient(160deg, #fffdf5 0%, #f3e4c3 100%);
    border: 3px solid var(--gold);
    border-radius: 16px;
    padding: 12px 16px 14px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.55), inset 0 0 0 2px rgba(255, 255, 255, 0.8);
  }
  .judge-progress { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 900; font-size: 0.9rem; color: #6b5a43; }
  .judge-dots { display: inline-flex; gap: 6px; }
  .judge-shield {
    display: inline-block;
    margin-left: 8px;
    background: #fef9c3;
    color: #713f12;
    border: 1.5px solid #eab308;
    border-radius: 999px;
    padding: 0 8px;
    font-size: 0.8rem;
    font-weight: 900;
  }
  .judge-dot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #b4771e; background: #fff; }
  .judge-dot.on { background: #16a34a; border-color: #15803d; }
  .judge-statement {
    position: relative;
    margin: 10px 0 12px;
    padding-right: 46px;
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1.6;
    color: #231b12;
  }
  .judge-stamp { position: absolute; right: 0; top: -4px; font-size: 2rem; animation: stampIn 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
  .judge-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .judge-btn {
    padding: 14px 10px;
    border-radius: 14px;
    border: 3px solid;
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: 2px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  }
  .judge-btn.ok { background: #dcfce7; color: #14532d; border-color: #16a34a; }
  .judge-btn.ng { background: #fee2e2; color: #7f1d1d; border-color: #dc2626; }
  .judge-btn:hover { transform: translateY(-3px); filter: brightness(1.04); }
  .judge-result { margin-top: 10px; border-radius: 10px; padding: 8px 12px; font-weight: 800; line-height: 1.6; }
  .judge-result.ok { background: #ecfdf5; border: 2px solid #16a34a; color: #14532d; }
  .judge-result.ng { background: #fef2f2; border: 2px solid #dc2626; color: #7f1d1d; }
  .judge-verdict { font-weight: 900; font-size: 1.04rem; }
  .judge-again { margin-top: 4px; font-size: 0.88rem; font-weight: 900; color: #9a3412; }
  .judge-next { display: flex; justify-content: center; margin-top: 10px; }
  .judge-next .btn-storybook-primary { width: auto; padding: 10px 28px; font-size: 1.02rem; }

  /* 🔢 數字牌 */
  .num-template {
    grid-column: 1 / -1;
    background: rgba(255, 253, 245, 0.96);
    color: #231b12;
    border: 2px dashed #b4771e;
    border-radius: 12px;
    padding: 8px 12px;
    font-weight: 800;
    line-height: 1.75;
  }
  .num-template-title { font-weight: 900; color: #8f1d21; font-size: 0.92rem; }
  .num-line { font-size: 1rem; }
  .num-no { color: #9a6516; margin-right: 4px; font-weight: 900; }
  .num-blank {
    display: inline-block;
    min-width: 2.4em;
    margin: 0 3px;
    border-bottom: 3px solid #8f1d21;
    text-align: center;
    color: #8f1d21;
    font-weight: 900;
  }
  .tcg-card.num-card .fc-name { font-size: 1.42rem; letter-spacing: 1px; }
  /* 數字牌四張：桌機排成 2×2 橫式卡（手機與窄螢幕維持一欄，沿用上面的橫式精簡卡） */
  @media (min-width: 861px) {
    .spell-hand.mode-number { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .spell-hand.mode-number .tcg-card {
      display: grid;
      grid-template-columns: 70px minmax(0, 1fr);
      grid-template-areas: "art title" "art pill" "art desc";
      column-gap: 10px;
      row-gap: 5px;
      align-items: start;
      min-height: 0;
    }
    .spell-hand.mode-number .tcg-art { grid-area: art; height: 100%; min-height: 76px; }
    .spell-hand.mode-number .tcg-titlebar { grid-area: title; }
    .spell-hand.mode-number .fc-law-pill { grid-area: pill; justify-self: start; }
    .spell-hand.mode-number .fc-desc { grid-area: desc; padding: 5px 9px; }
    .spell-hand.mode-number .tcg-collected { top: auto; bottom: 6px; right: 8px; }
  }

  /* 🔑 重點、星等 */
  .key-point {
    display: inline-block;
    margin-bottom: 6px;
    background: #fef9c3;
    border: 2px solid #ca8a04;
    color: #713f12;
    border-radius: 10px;
    padding: 3px 10px;
    font-weight: 900;
    font-size: 0.98rem;
    line-height: 1.5;
  }
  .cb-key {
    font-size: 0.86rem;
    font-weight: 900;
    color: #713f12;
    background: #fef9c3;
    border: 1.5px solid #eab308;
    border-radius: 8px;
    padding: 3px 8px;
    line-height: 1.5;
  }
  .round-stars { font-size: 0.86rem; letter-spacing: 1px; color: #7a3e00; line-height: 1.15; margin-top: 1px; }
  .proceed-wrap { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
  .stage-stars {
    color: #fef3c7;
    font-weight: 900;
    font-size: 0.98rem;
    background: rgba(16, 24, 40, 0.82);
    border: 1.5px solid rgba(247, 217, 126, 0.7);
    border-radius: 999px;
    padding: 5px 12px;
  }
  .stage-stars b { color: #fde047; letter-spacing: 2px; }
  .mob-qc-stars { color: #fde047; letter-spacing: 1px; margin-left: 4px; white-space: nowrap; }

  @media (max-width: 860px) {
    .ballot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 9px; }
  }
  @media (max-width: 760px) {
    #battleInner[data-mode="spot"] .portrait-frame { height: 96px; max-width: 120px; }
    .round-howto { font-size: 0.88rem; padding: 7px 10px; margin-bottom: 14px; }
    .ballot { padding: 12px 6px 6px; }
    .ballot-head { font-size: 0.72rem; }
    .ballot-head small { font-size: 0.64rem; }
    .ballot-row { grid-template-columns: 22px 13px minmax(0, 1fr); gap: 3px; min-height: 24px; font-size: 0.84rem; }
    .ring { width: 18px; height: 18px; }
    .stamp.cu { width: 36px; height: 36px; font-size: 0.56rem; }
    .stamp.sup { width: 27px; height: 27px; font-size: 0.54rem; }
    .ballot.marked::after { font-size: 1.08rem; letter-spacing: 3px; left: 10%; right: 10%; }
    .ballot.doc-card.marked::after { font-size: 0.84rem; letter-spacing: 2px; top: -19px; right: -4px; padding: 0 6px; border-width: 3px; }
    .doc-head { font-size: 0.86rem; padding: 5px 8px; }
    .doc-title { font-size: 0.94rem; }
    .doc-line { font-size: 0.84rem; padding: 3px 0; }
    .ballot-verdict { font-size: 0.76rem; padding: 3px 5px; }
    .spot-msg { font-size: 0.9rem; }
    .spot-submit { width: 100%; }
    .judge-panel { padding: 10px 12px 12px; }
    .judge-statement { font-size: 1.08rem; padding-right: 38px; }
    .judge-stamp { font-size: 1.6rem; }
    .judge-btn { font-size: 1.1rem; padding: 12px 8px; }
    .num-line { font-size: 0.92rem; line-height: 1.6; }
    .tcg-card.num-card .fc-name { font-size: 1.2rem; }
    .proceed-wrap { width: 100%; }
    .stage-stars { width: 100%; text-align: center; }
  }

  @media (prefers-reduced-motion: reduce) {
    .ballot.marked::after,
    .ballot.hint-glow,
    .judge-stamp { animation: none !important; }
    .ballot.hint-glow { box-shadow: 0 0 0 4px #fde047, 0 10px 22px rgba(0, 0, 0, 0.5); }
  }

  @media (prefers-reduced-motion: reduce) {
    .battle-inner.hit-shake,
    .portrait-frame.boss-ko,
    .portrait-frame.boss-ko::after,
    .tcg-collected { animation: none !important; }
  }

  @media print {
    #titleScreen, #mapScreen, #battleScreen, #cutinOverlay, .no-print { display: none !important; }
    .modal-backdrop { display: none !important; }
    #victoryModal { position: static; display: block !important; background: #fff; backdrop-filter: none; padding: 0; }
    .storybook-modal { border: none; box-shadow: none; max-height: none; }
    .sm-head { display: none !important; }
    .cert-ledger-seal { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  }

  /* =========================================================
     選務值班：文件一件件上門、你來判；判錯開糾正單、扣公信力
  ========================================================= */
  #dutyScreen {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    flex-direction: column;
    background: #0c121e;
    overflow-y: auto;
  }
  #dutyScreen.open { display: flex; }

  .duty-inner {
    position: relative;
    z-index: 5;
    flex: 1 0 auto;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 10px 14px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .duty-inner.hit-shake { animation: stageShake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

  .duty-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 10px;
    background: rgba(12, 18, 30, 0.84);
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 8px 12px;
    color: #fef3c7;
  }
  .duty-day { font-family: var(--serif); font-weight: 900; font-size: 1.04rem; color: var(--gold-bright); line-height: 1.3; }
  .duty-day small { display: block; font-family: var(--sans); font-size: 0.78rem; color: #cbd5e1; font-weight: 700; }
  .duty-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-weight: 900; }
  .duty-trust { display: inline-flex; align-items: center; gap: 1px; font-size: 1.12rem; }
  .duty-trust .lost { filter: grayscale(1); opacity: 0.3; }
  .duty-trust-label { font-size: 0.78rem; color: #cbd5e1; margin-right: 4px; }
  .duty-score { font-size: 0.98rem; color: #fde68a; }
  .duty-progress { font-size: 0.82rem; color: #cbd5e1; }
  .duty-streak { font-size: 0.86rem; color: #fb923c; }
  .duty-streak:empty { display: none; }
  .duty-tools { display: flex; gap: 6px; flex-wrap: wrap; }
  .duty-tools .hud-btn { padding: 6px 10px; font-size: 0.86rem; }
  .hud-btn.armed { background: #b91c1c; border-color: #fecaca; color: #fff; }

  .duty-queue {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 2.9rem;
    background: rgba(255, 253, 247, 0.1);
    border: 1.5px dashed rgba(247, 217, 126, 0.55);
    border-radius: 12px;
    padding: 6px 10px;
    color: #f8fafc;
    font-weight: 800;
    font-size: 0.9rem;
  }
  .duty-queue-label { color: #fde68a; }
  .duty-q-person {
    position: relative;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fffdf5, #efe3c8);
    border: 2px solid var(--gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
  }
  .duty-q-mood { position: absolute; right: -7px; bottom: -6px; font-size: 0.92rem; }
  .duty-q-more { color: #e2e8f0; }
  .duty-timer { margin-left: auto; font-variant-numeric: tabular-nums; color: #bbf7d0; }
  .duty-timer.mid { color: #fde68a; }
  .duty-timer.slow { color: #fca5a5; }
  .duty-q-msg { flex: 1 1 100%; font-size: 0.82rem; color: #fecaca; }
  .duty-pips { letter-spacing: 3px; color: #fca5a5; }

  .duty-stage { display: flex; flex-direction: column; gap: 10px; }

  .duty-visitor { display: flex; gap: 10px; align-items: flex-start; animation: dutyIn 0.35s ease both; }
  .duty-avatar {
    flex: 0 0 auto;
    width: 3.4rem;
    height: 3.4rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fffdf5, #efe3c8);
    border: 3px solid var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.95rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  }
  .duty-bubble {
    flex: 1 1 auto;
    min-width: 0;
    background: linear-gradient(180deg, #fffdf7, #f4e6c8);
    border: 2.5px solid var(--gold);
    border-radius: 14px;
    padding: 9px 13px;
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #24180b;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  }
  .duty-bubble b { color: #14532d; }
  .duty-bubble.boss { border-color: #dc2626; }
  .duty-bubble.boss b { color: #8f1d21; }
  .duty-role {
    display: inline-block;
    background: #14532d;
    color: #fff;
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.76rem;
    margin-right: 6px;
    vertical-align: 2px;
  }
  .duty-role.staff { background: #1e3a8a; }
  .duty-role.boss { background: #8f1d21; }
  .duty-role.mentor { background: #6d28d9; }

  .duty-doc,
  .duty-memo {
    position: relative;
    background: #fffef7;
    color: #2b2116;
    border: 2px solid #c9b48a;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5);
    animation: dutyIn 0.4s ease both;
  }
  .duty-doc { font-family: var(--serif); }
  .duty-doc-head {
    text-align: center;
    font-weight: 900;
    font-size: 0.95rem;
    border-bottom: 3px double #8a6d3b;
    padding: 0 4.8rem 6px;
    margin-bottom: 6px;
    line-height: 1.45;
  }
  .duty-doc-head small { display: block; font-family: var(--sans); font-weight: 700; font-size: 0.8rem; color: #6b5a43; }
  .duty-doc-title { font-weight: 900; font-size: 1.14rem; color: #14532d; padding: 2px 0 4px; }
  .duty-doc-line {
    font-family: var(--sans);
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.5;
    padding: 6px 0;
    border-bottom: 1px dashed #d8c9a6;
  }
  .duty-memo { font-size: 1.08rem; font-weight: 800; line-height: 1.7; border-left: 7px solid #1e3a8a; padding-right: 5.2rem; }
  .duty-memo-cap { display: block; font-size: 0.8rem; color: #6b5a43; margin-bottom: 4px; }

  .duty-stamp {
    position: absolute;
    right: 10px;
    top: 10px;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1.32rem;
    letter-spacing: 3px;
    padding: 2px 10px;
    border: 4px double currentColor;
    border-radius: 10px;
    background: rgba(255, 251, 235, 0.92);
    transform: rotate(-8deg);
    animation: stampIn 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both;
    pointer-events: none;
  }
  .duty-stamp.green { color: #15803d; }
  .duty-stamp.red { color: #dc2626; }
  .duty-stamp.blue { color: #1d4ed8; }

  .duty-boss { display: flex; gap: 10px; align-items: flex-start; animation: dutyIn 0.35s ease both; }
  .duty-boss img {
    flex: 0 0 auto;
    width: 4.6rem;
    height: 4.6rem;
    border-radius: 14px;
    object-fit: cover;
    border: 3px solid #b91c1c;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
  }
  .duty-boss-intro { text-align: center; }
  .duty-boss-intro img {
    width: 9rem;
    height: 9rem;
    border-radius: 18px;
    object-fit: cover;
    border: 4px solid #b91c1c;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  }

  .duty-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .duty-cards.num { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .duty-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    background: linear-gradient(160deg, #fffdf5, #f3e4c3);
    color: #23180b;
    border: 3px solid var(--gold);
    border-radius: 14px;
    padding: 12px 10px;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5);
    animation: dutyIn 0.35s ease both;
  }
  .duty-card:hover:not(:disabled) { transform: translateY(-4px); box-shadow: 0 16px 30px rgba(0, 0, 0, 0.6), 0 0 18px rgba(247, 217, 126, 0.6); }
  .duty-card:disabled { cursor: default; }
  .duty-card-icon { font-size: 2rem; line-height: 1; }
  .duty-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .duty-card-name { font-family: var(--serif); font-weight: 900; font-size: 1.12rem; color: #14532d; }
  .duty-card.num .duty-card-name { font-size: 1.34rem; color: #142038; letter-spacing: 1px; }
  .duty-card-desc { font-weight: 800; font-size: 0.96rem; line-height: 1.5; }
  .duty-card.is-right { border-color: #16a34a; background: linear-gradient(160deg, #dcfce7, #bbf7d0); }
  .duty-card.is-wrong { border-color: #dc2626; background: linear-gradient(160deg, #fee2e2, #fecaca); }
  .duty-card.is-dim { opacity: 0.5; }
  .duty-num-template { margin-bottom: 0; }

  .duty-result { border-radius: 12px; padding: 10px 14px; font-weight: 800; line-height: 1.6; animation: dutyIn 0.3s ease both; }
  .duty-result.ok { background: #ecfdf5; border: 2.5px solid #16a34a; color: #14532d; }
  .duty-result-title { font-weight: 900; font-size: 1.1rem; }
  .duty-plus { color: #15803d; margin-left: 4px; }
  .duty-bonus { display: inline-block; color: #b45309; font-weight: 900; margin-left: 8px; }
  .duty-law {
    display: inline-block;
    margin-top: 4px;
    background: #142038;
    color: var(--gold-bright);
    border-radius: 999px;
    padding: 1px 10px;
    font-size: 0.84rem;
    font-weight: 800;
  }

  .duty-ticket {
    position: relative;
    background: #fff7f7;
    border: 3px solid #dc2626;
    border-radius: 6px;
    padding: 10px 14px 12px;
    color: #450a0a;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
    animation: ticketIn 0.42s cubic-bezier(0.2, 1.2, 0.4, 1) both;
  }
  .duty-ticket-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 2px 10px;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 1.15rem;
    color: #b91c1c;
    border-bottom: 2px solid #fca5a5;
    padding-bottom: 4px;
    margin-bottom: 6px;
  }
  .duty-ticket-head small { font-family: var(--sans); font-size: 0.82rem; color: #7f1d1d; }
  .duty-ticket-row { font-weight: 800; line-height: 1.6; font-size: 1rem; padding-right: 3.6rem; }
  .duty-ticket-row .lbl { display: inline-block; min-width: 4.6em; color: #7f1d1d; }
  .duty-ticket-row .right { color: #14532d; font-weight: 900; }
  .duty-ticket-row .wrong { text-decoration: line-through; color: #9f1239; }
  .duty-ticket-seal {
    position: absolute;
    right: 12px;
    bottom: 12px;
    color: #dc2626;
    border: 3px solid #dc2626;
    border-radius: 50%;
    width: 3.4rem;
    height: 3.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif);
    font-weight: 900;
    font-size: 0.92rem;
    transform: rotate(12deg);
    opacity: 0.8;
  }
  .duty-trust-drop { color: #b91c1c; font-weight: 900; margin-top: 4px; }

  .duty-panel {
    background: linear-gradient(180deg, #fffdf7, #f4e6c8);
    border: 3px solid var(--gold);
    border-radius: 16px;
    padding: 14px 16px;
    color: #24180b;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55);
    animation: dutyIn 0.35s ease both;
  }
  .duty-panel h2 { margin: 0 0 8px; font-family: var(--serif); color: #14532d; font-size: 1.3rem; line-height: 1.4; }
  .duty-panel p { font-weight: 800; line-height: 1.65; margin: 8px 0; }
  .duty-rules { margin: 10px 0 4px; padding-left: 1.1em; line-height: 1.7; font-weight: 800; }
  .duty-rules li { margin: 3px 0; }
  .duty-best { margin-top: 8px; font-weight: 900; color: #9a6516; }
  .duty-stars-big { font-size: 2.1rem; color: #f59e0b; text-align: center; letter-spacing: 4px; }
  .duty-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
  .duty-stat { background: #fffef7; border: 2px solid #e6d3a5; border-radius: 10px; padding: 6px 10px; font-weight: 900; }
  .duty-stat small { display: block; color: #6b5a43; font-size: 0.78rem; font-weight: 800; }
  .duty-score-big { text-align: center; font-weight: 900; font-size: 1.08rem; margin: 6px 0; }
  .duty-score-big b { font-size: 1.5rem; color: #9a6516; }
  .duty-reward { background: #fef9c3; border: 2px solid #ca8a04; border-radius: 10px; padding: 6px 10px; font-weight: 900; color: #713f12; margin: 8px 0; }
  .duty-clean { background: #ecfdf5; border: 2px solid #16a34a; border-radius: 10px; padding: 6px 10px; font-weight: 900; color: #14532d; margin-top: 8px; }
  .duty-sub { margin: 12px 0 4px; font-family: var(--serif); color: #8f1d21; font-size: 1.05rem; }
  .duty-ticket-list { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 6px; }
  .duty-ticket-list li {
    background: #fff7f7;
    border: 1.5px solid #fca5a5;
    border-left: 5px solid #dc2626;
    border-radius: 6px;
    padding: 6px 10px;
    font-weight: 800;
    font-size: 0.94rem;
    line-height: 1.55;
  }

  /* 開票關：一張張驗選票（沿用找碴關的選票畫法，放大給長輩看） */
  .duty-ballot {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    padding: 16px 14px 10px;
    animation: dutyIn 0.4s ease both;
  }
  .duty-ballot .ballot-head { font-size: 1rem; }
  .duty-ballot .ballot-head small { font-size: 0.8rem; }
  .duty-ballot .ballot-row { grid-template-columns: 32px 22px minmax(0, 1fr); min-height: 36px; font-size: 1.08rem; }
  .duty-ballot .ballot-mark { width: 32px; height: 32px; }
  .duty-ballot .ring { width: 25px; height: 25px; border-width: 3px; }
  .duty-ballot .ballot-no { font-size: 0.86rem; }
  .duty-ballot .ballot-note { font-size: 0.92rem; }
  .duty-ballot .stamp.cu { width: 50px; height: 50px; font-size: 0.74rem; }
  .duty-ballot .stamp.sup { width: 40px; height: 40px; font-size: 0.7rem; }
  .duty-ballot .stamp-cap { font-size: 0.74rem; }
  .duty-ballot .duty-stamp { top: 42%; bottom: auto; right: 10px; } /* 蓋在名單右側空白處，不遮社印、監事印 */

  /* 最終關：清冊佐證 */
  .duty-card.is-struck { opacity: 0.45; filter: grayscale(0.85); border-style: dashed; }
  .duty-struck-tag {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #475569;
    color: #f1f5f9;
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.76rem;
    font-weight: 900;
  }
  .duty-ledger-line {
    background: #ecfdf5;
    border: 2px solid #16a34a;
    border-radius: 10px;
    padding: 6px 10px;
    color: #14532d;
  }
  .duty-ledger-badge {
    display: inline-block;
    background: #14532d;
    color: #fef3c7;
    border: 1.5px solid var(--gold-bright);
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.8rem;
  }
  .duty-trust-drop.shielded { color: #15803d; }

  /* 玩到才出現的一行小提示；第一件時手冊按鈕發光 */
  .duty-hint {
    background: #fef9c3;
    border: 2px dashed #ca8a04;
    color: #713f12;
    border-radius: 10px;
    padding: 7px 12px;
    font-weight: 900;
    font-size: 1rem;
    line-height: 1.6;
    animation: dutyIn 0.35s ease both;
  }
  .duty-tip { margin-top: 6px; font-size: 0.92rem; color: #92400e; font-weight: 900; }
  .hud-btn.duty-glow { animation: dutyGlow 1.2s ease-in-out infinite; }
  @keyframes dutyGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(247, 217, 126, 0); }
    50% { box-shadow: 0 0 0 4px rgba(247, 217, 126, 0.85); }
  }

  .duty-manual-tip { font-weight: 800; color: #6b5a43; margin: 0 0 6px; line-height: 1.6; }
  .duty-manual-item { border-bottom: 1px dashed #d8c9a6; padding: 9px 0; }
  .duty-manual-item b { color: #14532d; font-size: 1.04rem; }
  .duty-manual-item p { margin: 3px 0; font-weight: 700; line-height: 1.7; }

  /* 按鈕列跟在申請書、糾正單後面（不浮在畫面底部），一定看完內容才按得到 */
  .duty-actions {
    position: relative;
    z-index: 6;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 2px 0 calc(18px + env(safe-area-inset-bottom, 0px));
    scroll-margin-bottom: 12px;
  }
  .duty-actions.single { grid-template-columns: 1fr; }
  .duty-actions:empty { display: none; }
  .duty-act {
    border-radius: 14px;
    padding: 14px 10px;
    font-size: 1.16rem;
    font-weight: 900;
    border: 3px solid;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  }
  .duty-act.ok { background: linear-gradient(180deg, #dcfce7, #bbf7d0); color: #14532d; border-color: #16a34a; }
  .duty-act.ng { background: linear-gradient(180deg, #fee2e2, #fecaca); color: #7f1d1d; border-color: #dc2626; }
  .duty-act.gold { background: linear-gradient(180deg, #fef3c7, #f7d97e); color: #422006; border-color: #c8963e; }
  .duty-act:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.04); }
  .duty-next { font-size: 1.12rem; padding: 13px 18px; }

  @keyframes dutyIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: none; }
  }
  @keyframes ticketIn {
    0% { opacity: 0; transform: translateY(-22px) rotate(-2deg); }
    100% { opacity: 1; transform: none; }
  }
  @media (prefers-reduced-motion: reduce) {
    .duty-visitor, .duty-doc, .duty-memo, .duty-stamp, .duty-boss, .duty-card,
    .duty-result, .duty-ticket, .duty-panel, .duty-inner.hit-shake,
    .duty-hint, .hud-btn.duty-glow { animation: none !important; }
  }
  @media (max-width: 760px) {
    .duty-inner { padding: 8px 10px 0; gap: 8px; }
    .duty-top { padding: 7px 10px; }
    .duty-day { font-size: 0.98rem; }
    .duty-cards, .duty-cards.num { grid-template-columns: 1fr; }
    .duty-card { flex-direction: row; align-items: center; text-align: left; padding: 10px 12px; }
    .duty-card-icon { font-size: 1.7rem; }
    .duty-doc-head { padding: 0 0 6px; }
    .duty-memo { padding-right: 14px; }
    .duty-act { padding: 13px 8px; font-size: 1.08rem; }
    .duty-boss img { width: 3.8rem; height: 3.8rem; }
    .duty-queue { gap: 6px; padding: 5px 8px; min-height: 0; font-size: 0.86rem; }
    .duty-q-person { width: 1.95rem; height: 1.95rem; font-size: 1.08rem; }
    .duty-q-mood { font-size: 0.8rem; right: -6px; bottom: -5px; }
    .duty-tools .hud-btn { padding: 6px 9px; font-size: 0.82rem; }
    .duty-panel h2 { font-size: 1.12rem; }
    .duty-panel .duty-avatar { width: 2.6rem; height: 2.6rem; font-size: 1.45rem; }
  }
  /* =========================================================
     開始前確認是官方帳號好友（LINE 官方帳號 @489koowc）
  ========================================================= */
  #laifuGate { z-index: 120; }
  .laifu-gate-modal { max-width: 480px; }
  .laifu-gate-modal .sm-head { background: linear-gradient(135deg, #c2410c 0%, #14532d 100%); }
  .laifu-body { display: flex; flex-direction: column; gap: 12px; }
  .laifu-intro { display: flex; align-items: center; gap: 14px; }
  .laifu-dog {
    width: 6.2rem; height: 6.2rem; flex: 0 0 auto;
    border-radius: 50%; background: #fff; border: 3px solid var(--gold);
    object-fit: cover; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  }
  .laifu-lead { font-weight: 900; font-size: 1.08rem; color: var(--emerald); margin-bottom: 6px; }
  .laifu-feats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
  .laifu-feats li { font-weight: 800; font-size: 1.04rem; color: var(--ink); }
  .laifu-feats li::before { content: '・'; color: #c2410c; }
  .laifu-name-note { font-size: 0.95rem; color: var(--muted); font-weight: 700; text-align: center; }
  .laifu-step { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  .laifu-btn { display: block; text-align: center; text-decoration: none; font-size: 1.14rem; padding: 14px 18px; min-height: 48px; }
  .laifu-btn2 { width: 100%; font-size: 1.02rem; min-height: 46px; background: #1e3a5f; }
  .laifu-hint { font-size: 0.95rem; color: var(--muted); font-weight: 700; line-height: 1.55; text-align: center; }
  .laifu-msg { font-size: 1.06rem; font-weight: 800; color: var(--emerald); text-align: center; padding: 14px 6px; }
  .laifu-note { font-size: 1rem; font-weight: 900; color: var(--crimson); text-align: center; line-height: 1.5; }
  .laifu-qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .laifu-qr { width: 12.5rem; height: 12.5rem; background: #fff; padding: 6px; border-radius: 12px; border: 2px solid var(--gold); }
  .laifu-qr-cap { font-weight: 900; color: var(--ink); font-size: 1.02rem; text-align: center; }
  .laifu-link {
    background: none; border: none; color: #1d4ed8; text-decoration: underline;
    font-weight: 800; font-size: 0.98rem; padding: 10px; min-height: 44px; cursor: pointer;
  }
  .hud-btn.laifu-ask-btn {
    background: linear-gradient(180deg, #fb923c, #c2410c); color: #fff;
    border-color: #ffedd5; padding: 12px 18px; font-size: 0.95rem;
  }
  @media (max-width: 760px) {
    .laifu-dog { width: 5rem; height: 5rem; }
    .laifu-qr { width: 11rem; height: 11rem; }
  }
