/* =========================================================================
   《寻宝奇兵》H5 外壳样式（game-shell）
   规范来源：docs/GAMEDESIGN.md 5.4
   - 深色渐变 + 星点/雾气，金 / 翡翠 / 蓝配色
   - 圆角按钮，触屏目标 >= 48px，安全区适配
   - 无外部字体 / 图片 / CDN 依赖
   ========================================================================= */

:root {
  --gold: #f5c542;
  --gold-bright: #ffd76a;
  --gold-soft: #f7d67c;
  --gold-line: rgba(245, 197, 66, 0.22);
  --jade: #3ddc97;
  --blue: #5b8cff;
  --bg-deep: #05070d;
  --bg: #1b2233;
  --text: #eef2fb;
  --text-dim: #98a5bf;
  --text-faint: #6b7894;
  --danger: #ff6b6b;
  --panel-bg: linear-gradient(165deg, rgba(27, 37, 59, 0.94), rgba(12, 17, 28, 0.96));
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 12px;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --font: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC",
    "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
}

/* ---------------- 背景 ---------------- */

.app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 70% at 50% 8%, #1d2c4f 0%, rgba(13, 20, 37, 0.6) 46%, rgba(5, 7, 13, 0) 78%),
    radial-gradient(ellipse 70% 60% at 12% 100%, #14202f 0%, rgba(5, 7, 13, 0) 70%),
    linear-gradient(180deg, #0a0f1c 0%, #070a13 55%, #04060b 100%);
}

.bg-stars {
  position: absolute;
  inset: 0;
  opacity: 0.85;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 22%, rgba(255, 255, 255, 0.9), transparent 60%),
    radial-gradient(1.2px 1.2px at 78% 14%, rgba(200, 220, 255, 0.85), transparent 60%),
    radial-gradient(1.8px 1.8px at 42% 8%, rgba(255, 240, 200, 0.9), transparent 60%),
    radial-gradient(1.2px 1.2px at 62% 34%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1.4px 1.4px at 88% 58%, rgba(190, 220, 255, 0.75), transparent 60%),
    radial-gradient(1.2px 1.2px at 24% 68%, rgba(255, 255, 255, 0.6), transparent 60%),
    radial-gradient(1.6px 1.6px at 8% 84%, rgba(255, 235, 190, 0.7), transparent 60%),
    radial-gradient(1.2px 1.2px at 52% 90%, rgba(200, 220, 255, 0.6), transparent 60%),
    radial-gradient(1.4px 1.4px at 72% 78%, rgba(255, 255, 255, 0.65), transparent 60%),
    radial-gradient(1.2px 1.2px at 34% 46%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1.2px 1.2px at 94% 36%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1.2px 1.2px at 4% 52%, rgba(200, 220, 255, 0.5), transparent 60%);
  animation: starTwinkle 7s ease-in-out infinite alternate;
}

.bg-glow {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  pointer-events: none;
}

.bg-glow-a {
  top: -18vmax;
  right: -10vmax;
  background: radial-gradient(circle, rgba(245, 197, 66, 0.3) 0%, rgba(245, 197, 66, 0) 68%);
  animation: glowFloat 16s ease-in-out infinite alternate;
}

.bg-glow-b {
  bottom: -22vmax;
  left: -12vmax;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.28) 0%, rgba(91, 140, 255, 0) 70%);
  animation: glowFloat 19s ease-in-out infinite alternate-reverse;
}

.bg-fog {
  position: absolute;
  inset: -15%;
  opacity: 0.45;
  background:
    radial-gradient(ellipse 40% 26% at 28% 78%, rgba(61, 220, 151, 0.1), transparent 70%),
    radial-gradient(ellipse 46% 30% at 74% 62%, rgba(91, 140, 255, 0.12), transparent 72%),
    radial-gradient(ellipse 34% 22% at 50% 100%, rgba(245, 197, 66, 0.06), transparent 70%);
  animation: fogDrift 24s ease-in-out infinite alternate;
}

@keyframes starTwinkle {
  from { opacity: 0.55; }
  to { opacity: 0.95; }
}

@keyframes glowFloat {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-4vmax, 3vmax, 0) scale(1.12); }
}

@keyframes fogDrift {
  from { transform: translate3d(-1.5%, 1%, 0); }
  to { transform: translate3d(1.5%, -1.5%, 0); }
}

/* ---------------- 页面容器 ---------------- */

.screens {
  position: fixed;
  inset: 0;
  z-index: 2;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s ease, visibility 0.32s ease;
  padding:
    calc(20px + var(--sat))
    calc(20px + var(--sar))
    calc(20px + var(--sab))
    calc(20px + var(--sal));
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen-game {
  padding: 0;
  overflow: hidden;
  background: #02040a;
  align-items: center;
  justify-content: center;
}

/* ---------------- 通用面板 / 标题 ---------------- */

.panel {
  position: relative;
  margin: auto;
  width: 100%;
  max-width: 430px;
  padding: 30px 28px 26px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold-line);
  background: var(--panel-bg);
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel-wide {
  max-width: 780px;
}

.brand {
  text-align: center;
}

.brand-emblem {
  position: relative;
  width: 46px;
  height: 46px;
  margin: 0 auto 22px;
  transform: rotate(45deg);
  border: 2px solid rgba(245, 197, 66, 0.75);
  border-radius: 12px;
  box-shadow:
    0 0 26px rgba(245, 197, 66, 0.35),
    inset 0 0 16px rgba(245, 197, 66, 0.22);
}

.brand-emblem span {
  position: absolute;
  inset: 10px;
  border-radius: 7px;
  background: radial-gradient(circle at 34% 30%, rgba(255, 240, 190, 0.95), rgba(245, 197, 66, 0.16) 72%);
}

.brand-title {
  margin: 0;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 8px;
  text-indent: 8px;
  background: linear-gradient(180deg, #fff3c4 0%, #f5c542 48%, #cf9a2a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 16px rgba(245, 197, 66, 0.3));
}

.brand-title.small {
  font-size: 30px;
  letter-spacing: 6px;
}

.brand-sub {
  margin: 12px 0 0;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.panel-head {
  text-align: center;
  margin-bottom: 24px;
}

.panel-head .brand-sub {
  margin-top: 8px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.page-title {
  flex: 1;
  margin: 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold-soft);
}

.page-side {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------------- 启动页 ---------------- */

.boot {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 46px;
  text-align: center;
  padding: 24px;
}

.boot-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(78vw, 280px);
}

.boot-progress .bar {
  width: 100%;
}

.boot-status {
  margin: 0;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.boot .version-line {
  margin: 0;
}

/* ---------------- 按钮 ---------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:active {
  transform: scale(0.972);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(180deg, #ffd76a 0%, #f5c542 55%, #e2ab2f 100%);
  color: #261b04;
  box-shadow:
    0 10px 28px rgba(245, 197, 66, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn-ghost {
  border-color: rgba(245, 197, 66, 0.42);
  color: var(--gold-soft);
  background: rgba(245, 197, 66, 0.06);
}

.btn-danger-ghost {
  border-color: rgba(255, 107, 107, 0.42);
  color: #ff9b9b;
  background: rgba(255, 107, 107, 0.06);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  min-height: 54px;
  font-size: 17px;
}

.btn-xl {
  min-height: 56px;
  font-size: 18px;
}

.btn-sm {
  min-height: 48px;
  padding: 0 16px;
  font-size: 14px;
}

.btn-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #c9d3e8;
  font-size: 20px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.btn-icon:active {
  transform: scale(0.94);
}

@media (hover: hover) {
  .btn-primary:hover {
    background: linear-gradient(180deg, #ffe08a 0%, #ffd054 55%, #eab533 100%);
    box-shadow: 0 14px 36px rgba(245, 197, 66, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }

  .btn-ghost:hover {
    background: rgba(245, 197, 66, 0.12);
    border-color: rgba(245, 197, 66, 0.7);
  }

  .btn-danger-ghost:hover {
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.7);
  }

  .btn-icon:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(245, 197, 66, 0.45);
  }
}

/* ---------------- 表单 ---------------- */

.form {
  display: flex;
  flex-direction: column;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 10, 18, 0.72);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
}

.input::placeholder {
  color: #56617a;
}

.input:focus {
  border-color: rgba(245, 197, 66, 0.7);
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.14);
}

.form .btn-block + .btn-block {
  margin-top: 12px;
}

.form-error {
  min-height: 20px;
  margin: 0 0 12px;
  color: #ff8a8a;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
}

.tip {
  margin: 16px 0 0;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--gold-soft);
  text-align: center;
}

.tip.dim {
  margin-top: 6px;
  color: var(--text-faint);
}

.tip.center {
  text-align: center;
}

.version-line {
  margin: 18px 0 0;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  text-align: center;
}

/* ---------------- 主菜单 ---------------- */

.panel-menu {
  max-width: 560px;
}

.menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.menu-brand .brand-title {
  text-align: left;
  font-size: 34px;
  letter-spacing: 6px;
}

.menu-welcome {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.menu-progress {
  margin: 28px 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(7, 11, 20, 0.5);
}

.progress-label {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.menu-foot {
  margin-top: 24px;
}

.menu-foot .version-line {
  margin: 0;
}

.badge-dot {
  flex: 0 0 auto;
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff5c5c;
  box-shadow: 0 0 0 3px rgba(255, 92, 92, 0.2), 0 0 10px rgba(255, 92, 92, 0.8);
  animation: dotPulse 1.6s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.82); }
}

/* ---------------- 进度条 ---------------- */

.bar {
  position: relative;
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--jade));
  box-shadow: 0 0 12px rgba(61, 220, 151, 0.5);
  transition: width 0.3s ease;
}

.bar-gold i {
  background: linear-gradient(90deg, #e2ab2f, var(--gold-bright));
  box-shadow: 0 0 14px rgba(245, 197, 66, 0.6);
}

.progress {
  margin-top: 14px;
}

.progress-text {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* ---------------- 选关 ---------------- */

/* 列数随关卡数量自适应：v2 起 4 关，桌面一行 4 卡；更多关卡自动换行，不写死列数 */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 158px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(91, 140, 255, 0.28);
  background: linear-gradient(160deg, rgba(40, 57, 90, 0.9), rgba(17, 24, 40, 0.95));
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.level-card:focus-visible {
  outline: 2px solid rgba(245, 197, 66, 0.8);
  outline-offset: 2px;
}

.level-card:active {
  transform: scale(0.98);
}

.level-card-play {
  align-self: stretch;
  margin-top: 12px;
  min-height: 48px;
  font-size: 14px;
  letter-spacing: 2px;
}

.level-card.is-locked {
  cursor: not-allowed;
  opacity: 0.56;
  border-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(160deg, rgba(30, 37, 54, 0.82), rgba(14, 18, 28, 0.92));
}

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: 1px solid rgba(245, 197, 66, 0.5);
  background: rgba(245, 197, 66, 0.13);
  color: var(--gold-soft);
  font-size: 16px;
  font-weight: 700;
}

.level-card.is-locked .level-badge {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-faint);
  font-size: 15px;
}

.level-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

.level-theme {
  font-size: 12px;
  color: var(--text-dim);
}

.level-best {
  margin-top: auto;
  padding-top: 10px;
  font-size: 12px;
  color: #9fe6c4;
  font-variant-numeric: tabular-nums;
}

.level-card.is-locked .level-best {
  color: var(--text-faint);
}

@media (hover: hover) {
  .level-card:not(.is-locked):hover {
    transform: translateY(-3px);
    border-color: rgba(245, 197, 66, 0.6);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45);
  }
}

/* ---------------- 设置 ---------------- */

.settings-group {
  margin-bottom: 16px;
  padding: 6px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(7, 11, 20, 0.48);
}

.settings-group:last-child {
  margin-bottom: 0;
}

.group-title {
  margin: 16px 0 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--gold-soft);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 10px 0;
}

.setting-row + .setting-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 15px;
}

.setting-label small {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

.switch {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 72px;
  height: 48px;
  padding: 9px 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.switch i {
  position: relative;
  display: block;
  width: 56px;
  height: 30px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s ease;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #aab4c8;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.switch.is-on i {
  background: rgba(61, 220, 151, 0.32);
}

.switch.is-on i::after {
  transform: translateX(26px);
  background: var(--jade);
  box-shadow: 0 0 12px rgba(61, 220, 151, 0.75);
}

.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 0;
  font-size: 14px;
}

.version-label {
  color: var(--text-dim);
}

.version-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  text-align: right;
}

.update-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.update-status {
  flex: 1;
  min-width: 130px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

.update-status.is-ok { color: var(--jade); }
.update-status.is-warn { color: var(--gold); }
.update-status.is-error { color: #ff8a8a; }
.update-status.is-checking { color: #8fb3ff; }

#settings-version-group .tip {
  margin: 12px 0 16px;
  text-align: left;
  line-height: 1.6;
}

#settings-version-group .tip:empty {
  display: none;
}

/* ---------------- 游戏层 ---------------- */

.game-stage {
  position: relative;
  width: min(
    calc(100vw - var(--sal) - var(--sar)),
    calc((100vh - var(--sat) - var(--sab)) * 16 / 9)
  );
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.95);
}

.game-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---------------- 覆盖层 ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(20px + var(--sat))
    calc(20px + var(--sar))
    calc(20px + var(--sab))
    calc(20px + var(--sal));
  background: rgba(4, 7, 13, 0.68);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn 0.22s ease;
}

.overlay-card {
  width: min(92vw, 400px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 26px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold-line);
  background: var(--panel-bg);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.66);
  animation: cardIn 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.overlay-title {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
  color: var(--text);
}

.overlay-title.gold { color: var(--gold-soft); }
.overlay-title.danger { color: #ff8f8f; }

.overlay-desc {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-dim);
  text-align: center;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}

.stat {
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(7, 11, 20, 0.55);
  text-align: center;
}

.stat-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-dim);
}

.stat-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 更新弹窗 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(18px + var(--sat))
    calc(18px + var(--sar))
    calc(18px + var(--sab))
    calc(18px + var(--sal));
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 9, 0.76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(92vw, 470px);
  max-height: 86vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(245, 197, 66, 0.28);
  background: var(--panel-bg);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.72);
  animation: cardIn 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-title {
  margin: 0 0 12px;
  font-size: 23px;
  letter-spacing: 3px;
  color: var(--gold-soft);
}

.modal-version {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--text);
}

.modal-size {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.modal-subtitle {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.modal-notes {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(6, 10, 18, 0.6);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-error {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: #ff8a8a;
}

.modal-hint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-faint);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* ---------------- 轻提示 ---------------- */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--sab));
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 16px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: min(86vw, 380px);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(91, 140, 255, 0.3);
  border-left: 3px solid var(--blue);
  background: rgba(16, 24, 40, 0.96);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: toastIn 0.24s ease;
}

.toast-success { border-left-color: var(--jade); }
.toast-warn { border-left-color: var(--gold); }
.toast-error { border-left-color: var(--danger); }

.toast.is-out {
  animation: toastOut 0.3s ease forwards;
}

/* ---------------- 动画 ---------------- */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

/* ---------------- 响应式 ---------------- */

/* 竖屏小屏：选关单列，面板收紧 */
@media (max-width: 760px) {
  .level-grid {
    grid-template-columns: 1fr;
  }

  .level-card {
    min-height: 96px;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "badge name"
      "badge theme"
      "badge best"
      "play play";
    column-gap: 14px;
    align-items: center;
    padding: 14px 16px;
  }

  .level-badge {
    grid-area: badge;
    margin: 0;
  }

  .level-name { grid-area: name; }
  .level-theme { grid-area: theme; }

  .level-best {
    grid-area: best;
    padding-top: 4px;
  }

  .level-card-play {
    grid-area: play;
    margin-top: 10px;
  }

  .panel {
    padding: 24px 20px 22px;
  }

  .brand-title {
    font-size: 32px;
    letter-spacing: 6px;
    text-indent: 6px;
  }

  .menu-brand .brand-title {
    font-size: 28px;
  }
}

/* 横屏矮屏（安卓 APP 主力场景）：压缩纵向留白，保证登录页无滚动 */
@media (orientation: landscape) and (max-height: 560px) {
  .screen {
    padding:
      calc(10px + var(--sat))
      calc(24px + var(--sar))
      calc(10px + var(--sab))
      calc(24px + var(--sal));
  }

  .brand-emblem {
    width: 34px;
    height: 34px;
    margin-bottom: 14px;
  }

  .brand-title {
    font-size: 27px;
    letter-spacing: 5px;
  }

  .brand-title.small {
    font-size: 23px;
  }

  .brand-sub {
    margin-top: 6px;
    font-size: 12px;
  }

  .panel {
    max-width: 640px;
    padding: 18px 24px 16px;
  }

  .panel-auth {
    max-width: 560px;
  }

  .panel-auth .panel-head {
    margin-bottom: 14px;
  }

  .panel-auth .brand-emblem,
  .panel-auth .brand-sub {
    display: none;
  }

  .field {
    margin-bottom: 10px;
  }

  .field-label {
    margin-bottom: 4px;
  }

  .input {
    height: 48px;
  }

  .form-error {
    min-height: 18px;
    margin-bottom: 8px;
  }

  .form .btn-block + .btn-block {
    margin-top: 8px;
  }

  .tip {
    margin-top: 10px;
  }

  .panel-auth .tip.dim {
    display: none;
  }

  .version-line {
    margin-top: 10px;
  }

  .boot {
    gap: 26px;
  }

  .menu-progress {
    margin: 16px 0;
    padding: 12px 16px;
  }

  .menu-actions {
    flex-direction: row;
  }

  .menu-actions .btn {
    flex: 1;
  }

  .menu-foot {
    margin-top: 14px;
  }

  .settings-group {
    margin-bottom: 10px;
  }

  .setting-row {
    min-height: 54px;
    padding: 6px 0;
  }

  .level-grid {
    gap: 12px;
  }

  .level-card {
    min-height: 128px;
    padding: 14px;
  }

  .level-badge {
    width: 32px;
    height: 32px;
    margin-bottom: 6px;
  }

  .level-name {
    font-size: 16px;
  }

  .overlay-card {
    padding: 20px 24px;
  }

  .overlay-title {
    font-size: 22px;
    margin-bottom: 6px;
  }

  .overlay-desc {
    margin-bottom: 14px;
  }

  .modal-card {
    padding: 20px 22px;
  }

  .modal-notes {
    margin-bottom: 12px;
  }
}

/* 横屏且很窄的高度（如 360dp 高度）：登录页使用紧凑布局，避免溢出滚动 */
@media (orientation: landscape) and (max-height: 430px) {
  .panel-auth {
    padding: 12px 22px;
  }

  .panel-auth .panel-head {
    margin-bottom: 8px;
  }

  .panel-auth .brand-emblem {
    display: none;
  }

  .panel-auth .brand-title,
  .brand-title {
    font-size: 22px;
    letter-spacing: 4px;
  }

  .panel-auth .brand-sub {
    display: none;
  }

  .panel-auth .field {
    margin-bottom: 7px;
  }

  .panel-auth .field-label {
    display: none;
  }

  .panel-auth .input {
    height: 46px;
  }

  .panel-auth .form-error {
    min-height: 16px;
    margin-bottom: 5px;
  }

  .panel-auth .form .btn-block + .btn-block {
    margin-top: 7px;
  }

  .panel-auth .btn {
    min-height: 48px;
  }

  .panel-auth .tip,
  .panel-auth .tip.dim {
    display: none;
  }

  .panel-auth .version-line {
    margin-top: 7px;
  }

  .boot .brand-emblem {
    display: none;
  }

  .boot {
    gap: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
