@font-face {
  font-family: "Lilita One";
  src: url("../fonts/LilitaOne-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "源古黑體-F";
  src: url("../fonts/源古黑體-F.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
* {
  box-sizing: border-box;
}
html {
  height: 100%;
  /* 英文 Lilita；中文见 [data-lang="zh"] 覆盖为源古黑體-F */
  --font-panel: "Lilita One", ui-sans-serif, system-ui, sans-serif;
  /* 数字/时间固定沿用英文面板字体（不随中文切换） */
  --font-panel-en: "Lilita One", ui-sans-serif, system-ui, sans-serif;
  /* 随视口宽度缩放（clamp），与 personality 同一思路；新文案可复用变量 */
  --fs-field: clamp(11px, calc(0.7vw + 0.7vh), 26px);
  --fs-personality: clamp(10px, calc(0.6vw + 0.6vh), 23px);
  --fs-stat-value: clamp(9px, calc(0.58vw + 0.55vh), 23px);
  --fs-corner: clamp(12px, calc(0.9vw + 0.9vh), 26px);
  --fs-debug: clamp(10px, calc(0.4vw + 0.6vh), 13px);
  --fs-debug-label: clamp(9px, calc(0.4vw + 0.5vh), 12px);
  --fs-debug-note: clamp(8px, calc(0.35vw + 0.45vh), 11px);
  /* 照片区 / 进度条上方英文标题（与正文成比例，可在此微调 clamp） */
  --fs-section-heading: clamp(9px, calc(0.95vw + 0.9vh), 28px);
  /* 下载 225×207、分享 150×138：比例已写死在 aspect-ratio；改大小调下面两个 width，改位置调 .corner-btn--* 的 right / top */
  --corner-download-w: 5.8%;
  --corner-share-w: 5.8%;
  font-family: var(--font-panel);
  color: #000;
}
html[data-lang="zh"] {
  --font-panel: "源古黑體-F", "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
}
/* 语言切换：相对视口右上角，不压在 .stage 画布内 */
.lang-switch {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  z-index: 100;
  display: flex;
  gap: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.lang-switch button {
  margin: 0;
  padding: 6px 12px;
  border: none;
  background: rgba(26, 40, 72, 0.92);
  color: #e8eef8;
  font-family: "源古黑體-F", "Lilita One", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(11px, 2.5vw, 14px);
  font-weight: 400;
  cursor: pointer;
  line-height: 1.2;
}
.lang-switch button:hover {
  background: rgba(40, 60, 100, 0.95);
}
.lang-switch button[aria-pressed="true"] {
  background: rgba(230, 236, 248, 0.98);
  color: #0a1628;
}
html[data-lang="en"] .lang-switch button {
  font-family: "Lilita One", ui-sans-serif, system-ui, sans-serif;
}
html,
body {
  margin: 0;
  overflow-x: hidden;
  background-color: #0a1628;
}
body {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  font-family: var(--font-panel);
  color: #000;
  isolation: isolate;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: #0a1628;
  background-image: url("../bg-vertical.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}
/* 主画布区域：占满「视口减去底部调试条」后的剩余空间，不把调试条叠在上面 */
.viewport {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  container-type: size;
  container-name: panel;
}
@media (orientation: landscape) {
  body::before {
    background-image: url("../bg-horizontal.jpg");
  }
  .viewport {
    background: transparent;
  }
}
@media (orientation: portrait) {
  html {
    --fs-field: clamp(12px, calc(1.2vw + 0.95vh), 24px);
    --fs-personality: clamp(10px, calc(0.95vw + 0.75vh), 20px);
    --fs-stat-value: clamp(10px, calc(0.95vw + 0.75vh), 22px);
    --fs-section-heading: clamp(10px, calc(1.2vw + 0.95vh), 24px);
    --corner-download-w: 7.2%;
    --corner-share-w: 7.2%;
  }
  .field--1 {
    top: 70.8%;
    min-height: 6.2%;
  }
  .field--2 {
    top: 79.6%;
    min-height: 10.0%;
    overflow: hidden;
  }
  .field--3 {
    top: 91.2%;
    min-height: 6.4%;
  }
  .field--3 .id-display {
    font-size: clamp(7px, calc(0.3vw + 0.38vh), 12px);
  }
  .field--2 #leopard-personality {
    line-height: 1.08;
    padding-top: 0.46em;
    padding-bottom: 0.46em;
  }
}
/* 约 16:9 画布，在 .viewport 内完整可见；页面背景由 .viewport 的 bg-vertical / bg-horizontal 铺满 */
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100cqw, 100cqh * 16 / 9);
  height: auto;
  max-width: 100cqw;
  max-height: 100cqh;
  background: transparent;
  contain: layout paint;
}
@supports not (width: 1cqw) {
  .stage {
    width: min(100vw, 100vh * 16 / 9);
    height: min(100vh, 100vw * 9 / 16);
    max-width: 100vw;
    max-height: 100%;
  }
}
.stage > * {
  position: absolute;
}
/* 左侧雪豹形象区（leopard-empty.png 原始比例 742×874，外框与图一致，主要调 width 即可缩放） */
.leopard {
  left: 2.5%;
  top: 5.9%;
  width: 28.9%;
  height: auto;
  aspect-ratio: 742 / 874;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #3a96ff;
  border-radius: 10px;
}
/* 三个照片格：photo-empty.png 比例 468×390（即 6:5），外框与图一致；改大小主要调 width */
.photo-slot {
  top: 26.8%;
  width: 18.2%;
  height: auto;
  aspect-ratio: 468 / 390;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #3a96ff;
  border-radius: 8px;
}
.photo-slot--1 {
  left: 35%;
}
.photo-slot--2 {
  left: 57.1%;
}
.photo-slot--3 {
  left: 79.4%;
}
/*
 * ========== 区块英文标题（相对 .stage 的 %）==========
 * 统一：黑色、Lilita（继承）、字号 var(--fs-section-heading)
 * 可调：每个 .stage-heading--* 的 left / top / width / text-align / letter-spacing
 * 字号：改 html 里的 --fs-section-heading，或单独覆盖 font-size
 */
.stage-heading {
  position: absolute;
  margin: 0;
  padding: 0;
  font-family: var(--font-panel);
  font-weight: 400;
  font-size: var(--fs-section-heading);
  line-height: 1.15;
  color: #000;
  letter-spacing: 0.03em;
  pointer-events: none;
}
/* COLLECTED PHOTOS — 对齐照片列上方 */
.stage-heading--photos {
  left: 34.8%;
  top: 21%;
  width: 62.5%;
  text-align: left;
}
/* SENSE OF SECURITY — 对齐第一条进度条上方 */
.stage-heading--security {
  left: 34.8%;
  top: 56.5%;
  width: 62.3%;
  text-align: left;
}
/* HABITAT HEALTH */
.stage-heading--habitat {
  left: 34.8%;
  top: 70%;
  width: 62.3%;
  text-align: left;
}
/* CONSERVATION STATUS */
.stage-heading--conservation {
  left: 34.8%;
  top: 84.2%;
  width: 62.3%;
  text-align: left;
}
/* tags-bg.png 比例 748×94：只调 left、width、下面三行 top；高度随 width 按比例自动算（勿写 height） */
.field {
  left: 2.4%;
  width: 29.4%;
  height: auto;
  aspect-ratio: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2.5%;
  background: #fff;
  border: 2px solid #3a96ff;
  border-radius: 10px;
  min-height: 6.6%;
}
.field--1 {
  top: 69.8%;
}
.field--2 {
  top: 79.3%;
}
.field--3 {
  top: 90.2%;
}
.field--2,
.field--3 {
  min-height: 7.6%;
  padding: 0.4% 0.45%;
}
.field input,
.field textarea,
.field .personality-display,
.field .id-display {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 2%;
  border: none;
  outline: none;
  background: transparent;
  color: #000;
  font-weight: 400;
  font-size: var(--fs-field);
  text-align: center;
  font-family: var(--font-panel);
}
.field input::placeholder {
  color: rgba(0, 0, 0, 0.45);
  font-weight: 400;
}
.field textarea::placeholder {
  color: rgba(0, 0, 0, 0.45);
  font-weight: 400;
}
/* Personality 行文案较长，字号介于名字行与上一版之间 */
.field--2 #leopard-personality {
  font-size: var(--fs-personality);
  padding: 0.2em 0.25em;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}
.field--2 #leopard-personality.personality-display {
  display: flex;
  align-items: center;
  justify-content: center;
}
.field textarea {
  resize: none;
  overflow: hidden;
}
html[data-lang="en"] .field--2 #leopard-personality {
  min-height: 2.35em;
}
.field .id-display {
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: all;
  cursor: default;
}
.field--3 .id-display {
  font-size: clamp(8px, calc(0.45vw + 0.45vh), 15px);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
/* 右上角：PNG 图标，contain 铺满按钮框；比例与素材像素一致 */
.corner-btn {
  top: 6.3%;
  height: auto;
  border: none;
  border-radius: 0;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-panel);
  font-weight: 400;
}
.corner-btn:active {
  filter: brightness(0.92);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.corner-btn--download {
  right: 11.5%;
  width: var(--corner-download-w);
  aspect-ratio: 225 / 207;
  background-image: url("../panel1/download.png");
}
.corner-btn--share {
  right: 2.4%;
  width: var(--corner-share-w);
  aspect-ratio: 150 / 138;
  background-image: url("../panel1/share.png");
}
/* 三条进度条：每条单独改 left / top / width / height（相对 .stage 的百分比） */
.stat-bar {
  position: absolute;
  display: flex;
  flex-direction: column;
}
/* 社恐值 */
.stat-bar--security {
  left: 35.1%;
  top: 62.6%;
  width: 62.3%;
  height: 4%;
}
/* 栖息地健康度 */
.stat-bar--habitat {
  left: 35.1%;
  top: 76%;
  width: 62.3%;
  height: 4%;
}
/* 雪豹生存状况 */
.stat-bar--conservation {
  left: 35.1%;
  top: 90.1%;
  width: 62.3%;
  height: 4%;
}
.stat-bar__track {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  border-radius: 4px;
  overflow: hidden;
}
.stat-bar__bg {
  position: absolute;
  inset: 0;
  background: url("../panel1/progress-bg.png") center / 100% 100% no-repeat;
  z-index: 0;
}
.stat-bar__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  z-index: 1;
  background: url("../panel1/progress-fill.png") left center / 100% 100% no-repeat;
  transition: width 0.8s ease;
  will-change: width;
}

@media (prefers-reduced-motion: reduce) {
  .stat-bar__fill {
    transition: none;
  }
}
.stat-bar__value {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-stat-value);
  font-weight: 400;
  color: #000;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.75);
  font-family: var(--font-panel);
  pointer-events: none;
}

/* 中文模式下：进度条数字与时间/ID 不用中文字体，沿用英文字体 */
.stat-bar__value,
#user-id {
  font-family: var(--font-panel-en);
  font-variant-numeric: tabular-nums;
}
/* Demo 调试面板：与主画布拉开间距，整体更紧凑；上线前移除 */
.debug-panel {
  flex-shrink: 0;
  width: 100%;
  margin-top: clamp(10px, 2.2vw, 22px);
  padding: clamp(4px, 1vw, 8px) clamp(8px, 1.8vw, 14px) clamp(4px, 1vw, 8px);
  padding-bottom: calc(clamp(4px, 1vw, 8px) + env(safe-area-inset-bottom, 0px));
  background: rgba(245, 246, 248, 0.94);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  color: #000;
  font-family: var(--font-panel);
  font-size: var(--fs-debug);
  font-weight: 400;
}
.debug-panel__row {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 8px);
  margin-bottom: clamp(2px, 0.5vw, 5px);
  flex-wrap: wrap;
}
.debug-panel__row:last-of-type {
  margin-bottom: 0;
}
.debug-panel__label {
  flex: 0 0 7em;
  white-space: nowrap;
  font-size: var(--fs-debug-label);
}
.debug-panel input[type="range"] {
  flex: 1 1 80px;
  min-width: 72px;
  max-width: 220px;
}
.debug-panel__num {
  flex: 0 0 2em;
  text-align: right;
  font-size: var(--fs-debug-label);
  font-variant-numeric: tabular-nums;
}
.debug-panel__note {
  margin-top: clamp(3px, 0.6vw, 6px);
  font-size: var(--fs-debug-note);
  color: rgba(0, 0, 0, 0.5);
  line-height: 1.35;
}

/* Panel 底部：打开聊天页（URL 在点击时按当前存档与表单拼装） */
.panel-chat-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: max(10px, env(safe-area-inset-bottom, 0px)) 12px 14px;
  z-index: 50;
}
.panel-chat-open-btn {
  margin: 0;
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(26, 40, 72, 0.92);
  color: #e8eef8;
  font-family: inherit;
  font-size: clamp(12px, calc(0.5vw + 0.55vh), 16px);
  font-weight: 400;
  cursor: pointer;
  line-height: 1.25;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.panel-chat-open-btn:hover {
  background: rgba(40, 60, 100, 0.95);
}
.panel-chat-open-btn:active {
  transform: translateY(1px);
}
html[data-lang="en"] .panel-chat-open-btn {
  font-family: var(--font-panel-en);
}
