/* ===========================================================
   深海小鲸鱼 · HUD 与面板样式
   配色取 design/art/art-bible.md 第 2 节
   =========================================================== */
:root {
  --deep: #0B2C4D;
  --mid: #1E6B8C;
  --sand: #E8CFA0;
  --coral: #FF8A7A;
  --coral-alt: #FFC46B;
  --kelp: #5FD3A6;
  --back: #4A7BD1;
  --belly: #FFF3E0;
  --gold: #FFB627;
  --text: #EAF6FF;
  --dim: #9FC6DE;
  --glass: rgba(255, 255, 255, 0.12);
  --glass-line: rgba(255, 255, 255, 0.35);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

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

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--deep); color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

#scene {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: none;
}

.hidden { display: none !important; }

/* ---------- 毛玻璃通用 ---------- */
.glass {
  background: var(--glass);
  border: 2px solid var(--glass-line);
  box-shadow: 0 8px 24px rgba(6, 20, 36, 0.35), 0 0 24px rgba(120, 220, 255, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
}

/* ===========================================================
   HUD
   =========================================================== */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  padding: 18px clamp(14px, 2.4vw, 32px);
  font-variant-numeric: tabular-nums;
}

.hud-tl { position: absolute; top: 18px; left: clamp(14px, 2.4vw, 32px); }
.hud-tr {
  position: absolute; top: 18px; right: clamp(14px, 2.4vw, 32px);
  display: flex; align-items: center; gap: 8px;
}

.score-card { padding: 10px 18px 12px; min-width: 132px; }
.score-num { display: flex; align-items: baseline; gap: 4px; line-height: 1; }
.score-num span {
  font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 800; letter-spacing: -0.5px;
  text-shadow: 0 2px 12px rgba(120, 220, 255, 0.45);
  transition: transform 120ms ease-out;
}
.score-num i { font-style: normal; font-size: 13px; color: var(--dim); font-weight: 600; }
.score-num.bump span { transform: scale(1.15); }

.combo {
  margin-top: 6px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--dim);
}
.combo-mult {
  font-size: 15px; font-weight: 800; color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 182, 39, 0.7);
  transition: transform 160ms cubic-bezier(.2, 1.6, .4, 1);
}
.combo-mult b { font-size: 17px; }
.combo-count b { color: var(--text); }
.combo.pop { animation: comboPop 320ms cubic-bezier(.2, 1.6, .4, 1); }
@keyframes comboPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.chip {
  padding: 6px 14px; border-radius: 999px;
  display: flex; align-items: baseline; gap: 4px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip b { font-size: 17px; font-weight: 800; }
.chip em { font-style: normal; color: var(--dim); font-size: 12px; }
.level-chip span { color: var(--dim); font-size: 12px; }
.level-chip b { color: var(--text); }
.timer-chip b { color: var(--coral-alt); font-size: 20px; }
.timer-chip.warn b { color: var(--coral); animation: pulseWarn 1s ease-in-out infinite; }
@keyframes pulseWarn { 50% { opacity: 0.45; } }

.icon-btn {
  pointer-events: auto;
  width: 40px; height: 40px; border-radius: 999px;
  color: var(--text); font-size: 17px; font-weight: 700;
  cursor: pointer; transition: transform 150ms ease-out, background 150ms;
  display: grid; place-items: center;
}
.icon-btn:hover { transform: scale(1.06); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.off { color: var(--dim); opacity: 0.55; }
.icon-btn.off::after {
  content: ''; position: absolute; width: 24px; height: 2px;
  background: var(--coral); transform: rotate(-45deg); border-radius: 2px;
}

/* 底部目标进度 */
.hud-bottom {
  position: absolute; left: 50%; bottom: clamp(16px, 3vh, 34px);
  transform: translateX(-50%);
  width: min(360px, 76vw);
}
.goal-wrap { display: flex; flex-direction: column; align-items: center; }
.goal-bar {
  width: 100%; height: 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  /* 1px 内描边：不改变尺寸，也不容易被水色吃掉 */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2), 0 4px 18px rgba(6, 20, 36, 0.35);
  overflow: hidden;
}
#goal-fill {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4FD0FF, #8FE7FF);
  box-shadow: 0 0 14px rgba(120, 220, 255, 0.7);
  transition: width 220ms cubic-bezier(.22, .9, .25, 1), background 400ms;
}
.goal-bar.full #goal-fill {
  background: linear-gradient(90deg, #FFB627, #FFE08A);
  box-shadow: 0 0 20px rgba(255, 182, 39, 0.85);
}
/* 文字移到条下方，配双层暗描边，任何海色下都读得清 */
.goal-txt {
  margin-top: 7px;
  display: flex; align-items: baseline; gap: 3px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.4px;
  color: rgba(224, 241, 255, 0.78);
  text-shadow: 0 1px 2px rgba(2, 12, 24, 0.95), 0 2px 10px rgba(2, 12, 24, 0.9);
}
.goal-txt b { color: #F2FBFF; font-size: 13px; font-weight: 700; }
.goal-txt b:last-child { color: rgba(224, 241, 255, 0.66); font-weight: 600; }

/* 横幅 */
.banner {
  position: absolute; top: 22%;
  left: 50%; transform: translateX(-50%);
  padding: 10px 30px; border-radius: 999px;
  font-size: clamp(18px, 2.2vw, 26px); font-weight: 800; letter-spacing: 2px;
  color: #43290B;
  background: linear-gradient(100deg, #FFD98A, #FFB627);
  box-shadow: 0 10px 40px rgba(255, 182, 39, 0.55);
  animation: bannerIn 2.4s ease-out forwards;
}
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -18px) scale(0.94); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(0.98); }
}

/* ===========================================================
   特效层
   =========================================================== */
#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; }
#vignette {
  position: absolute; inset: -10%;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,138,122,0) 42%, rgba(255,138,122,0.42) 100%);
  transition: opacity 200ms ease-out;
}
#vignette.on { opacity: 1; transition: opacity 90ms ease-out; }

.float {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 20px; font-weight: 800; color: var(--coral-alt);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), 0 0 18px rgba(255, 196, 107, 0.5);
  font-variant-numeric: tabular-nums;
  animation: floatUp 800ms cubic-bezier(.2, .8, .3, 1) forwards;
  white-space: nowrap;
}
.float.bad { color: #FF8A7A; text-shadow: 0 2px 10px rgba(0,0,0,.45), 0 0 18px rgba(255,90,90,.5); }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  18% { opacity: 1; transform: translate(-50%, -64%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(0.96); }
}

/* ===========================================================
   全屏遮罩 / 面板
   =========================================================== */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 40%, rgba(11, 44, 77, 0.15), rgba(4, 16, 30, 0.62));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 320ms ease-out;
  z-index: 10;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 按钮 ---------- */
.btn {
  font-family: var(--font);
  border: none; border-radius: 16px;
  padding: 13px 30px;
  font-size: 16px; font-weight: 700;
  color: var(--text);
  background: #2A9FD0;
  cursor: pointer;
  transition: transform 150ms ease-out, background 150ms, box-shadow 150ms;
  box-shadow: 0 8px 22px rgba(6, 20, 36, 0.4);
}
.btn:hover { background: #3FB8E6; transform: scale(1.04); box-shadow: 0 10px 28px rgba(63, 184, 230, 0.4); }
.btn:active { background: #1E7FA6; transform: scale(0.96); }
.btn-lg { padding: 17px 56px; font-size: 19px; border-radius: 20px; letter-spacing: 2px; }
.btn-sm { padding: 8px 18px; font-size: 13px; border-radius: 12px; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.2); box-shadow: 0 8px 22px rgba(6,20,36,.3); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; background: rgba(255,255,255,.14); box-shadow: none; }

.link-btn {
  background: none; border: none; color: var(--dim);
  font-family: var(--font); font-size: 13px; cursor: pointer;
  padding: 8px; margin-top: 6px; text-decoration: underline;
  text-underline-offset: 4px;
}
.link-btn:hover { color: var(--text); }

/* ---------- 加载 ---------- */
#boot { background: var(--deep); z-index: 30; }
.boot-inner { text-align: center; }
.boot-title {
  font-size: 30px; font-weight: 800; letter-spacing: 6px;
  text-shadow: 0 0 30px rgba(120, 220, 255, 0.55);
}
.boot-bar {
  width: 180px; height: 4px; margin: 22px auto 0;
  background: rgba(255, 255, 255, 0.14); border-radius: 999px; overflow: hidden;
}
.boot-bar i {
  display: block; width: 40%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #4FD0FF, #8FE7FF);
  animation: bootSlide 1.1s ease-in-out infinite;
}
@keyframes bootSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.boot-tip { margin-top: 14px; font-size: 12px; color: var(--dim); letter-spacing: 2px; }

/* ---------- 开始页 ---------- */
.start-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 22px; text-align: center;
  animation: riseIn 520ms cubic-bezier(.2, 1.1, .3, 1);
}
@keyframes riseIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.logo h1 {
  margin: 0; font-size: clamp(34px, 6vw, 58px); font-weight: 900;
  letter-spacing: clamp(2px, 0.6vw, 8px);
  background: linear-gradient(180deg, #FFFFFF, #A8E4FF 70%, #6FC3E8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 26px rgba(120, 220, 255, 0.45));
}
.logo p { margin: 8px 0 0; font-size: 14px; color: var(--dim); letter-spacing: 4px; }

.start-card { padding: 16px 22px; display: flex; flex-direction: column; gap: 9px; max-width: 420px; }
.rule-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #DCEEFA; text-align: left; }
.dot { width: 10px; height: 10px; border-radius: 999px; background: var(--dim); flex: 0 0 auto; }
.dot.warm { background: var(--coral-alt); box-shadow: 0 0 10px rgba(255, 196, 107, 0.85); }
.dot.cold { background: #D98BFF; box-shadow: 0 0 10px rgba(217, 139, 255, 0.85); }
.hint { font-size: 12px; color: var(--dim); letter-spacing: 1px; }

/* ---------- 选关 ---------- */
.select-inner { width: min(880px, 100%); animation: riseIn 420ms cubic-bezier(.2, 1.1, .3, 1); }
.select-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.select-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: 3px; }
.select-foot { text-align: center; font-size: 12px; color: var(--dim); margin-top: 14px; }

.level-list {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.level-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 14px 16px 12px;
  border-radius: 20px; border: 2px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(6, 20, 36, 0.35);
  color: var(--text); font-family: var(--font);
  cursor: pointer; text-align: left;
  transition: transform 160ms ease-out, box-shadow 160ms, border-color 160ms;
}
.level-card:hover { transform: translateY(-3px); border-color: rgba(255, 255, 255, 0.6); box-shadow: 0 12px 30px rgba(6, 20, 36, 0.5); }
.level-card.locked {
  cursor: not-allowed; opacity: 0.45; filter: grayscale(0.6);
}
.level-card.locked:hover { transform: none; border-color: var(--glass-line); }
.level-card .idx { font-size: 11px; font-weight: 700; color: var(--dim); letter-spacing: 2px; }
.level-card .nm { font-size: 17px; font-weight: 800; letter-spacing: 1px; }
.level-card .meta { font-size: 11px; color: var(--dim); }
.level-card .stars { margin-top: 2px; font-size: 15px; letter-spacing: 2px; color: rgba(255, 255, 255, 0.22); }
.level-card .stars .on { color: var(--gold); text-shadow: 0 0 12px rgba(255, 182, 39, 0.8); }
.level-card .lock {
  position: absolute; right: 14px; top: 14px;
  font-size: 11px; color: var(--dim);
  border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 2px 8px;
}

/* ---------- 结算 ---------- */
.result-card {
  width: min(420px, 100%); padding: 26px 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: riseIn 460ms cubic-bezier(.2, 1.1, .3, 1);
}
.result-head { text-align: center; }
.result-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.result-head p { margin: 6px 0 0; font-size: 13px; color: var(--dim); letter-spacing: 2px; }

.stars { display: flex; gap: 10px; margin: 14px 0 6px; }
.stars .star {
  font-size: 34px; line-height: 1;
  color: rgba(255, 255, 255, 0.14);
  transition: color 300ms, transform 400ms cubic-bezier(.2, 1.8, .4, 1), text-shadow 300ms;
}
.stars .star.on {
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 182, 39, 0.85);
  transform: scale(1.12);
}

.result-stats {
  width: 100%; margin: 12px 0 6px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.stat {
  background: rgba(6, 20, 36, 0.3); border-radius: 14px;
  padding: 10px 8px; text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.stat span { display: block; font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.stat b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }

.result-actions { display: flex; gap: 10px; width: 100%; margin-top: 12px; }
.result-actions .btn { flex: 1; padding: 13px 10px; }

/* ---------- 竖屏适配 ---------- */
@media (max-aspect-ratio: 3/4) {
  .hud-bottom { width: min(300px, 82vw); }
  .chip { padding: 5px 10px; font-size: 12px; }
  .chip b { font-size: 15px; }
  .level-chip span { display: none; }
  .score-card { padding: 8px 14px 10px; min-width: 108px; }
  .result-stats { grid-template-columns: 1fr; }
  .start-card { display: none; }
}

@media (max-height: 520px) {
  .logo h1 { font-size: 30px; }
  .start-inner { gap: 12px; }
  .start-card { display: none; }
}
