/* ════════════════════════════════════════════════════════════════════
   SUPREME ARCADE 2027：煥新戰記 — Quiet Luxury · Bright Retro
   ════════════════════════════════════════════════════════════════════ */

:root {
  --sky-top: #7ADCE4;
  --sky-bottom: #A8EBF0;
  --pearl: #F7F9F8;
  --charcoal: #1E2022;
  --gold: #D4AF37;
  --gold-light: #F1DC8E;
  --gold-deep: #9C7C1C;
  --burgundy: #8B1E3F;
  --plum: #4A1942;
  --ice: #4CC9F0;
  --navy: #0D3B66;

  --font-pix: "Silkscreen", "Noto Sans TC", "PingFang HK", "PingFang TC", monospace;
  --font-zh: "Noto Sans TC", "PingFang HK", "PingFang TC", "Heiti TC", system-ui, sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  --outline: 2px solid var(--charcoal);
  --press: 0 4px 0 var(--charcoal);
  --glass: rgba(247, 249, 248, 0.74);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--charcoal);
  font-family: var(--font-zh);
  /* pearl paper with a faint champagne bloom (desktop letterbox only) */
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(212, 175, 55, 0.10), transparent 60%),
    radial-gradient(90% 70% at 50% 100%, rgba(122, 220, 228, 0.22), transparent 70%),
    var(--pearl);
}

/* ─────────── 9:16 stage ─────────── */
.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  isolation: isolate;
}

/* Wider than 9:16 (desktop / tablet landscape) → framed cabinet */
@media (min-aspect-ratio: 9/16) {
  .stage {
    height: min(100dvh, 960px);
    width: calc(min(100dvh, 960px) * 9 / 16);
    outline: var(--outline);
    box-shadow: 0 10px 0 var(--charcoal), 0 30px 80px rgba(13, 59, 102, 0.22);
    border-radius: 6px;
  }
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  cursor: grab;
}
#game:active { cursor: grabbing; }

/* ─────────── UI overlay root ─────────── */
.ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 20px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 20px) calc(var(--safe-l) + 18px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.screen.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.28s ease, visibility 0s;
}

/* ─────────── shared surfaces ─────────── */
.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 40%),
    var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border: var(--outline);
  border-radius: 6px;
  box-shadow: 0 6px 0 var(--charcoal), 0 22px 44px rgba(13, 59, 102, 0.18);
}

.pix {
  font-family: var(--font-pix);
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ─────────── buttons ─────────── */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: var(--outline);
  border-radius: 4px;
  font-family: var(--font-zh);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
  cursor: pointer;
  box-shadow: var(--press);
  transform: translateY(0);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.2s ease, color 0.2s ease;
  touch-action: manipulation;
  overflow: hidden;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--charcoal); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.btn-primary { background: var(--charcoal); color: var(--gold-light); }
.btn-primary:hover { background: #2B2E31; color: #FFF1C2; }

.btn-ghost { background: var(--pearl); color: var(--charcoal); }
.btn-ghost:hover { background: #FFFFFF; }

/* champagne sheen sweeping across the CTA */
.btn-cta {
  min-height: 58px;
  font-family: var(--font-pix), var(--font-zh);
  font-size: 16px;
  letter-spacing: 0.1em;
}
.btn-cta::after {
  content: "";
  position: absolute;
  inset: -2px auto -2px -40%;
  width: 30%;
  background: linear-gradient(100deg, transparent, rgba(241, 220, 142, 0.35), transparent);
  transform: skewX(-18deg);
  animation: sheen 3.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%, 55% { left: -40%; }
  100% { left: 120%; }
}

/* ─────────── title screen ─────────── */
.screen-title {
  align-items: stretch;
  background:
    linear-gradient(180deg, rgba(247, 249, 248, 0) 45%, rgba(247, 249, 248, 0.55) 100%);
}

.title-wrap {
  width: 100%;
  max-width: 360px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.eyebrow {
  margin: 0;
  font-family: var(--font-pix);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(30, 32, 34, 0.72);
}

.game-title { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }

.game-title-en {
  font-family: var(--font-pix);
  font-weight: 700;
  font-size: clamp(26px, 8vw, 32px);
  line-height: 1.12;
  letter-spacing: 0.04em;
  color: var(--charcoal);
  text-shadow: 2px 2px 0 var(--gold), 3px 3px 0 var(--charcoal);
  text-wrap: balance;
}

.game-title-zh {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: clamp(38px, 12vw, 48px);
  line-height: 1;
  letter-spacing: 0.22em;
  padding-left: 0.22em; /* optically re-centre the tracked glyphs */
  color: var(--charcoal);
}
.game-title-zh .rule {
  display: block;
  width: 26px;
  height: 2px;
  background: var(--gold);
  box-shadow: 0 0 0 1px var(--charcoal);
  position: relative;
}
.game-title-zh .rule::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  background: var(--gold);
  border: 1.5px solid var(--charcoal);
  transform: translateY(-50%) rotate(45deg);
}
.game-title-zh .rule:first-child::after { right: -4px; }
.game-title-zh .rule:last-child::after { left: -4px; }

.tagline {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.06em;
  color: rgba(30, 32, 34, 0.86);
  text-wrap: balance;
}

.rules {
  list-style: none;
  margin: 4px 0 6px;
  padding: 14px 16px;
  width: 100%;
  display: grid;
  gap: 10px;
  text-align: left;
}
.rules li {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.03em;
}
.rule-no {
  font-family: var(--font-pix);
  font-size: 10px;
  font-weight: 700;
  color: var(--gold-deep);
  letter-spacing: 0.08em;
}

/* ─────────── modals (checkpoints / results) ─────────── */
.screen-modal {
  background: rgba(30, 32, 34, 0.28);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.modal {
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  animation: pop 0.38s cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }

/* coupon ticket with perforated notches */
.ticket {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 150px;
  padding: 10px 22px 12px;
  border: var(--outline);
  border-radius: 4px;
  background: linear-gradient(180deg, #E8CB66, var(--gold));
  box-shadow: 0 4px 0 var(--charcoal);
  position: relative;
  -webkit-mask: radial-gradient(circle 7px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 7px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 7px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle 7px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
}
.ticket-label {
  font-family: var(--font-pix);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: rgba(30, 32, 34, 0.8);
}
.ticket-value {
  font-family: var(--font-pix);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--charcoal);
  text-shadow: 2px 2px 0 rgba(247, 249, 248, 0.7);
}

.modal-heading {
  margin: 2px 0 0;
  line-height: 1.35;
}
.modal-heading .pix {
  font-size: 12px;
  color: var(--gold-deep);
  letter-spacing: 0.16em;
}
.modal-heading .sep {
  font-family: var(--font-pix);
  font-size: 12px;
  color: var(--gold-deep);
}
.modal-heading .zh {
  display: block;
  margin-top: 6px;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--charcoal);
  text-wrap: balance;
}
.modal-heading > .pix:only-child { font-size: 18px; color: var(--charcoal); }

.modal-body {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: 0.04em;
  text-wrap: balance;
}
.modal-prompt {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: 0.03em;
  color: rgba(30, 32, 34, 0.82);
  text-wrap: pretty;
}
.modal-footer {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: rgba(30, 32, 34, 0.6);
}

/* player status (HP / overheal / shield / weapon) */
.status {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 4px;
  background: rgba(13, 59, 102, 0.06);
  box-shadow: inset 0 0 0 1px rgba(30, 32, 34, 0.12);
}
.status-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.status-label { font-family: var(--font-pix); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; }
.status-value { font-family: var(--font-pix); font-size: 11px; font-weight: 700; color: var(--navy); min-width: 64px; text-align: left; }

.hp-cells { display: flex; align-items: center; gap: 4px; }
.cell {
  display: block;
  width: 12px;
  height: 18px;
  border: var(--outline);
  background: rgba(247, 249, 248, 0.9);
}
.cell.filled {
  background: linear-gradient(180deg, var(--ice) 0 72%, var(--navy) 72% 100%);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.6);
}
.cell.over { border-style: dashed; background: rgba(13, 59, 102, 0.1); }
.cell.over.filled {
  border-style: solid;
  background: linear-gradient(180deg, #8BE3FA 0 72%, var(--navy) 72% 100%);
  box-shadow: inset 2px 2px 0 #FFFFFF, 0 0 10px rgba(76, 201, 240, 0.85);
  animation: glow 1.4s ease-in-out infinite alternate;
}
@keyframes glow { to { box-shadow: inset 2px 2px 0 #FFFFFF, 0 0 16px rgba(76, 201, 240, 1); } }
.cell-gap { display: block; width: 4px; }

.chips { gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border: var(--outline);
  border-radius: 999px;
  font-family: var(--font-pix), var(--font-zh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--pearl);
}
.chip.shield { opacity: 0.5; }
.chip.shield.on { opacity: 1; background: #DCE3E8; }
.chip.weapon { background: #FBF3D6; }

.actions { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 4px; }

/* paused */
.paused-hit {
  all: unset;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
}
.paused-title { font-size: 28px; color: var(--pearl); text-shadow: 2px 2px 0 var(--charcoal); }
.paused-sub { font-size: 14px; font-weight: 700; letter-spacing: 0.2em; color: var(--pearl); text-shadow: 1px 1px 0 var(--charcoal); }

.noscript { position: absolute; inset: auto 0 40% 0; text-align: center; font-weight: 700; }

/* ─────────── top-right 8-bit audio toggle ─────────── */
.audio-toggle {
  position: absolute;
  top: calc(var(--safe-t) + 9px);
  right: calc(var(--safe-r) + 12px);
  z-index: 5;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 9px;
  border: var(--outline);
  border-radius: 4px;
  background: rgba(247, 249, 248, 0.9);
  color: var(--charcoal);
  font-family: var(--font-pix), var(--font-zh);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 0 var(--charcoal);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}
.audio-toggle:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--charcoal); }
.audio-toggle.is-muted { opacity: 0.65; background: rgba(220, 227, 232, 0.85); }

/* ─────────── 2027 Goat Edition badge (bottom-left of title) ─────────── */
.goat-badge {
  position: absolute;
  left: calc(var(--safe-l) + 14px);
  bottom: calc(var(--safe-b) + 12px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 7px;
  border: 1.5px solid var(--charcoal);
  border-radius: 4px;
  background: rgba(247, 249, 248, 0.78);
  box-shadow: 0 2px 0 var(--charcoal);
  pointer-events: none;
}
.goat-badge-icon { display: inline-flex; align-items: center; }
.goat-icon { display: block; image-rendering: pixelated; }
.goat-badge-text {
  font-family: var(--font-pix);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold-deep);
}

/* ─────────── Round 3 Result & Conversion Screen ─────────── */
.screen-result {
  align-items: flex-start;
  padding-top: calc(var(--safe-t) + 46px);
  padding-bottom: calc(var(--safe-b) + 32px);
}

.result-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: pop 0.36s cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
}

.result-header {
  padding: 18px 18px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.result-title-pill {
  display: inline-block;
  padding: 4px 12px;
  border: var(--outline);
  border-radius: 4px;
  background: linear-gradient(180deg, #F5E097, var(--gold));
  color: var(--charcoal);
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  box-shadow: 0 2px 0 var(--charcoal);
}

.result-headline {
  margin: 2px 0 0;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.4;
  letter-spacing: 0.06em;
  color: var(--charcoal);
  text-wrap: balance;
}

.result-subcopy {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: 0.03em;
  color: rgba(30, 32, 34, 0.84);
  text-wrap: pretty;
}

/* Promo Card (DOM only — Ending A & B) */
.promo-card {
  padding: 16px 16px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.promo-label {
  margin: 0;
  font-family: var(--font-pix), var(--font-zh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--gold-deep);
}

.promo-reward {
  margin: -4px 0 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--charcoal);
}

.promo-code-box {
  padding: 10px 12px;
  border: 2px dashed var(--gold-deep);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.88);
  font-family: var(--font-pix);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--charcoal);
  -webkit-user-select: text;
  user-select: text;
}

.promo-notice {
  margin: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--burgundy);
  border-radius: 4px;
  background: rgba(139, 30, 63, 0.08);
  color: var(--burgundy);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-wrap: pretty;
}

/* Title & Result Challenger Name Inputs */
input {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

.name-field {
  width: 100%;
  padding: 10px 14px 12px;
  display: grid;
  gap: 6px;
  text-align: left;
}

.name-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-deep);
}

.name-input,
.quick-name-input {
  width: 100%;
  min-height: 40px;
  padding: 7px 11px;
  border: 1.5px solid var(--charcoal);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--charcoal);
  font-family: var(--font-zh);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.name-input::placeholder,
.quick-name-input::placeholder {
  color: rgba(30, 32, 34, 0.42);
  font-weight: 500;
}

.name-input:focus,
.quick-name-input:focus {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.35);
}

.quick-name-row {
  width: 100%;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.quick-name-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--charcoal);
  white-space: nowrap;
}

.quick-name-input {
  min-height: 36px;
  padding: 5px 10px;
  font-size: 13px;
}

.btn-wa {
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* 9:16 Shareable Battle Poster */
.poster-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.poster-frame {
  width: 100%;
  border: var(--outline);
  border-radius: 6px;
  overflow: hidden;
  background: var(--pearl);
  box-shadow: 0 6px 0 var(--charcoal), 0 18px 36px rgba(13, 59, 102, 0.2);
}

.poster-img {
  display: block;
  width: 100%;
  height: auto;
  /* Critical for iOS Safari / IG WebView long-press Save Image */
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
  touch-action: pan-y;
}

.poster-hint {
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(30, 32, 34, 0.78);
  color: var(--gold-light);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.result-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-link {
  text-decoration: none;
  font-size: 13px;
}

/* Collapsible T&Cs */
.tnc {
  padding: 12px 14px;
  text-align: left;
}

.tnc-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(30, 32, 34, 0.8);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tnc-summary::-webkit-details-marker { display: none; }
.tnc-summary::after { content: "＋"; font-weight: 700; color: var(--gold-deep); }
.tnc[open] .tnc-summary::after { content: "－"; }

.tnc-list {
  margin: 10px 0 2px;
  padding-left: 16px;
  display: grid;
  gap: 6px;
  font-size: 11px;
  line-height: 1.55;
  color: rgba(30, 32, 34, 0.72);
}

/* Toast notification */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 26px);
  z-index: 20;
  transform: translate(-50%, 10px);
  opacity: 0;
  padding: 9px 18px;
  border: var(--outline);
  border-radius: 999px;
  background: var(--charcoal);
  color: var(--gold-light);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 0 rgba(30, 32, 34, 0.35);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ─────────── Compendium Modal (SUPREME ARCHIVE · 2027 圖鑑) ─────────── */
.btn-archive-entry {
  min-height: 44px;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.btn-follow-full {
  grid-column: 1 / -1;
}

.archive-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 12px);
  background: rgba(30, 32, 34, 0.36);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  animation: fadeIn 0.2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.archive-modal {
  width: 100%;
  max-width: 390px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 14px 14px 12px;
  gap: 10px;
  animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.25, 1.15) both;
}

.archive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--charcoal);
}

.archive-title {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--charcoal);
}

.archive-close {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: var(--outline);
  border-radius: 4px;
  background: var(--pearl);
  color: var(--charcoal);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 0 var(--charcoal);
  cursor: pointer;
  touch-action: manipulation;
}
.archive-close:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--charcoal); }

.archive-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.archive-tab {
  min-height: 38px;
  padding: 6px 10px;
  border: var(--outline);
  border-radius: 4px;
  background: rgba(247, 249, 248, 0.85);
  color: var(--charcoal);
  font-family: var(--font-zh);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 2px 0 var(--charcoal);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.archive-tab.is-active {
  background: var(--charcoal);
  color: var(--gold-light);
}

.archive-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 2px 6px;
}

.archive-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: var(--outline);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 3px 0 var(--charcoal);
  text-align: left;
}
.archive-card.is-boss {
  background: linear-gradient(135deg, rgba(139, 30, 63, 0.08), rgba(212, 175, 55, 0.12) 55%, rgba(255, 255, 255, 0.9));
}

.archive-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: var(--outline);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  overflow: hidden;
}
.archive-thumb.is-silhouette {
  background: linear-gradient(180deg, #5BA8B2, #7BC5CE);
}

.archive-thumb-canvas {
  width: 56px;
  height: 56px;
  display: block;
  image-rendering: pixelated;
}

.archive-qmark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-pix);
  font-size: 26px;
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: 0 0 8px rgba(139, 30, 63, 0.95), 2px 2px 0 var(--burgundy);
  animation: qPulse 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes qPulse {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.12); opacity: 1; }
}

.archive-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.archive-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.archive-badge {
  display: inline-block;
  padding: 2px 6px;
  border: 1.5px solid var(--charcoal);
  border-radius: 3px;
  background: #FBF3D6;
  color: var(--gold-deep);
  font-family: var(--font-pix), var(--font-zh);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.archive-badge.is-final {
  background: var(--burgundy);
  color: var(--gold-light);
}

.archive-name {
  margin: 0;
  font-family: var(--font-serif), var(--font-zh);
  font-size: 15px;
  font-weight: 900;
  color: var(--charcoal);
  letter-spacing: 0.04em;
}

.archive-line {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: rgba(30, 32, 34, 0.88);
}

.archive-therapy {
  color: rgba(30, 32, 34, 0.68);
  font-size: 11.5px;
}

.archive-key {
  font-weight: 700;
  color: var(--gold-deep);
}

/* ─────────── Title 2-column secondary row & Top 10 Ranking Modal ─────────── */
.title-secondary-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.top10-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1.5px solid var(--gold-deep);
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.16);
  color: var(--gold-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.top10-badge[hidden] { display: none; }

.lb-title-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}

.lb-subtitle {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(30, 32, 34, 0.68);
}

.lb-state {
  margin: auto 0;
  padding: 36px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(30, 32, 34, 0.72);
}
.lb-error { color: var(--burgundy); }

.lb-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: var(--outline);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 3px 0 var(--charcoal);
  text-align: left;
}
.lb-row.is-self {
  border-color: var(--gold-deep);
  background: linear-gradient(90deg, rgba(122, 220, 228, 0.24), rgba(241, 220, 142, 0.26));
  box-shadow: 0 0 0 1.5px var(--gold), 0 3px 0 var(--charcoal);
}

.lb-rank {
  display: grid;
  place-items: center;
  width: 36px;
  height: 30px;
  border: 1.5px solid var(--charcoal);
  border-radius: 4px;
  font-family: var(--font-pix);
  font-size: 11px;
  font-weight: 700;
  color: var(--pearl);
  background: var(--charcoal);
}
.lb-rank.r1 { background: #D4AF37; color: var(--charcoal); }
.lb-rank.r2 { background: #C0C8CE; color: var(--charcoal); }
.lb-rank.r3 { background: #C68B59; color: var(--pearl); }
.lb-rank.rn { background: var(--charcoal); color: var(--pearl); }

.lb-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.lb-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--charcoal);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-title-tag {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--gold-deep);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--charcoal);
  white-space: nowrap;
  text-align: right;
}

@media (max-height: 700px) {
  .title-wrap { gap: 10px; }
  .game-title-zh { font-size: 36px; }
  .rules { padding: 10px 14px; gap: 6px; }
  .modal { gap: 9px; padding: 18px 16px 14px; }
  .ticket-value { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
