/* ============================================================
   许个愿 · UI
   ============================================================ */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --ink: #fff0e4;
  --muted: rgba(255, 220, 200, .64);
  --faint: rgba(255, 200, 170, .4);
  --orange: #ff7a3d;
  --gold: #ffc247;
  --red: #e8442a;
  --line: rgba(255, 180, 150, .17);
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "Newsreader", "Iowan Old Style", Georgia, serif;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: #160810;
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stage { position: fixed; inset: 0; overflow: hidden; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ── HUD ─────────────────────────────────────────────── */
.hud {
  position: absolute; inset: 0;
  padding: max(14px, env(safe-area-inset-top)) 16px 16px;
  pointer-events: none;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
}

.hud__left { width: min(320px, 44vw); }
.hud__center { text-align: center; flex: 1; }
.hud__right { display: flex; align-items: center; gap: 14px; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar {
  position: relative;
  height: 14px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .38);
  border: 1px solid rgba(255, 180, 150, .18);
  overflow: hidden;
}
.bar i {
  display: block; height: 100%; width: 100%;
  transition: width .16s ease-out;
}
.bar--hp i { background: linear-gradient(90deg, #e8442a, #ff7a3d 60%, #ffc247); box-shadow: 0 0 12px rgba(255,100,60,.55); }
.bar--en { height: 9px; }
.bar--en i { background: linear-gradient(90deg, #5ec8ff, #9be8ff 70%, #e6f9ff); box-shadow: 0 0 10px rgba(120,220,255,.5); }
.bar span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 9px; letter-spacing: .08em; color: rgba(255,240,230,.9);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}

.skills { display: flex; gap: 6px; margin-top: 10px; flex-wrap: nowrap; }
.skill {
  position: relative;
  min-width: 54px;
  padding: 6px 8px 5px;
  border-radius: 10px;
  border: 1px solid rgba(255, 180, 150, .18);
  background: rgba(30, 12, 18, .5);
  overflow: hidden;
}
.skill b {
  display: block;
  font-size: 9.5px; font-weight: 600; letter-spacing: .04em;
  color: rgba(255, 226, 205, .85);
  white-space: nowrap;
}
.skill em {
  position: absolute; right: 5px; top: 4px;
  font-style: normal; font-size: 8px; color: rgba(255, 200, 170, .4);
}
.skill i {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: rgba(255, 90, 60, .35);
  transition: height .1s linear;
}
.skill.is-ready { border-color: rgba(255, 200, 120, .45); }
.skill.is-ready b { color: #ffe0a8; }
.skill.is-nocost b { color: rgba(255, 200, 170, .35); }

.wave {
  font-family: var(--font-display);
  font-size: clamp(18px, 2.6vw, 24px);
  letter-spacing: .06em;
  color: #fff0e0;
  text-shadow: 0 2px 20px rgba(255, 120, 60, .4);
}
.wave-sub { margin-top: 2px; font-size: 9.5px; letter-spacing: .18em; color: var(--faint); }

.combo { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.combo b {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 500;
  color: #ffd9a0;
  font-variant-numeric: tabular-nums;
  transition: transform .12s ease-out, color .2s;
}
.combo.is-hot b { color: #ff9a4d; text-shadow: 0 0 18px rgba(255,110,40,.7); }
.combo span { font-size: 8.5px; letter-spacing: .2em; color: var(--faint); margin-top: 4px; }
.combo.is-pop b { transform: scale(1.18); }

.iconbtn {
  pointer-events: auto;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(30, 12, 18, .55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: grid; place-items: center;
  color: rgba(255, 226, 200, .85);
  cursor: pointer;
}
.iconbtn svg { width: 18px; height: 18px; fill: currentColor; }
.iconbtn:active { transform: scale(.94); }

.desk-hint {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  font-size: 10px; letter-spacing: .08em;
  color: rgba(255, 210, 190, .32);
  white-space: nowrap;
  pointer-events: none;
}
.stage.is-touch .desk-hint { display: none; }

/* ── 触屏 ─────────────────────────────────────────────── */
.touch {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
  pointer-events: none;
  z-index: 6;
}
.stage.is-touch .touch { display: flex; }

.dpad { display: flex; gap: 10px; pointer-events: auto; }
.actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: auto; }
.actions__row { display: flex; gap: 8px; align-items: flex-end; }
.actions__row--sm .tbtn--sm { opacity: .92; }

.tbtn {
  pointer-events: auto;
  border: 1px solid rgba(255, 180, 150, .22);
  background: rgba(28, 12, 18, .55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: rgba(255, 230, 215, .9);
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: inherit;
  font-size: 12px;
  touch-action: none;
  user-select: none;
  transition: transform .08s, background .12s;
}
.tbtn:active, .tbtn.is-down { transform: scale(.94); background: rgba(255, 150, 100, .28); }

.tbtn--dir { width: 68px; height: 68px; font-size: 26px; border-radius: 22px; }
.tbtn--sm { width: 54px; height: 54px; font-size: 11px; }
.tbtn--atk { width: 74px; height: 74px; font-size: 14px; font-weight: 600; background: rgba(255, 120, 60, .22); border-color: rgba(255, 180, 120, .42); }

/* ── 覆盖层 ───────────────────────────────────────────── */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(14, 5, 9, .76);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
  overflow-y: auto;
}
.overlay.is-open { opacity: 1; visibility: visible; }

.panel {
  width: min(520px, 100%);
  padding: 34px 32px 30px;
  border-radius: 24px;
  background: linear-gradient(168deg, rgba(255, 220, 190, .1), rgba(44, 16, 22, .94) 55%, rgba(26, 9, 14, .97));
  border: 1px solid rgba(255, 180, 150, .2);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 240, 220, .22);
  animation: pop .35s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.kicker { font-size: 9.5px; font-weight: 600; letter-spacing: .3em; color: rgba(255, 200, 170, .5); }
.panel h2 {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4.6vw, 2.4rem);
  font-weight: 500; line-height: 1.12; letter-spacing: -.01em;
  color: #fff3e6;
}
.panel h2 em {
  font-style: italic;
  background: linear-gradient(100deg, #ffd48a, #ff9a4d 55%, #ff5a1c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.tut-list { margin: 20px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.tut-list li { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: baseline; }
.tut-list b { font-size: 10px; letter-spacing: .1em; font-weight: 600; color: rgba(255, 190, 150, .85); padding: 4px 0; }
.tut-list span { font-size: 13px; line-height: 1.75; color: var(--muted); }

.panel__actions { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border-radius: 99px;
  font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .2s, box-shadow .2s, background .2s;
  text-decoration: none; font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn--primary {
  color: #2a0d04;
  background: linear-gradient(180deg, #fff6e2, #ffd89a 48%, #ffb062);
  box-shadow: 0 14px 32px -14px rgba(255, 110, 40, .8), inset 0 1px 0 rgba(255, 255, 255, .8);
}
.btn--ghost {
  color: rgba(255, 226, 205, .85);
  background: rgba(255, 190, 160, .07);
  border-color: rgba(255, 190, 160, .18);
}
.btn--ghost:hover { background: rgba(255, 190, 160, .13); }

.panel--result { text-align: center; }
.result-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-top: 24px; padding: 18px 6px;
  border-radius: 16px;
  background: rgba(255, 190, 160, .05);
  border: 1px solid rgba(255, 190, 160, .12);
}
.result-grid div { display: flex; flex-direction: column; gap: 6px; }
.result-grid span { font-size: 9.5px; letter-spacing: .14em; color: var(--faint); }
.result-grid b {
  font-family: var(--font-display);
  font-size: clamp(18px, 3.4vw, 24px);
  font-weight: 500; color: #ffe3bb;
  font-variant-numeric: tabular-nums;
}
.result__note { margin-top: 16px; font-size: 12px; line-height: 1.7; color: var(--faint); min-height: 1.7em; }
.panel--result .panel__actions { justify-content: center; }

/* 波次横幅 */
.banner {
  position: absolute; left: 50%; top: 38%;
  transform: translate(-50%, -50%) scale(.94);
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: .04em;
  color: #fff3e2;
  text-shadow: 0 6px 40px rgba(255, 90, 40, .6);
  opacity: 0; pointer-events: none;
  transition: opacity .35s, transform .35s;
  z-index: 12;
  white-space: nowrap;
}
.banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ── 响应式 ───────────────────────────────────────────── */
@media (max-width: 720px) {
  .hud { padding: max(10px, env(safe-area-inset-top)) 12px 12px; }
  .hud__left { width: 52vw; }
  .skills { gap: 4px; }
  .skill { min-width: 0; flex: 1 1 0; padding: 4px 4px; text-align: center; }
  .skill b { font-size: 8px; letter-spacing: 0; }
  .skill em { display: none; }
  .combo b { font-size: 22px; }
  .panel { padding: 26px 22px 24px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .tut-list { gap: 9px; }
  .tut-list li { grid-template-columns: 62px 1fr; }
  .tut-list span { font-size: 12.5px; }
  .panel__actions .btn { flex: 1 1 auto; }
}

@media (max-height: 620px) {
  .panel { padding: 20px 20px 18px; }
  .panel h2 { font-size: 1.45rem; }
  .tut-list span { font-size: 12px; }
  .tbtn--dir { width: 58px; height: 58px; }
  .tbtn--sm { width: 48px; height: 48px; font-size: 10px; }
  .tbtn--atk { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
