/* 《天际疾奔》界面层：明亮的天空色、左侧玻璃标题板、四角胶囊读数。 */

:root {
  --ink: #17334b;
  --ink-2: #31536c;
  --ink-3: #64839a;
  --sky: #eaf8ff;
  --sky-2: #d5edfa;
  --paper: rgba(255, 255, 255, 0.82);
  --paper-strong: rgba(255, 255, 255, 0.94);
  --paper-soft: rgba(255, 255, 255, 0.54);
  --line: rgba(255, 255, 255, 0.92);
  --line-2: rgba(34, 105, 142, 0.14);
  --aqua: #139ac0;
  --aqua-dark: #0b7397;
  --mint: #25b89c;
  --sun: #f7a52b;
  --sun-dark: #e67a26;
  --coral: #f2634d;
  --gold: #ffca37;
  --violet: #8d83d8;
  --heart: #ff6e70;
  --shadow-panel: 0 26px 70px rgba(20, 71, 105, 0.20), 0 4px 14px rgba(20, 71, 105, 0.10);
  --shadow-soft: 0 8px 24px rgba(23, 73, 106, 0.14);
  --blur: saturate(135%) blur(16px);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --hud-dark: rgba(12, 31, 49, 0.48);
  --font: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #bce5f6;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

#screen-flash,
#fade-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

#screen-flash {
  z-index: 12;
  --flash-alpha: 0.5;
  animation: none;
}

#fade-layer {
  z-index: 13;
  background: radial-gradient(120% 100% at 50% 45%, rgba(12, 30, 48, 0.62), #0d2235 92%);
  transition: opacity 420ms ease;
}

@keyframes screenFlash {
  0% {
    opacity: var(--flash-alpha);
  }
  100% {
    opacity: 0;
  }
}

/* 菜单根节点不吃鼠标事件；只有当前页接受点击，3D 场景在标题页保持可见。 */
#screens {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3.2vh, 40px) clamp(16px, 3.2vw, 52px);
  pointer-events: auto;
  overflow: hidden;
}

.screen.active {
  display: flex;
  animation: screenFade 320ms ease both;
}

.screen:not(.title-screen) {
  background: radial-gradient(95% 80% at 50% 42%, rgba(234, 248, 255, 0.10) 0%, rgba(230, 246, 255, 0.50) 64%, rgba(218, 240, 252, 0.72) 100%);
  backdrop-filter: saturate(108%) blur(3px);
}

.screen:not(.title-screen)::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(58% 52% at 50% 50%, transparent 65%, rgba(48, 104, 137, 0.12) 100%);
}

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

/* 统一的玻璃面板与按钮。 */
.panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(560px, 94vw);
  max-height: calc(100vh - clamp(28px, 6vh, 72px));
  padding: clamp(18px, 2.3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-panel), inset 0 1px 0 rgba(255, 255, 255, 0.92);
  backdrop-filter: var(--blur);
  overflow: hidden;
}

.panel.wide {
  width: min(1080px, calc(100vw - clamp(32px, 7vw, 120px)));
}

.panel.compact {
  width: min(420px, 90vw);
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  margin-bottom: clamp(12px, 1.8vh, 20px);
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  flex: 0 0 auto;
  margin-top: clamp(12px, 1.8vh, 20px);
  padding-top: clamp(10px, 1.4vh, 16px);
  border-top: 1px solid var(--line-2);
}

.panel-foot .btn {
  margin: 0;
}

.eyebrow {
  color: var(--aqua-dark);
  font-size: clamp(10px, 0.85vw, 12px);
  font-weight: 800;
  letter-spacing: 0.24em;
  line-height: 1.6;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  color: var(--ink);
  font-size: clamp(23px, 2.2vw, 34px);
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.lede {
  max-width: 48ch;
  color: var(--ink-2);
  font-size: clamp(13px, 1.15vw, 16px);
  line-height: 1.72;
}

.dim {
  color: var(--ink-3);
  font-size: clamp(11px, 0.95vw, 13px);
  line-height: 1.55;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65em;
  min-height: 1.65em;
  padding: 2px 7px;
  border: 1px solid rgba(45, 104, 139, 0.20);
  border-bottom-width: 3px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 5px rgba(38, 83, 114, 0.10);
  color: var(--aqua-dark);
  font-family: inherit;
  font-size: 0.88em;
  font-weight: 750;
  line-height: 1.15;
  vertical-align: middle;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px clamp(14px, 1.5vw, 22px);
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: clamp(12px, 1.02vw, 15px);
  font-weight: 760;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.btn.primary {
  border-color: rgba(255, 255, 255, 0.36);
  background: linear-gradient(135deg, #ffca56 0%, #f79a2f 52%, #ef7436 100%);
  box-shadow: 0 10px 22px rgba(235, 132, 40, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  color: #35220f;
}

.btn.ghost {
  border-color: rgba(35, 120, 156, 0.22);
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink-2);
  box-shadow: 0 4px 12px rgba(31, 93, 129, 0.07);
}

.btn.primary:hover,
.btn.ghost:hover {
  transform: translateY(-2px);
}

.btn.primary:hover {
  box-shadow: 0 14px 28px rgba(235, 132, 40, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn.ghost:hover {
  border-color: rgba(19, 154, 192, 0.52);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 18px rgba(31, 93, 129, 0.14);
}

.btn:active {
  transform: translateY(0) scale(0.985);
}

.btn:focus-visible,
.nav.is-focused,
.set-row.is-focused {
  outline: 3px solid rgba(19, 154, 192, 0.46);
  outline-offset: 3px;
}

.stack {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.stack .btn {
  width: 100%;
}

/* 标题页：没有整屏暗层，只有左边一块半透明玻璃，右侧全部留给真实 3D 场景。 */
.title-screen {
  justify-content: flex-start;
  background: none;
  backdrop-filter: none;
}

.title-screen::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: min(58vw, 700px);
  pointer-events: none;
  background: linear-gradient(90deg, rgba(232, 248, 255, 0.26), rgba(232, 248, 255, 0.06) 70%, transparent 100%);
}

.title-panel {
  position: relative;
  z-index: 1;
  width: clamp(290px, 32vw, 430px);
  max-height: calc(100vh - 48px);
  padding: clamp(20px, 2.4vw, 38px);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.83), rgba(236, 250, 255, 0.66));
  box-shadow: 0 24px 70px rgba(24, 84, 121, 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: var(--blur);
  overflow: auto;
}

.title-panel h1 {
  margin: clamp(12px, 2vh, 24px) 0 clamp(10px, 1.6vh, 18px);
  font-size: clamp(54px, 6.2vw, 98px);
  font-weight: 900;
  letter-spacing: -0.09em;
  line-height: 0.92;
  text-shadow: 3px 4px 0 rgba(255, 255, 255, 0.7);
}

.title-panel h1 em {
  display: inline-block;
  background: linear-gradient(170deg, #ffc13c 0%, #f37337 88%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-style: normal;
}

.title-panel .lede {
  margin-bottom: clamp(16px, 2.4vh, 26px);
  max-width: 30ch;
}

.title-panel .btn.primary {
  width: 100%;
  min-height: 48px;
  justify-content: space-between;
  padding-inline: clamp(18px, 2vw, 28px);
  font-size: clamp(14px, 1.25vw, 17px);
}

.title-panel .btn.primary span {
  font-size: 1.35em;
  line-height: 1;
}

.title-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.title-links .btn {
  flex: 1 1 auto;
  padding-inline: clamp(11px, 1.2vw, 17px);
}

.start-tip {
  margin-top: clamp(14px, 2.2vh, 22px);
  padding-top: clamp(10px, 1.4vh, 15px);
  border-top: 1px solid var(--line-2);
  color: var(--ink-3);
  font-size: clamp(10px, 0.9vw, 12px);
  line-height: 2;
}

.title-badge {
  position: absolute;
  right: clamp(18px, 3vw, 54px);
  bottom: clamp(18px, 4vh, 44px);
  z-index: 1;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.70);
  box-shadow: var(--shadow-soft);
  color: var(--ink-2);
  font-size: clamp(10px, 0.95vw, 13px);
  font-weight: 650;
  letter-spacing: 0.02em;
  backdrop-filter: blur(10px);
}

/* 选关页页头：关卡数与全局收集读数保持同一基线。 */
.sel-head {
  align-items: center;
}

.sel-head .total-counter {
  letter-spacing: 0.02em;
}

.total-counter {
  padding: 8px 15px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--aqua-dark);
  font-size: clamp(12px, 1.1vw, 15px);
  font-weight: 820;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
}

/* HUD：读数全部贴在左右上角，字体与胶囊随视口缩放；下半屏保持干净。 */
#hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  transition: opacity 260ms ease;
}

.hud-corner {
  position: absolute;
  top: clamp(10px, 1.8vh, 22px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(5px, 0.7vh, 8px);
  max-width: 19vw;
}

.hud-left {
  left: clamp(10px, 1.8vw, 30px);
}

.hud-right {
  right: clamp(10px, 1.8vw, 30px);
  align-items: flex-end;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: clamp(5px, 0.6vw, 9px);
  max-width: 100%;
  padding: 5px clamp(8px, 0.85vw, 13px);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: var(--hud-dark);
  box-shadow: 0 5px 15px rgba(9, 28, 47, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(9px);
  color: #f8fdff;
  font-size: clamp(11px, 1.3vw, 18px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  white-space: nowrap;
}

.hud-pill.tiny {
  padding-block: 4px;
  color: rgba(236, 250, 255, 0.90);
  font-size: clamp(9px, 0.95vw, 12px);
  font-weight: 600;
}

.hud-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-hearts {
  letter-spacing: 0.06em;
}

.hud-hearts .heart {
  color: #ff8d87;
  font-size: 1.08em;
  text-shadow: 0 0 8px rgba(255, 116, 112, 0.5);
}

.hud-hearts .heart.empty {
  color: rgba(242, 250, 255, 0.42);
  text-shadow: none;
}

.hud-icon {
  font-size: 1.05em;
}

.star-icon {
  color: var(--gold);
}

.gem-icon {
  color: #8df0e7;
}

.hud-meter {
  width: clamp(100px, 14vw, 190px);
  height: 6px;
  margin-top: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(11, 32, 50, 0.46);
  box-shadow: 0 1px 4px rgba(9, 30, 48, 0.22);
}

#hud-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #65e2de, #ffd15c 76%, #ff9c48);
  transition: width 180ms linear;
}

/* 顶部一条 3 px 的路线进度细线，没有底板也没有文字。 */
#hud-route {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  pointer-events: none;
}

#hud-route i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(101, 226, 222, 0.86), rgba(255, 205, 83, 0.92));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms linear;
}

/* 空中动作和评级三件套都收在原有胶囊里，不往屏幕中央加面板。 */
.air-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-style: normal;
  color: #7cebdc;
  transition: color 180ms ease, opacity 180ms ease;
}

.air-icon + .air-icon::before {
  content: "·";
  margin-right: 3px;
  color: rgba(236, 250, 255, 0.45);
}

.air-icon.spent {
  color: rgba(225, 239, 245, 0.40);
}

.air-icon b {
  font-size: 1.1em;
  font-weight: 900;
}

.hud-rating-trio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hud-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  height: 1.5em;
  border-radius: 6px;
  background: linear-gradient(140deg, #ffe18c, #f2a02e);
  color: #4b2f0b;
  font-size: 0.9em;
  font-weight: 900;
}

.hud-grade[data-tier="A"] {
  background: linear-gradient(140deg, #d9f7ff, #68c7df);
  color: #143f54;
}

.hud-grade[data-tier="B"] {
  background: linear-gradient(140deg, #e8f7cd, #9bcf68);
  color: #234824;
}

.hud-grade[data-tier="C"] {
  background: linear-gradient(140deg, #ffe3dd, #eaa095);
  color: #5a2630;
}

.hud-grade.pop {
  animation: gradePop 320ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes gradePop {
  50% {
    transform: scale(1.35);
  }
}

.hud-tier-track {
  display: inline-block;
  width: clamp(24px, 3vw, 46px);
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(235, 248, 255, 0.22);
}

.hud-tier-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fff0a2, #ffb94b);
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform 220ms linear;
}

.hud-deadline {
  font-style: normal;
  color: #ffe4a4;
  font-size: 0.85em;
}

#hud-shadow {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(72% 62% at 50% 50%, transparent 62%, rgba(232, 65, 55, 0.48) 100%);
  transition: opacity 220ms ease;
}

#hud.hurt #hud-shadow {
  opacity: 1;
}

.hud-toast {
  position: absolute;
  top: clamp(58px, 9vh, 92px);
  left: 50%;
  max-width: min(60vw, 560px);
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  font-size: clamp(11px, 1.05vw, 14px);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, -12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, transform 260ms ease, visibility 220ms;
  backdrop-filter: blur(12px);
}

.hud-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.hud-combo {
  position: absolute;
  top: clamp(86px, 13vh, 140px);
  right: clamp(10px, 1.8vw, 30px);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 198, 53, 0.9);
  box-shadow: 0 6px 18px rgba(224, 145, 30, 0.22);
  color: #40270a;
  font-size: clamp(10px, 1vw, 13px);
  font-weight: 850;
  opacity: 0;
  transform: translateY(-6px) scale(0.9);
  transition: opacity 180ms ease, transform 220ms ease;
}

.hud-combo.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.hud-hint {
  position: absolute;
  bottom: 5vh;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  width: max-content;
  max-width: min(76vw, 700px);
  padding: 9px 20px;
  border: 1px solid rgba(255, 255, 255, 0.70);
  border-radius: 999px;
  background: rgba(14, 38, 58, 0.62);
  box-shadow: 0 8px 24px rgba(12, 37, 58, 0.22);
  color: #f7fcff;
  font-size: clamp(11px, 1.08vw, 15px);
  font-weight: 650;
  line-height: 1.6;
  text-align: center;
  transform: translate(-50%, 16px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, transform 260ms ease, visibility 220ms;
  backdrop-filter: blur(10px);
}

.hud-hint.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.hud-hint kbd {
  margin-inline: 1px;
  border-bottom-width: 2px;
  padding: 1px 6px;
}

/* 关卡开场卡、全局闪屏和启动失败提示。 */
.title-card {
  position: absolute;
  top: clamp(76px, 14vh, 160px);
  left: 50%;
  z-index: 6;
  width: min(520px, 76vw);
  padding: clamp(14px, 2vw, 24px) clamp(20px, 3vw, 36px);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-md);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.86), rgba(221, 243, 253, 0.72));
  box-shadow: var(--shadow-panel);
  text-align: center;
  pointer-events: none;
  backdrop-filter: var(--blur);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -18px) scale(0.96);
  transition: opacity 340ms ease, transform 420ms cubic-bezier(0.2, 1.2, 0.4, 1), visibility 340ms;
}

.title-card.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
}

.title-kicker {
  color: var(--aqua-dark);
  font-size: clamp(10px, 0.9vw, 12px);
  font-weight: 850;
  letter-spacing: 0.24em;
}

.title-name {
  margin: 5px 0 8px;
  color: var(--ink);
  font-size: clamp(26px, 3.2vw, 48px);
  font-weight: 880;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.title-line {
  color: var(--ink-2);
  font-size: clamp(11px, 1.1vw, 15px);
  line-height: 1.55;
}

.title-card::after {
  content: "";
  display: block;
  width: 44%;
  height: 3px;
  margin: 12px auto 0;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--sun), transparent);
}

.boot-error {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: min(540px, 88vw);
  padding: 20px 26px;
  border: 1px solid rgba(237, 133, 112, 0.55);
  border-radius: var(--radius-md);
  background: rgba(255, 247, 243, 0.96);
  box-shadow: var(--shadow-panel);
  color: #963b32;
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
  transform: translate(-50%, -50%);
}

/* 选关卡片：颜色块、锁定状态、收集与评级都从关卡表和存档生成。 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(9px, 1.2vw, 16px);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 3px 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(19, 154, 192, 0.40) transparent;
}

.level-card {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vh, 13px);
  min-height: 260px;
  padding: clamp(12px, 1.3vw, 18px);
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 20px rgba(25, 82, 118, 0.10);
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.level-card:hover,
.level-card.is-focused {
  border-color: rgba(19, 154, 192, 0.55);
  box-shadow: 0 16px 32px rgba(25, 82, 118, 0.18);
  transform: translateY(-3px);
}

.level-card.locked {
  background: rgba(241, 247, 251, 0.88);
  border-style: dashed;
  border-color: rgba(64, 99, 123, 0.34);
}

.lc-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(68px, 9vh, 108px);
  overflow: hidden;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--swatch-a, #82d36b), var(--swatch-b, #53a7c6) 62%, var(--swatch-c, #d7f0ff));
  box-shadow: inset 0 -18px 24px rgba(18, 58, 90, 0.13);
}

.lc-thumb::after {
  content: "";
  position: absolute;
  width: 58%;
  height: 160%;
  left: -12%;
  top: -30%;
  transform: rotate(22deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), transparent);
}

.lc-number {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.96);
  font-size: clamp(32px, 4vw, 58px);
  font-weight: 900;
  letter-spacing: -0.08em;
  line-height: 1;
  text-shadow: 0 5px 14px rgba(14, 49, 74, 0.28);
}

.lc-lock {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 9px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(24, 46, 65, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 780;
  letter-spacing: 0.04em;
}

.level-card.locked .lc-thumb {
  filter: saturate(0.42) brightness(0.9);
}

.lc-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.lc-name {
  color: var(--ink);
  font-size: clamp(16px, 1.5vw, 21px);
  font-weight: 850;
  letter-spacing: -0.03em;
}

.lc-theme {
  color: var(--aqua-dark);
  font-size: clamp(10px, 0.9vw, 12px);
  font-weight: 750;
  white-space: nowrap;
}

.lc-tagline {
  min-height: 2.7em;
  color: var(--ink-3);
  font-size: clamp(10px, 0.95vw, 12px);
  line-height: 1.35;
}

.lc-meter {
  height: 5px;
  margin-top: -2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(42, 104, 140, 0.14);
}

.lc-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #52cfbc, #ffcb3c);
}

.lc-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin-top: auto;
  padding-top: 9px;
  border-top: 1px solid var(--line-2);
  color: var(--ink-2);
  font-size: clamp(10px, 0.95vw, 12px);
  font-variant-numeric: tabular-nums;
}

.lc-metrics span {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.lc-metrics b {
  color: var(--ink);
  font-weight: 800;
}

.lc-gems {
  letter-spacing: 0.14em;
  color: var(--aqua-dark);
}

.lc-rating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7em;
  height: 1.7em;
  border-radius: 7px;
  background: linear-gradient(140deg, #ffe18c, #f2a02e);
  color: #51320a;
  font-size: 0.95em;
  font-weight: 900;
}

/* 说明页：九行键位由 INPUT_HELP 生成，键帽与技巧统一画法。 */
.key-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(7px, 0.9vw, 12px);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 3px 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(19, 154, 192, 0.40) transparent;
}

.key-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) minmax(130px, 1fr);
  gap: 4px 10px;
  align-items: center;
  padding: clamp(8px, 1vh, 12px) clamp(10px, 1vw, 14px);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.68);
}

.key-label {
  color: var(--ink);
  font-size: clamp(11px, 1.05vw, 14px);
  font-weight: 800;
}

.key-caps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.key-sep {
  color: var(--ink-3);
  font-size: 11px;
}

.key-word {
  color: var(--ink-2);
  font-size: clamp(10px, 0.9vw, 12px);
  font-weight: 650;
}

.key-desc {
  grid-column: 1 / -1;
  color: var(--ink-3);
  font-size: clamp(10px, 0.9vw, 12px);
  line-height: 1.45;
}

.help-tips {
  display: grid;
  gap: 5px;
  flex: 0 0 auto;
  margin-top: clamp(8px, 1.4vh, 14px);
  padding: clamp(9px, 1.2vh, 14px) clamp(12px, 1.2vw, 18px);
  border-radius: 14px;
  background: linear-gradient(100deg, rgba(219, 243, 251, 0.86), rgba(255, 246, 223, 0.78));
  color: var(--ink-2);
  font-size: clamp(10px, 0.95vw, 13px);
  line-height: 1.6;
}

.help-tips b {
  color: var(--aqua-dark);
}

/* 设置页：八行都由表驱动；每行标签、中间值、左右箭头。 */
.settings-list {
  display: grid;
  gap: clamp(4px, 0.7vh, 8px);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 3px 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(19, 154, 192, 0.40) transparent;
}

.set-row {
  display: grid;
  grid-template-columns: minmax(112px, 0.86fr) minmax(190px, 1.3fr);
  align-items: center;
  gap: clamp(8px, 1vw, 16px);
  min-height: 47px;
  padding: 5px clamp(8px, 0.9vw, 13px);
  border: 1px solid rgba(255, 255, 255, 0.70);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.58);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.set-row:hover,
.set-row.is-focused {
  border-color: rgba(19, 154, 192, 0.44);
  background: rgba(255, 255, 255, 0.90);
  box-shadow: 0 6px 15px rgba(27, 93, 128, 0.10);
}

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

.set-label strong {
  color: var(--ink);
  font-size: clamp(11px, 1.05vw, 14px);
  font-weight: 800;
}

.set-label small {
  color: var(--ink-3);
  font-size: clamp(9px, 0.82vw, 11px);
  line-height: 1.35;
}

.set-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  padding: 0;
  border: 1px solid rgba(36, 111, 146, 0.22);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--aqua-dark);
  font-size: 21px;
  font-weight: 600;
  line-height: 1;
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.arrow:hover {
  background: #dff5fd;
  box-shadow: 0 3px 10px rgba(19, 154, 192, 0.18);
  transform: translateY(-1px);
}

.arrow:active {
  transform: scale(0.9);
}

.set-middle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.set-value {
  min-width: 54px;
  color: var(--ink);
  font-size: clamp(11px, 1.03vw, 14px);
  font-weight: 820;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.set-value.choice {
  min-width: 62px;
}

.set-sub {
  color: var(--ink-3);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.meter-cells {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 45px;
  max-width: 128px;
}

.meter-cells i {
  flex: 1 1 0;
  height: 9px;
  border-radius: 3px;
  background: rgba(48, 109, 141, 0.15);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.meter-cells i.on {
  background: linear-gradient(180deg, #69ded8, #129ec4);
  box-shadow: 0 0 6px rgba(25, 164, 197, 0.30);
}

.choice-dots {
  display: inline-flex;
  gap: 4px;
}

.choice-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(48, 109, 141, 0.18);
}

.choice-dots i.on {
  background: var(--aqua);
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: rgba(62, 103, 126, 0.25);
  transition: background 180ms ease;
}

.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(20, 55, 78, 0.22);
  transition: transform 180ms ease;
}

.switch.on {
  background: linear-gradient(90deg, #37c6a9, #129ec4);
}

.switch.on i {
  transform: translateX(17px);
}

.set-value.toggle.on {
  color: var(--aqua-dark);
}

.set-value.toggle.off {
  color: var(--ink-3);
}

/* 暂停页、加载遮罩、尾声页。 */
.compact .dim {
  margin-top: 8px;
  font-size: clamp(11px, 1vw, 13px);
}

.loading-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: min(330px, 86vw);
  padding: 30px 36px;
  border: 1px solid rgba(255, 255, 255, 0.90);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.80);
  box-shadow: var(--shadow-panel);
  color: var(--ink);
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 780;
  text-align: center;
  backdrop-filter: var(--blur);
}

.loading-card small {
  color: var(--ink-3);
  font-size: clamp(10px, 0.95vw, 12px);
  font-weight: 600;
  min-height: 1.4em;
}

.loading-ring {
  width: 38px;
  height: 38px;
  margin-bottom: 5px;
  border: 4px solid rgba(19, 154, 192, 0.16);
  border-top-color: var(--aqua);
  border-right-color: var(--sun);
  border-radius: 50%;
  animation: ringSpin 950ms linear infinite;
}

@keyframes ringSpin {
  to {
    transform: rotate(360deg);
  }
}

.finale-panel .lede {
  margin-top: 10px;
  margin-bottom: clamp(12px, 1.8vh, 20px);
}

.finale-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(100deg, #ffdf82, #ffc247);
  box-shadow: 0 7px 16px rgba(228, 158, 39, 0.22);
  color: #51330a;
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 820;
}

/* 结算：评级章先盖章，统计格再逐格弹出，评语和新纪录最后出现。 */
.result-top {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
  flex: 0 0 auto;
  min-height: 104px;
  padding-bottom: clamp(10px, 1.6vh, 18px);
}

.rating-stamp {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: clamp(76px, 8vw, 112px);
  height: clamp(76px, 8vw, 112px);
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #ffe9a4, #f6ad32 62%, #e9792f);
  box-shadow: 0 12px 24px rgba(224, 137, 37, 0.30), inset 0 0 0 5px rgba(255, 255, 255, 0.32);
  color: #58330a;
  font-size: clamp(40px, 5vw, 68px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 1px 2px 0 rgba(255, 255, 255, 0.38);
  opacity: 0;
  transform: scale(1.65) rotate(-13deg);
}

.rating-stamp[data-rating="A"] {
  background: radial-gradient(circle at 30% 25%, #d9f7ff, #68c7df 62%, #2b8eb3);
  color: #143f54;
}

.rating-stamp[data-rating="B"] {
  background: radial-gradient(circle at 30% 25%, #e8f7cd, #9bcf68 62%, #58a35c);
  color: #234824;
}

.rating-stamp[data-rating="C"] {
  background: radial-gradient(circle at 30% 25%, #ffe3dd, #eaa095 62%, #bc7182);
  color: #5a2630;
}

.rating-stamp.in {
  animation: stampIn 620ms cubic-bezier(0.18, 1.5, 0.38, 1) both;
}

@keyframes stampIn {
  0% {
    opacity: 0;
    transform: scale(1.65) rotate(-13deg);
  }
  60% {
    opacity: 1;
    transform: scale(0.93) rotate(4deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(-5deg);
  }
}

.result-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.result-note {
  max-width: 58ch;
  color: var(--ink-2);
  font-size: clamp(11px, 1.05vw, 14px);
  line-height: 1.6;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 380ms ease, transform 380ms ease;
}

.result-note.in {
  opacity: 1;
  transform: translateY(0);
}

.new-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-top: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(100deg, #fff2bd, #ffd769);
  box-shadow: 0 6px 15px rgba(223, 157, 37, 0.24);
  color: #633b06;
  font-size: clamp(10px, 0.95vw, 13px);
  font-weight: 850;
  opacity: 0;
  transform: scale(0.8);
}

.new-best.near {
  background: linear-gradient(100deg, #eaf6fd, #d4ecf8);
  box-shadow: 0 6px 15px rgba(41, 103, 137, 0.15);
  color: var(--ink-2);
}

.new-best.in {
  animation: newBestPop 520ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes newBestPop {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(7px, 0.95vw, 13px);
  flex: 1 1 auto;
  min-height: 0;
  align-content: center;
  padding: 2px 3px 4px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.stat-cell {
  min-height: clamp(64px, 9vh, 92px);
  padding: clamp(9px, 1.1vw, 15px);
  border: 1px solid rgba(255, 255, 255, 0.90);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 5px 14px rgba(24, 80, 116, 0.07);
  opacity: 0;
  transform: translateY(14px) scale(0.86);
}

/* 达到的评级档在这格里高亮，下面同时列出 S / A / B 三档时间线。 */
.stat-cell[data-tier] {
  border-color: rgba(246, 169, 48, 0.55);
  box-shadow: inset 0 3px 0 rgba(246, 169, 48, 0.32), 0 5px 14px rgba(24, 80, 116, 0.08);
}

.stat-cell[data-tier="A"] {
  border-color: rgba(19, 154, 192, 0.48);
  box-shadow: inset 0 3px 0 rgba(19, 154, 192, 0.30), 0 5px 14px rgba(24, 80, 116, 0.08);
}

.stat-cell[data-tier="A"] .stat-value {
  color: var(--aqua-dark);
}

.stat-cell[data-tier="B"] {
  border-color: rgba(91, 168, 91, 0.50);
  box-shadow: inset 0 3px 0 rgba(91, 168, 91, 0.28), 0 5px 14px rgba(24, 80, 116, 0.08);
}

.stat-cell[data-tier="B"] .stat-value {
  color: #357942;
}

.stat-cell[data-tier="C"] {
  border-color: rgba(190, 113, 130, 0.45);
  box-shadow: inset 0 3px 0 rgba(190, 113, 130, 0.26), 0 5px 14px rgba(24, 80, 116, 0.08);
}

.stat-grid.in .stat-cell {
  animation: statPop 460ms cubic-bezier(0.16, 1.35, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 115ms);
}

@keyframes statPop {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.86);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stat-label {
  display: block;
  color: var(--ink-3);
  font-size: clamp(9px, 0.85vw, 11px);
  font-weight: 680;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.stat-value {
  display: block;
  margin: 5px 0 2px;
  color: var(--ink);
  font-size: clamp(17px, 1.8vw, 25px);
  font-weight: 860;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.stat-value.accent {
  color: var(--aqua-dark);
}

.stat-sub {
  display: block;
  color: var(--ink-3);
  font-size: clamp(9px, 0.83vw, 11px);
  line-height: 1.35;
}

.all-done .stat-grid .stat-cell {
  border-color: rgba(255, 206, 93, 0.65);
}

/* 窄屏与矮屏：960×600 和不高的笔记本都不挤，宽屏保持留白。 */
@media (max-width: 1000px) {
  .panel.wide {
    width: calc(100vw - 40px);
  }

  .panel {
    padding: clamp(14px, 1.8vw, 22px);
  }

  .title-panel {
    width: clamp(280px, 38vw, 370px);
  }

  .level-card {
    min-height: 232px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .key-grid {
    gap: 7px;
  }
}

@media (max-height: 700px) {
  .screen {
    padding: 14px 22px;
  }

  .panel {
    max-height: calc(100vh - 28px);
    border-radius: 20px;
    padding: 16px 20px;
  }

  .panel-head {
    margin-bottom: 9px;
  }

  .panel-foot {
    margin-top: 9px;
    padding-top: 8px;
  }

  .btn {
    min-height: 36px;
    padding-block: 6px;
  }

  .title-panel {
    padding: 18px 22px;
  }

  .title-panel h1 {
    margin: 8px 0;
    font-size: clamp(46px, 6vw, 68px);
  }

  .title-panel .lede {
    margin-bottom: 12px;
  }

  .title-panel .btn.primary {
    min-height: 42px;
  }

  .start-tip {
    margin-top: 9px;
    padding-top: 8px;
    line-height: 1.7;
  }

  .set-row {
    min-height: 42px;
    padding-block: 3px;
  }

  .level-card {
    min-height: 206px;
    gap: 7px;
  }

  .lc-thumb {
    height: 60px;
  }

  .lc-tagline {
    min-height: 2.4em;
  }

  .result-top {
    min-height: 78px;
    padding-bottom: 8px;
  }

  .rating-stamp {
    width: 72px;
    height: 72px;
    font-size: 40px;
  }

  .stat-cell {
    min-height: 58px;
    padding: 8px 10px;
  }

  .help-tips {
    margin-top: 7px;
    padding-block: 7px;
  }

  .hud-corner {
    gap: 4px;
  }
}

@media (max-width: 760px) {
  .title-screen {
    align-items: flex-end;
    padding: 14px;
  }

  .title-screen::before {
    width: 100%;
    background: linear-gradient(0deg, rgba(232, 248, 255, 0.35), transparent 70%);
  }

  .title-panel {
    width: min(430px, 100%);
    max-height: min(72vh, 520px);
  }

  .title-badge {
    display: none;
  }

  .panel.wide {
    width: calc(100vw - 24px);
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .card-grid,
  .key-grid {
    grid-template-columns: 1fr;
  }

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

  .set-row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding-block: 7px;
  }

  .set-label small {
    display: none;
  }

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

  .hud-corner {
    max-width: 42vw;
  }

  .hud-pill {
    padding: 4px 9px;
  }
}

@media (min-width: 1600px) {
  .screen {
    padding: 44px 70px;
  }

  .panel.wide {
    width: min(1160px, 82vw);
  }

  .hud-corner {
    max-width: 17vw;
  }

  .title-panel {
    width: 430px;
    padding: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
