:root {
      --void: #05080b;
      --ink: #0a1015;
      --panel: rgba(7, 12, 17, .82);
      --panel-strong: rgba(4, 8, 12, .94);
      --paper: #f2eadb;
      --muted: rgba(242, 234, 219, .68);
      --dim: rgba(242, 234, 219, .42);
      --line: rgba(242, 234, 219, .2);
      --cyan: #3df1dc;
      --cyan-soft: rgba(61, 241, 220, .22);
      --magenta: #ff4a91;
      --amber: #e5b85b;
      --red: #ff5b55;
      --green: #8de37d;
      --radius: 8px;
      --stage-top: 13vh;
      --dialogue-safe-bottom: clamp(198px, 24vh, 250px);
      color-scheme: dark;
      font-family: "Avenir Next", "Trebuchet MS", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    }

    * { box-sizing: border-box; }

    html,
    body {
      width: 100%;
      height: 100%;
      min-width: 320px;
      margin: 0;
      overflow: hidden;
      background: var(--void);
      color: var(--paper);
    }

    body {
      position: fixed;
      inset: 0;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }

    [hidden] {
      display: none !important;
    }

    button {
      font: inherit;
      color: inherit;
    }

    button:focus-visible,
    [tabindex]:focus-visible {
      outline: 2px solid var(--cyan);
      outline-offset: 3px;
    }

    .vn {
      position: relative;
      width: 100vw;
      height: 100dvh;
      min-height: 520px;
      overflow: hidden;
      background: #05080b;
      isolation: isolate;
    }

    .scene {
      position: absolute;
      inset: 0;
      background:
        linear-gradient(180deg, rgba(5, 8, 11, .08), rgba(5, 8, 11, .46) 55%, rgba(5, 8, 11, .78)),
        var(--scene-image),
        radial-gradient(circle at 68% 24%, rgba(61, 241, 220, .2), transparent 26%),
        linear-gradient(120deg, #08121a, #10120f 45%, #06080d);
      background-size: cover, cover, auto, auto;
      background-position: center;
      transform: scale(1.028);
      filter: saturate(.88) contrast(1.08) brightness(.88);
      transition: filter 480ms ease, transform 800ms ease, background-image 320ms ease;
      z-index: -5;
    }

    .scene::before,
    .scene::after,
    .weather,
    .scan {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    .scene::before {
      background:
        linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255,255,255,.022) 1px, transparent 1px);
      background-size: 64px 64px, 64px 64px;
      mix-blend-mode: screen;
      opacity: .38;
    }

    .scene::after {
      background:
        radial-gradient(ellipse at center, transparent 44%, rgba(0,0,0,.62) 100%),
        linear-gradient(90deg, rgba(255,74,145,.12), transparent 16%, transparent 80%, rgba(61,241,220,.1));
    }

    .weather {
      z-index: -3;
      background:
        repeating-linear-gradient(112deg, transparent 0 18px, rgba(183, 241, 255, .16) 19px 20px),
        repeating-linear-gradient(112deg, transparent 0 47px, rgba(255, 255, 255, .08) 48px 49px);
      background-size: 260px 260px, 430px 430px;
      animation: rain 1.7s linear infinite;
      opacity: .42;
    }

    .scan {
      z-index: 12;
      background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 5px);
      mix-blend-mode: soft-light;
      opacity: .58;
    }

    .glitch {
      position: absolute;
      inset: 0;
      z-index: -2;
      opacity: 0;
      background:
        linear-gradient(90deg, transparent, rgba(61, 241, 220, .35), transparent),
        linear-gradient(180deg, transparent 10%, rgba(255, 74, 145, .16) 10% 12%, transparent 12% 45%, rgba(229, 184, 91, .14) 45% 47%, transparent 47%);
      mix-blend-mode: screen;
      transform: translateX(-100%);
      pointer-events: none;
    }

    .vn.flash .glitch {
      animation: glitch-pass 600ms steps(3, end);
    }

    .topbar {
      position: absolute;
      top: env(safe-area-inset-top, 0);
      left: 0;
      right: 0;
      z-index: 95;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 12px;
      align-items: start;
      padding: 14px clamp(12px, 3vw, 34px) 0;
      pointer-events: none;
    }

    .case-id {
      min-width: 0;
      color: var(--muted);
      text-shadow: 0 2px 16px rgba(0,0,0,.9);
    }

    .case-id b {
      display: block;
      margin-bottom: 5px;
      color: var(--paper);
      font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
      font-size: clamp(22px, 4.5vw, 44px);
      line-height: 1;
      letter-spacing: 0;
    }

    .case-id span {
      display: block;
      max-width: min(680px, 88vw);
      font-size: 12px;
      font-weight: 800;
      letter-spacing: .1em;
      text-transform: uppercase;
    }

    .tools {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      pointer-events: auto;
      justify-content: flex-end;
    }

    .settings-wrap {
      position: relative;
      display: inline-grid;
      place-items: center;
    }

    .icon-btn,
    .text-btn {
      display: inline-grid;
      min-width: 38px;
      height: 38px;
      place-items: center;
      border: 1px solid rgba(242, 234, 219, .24);
      border-radius: var(--radius);
      background: rgba(5, 8, 11, .58);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.025), 0 12px 30px rgba(0,0,0,.25);
      backdrop-filter: blur(14px);
      cursor: pointer;
      transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
    }

    .text-btn {
      width: auto;
      padding: 0 12px;
      font-size: 12px;
      font-weight: 950;
      letter-spacing: .08em;
    }

    .icon-btn:hover,
    .text-btn:hover {
      border-color: rgba(61, 241, 220, .58);
      background: rgba(11, 25, 30, .72);
      transform: translateY(-1px);
    }

    .icon {
      width: 18px;
      height: 18px;
      fill: none;
      stroke: currentColor;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .settings-panel {
      position: absolute;
      top: calc(100% + 10px);
      right: 0;
      width: min(330px, calc(100vw - 28px));
      display: none;
      padding: 10px;
      border: 1px solid rgba(61, 241, 220, .24);
      border-radius: var(--radius);
      background:
        linear-gradient(180deg, rgba(8, 15, 18, .96), rgba(3, 7, 10, .94)),
        rgba(5, 8, 11, .96);
      box-shadow: 0 24px 70px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .035);
      backdrop-filter: blur(18px);
    }

    .settings-panel.open {
      display: block;
    }

    .settings-menu {
      display: grid;
      gap: 7px;
    }

    .settings-menu button,
    .save-slot,
    .chapter-slot {
      width: 100%;
      min-height: 42px;
      border: 1px solid rgba(242, 234, 219, .18);
      border-radius: var(--radius);
      background: rgba(255, 255, 255, .035);
      color: var(--paper);
      cursor: pointer;
      transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
    }

    .settings-menu button {
      padding: 0 12px;
      text-align: left;
      font-size: 12px;
      font-weight: 950;
      letter-spacing: .08em;
    }

    .settings-menu button:hover,
    .settings-menu button.active,
    .save-slot:hover:not(:disabled),
    .chapter-slot:hover:not(:disabled) {
      border-color: rgba(61, 241, 220, .56);
      background: rgba(61, 241, 220, .1);
      transform: translateY(-1px);
    }

    .settings-status {
      min-height: 28px;
      padding: 10px 2px 0;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.45;
    }

    .settings-slots {
      display: grid;
      gap: 7px;
      margin-top: 8px;
      max-height: min(48vh, 380px);
      overflow: auto;
    }

    .save-slot,
    .chapter-slot {
      display: grid;
      grid-template-columns: auto 1fr auto;
      align-items: center;
      gap: 10px;
      padding: 9px 10px;
      text-align: left;
    }

    .save-slot b,
    .chapter-slot b {
      font-size: 12px;
      letter-spacing: .06em;
      white-space: nowrap;
    }

    .save-slot span,
    .chapter-slot span {
      min-width: 0;
      overflow: hidden;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.35;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .save-slot small,
    .chapter-slot small {
      color: var(--cyan);
      font-size: 10px;
      font-weight: 950;
      letter-spacing: .08em;
    }

    .save-slot:disabled,
    .chapter-slot:disabled {
      cursor: default;
      opacity: .52;
    }

    .chapter-slot.locked small {
      color: rgba(242, 234, 219, .48);
    }

    .stage {
      position: absolute;
      inset: 0;
      z-index: 5;
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(180px, 30vw) minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr);
      align-items: end;
      padding: var(--stage-top) clamp(12px, 4vw, 54px) var(--dialogue-safe-bottom);
      pointer-events: none;
    }

    .portrait {
      position: relative;
      grid-row: 1 / 2;
      align-self: end;
      justify-self: center;
      margin: 0;
      width: min(30vw, 320px);
      min-width: 160px;
      max-height: calc(100dvh - var(--stage-top) - var(--dialogue-safe-bottom));
      opacity: 0;
      transform: translateY(18px) scale(.96);
      filter: drop-shadow(0 32px 48px rgba(0,0,0,.72)) grayscale(.1) brightness(.72);
      transition: opacity 280ms ease, transform 360ms ease, filter 280ms ease;
    }

    .portrait.active {
      z-index: 2;
      opacity: 1;
      transform: translateY(0) scale(1);
      filter: drop-shadow(0 34px 54px rgba(0,0,0,.82)) brightness(1.02);
    }

    .portrait.left { grid-column: 1; }
    .portrait.center { grid-column: 2; }
    .portrait.right { grid-column: 3; }

    .portrait.character-lin {
      width: min(34vw, 360px);
    }

    .portrait img {
      display: block;
      width: 100%;
      height: auto;
      max-height: inherit;
      object-fit: contain;
      object-position: bottom center;
      user-select: none;
      -webkit-user-drag: none;
    }

    .portrait .silhouette {
      display: none;
      width: 100%;
      aspect-ratio: 3 / 4.5;
      border: 1px solid rgba(61, 241, 220, .26);
      border-radius: 44% 44% 8px 8px;
      background:
        radial-gradient(circle at 50% 20%, rgba(242,234,219,.15) 0 13%, transparent 14%),
        linear-gradient(180deg, rgba(61,241,220,.22), rgba(255,74,145,.08) 54%, rgba(0,0,0,.54)),
        #080d12;
      box-shadow: inset 0 0 48px rgba(61,241,220,.08);
    }

    .portrait.missing img { display: none; }
    .portrait.missing .silhouette { display: block; }

    .portrait::after {
      content: attr(data-label);
      position: absolute;
      left: 50%;
      bottom: 4px;
      transform: translateX(-50%);
      padding: 4px 8px;
      border: 1px solid rgba(242, 234, 219, .2);
      border-radius: var(--radius);
      background: rgba(0,0,0,.42);
      color: rgba(242,234,219,.72);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: .06em;
      white-space: nowrap;
      opacity: .76;
    }

    .caption-wrap {
      position: absolute;
      left: max(12px, env(safe-area-inset-left, 0));
      right: max(12px, env(safe-area-inset-right, 0));
      bottom: max(12px, env(safe-area-inset-bottom, 0));
      z-index: 30;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      align-items: end;
      pointer-events: none;
    }

    .caption {
      position: relative;
      min-height: 156px;
      overflow: hidden;
      border: 1px solid rgba(242, 234, 219, .24);
      border-radius: var(--radius);
      background:
        linear-gradient(180deg, rgba(255,255,255,.06), transparent 22%),
        rgba(4, 8, 12, .84);
      box-shadow: 0 24px 70px rgba(0,0,0,.52), inset 0 0 0 1px rgba(255,255,255,.026);
      backdrop-filter: blur(18px);
      pointer-events: auto;
      cursor: pointer;
    }

    .caption::before {
      content: "";
      position: absolute;
      inset: 0;
      background:
        linear-gradient(90deg, rgba(61,241,220,.16), transparent 28%),
        repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 6px);
      pointer-events: none;
    }

    .speaker {
      position: relative;
      display: inline-flex;
      min-width: 132px;
      min-height: 36px;
      align-items: center;
      margin: 14px 16px 0;
      padding: 0 12px;
      border-left: 3px solid var(--cyan);
      background: rgba(61, 241, 220, .1);
      color: var(--paper);
      font-size: 14px;
      font-weight: 950;
      letter-spacing: .12em;
    }

    .text {
      position: relative;
      margin: 10px 16px 42px;
      color: var(--paper);
      font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
      font-size: clamp(18px, 2.2vw, 25px);
      line-height: 1.65;
      letter-spacing: 0;
      text-shadow: 0 1px 12px rgba(0,0,0,.75);
    }

    .hint {
      position: absolute;
      right: 16px;
      bottom: 12px;
      color: var(--dim);
      font-size: 12px;
      font-weight: 850;
      letter-spacing: .08em;
    }

    .hint::after {
      content: "";
      display: inline-block;
      width: 7px;
      height: 7px;
      margin-left: 8px;
      border-right: 2px solid var(--cyan);
      border-bottom: 2px solid var(--cyan);
      transform: rotate(45deg) translateY(-2px);
      animation: pulse 900ms ease-in-out infinite;
    }

    .modal {
      position: fixed;
      inset: 0;
      z-index: 110;
      display: none;
      place-items: center;
      padding: max(14px, env(safe-area-inset-top, 0)) max(14px, env(safe-area-inset-right, 0)) max(14px, env(safe-area-inset-bottom, 0)) max(14px, env(safe-area-inset-left, 0));
      background: rgba(0, 0, 0, .68);
      backdrop-filter: blur(12px);
    }

    .modal.open { display: grid; }

    .modal-panel {
      width: min(900px, 100%);
      max-height: min(760px, calc(100dvh - 28px));
      overflow: hidden;
      border: 1px solid rgba(242, 234, 219, .22);
      border-radius: var(--radius);
      background:
        linear-gradient(135deg, rgba(61,241,220,.08), transparent 36%),
        rgba(5, 8, 11, .94);
      box-shadow: 0 28px 100px rgba(0,0,0,.74);
    }

    .modal-head {
      display: flex;
      gap: 12px;
      align-items: center;
      justify-content: space-between;
      padding: 14px 16px;
      border-bottom: 1px solid rgba(242, 234, 219, .15);
    }

    .modal-title {
      min-width: 0;
    }

    .modal-title b {
      display: block;
      font-size: 18px;
      font-weight: 950;
      letter-spacing: .06em;
    }

    .modal-title span {
      display: block;
      margin-top: 3px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      letter-spacing: .08em;
    }

    .modal-body {
      max-height: calc(min(760px, 100dvh - 28px) - 68px);
      overflow: auto;
      padding: 16px;
      overscroll-behavior: contain;
    }

    .case-review {
      display: grid;
      gap: 14px;
      min-width: 0;
    }

    .case-tabs {
      display: flex;
      gap: 8px;
      min-width: 0;
      max-width: 100%;
      overflow-x: auto;
      padding-bottom: 2px;
      scrollbar-width: thin;
    }

    .case-tab {
      flex: 0 0 auto;
      min-height: 34px;
      padding: 0 12px;
      border: 1px solid rgba(242, 234, 219, .18);
      border-radius: 6px;
      color: rgba(242, 234, 219, .72);
      background: rgba(255,255,255,.045);
      font: inherit;
      font-size: 12px;
      font-weight: 900;
      letter-spacing: .04em;
      cursor: pointer;
    }

    .case-tab:hover,
    .case-tab.active {
      border-color: rgba(61, 241, 220, .58);
      color: var(--cyan);
      background: rgba(61, 241, 220, .12);
    }

    .evidence-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 16px;
      min-width: 0;
    }

    .case-group {
      display: grid;
      gap: 9px;
      min-width: 0;
    }

    .case-group > h3 {
      margin: 0;
      padding: 0 0 7px;
      border-bottom: 1px solid rgba(61, 241, 220, .22);
      color: var(--cyan);
      font-size: 13px;
      line-height: 1.3;
      letter-spacing: .08em;
    }

    .case-group-list {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      min-width: 0;
    }

    .case-empty,
    .receipt-link-note {
      margin: 0;
      padding: 11px 12px;
      border: 1px solid rgba(242, 234, 219, .13);
      border-radius: 6px;
      background: rgba(255,255,255,.04);
      color: var(--muted);
      font-size: 12px;
      line-height: 1.6;
    }

    .receipt-link-note {
      border-left: 2px solid rgba(61, 241, 220, .48);
    }

    .evidence-card {
      position: relative;
      min-height: 190px;
      padding: 12px;
      overflow: hidden;
      border: 1px solid rgba(242, 234, 219, .16);
      border-radius: var(--radius);
      background:
        linear-gradient(180deg, rgba(255,255,255,.055), transparent 36%),
        rgba(10, 16, 21, .88);
    }

    .evidence-card.locked {
      filter: grayscale(1);
      opacity: .55;
    }

    .evidence-card::before {
      content: "";
      display: block;
      width: 100%;
      aspect-ratio: 1 / .78;
      margin-bottom: 10px;
      border: 1px solid rgba(61, 241, 220, .22);
      border-radius: 6px;
      background:
        linear-gradient(135deg, rgba(61,241,220,.2), transparent 40%),
        repeating-linear-gradient(0deg, rgba(242,234,219,.12) 0 1px, transparent 1px 8px),
        rgba(0,0,0,.22);
    }

    .evidence-card.has-visual::before {
      display: none;
    }

    .evidence-visual {
      width: 100%;
      aspect-ratio: 1 / .78;
      margin-bottom: 10px;
      border: 1px solid rgba(61, 241, 220, .22);
      border-radius: 6px;
      background-color: rgba(0,0,0,.22);
      background-repeat: no-repeat;
      background-position: center;
      background-size: cover;
      box-shadow: inset 0 0 24px rgba(0,0,0,.32);
    }

    .evidence-card.note .evidence-visual,
    .evidence-card.receipt .evidence-visual,
    .evidence-card.route .evidence-visual,
    .evidence-card.path .evidence-visual {
      background-size: contain;
    }

    .evidence-card.receipt::before {
      background:
        linear-gradient(90deg, transparent 8%, rgba(61,241,220,.38) 8% 10%, transparent 10%),
        repeating-linear-gradient(0deg, rgba(61,241,220,.18) 0 2px, transparent 2px 13px),
        rgba(5, 16, 19, .86);
      box-shadow: inset 0 0 28px rgba(61,241,220,.16);
    }

    .evidence-card.burn::before {
      background:
        radial-gradient(circle at 66% 48%, rgba(0,0,0,.9) 0 16%, transparent 17%),
        radial-gradient(circle at 28% 68%, rgba(255,91,85,.28), transparent 18%),
        linear-gradient(135deg, #36291c, #d2b67a 50%, #18100d);
    }

    .evidence-card.lock::before,
    .evidence-card.seal::before {
      background:
        radial-gradient(circle at center, transparent 0 22%, rgba(61,241,220,.36) 23% 25%, transparent 26%),
        linear-gradient(90deg, rgba(255,255,255,.06), transparent),
        #11161a;
    }

    .evidence-card.note::before,
    .evidence-card.memo::before {
      background:
        linear-gradient(8deg, transparent 10%, rgba(255,74,145,.18) 10% 12%, transparent 12%),
        repeating-linear-gradient(0deg, rgba(7,12,17,.2) 0 1px, transparent 1px 13px),
        #d9c68b;
    }

    .evidence-card.route::before,
    .evidence-card.path::before {
      background:
        linear-gradient(135deg, transparent 48%, rgba(255,74,145,.46) 49% 51%, transparent 52%),
        linear-gradient(45deg, transparent 48%, rgba(61,241,220,.42) 49% 51%, transparent 52%),
        repeating-linear-gradient(90deg, rgba(242,234,219,.12) 0 2px, transparent 2px 16px),
        #12191d;
    }

    .evidence-card h3 {
      margin: 5px 0 0;
      color: var(--paper);
      font-size: 14px;
      line-height: 1.3;
      letter-spacing: .02em;
      overflow-wrap: anywhere;
    }

    .evidence-card p {
      margin: 8px 0 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
      overflow-wrap: anywhere;
    }

    .evidence-meta {
      display: block;
      color: rgba(61, 241, 220, .72);
      font-size: 10px;
      font-weight: 900;
      line-height: 1.35;
      letter-spacing: .06em;
      overflow-wrap: anywhere;
    }

    .log-list {
      display: grid;
      gap: 9px;
    }

    .log-item {
      padding: 10px 12px;
      border-left: 2px solid rgba(61, 241, 220, .44);
      background: rgba(255,255,255,.045);
      color: rgba(242, 234, 219, .78);
      line-height: 1.55;
    }

    .log-item b {
      color: var(--paper);
      margin-right: 8px;
    }

    .blackbox-console {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(240px, .72fr);
      gap: 12px;
    }

    .blackbox-screen,
    .blackbox-feeds {
      min-height: 330px;
      border: 1px solid rgba(61, 241, 220, .2);
      border-radius: var(--radius);
      background:
        linear-gradient(135deg, rgba(61,241,220,.08), transparent 38%),
        repeating-linear-gradient(0deg, rgba(61,241,220,.045) 0 1px, transparent 1px 7px),
        rgba(3, 8, 10, .88);
      overflow: hidden;
    }

    .blackbox-screen {
      padding: 14px;
      color: rgba(141, 227, 125, .8);
      font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
      font-size: 12px;
      line-height: 1.65;
    }

    .blackbox-line {
      margin: 0 0 10px;
    }

    .blackbox-line b {
      color: var(--cyan);
      font-weight: 900;
    }

    .blackbox-feeds {
      display: grid;
      align-content: start;
      gap: 8px;
      padding: 12px;
    }

    .feed-btn {
      min-height: 42px;
      padding: 9px 10px;
      border: 1px solid rgba(242, 234, 219, .15);
      border-radius: var(--radius);
      background: rgba(255,255,255,.045);
      color: rgba(242, 234, 219, .78);
      font-size: 12px;
      font-weight: 850;
      text-align: left;
      cursor: pointer;
      transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
    }

    .feed-btn:hover {
      border-color: rgba(61, 241, 220, .54);
      background: rgba(61, 241, 220, .1);
      color: var(--paper);
      transform: translateY(-1px);
    }

    .feed-btn:disabled {
      cursor: not-allowed;
      filter: grayscale(1);
      opacity: .5;
      transform: none;
    }

    .feed-btn small {
      display: block;
      margin-top: 3px;
      color: var(--dim);
      font-size: 11px;
      font-weight: 700;
      line-height: 1.35;
    }



    .receipt-panel {
      width: min(1180px, calc(100vw - 28px));
    }

    .receipt-panel .modal-body {
      overflow: hidden;
      padding: 0;
    }

    .receipt-desk {
      display: grid;
      grid-template-rows: auto minmax(0, 1fr);
      gap: 12px;
      min-height: 520px;
      height: min(660px, calc(100dvh - 116px));
      padding: 14px;
      overflow: hidden;
    }

    .receipt-empty-state {
      display: grid;
      place-content: center;
      gap: 8px;
      min-height: 360px;
      text-align: center;
      color: var(--muted);
    }

    .receipt-empty-state b {
      color: var(--paper);
      font-size: 18px;
    }

    .receipt-empty-state span {
      font-size: 13px;
    }

    .receipt-steps {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 8px;
      min-width: 0;
      align-items: stretch;
    }

    .receipt-step {
      appearance: none;
      display: grid;
      grid-template-columns: 28px minmax(0, 1fr);
      grid-template-rows: 16px 14px;
      column-gap: 10px;
      align-content: center;
      align-items: center;
      min-height: 54px;
      padding: 9px 12px;
      border: 1px solid rgba(242, 234, 219, .14);
      border-radius: var(--radius);
      background: rgba(2, 6, 8, .7);
      color: var(--dim);
      min-width: 0;
      font: inherit;
      text-align: left;
    }

    button.receipt-step {
      cursor: pointer;
    }

    button.receipt-step.jumpable:hover,
    button.receipt-step.jumpable:focus-visible {
      border-color: rgba(61, 241, 220, .52);
      color: var(--paper);
      outline: none;
      box-shadow: inset 0 0 0 1px rgba(61, 241, 220, .12), 0 0 0 3px rgba(61, 241, 220, .12);
    }

    .receipt-step i {
      grid-row: 1 / 3;
      align-self: center;
      justify-self: center;
      display: grid;
      place-items: center;
      width: 26px;
      height: 26px;
      border: 1px solid rgba(242, 234, 219, .2);
      border-radius: 50%;
      color: rgba(242, 234, 219, .76);
      font-style: normal;
      font-size: 12px;
      font-weight: 950;
      line-height: 1;
    }

    .receipt-step b,
    .receipt-step small {
      display: block;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      line-height: 1;
    }

    .receipt-step b {
      color: rgba(242, 234, 219, .88);
      font-size: 12px;
      font-weight: 950;
    }

    .receipt-step small {
      color: var(--dim);
      font-size: 10px;
      font-weight: 800;
    }

    .receipt-step.active {
      border-color: rgba(61, 241, 220, .48);
      background:
        linear-gradient(180deg, rgba(61, 241, 220, .12), rgba(61, 241, 220, .04)),
        rgba(4, 11, 13, .86);
      box-shadow: inset 0 0 0 1px rgba(61, 241, 220, .08);
    }

    .receipt-step.active i,
    .receipt-step.done i {
      border-color: rgba(61, 241, 220, .62);
      color: var(--cyan);
      background: rgba(61, 241, 220, .09);
    }

    .receipt-step.done {
      border-color: rgba(141, 227, 125, .32);
      color: var(--muted);
    }

    .receipt-step.done i::after {
      content: "";
      display: block;
      width: 8px;
      height: 5px;
      border-left: 2px solid var(--green);
      border-bottom: 2px solid var(--green);
      transform: rotate(-45deg);
    }

    .receipt-step.done i {
      font-size: 0;
    }

    .receipt-workspace,
    .receipt-blackbox-stage {
      display: grid;
      grid-template-columns: minmax(250px, .9fr) minmax(320px, 1fr) minmax(260px, .9fr);
      gap: 12px;
      min-height: 0;
      overflow: hidden;
    }

    .receipt-blackbox-stage {
      grid-template-columns: minmax(280px, .86fr) minmax(420px, 1.34fr);
    }

    .receipt-card {
      display: grid;
      grid-template-rows: auto auto minmax(0, 1fr);
      min-width: 0;
      min-height: 0;
      border: 1px solid rgba(242, 234, 219, .17);
      border-radius: var(--radius);
      background:
        linear-gradient(140deg, rgba(229,184,91,.08), transparent 34%),
        rgba(5, 8, 11, .68);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.025);
      padding: 12px;
      overflow: hidden;
    }

    .receipt-card.waiting {
      opacity: .76;
    }

    .receipt-card-head {
      min-width: 0;
      margin-bottom: 10px;
    }

    .receipt-card-head span {
      display: block;
      margin-bottom: 4px;
      color: var(--cyan);
      font-size: 11px;
      font-weight: 950;
      letter-spacing: .1em;
    }

    .receipt-card-head strong {
      display: block;
      min-width: 0;
      overflow: hidden;
      color: var(--paper);
      font-size: 14px;
      line-height: 1.35;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .receipt-card-head.alert span {
      color: var(--amber);
    }

    .receipt-materials,
    .receipt-compose,
    .receipt-finish,
    .receipt-recap-card,
    .receipt-blackbox-card {
      align-content: start;
    }

    .receipt-materials {
      grid-template-rows: auto auto minmax(0, 1fr);
    }

    .receipt-materials .receipt-note {
      margin-bottom: 10px;
    }

    .receipt-compose {
      grid-template-rows: auto auto minmax(0, 1fr);
    }

    .receipt-finish {
      grid-template-rows: auto minmax(0, 1fr) auto auto;
    }

    .receipt-column h3,
    .receipt-tray h3,
    .receipt-result h3 {
      margin: 0 0 10px;
      color: rgba(242, 234, 219, .9);
      font-size: 12px;
      font-weight: 950;
      letter-spacing: .12em;
    }

    .receipt-puzzle-title {
      display: block;
      margin: -2px 0 8px;
      color: var(--paper);
      font-size: 15px;
      line-height: 1.35;
    }

    .receipt-tray.waiting,
    .receipt-result.waiting {
      opacity: .78;
    }

    .receipt-tray.waiting .receipt-slots {
      opacity: .72;
    }

    .fragment-list,
    .receipt-actions {
      display: grid;
      gap: 8px;
      min-height: 0;
      overflow: auto;
      padding: 2px 4px 6px 2px;
      overscroll-behavior: contain;
    }

    .fragment-list {
      align-content: start;
    }

    .fragment-card,
    .receipt-action {
      width: 100%;
      min-height: 48px;
      padding: 9px 10px;
      border: 1px solid rgba(242, 234, 219, .16);
      border-radius: var(--radius);
      background: rgba(255,255,255,.045);
      color: rgba(242, 234, 219, .78);
      text-align: left;
      cursor: pointer;
      transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
    }

    .fragment-card:hover,
    .receipt-action:hover,
    .fragment-card.active,
    .receipt-action.active {
      border-color: rgba(229, 184, 91, .62);
      background: rgba(229, 184, 91, .1);
      color: var(--paper);
      transform: translateY(-1px);
    }

    .fragment-card:disabled,
    .receipt-action:disabled,
    .receipt-seal:disabled {
      cursor: not-allowed;
      filter: grayscale(1);
      opacity: .48;
      transform: none;
    }

    .fragment-card b,
    .receipt-action b {
      display: block;
      font-size: 13px;
      line-height: 1.35;
    }

    .fragment-card small,
    .receipt-action small {
      display: block;
      margin-top: 4px;
      color: var(--dim);
      font-size: 11px;
      line-height: 1.45;
    }

    .receipt-slots {
      display: grid;
      gap: 8px;
      margin-bottom: 12px;
      overflow: auto;
      padding: 2px 4px 6px 2px;
      overscroll-behavior: contain;
    }

    .receipt-slot {
      display: grid;
      grid-template-columns: 28px minmax(0, 1fr);
      gap: 8px;
      align-items: center;
      min-height: 48px;
      padding: 10px;
      border: 1px dashed rgba(61, 241, 220, .28);
      border-radius: var(--radius);
      color: var(--muted);
      background: rgba(61,241,220,.035);
      font-size: 12px;
      line-height: 1.45;
    }

    .receipt-slot.filled {
      border-style: solid;
      background: rgba(61, 241, 220, .07);
    }

    .receipt-slot span {
      grid-row: 1 / 3;
      display: grid;
      place-items: center;
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background: rgba(61, 241, 220, .1);
      color: var(--cyan);
      font-size: 11px;
      font-weight: 950;
    }

    .receipt-slot b,
    .receipt-slot small {
      grid-column: 2;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .receipt-slot b {
      display: block;
      color: var(--paper);
      white-space: nowrap;
    }

    .receipt-slot small {
      display: block;
      color: var(--dim);
      line-height: 1.4;
      white-space: nowrap;
    }

    .receipt-slot:not(.filled) small {
      grid-column: 1 / -1;
      white-space: normal;
    }

    .receipt-empty,
    .receipt-note {
      margin: 0;
      color: var(--dim);
      font-size: 12px;
      line-height: 1.6;
    }

    .receipt-feedback {
      margin-top: 12px;
      padding: 13px;
      border: 1px solid rgba(61, 241, 220, .18);
      border-radius: var(--radius);
      background:
        repeating-linear-gradient(0deg, rgba(61,241,220,.035) 0 1px, transparent 1px 8px),
        rgba(3, 8, 10, .72);
      color: rgba(242, 234, 219, .78);
      font-size: 13px;
      line-height: 1.7;
    }

    .receipt-feedback.compact {
      min-height: 118px;
      margin-top: 0;
    }

    .receipt-feedback.result {
      min-height: 82px;
    }

    .receipt-feedback b {
      display: block;
      margin-bottom: 6px;
      color: var(--cyan);
      font-size: 12px;
      letter-spacing: .08em;
    }

    .receipt-feedback p {
      margin: 0;
    }

    .receipt-seal {
      width: 100%;
      margin-top: 10px;
      border-color: rgba(61, 241, 220, .45);
      background: rgba(61, 241, 220, .12);
      color: var(--cyan);
    }

    .receipt-recap-list {
      display: grid;
      gap: 9px;
      align-content: start;
      overflow: auto;
      min-height: 0;
    }

    .receipt-recap-list p {
      margin: 0;
      padding: 10px;
      border: 1px solid rgba(242, 234, 219, .13);
      border-radius: var(--radius);
      background: rgba(255, 255, 255, .04);
    }

    .receipt-recap-list b,
    .receipt-recap-list span {
      display: block;
    }

    .receipt-recap-list b {
      margin-bottom: 4px;
      color: var(--cyan);
      font-size: 11px;
      letter-spacing: .08em;
    }

    .receipt-recap-list span {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
    }

    .receipt-blackbox-card {
      grid-template-rows: auto auto minmax(0, 1fr) auto;
    }

    .receipt-summary-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-bottom: 10px;
    }

    .receipt-summary-actions {
      align-content: start;
      max-height: 230px;
    }

    .handling-actions {
      max-height: 210px;
      align-content: start;
    }

    .relation-actions {
      max-height: 230px;
      align-content: start;
    }

    @media (max-width: 900px) {
      .modal {
        padding: max(8px, env(safe-area-inset-top, 0)) max(8px, env(safe-area-inset-right, 0)) max(8px, env(safe-area-inset-bottom, 0)) max(8px, env(safe-area-inset-left, 0));
      }

      .receipt-panel {
        width: min(100%, calc(100vw - 16px));
        max-height: calc(100dvh - 16px);
      }

      .receipt-panel .modal-head {
        padding: 10px 12px;
      }

      .receipt-panel .modal-title b {
        font-size: 16px;
      }

      .receipt-panel .modal-title span {
        max-width: 72vw;
        font-size: 11px;
        line-height: 1.35;
        letter-spacing: .02em;
      }

      .receipt-desk {
        height: min(720px, calc(100dvh - 86px));
        grid-template-columns: 1fr;
        min-height: 0;
        gap: 8px;
        padding: 10px;
        overflow: hidden;
      }

      .receipt-steps {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
      }

      .receipt-step {
        grid-template-columns: 1fr;
        grid-template-rows: 24px 14px;
        min-height: 50px;
        padding: 6px 4px;
        justify-items: center;
        text-align: center;
      }

      .receipt-step i {
        grid-row: 1;
        width: 24px;
        height: 24px;
        font-size: 11px;
      }

      .receipt-step b {
        font-size: 10px;
        line-height: 1.1;
        white-space: normal;
      }

      .receipt-step small {
        display: none;
      }

      .receipt-workspace,
      .receipt-blackbox-stage {
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-height: 0;
        overflow: hidden;
      }

      .receipt-summary-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        overflow: visible;
      }

      .receipt-card {
        padding: 10px;
      }

      .receipt-card.current {
        flex: 1 1 auto;
        overflow: hidden;
      }

      .receipt-card.collapsed {
        flex: 0 0 auto;
        grid-template-rows: auto;
        min-height: 54px;
        max-height: 64px;
        padding: 9px 10px;
        opacity: .78;
      }

      .receipt-card.collapsed > :not(.receipt-card-head) {
        display: none;
      }

      .receipt-card.done {
        border-color: rgba(141, 227, 125, .28);
      }

      .receipt-card.current .fragment-list,
      .receipt-card.current .receipt-actions,
      .receipt-card.current .receipt-slots,
      .receipt-recap-list {
        min-height: 0;
        overflow: auto;
      }

      .fragment-card,
      .receipt-action {
        min-height: 54px;
        padding: 10px 11px;
      }

      .fragment-card b,
      .receipt-action b {
        font-size: 13px;
      }

      .fragment-card small,
      .receipt-action small {
        font-size: 11px;
      }

      .receipt-card-head {
        margin-bottom: 8px;
      }

      .receipt-card-head span {
        letter-spacing: .04em;
      }

      .receipt-card-head strong {
        white-space: normal;
      }

      .receipt-materials,
      .receipt-compose,
      .receipt-finish {
        min-height: 0;
      }

      .receipt-finish {
        grid-template-rows: auto auto auto auto;
      }

      .handling-actions,
      .relation-actions,
      .receipt-summary-actions {
        max-height: none;
      }

      .receipt-blackbox-stage .receipt-recap-card {
        flex: 0 0 auto;
        max-height: 24%;
        overflow: hidden;
      }

      .receipt-blackbox-stage .receipt-blackbox-card {
        flex: 1 1 auto;
        grid-template-rows: auto auto minmax(120px, 1fr) auto;
        min-height: 0;
        overflow: hidden;
      }

      .receipt-blackbox-stage .receipt-recap-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
      }

      .receipt-blackbox-stage .receipt-recap-list p {
        padding: 7px;
      }

      .receipt-summary-grid {
        margin-bottom: 8px;
      }

      .receipt-summary-actions {
        overflow: auto;
      }

      .receipt-feedback {
        margin-top: 8px;
        padding: 10px;
        font-size: 12px;
        line-height: 1.55;
      }

      .receipt-feedback.compact {
        min-height: auto;
      }

      .receipt-feedback.result {
        min-height: auto;
      }
    }

    @media (max-width: 900px), (pointer: coarse) and (max-width: 1180px) {
      #receiptModal.modal {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
        background:
          radial-gradient(circle at 50% 0%, rgba(61, 241, 220, .1), transparent 32%),
          rgba(0, 0, 0, .9);
      }

      #receiptModal .receipt-panel {
        width: 100vw;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
      }

      #receiptModal .modal-head {
        min-height: 64px;
        padding:
          max(10px, env(safe-area-inset-top, 0))
          max(12px, env(safe-area-inset-right, 0))
          10px
          max(12px, env(safe-area-inset-left, 0));
      }

      #receiptModal .modal-title {
        min-width: 0;
      }

      #receiptModal .modal-title b {
        font-size: 18px;
        line-height: 1.05;
      }

      #receiptModal .modal-title span {
        display: none;
        max-width: calc(100vw - 76px);
        overflow: hidden;
        color: rgba(242, 234, 219, .72);
        font-size: 12px;
        line-height: 1.38;
        letter-spacing: 0;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
      }

      #receiptModal .modal-head .icon-btn {
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
      }

      #receiptModal .modal-body {
        height: calc(100dvh - 64px);
        min-height: 0;
      }

      #receiptModal .receipt-desk {
        height: 100%;
        min-height: 0;
        padding:
          10px
          max(12px, env(safe-area-inset-right, 0))
          max(12px, env(safe-area-inset-bottom, 0))
          max(12px, env(safe-area-inset-left, 0));
        grid-template-rows: auto minmax(0, 1fr);
        gap: 10px;
        overflow: hidden;
      }

      #receiptModal .receipt-steps {
        position: relative;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
        min-height: 34px;
        padding: 0 0 4px;
      }

      #receiptModal .receipt-steps::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 12.5%;
        right: 12.5%;
        height: 1px;
        background: rgba(242, 234, 219, .16);
      }

      #receiptModal .receipt-step {
        position: relative;
        z-index: 1;
        grid-template-columns: 1fr;
        grid-template-rows: 20px 12px;
        min-height: 32px;
        padding: 0 2px;
        border: 0;
        background: transparent;
        box-shadow: none;
        justify-items: center;
        text-align: center;
        opacity: .62;
      }

      #receiptModal .receipt-step.active,
      #receiptModal .receipt-step.done {
        opacity: 1;
      }

      #receiptModal .receipt-step i {
        grid-row: 1;
        width: 20px;
        height: 20px;
        border-color: rgba(242, 234, 219, .22);
        background: rgba(5, 8, 11, .96);
        font-size: 10px;
      }

      #receiptModal .receipt-step b {
        max-width: 100%;
        color: rgba(242, 234, 219, .76);
        font-size: 10px;
        line-height: 1.1;
        white-space: nowrap;
      }

      #receiptModal .receipt-step.active b {
        color: var(--cyan);
      }

      #receiptModal .receipt-step small {
        display: none;
      }

      #receiptModal .receipt-workspace {
        display: block;
        height: 100%;
        min-height: 0;
        overflow: hidden;
      }

      #receiptModal .receipt-workspace .receipt-card.collapsed {
        display: none;
      }

      #receiptModal .receipt-workspace .receipt-card.current {
        display: grid;
        height: 100%;
        min-height: 0;
        padding: 14px;
        border-radius: 12px;
        background:
          linear-gradient(155deg, rgba(61, 241, 220, .08), transparent 38%),
          rgba(5, 8, 11, .78);
        overflow: hidden;
      }

      #receiptModal .receipt-card-head {
        margin-bottom: 10px;
      }

      #receiptModal .receipt-card-head span {
        color: var(--cyan);
        font-size: 12px;
        letter-spacing: .02em;
      }

      #receiptModal .receipt-card-head strong {
        margin-top: 4px;
        color: var(--paper);
        font-size: 19px;
        line-height: 1.18;
        white-space: normal;
      }

      #receiptModal .receipt-note {
        margin-bottom: 12px;
        color: rgba(242, 234, 219, .72);
        font-size: 14px;
        line-height: 1.55;
      }

      #receiptModal .receipt-materials.current,
      #receiptModal .receipt-compose.current {
        grid-template-rows: auto auto minmax(0, 1fr);
      }

      #receiptModal .receipt-finish.current {
        grid-template-rows: auto minmax(0, 1fr) auto auto;
      }

      #receiptModal .fragment-list,
      #receiptModal .receipt-actions,
      #receiptModal .receipt-slots {
        min-height: 0;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        padding-right: 2px;
        padding-bottom: 8px;
      }

      #receiptModal .fragment-card,
      #receiptModal .receipt-action {
        min-height: 62px;
        padding: 12px 13px;
        border-radius: 10px;
      }

      #receiptModal .fragment-card b,
      #receiptModal .receipt-action b {
        font-size: 15px;
        line-height: 1.25;
      }

      #receiptModal .fragment-card small,
      #receiptModal .receipt-action small {
        margin-top: 5px;
        font-size: 12px;
        line-height: 1.35;
      }

      #receiptModal .receipt-slot {
        min-height: 60px;
        padding: 10px 12px;
        border-radius: 10px;
      }

      #receiptModal .receipt-slot span {
        width: 28px;
        height: 28px;
      }

      #receiptModal .receipt-slot b {
        font-size: 15px;
      }

      #receiptModal .receipt-slot small {
        font-size: 12px;
        line-height: 1.35;
      }

      #receiptModal .receipt-feedback {
        max-height: 112px;
        margin-top: 10px;
        padding: 10px;
        overflow: auto;
        font-size: 13px;
        line-height: 1.55;
      }

      #receiptModal .receipt-seal {
        min-height: 50px;
        margin-top: 10px;
        border-radius: 10px;
        font-size: 15px;
      }

      #receiptModal .receipt-blackbox-stage {
        display: grid;
        height: 100%;
        min-height: 0;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        gap: 10px;
        overflow: hidden;
      }

      #receiptModal .receipt-blackbox-stage .receipt-recap-card {
        display: grid;
        max-height: 70px;
        min-height: 0;
        padding: 10px;
        overflow: hidden;
      }

      #receiptModal .receipt-blackbox-stage .receipt-recap-card .receipt-card-head {
        margin-bottom: 0;
      }

      #receiptModal .receipt-blackbox-stage .receipt-recap-card strong {
        font-size: 15px;
      }

      #receiptModal .receipt-blackbox-stage .receipt-recap-list {
        display: none;
      }

      #receiptModal .receipt-blackbox-stage .receipt-blackbox-card {
        display: flex;
        flex-direction: column;
        min-height: 0;
        padding: 14px;
        overflow: hidden;
      }

      #receiptModal .receipt-summary-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 8px;
        flex: 0 0 auto;
      }

      #receiptModal .receipt-summary-grid .receipt-feedback {
        max-height: none;
        margin-top: 0;
      }

      #receiptModal .receipt-summary-grid .receipt-feedback p {
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }

      #receiptModal .receipt-summary-actions {
        min-height: 0;
        max-height: none;
        flex: 1 1 auto;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
      }

      #receiptModal .receipt-feedback.result {
        flex: 0 0 auto;
        max-height: 74px;
      }

      #receiptModal .receipt-feedback.result p {
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
    }

    .ending {
      position: fixed;
      inset: 0;
      z-index: 90;
      display: none;
      place-items: center;
      padding: 18px;
      background:
        linear-gradient(180deg, rgba(5,8,11,.58), rgba(5,8,11,.92)),
        radial-gradient(circle at 50% 18%, rgba(61,241,220,.16), transparent 34%),
        rgba(5,8,11,.88);
      backdrop-filter: blur(10px);
    }

    .ending.open { display: grid; }

    .ending.settings-bypass {
      pointer-events: none;
    }

    .ending-card {
      width: min(760px, 100%);
      max-height: calc(100dvh - 36px);
      display: flex;
      flex-direction: column;
      border: 1px solid rgba(242, 234, 219, .22);
      border-radius: var(--radius);
      background: rgba(5, 8, 11, .88);
      box-shadow: 0 32px 100px rgba(0,0,0,.74);
      padding: clamp(18px, 4vw, 34px);
      text-align: center;
    }

    .ending-card .stamp {
      display: inline-flex;
      min-height: 34px;
      align-items: center;
      padding: 0 12px;
      border: 1px solid rgba(255, 91, 85, .7);
      border-radius: 4px;
      color: var(--red);
      font-size: 12px;
      font-weight: 950;
      letter-spacing: .16em;
      transform: rotate(-2deg);
    }

    .ending-card h2 {
      margin: 16px 0 0;
      font-family: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
      font-size: clamp(30px, 7vw, 64px);
      line-height: 1.05;
      letter-spacing: 0;
    }

    .ending-card .ending-summary {
      margin: 14px auto 0;
      max-width: 620px;
      color: var(--muted);
      font-size: 16px;
      line-height: 1.75;
      overflow-y: auto;
    }

    .ending-card .ending-summary p {
      margin: 8px 0 0;
    }

    .ending-card .ending-summary p:first-child {
      margin-top: 0;
    }

    .ending-actions {
      display: flex;
      flex-shrink: 0;
      flex-wrap: wrap;
      gap: 10px;
      justify-content: center;
      margin-top: 20px;
    }

    .ending-actions .primary-action {
      border-color: rgba(61, 241, 220, .72);
      color: var(--cyan);
      background: rgba(61, 241, 220, .12);
    }

    @media (max-width: 820px) {
      :root {
        --stage-top: 15vh;
        --dialogue-safe-bottom: clamp(248px, 33vh, 320px);
      }

      .vn { min-height: 100dvh; }

      .topbar {
        grid-template-columns: 1fr;
        gap: 8px;
      }

      .tools {
        justify-content: flex-end;
      }

      .case-id span {
        max-width: 72vw;
        font-size: 10px;
      }


      .stage {
        grid-template-columns: 1fr 1fr 1fr;
        padding-inline: 2vw;
      }

      .portrait {
        width: 30vw;
        min-width: 0;
      }

      .portrait.center {
        width: 34vw;
      }

      .caption-wrap {
        grid-template-columns: 1fr;
      }

      .caption {
        min-height: 180px;
      }

      .speaker {
        min-width: 104px;
        min-height: 32px;
        margin: 12px 12px 0;
        font-size: 13px;
      }

      .text {
        margin: 9px 12px 44px;
        font-size: clamp(17px, 5vw, 22px);
        line-height: 1.55;
      }

      .evidence-grid {
        grid-template-columns: 1fr;
      }

      .case-group-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .blackbox-console {
        grid-template-columns: 1fr;
      }

      .evidence-card {
        min-height: 0;
      }

      .evidence-card::before {
        aspect-ratio: 4 / 1;
      }

      .evidence-visual {
        aspect-ratio: 4 / 1;
      }

      .ending {
        padding: max(10px, env(safe-area-inset-top, 0)) max(10px, env(safe-area-inset-right, 0)) max(10px, env(safe-area-inset-bottom, 0)) max(10px, env(safe-area-inset-left, 0));
      }

      .ending-card {
        max-height: calc(100dvh - 20px);
        padding: 16px 14px;
      }

      .ending-card h2 {
        margin-top: 12px;
        font-size: clamp(30px, 8vw, 42px);
      }

      .ending-card .ending-summary {
        width: 100%;
        max-height: min(52vh, calc(100dvh - 210px));
        padding-right: 4px;
        font-size: 14px;
        line-height: 1.55;
      }

      .ending-actions {
        margin-top: 14px;
      }
    }

    @media (max-width: 520px) {
      :root {
        --stage-top: 17vh;
        --dialogue-safe-bottom: clamp(270px, 36vh, 330px);
      }

      .case-id b { font-size: 25px; }
      .case-id span { max-width: 100%; }
      .tools { gap: 6px; }
      .icon-btn { min-width: 34px; height: 34px; }
      .text-btn { height: 34px; padding: 0 9px; font-size: 11px; }
      .portrait::after { display: none; }
      .caption { min-height: 190px; }
      .modal-body { padding: 12px; }
      .case-tabs { gap: 6px; }
      .case-tab { min-height: 32px; padding: 0 10px; font-size: 11px; }
      .case-group-list { grid-template-columns: 1fr; }
    }

    @keyframes rain {
      to { background-position: -110px 260px, -170px 430px; }
    }

    @keyframes pulse {
      0%, 100% { opacity: .35; transform: rotate(45deg) translateY(-2px); }
      50% { opacity: 1; transform: rotate(45deg) translate(2px, 2px); }
    }

    @keyframes glitch-pass {
      0% { opacity: 0; transform: translateX(-100%); }
      18% { opacity: .85; transform: translateX(-28%); }
      52% { opacity: .5; transform: translateX(18%); }
      100% { opacity: 0; transform: translateX(100%); }
    }


.hotspots {
  position: absolute;
  inset: var(--stage-top) clamp(10px, 4vw, 52px) var(--dialogue-safe-bottom);
  z-index: 14;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: inline-grid;
  grid-template-columns: 14px auto;
  gap: 8px;
  align-items: center;
  max-width: min(280px, 72vw);
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(61, 241, 220, .34);
  border-radius: var(--radius);
  background: rgba(5, 8, 11, .62);
  box-shadow: 0 0 28px rgba(61, 241, 220, .1), inset 0 0 0 1px rgba(255,255,255,.035);
  color: var(--paper);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(12px);
  transform: translate(-50%, -50%);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.hotspot::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 1px solid var(--cyan);
  transform: rotate(45deg);
  background: rgba(61, 241, 220, .16);
  box-shadow: 0 0 14px rgba(61, 241, 220, .42);
}

.hotspot:hover {
  border-color: rgba(229, 184, 91, .62);
  background: rgba(11, 20, 24, .78);
  transform: translate(-50%, -50%) translateY(-1px);
}

.hotspot.done {
  opacity: .42;
}

.hotspot.done::before {
  border-color: var(--amber);
  background: rgba(229, 184, 91, .18);
  box-shadow: 0 0 12px rgba(229, 184, 91, .36);
}

.vn[data-chapter="ch02"] .weather {
  opacity: .18;
}

.vn[data-chapter="ch02"] .scene::after {
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(0,0,0,.68) 100%),
    linear-gradient(90deg, rgba(255,74,145,.16), transparent 18%, transparent 78%, rgba(61,241,220,.14));
}

@media (max-width: 720px) {
  .hotspots {
    inset: 96px 10px calc(var(--dialogue-safe-bottom) + 18px);
  }

  .hotspot {
    max-width: min(230px, 72vw);
    min-height: 32px;
    padding: 7px 9px;
    font-size: 11px;
  }
}
