:root {
  --accent: #4ae4ff;
  --accent-soft: rgba(74, 228, 255, 0.2);
  --bg: #04060d;
  --ink: #eaf4ff;
  --ink-dim: rgba(234, 244, 255, 0.6);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

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

.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at 50% 52%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.42) 78%, rgba(0, 0, 0, 0.72) 100%);
}

.grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='0.7'/></svg>");
}

/* ---------------------------------------------------------------- HUD */
.hud {
  position: absolute; inset: 0; z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.hud.visible { opacity: 1; }

.hud-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 26px 30px 0;
}

.hud-left { display: flex; flex-direction: column; gap: 14px; }

.brand {
  display: flex; flex-direction: column; line-height: 1.15;
  font-size: 11px; letter-spacing: 0.42em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  padding-left: 12px; position: relative;
}
.brand::before {
  content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 2px;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.brand b { font-weight: 600; color: rgba(255, 255, 255, 0.86); letter-spacing: 0.4em; }

.hearts-wrap { display: flex; align-items: center; gap: 12px; }
.tag {
  font-size: 10px; letter-spacing: 0.3em; color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
}
.hearts { display: flex; gap: 11px; }
.heart {
  width: 13px; height: 13px; display: block;
  transform: rotate(45deg);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.heart.on {
  background: linear-gradient(140deg, #fff, var(--accent));
  border-color: transparent;
  box-shadow: 0 0 14px var(--accent), 0 0 34px var(--accent-soft);
}

.level-chip {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%);
  text-align: center; min-width: 280px;
}
.level-sub {
  font-size: 9.5px; letter-spacing: 0.34em; color: rgba(255, 255, 255, 0.4);
  margin-bottom: 7px;
}
.level-name {
  font-size: 21px; font-weight: 500; letter-spacing: 0.2em;
  text-shadow: 0 0 24px var(--accent-soft);
}
.level-name.swap { animation: chipIn 0.7s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes chipIn {
  from { opacity: 0; transform: translateY(-8px); letter-spacing: 0.45em; }
  to { opacity: 1; transform: translateY(0); letter-spacing: 0.2em; }
}

.shard-meter { margin-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.shard-bar {
  width: 240px; height: 2px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.13);
  overflow: visible; position: relative;
}
.shard-bar i {
  position: absolute; left: 0; top: 0; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent), #fff);
  box-shadow: 0 0 14px var(--accent);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.shard-bar.full { box-shadow: 0 0 24px var(--accent-soft); }
.shard-text {
  display: flex; align-items: baseline; gap: 4px;
  font-size: 10.5px; letter-spacing: 0.24em; color: rgba(255, 255, 255, 0.42);
}
.shard-text b { color: var(--accent); font-size: 13px; font-weight: 600; }
.shard-text em { font-style: normal; }
.shard-text i { font-style: normal; margin-left: 4px; }

.hud-right { display: flex; align-items: center; gap: 14px; pointer-events: auto; }
.timer {
  font-size: 19px; letter-spacing: 0.16em; font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.66);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px; cursor: pointer; display: grid; place-items: center;
  backdrop-filter: blur(8px);
  transition: all 0.25s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 20px var(--accent-soft); }
.icon-btn.muted { opacity: 0.45; }

.toast {
  position: absolute; left: 50%; top: 150px; transform: translate(-50%, 10px);
  padding: 10px 22px; border-radius: 999px;
  font-size: 12.5px; letter-spacing: 0.18em;
  background: rgba(8, 14, 26, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(12px);
  opacity: 0; transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
  white-space: nowrap; color: rgba(255, 255, 255, 0.82);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.accent { color: #fff; border-color: var(--accent-soft); box-shadow: 0 0 34px var(--accent-soft); }

.hint {
  position: absolute; left: 50%; bottom: 32px; transform: translateX(-50%);
  font-size: 11.5px; letter-spacing: 0.18em; color: rgba(255, 255, 255, 0.45);
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  opacity: 0; transition: opacity 0.8s ease;
}
.hint span { opacity: 0.4; }

kbd {
  font-family: var(--font);
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 5px; font-size: 10.5px; letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.72);
}

/* ---------------------------------------------------------------- 触屏 */
.touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch { display: block; position: absolute; inset: 0; z-index: 11; pointer-events: none; }
  .stick {
    position: absolute; left: 26px; bottom: 30px; width: 118px; height: 118px;
    border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03); pointer-events: auto; touch-action: none;
  }
  .stick i {
    position: absolute; left: 50%; top: 50%; width: 46px; height: 46px;
    margin: 0; border-radius: 50%; transform: translate(-50%, -50%);
    background: radial-gradient(circle at 40% 35%, #fff, var(--accent) 70%);
    box-shadow: 0 0 22px var(--accent-soft);
  }
  .touch-btns {
    position: absolute; right: 24px; bottom: 34px; display: flex; gap: 16px; align-items: flex-end;
  }
  .round-btn {
    pointer-events: auto; touch-action: none;
    width: 74px; height: 74px; border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(10, 18, 32, 0.5); color: #fff;
    font-size: 13px; letter-spacing: 0.1em; backdrop-filter: blur(6px);
  }
  .round-btn.jump { width: 86px; height: 86px; border-color: var(--accent-soft); box-shadow: 0 0 26px var(--accent-soft); }
  .round-btn.dash { opacity: 0.8; }
  .hint { display: none; }
  .brand { display: none; }
}

/* ---------------------------------------------------------------- 屏幕 */
.screen {
  position: absolute; inset: 0; z-index: 20;
  opacity: 0; pointer-events: none; transition: opacity 0.45s ease;
}
.screen.visible { opacity: 1; pointer-events: auto; }

.title-screen {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 0 7vh 7vw;
  background: linear-gradient(100deg, rgba(3, 5, 12, 0.94) 0%, rgba(3, 5, 12, 0.72) 38%, rgba(3, 5, 12, 0.12) 68%, transparent 84%);
}
.title-inner { max-width: 640px; }
.kicker {
  font-size: 10.5px; letter-spacing: 0.5em; color: var(--accent);
  display: flex; align-items: center; gap: 14px; text-transform: uppercase;
  opacity: 0.9;
}
.kicker::after { content: ""; flex: 0 0 70px; height: 1px; background: linear-gradient(90deg, var(--accent), transparent); }

.title-screen h1 {
  margin: 16px 0 0; font-size: clamp(56px, 8.2vw, 122px); line-height: 0.94;
  font-weight: 800; letter-spacing: 0.06em;
  background: linear-gradient(175deg, #ffffff 8%, #cfe8ff 46%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 60px var(--accent-soft));
}
.latin { margin-top: 14px; font-size: 12px; letter-spacing: 0.52em; color: rgba(255, 255, 255, 0.42); }
.desc { margin: 30px 0 36px; font-size: 13.5px; line-height: 2.05; color: rgba(255, 255, 255, 0.55); letter-spacing: 0.06em; }
.title-actions { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.tip { font-size: 11px; letter-spacing: 0.16em; color: rgba(255, 255, 255, 0.32); }

.keys { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 34px; font-size: 11px; letter-spacing: 0.12em; color: rgba(255, 255, 255, 0.4); }
.keys span { display: flex; align-items: center; gap: 5px; }

.title-meta {
  position: absolute; right: 40px; bottom: 30px; display: flex; align-items: center; gap: 14px;
  font-size: 9.5px; letter-spacing: 0.36em; color: rgba(255, 255, 255, 0.28);
}
.title-meta i { width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); }

.btn {
  font-family: var(--font);
  padding: 15px 36px; border-radius: 999px; cursor: pointer;
  font-size: 12.5px; letter-spacing: 0.28em; text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.9);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); color: #fff; }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.primary {
  background: linear-gradient(120deg, #ffffff, var(--accent) 90%);
  color: #041018; border-color: transparent; font-weight: 700;
  box-shadow: 0 14px 46px -12px var(--accent), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}
.btn.primary:hover { box-shadow: 0 18px 60px -10px var(--accent), 0 0 0 1px rgba(255, 255, 255, 0.45) inset; }
.btn.ghost { background: rgba(255, 255, 255, 0.02); }

.card-screen {
  display: grid; place-items: center;
  background: rgba(2, 4, 10, 0.55);
  backdrop-filter: blur(16px);
}
.card {
  width: min(92vw, 540px); padding: 46px 44px 40px;
  border-radius: 24px;
  background: linear-gradient(165deg, rgba(22, 32, 52, 0.92), rgba(7, 11, 20, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--accent-soft) inset;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
.screen.visible .card { transform: translateY(0) scale(1); }
.card-kicker { font-size: 10px; letter-spacing: 0.42em; color: var(--accent); opacity: 0.85; }
.card h2 { margin: 14px 0 0; font-size: 30px; font-weight: 600; letter-spacing: 0.08em; }
.card-desc { margin: 16px 0 30px; font-size: 13px; line-height: 1.95; color: rgba(255, 255, 255, 0.5); }
.card-desc b { color: var(--accent); font-weight: 600; }
.card-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.card.danger .card-kicker { color: #ff5f88; }
.card.danger { box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 95, 136, 0.22) inset; }
.card.victory .card-kicker { color: #ffd479; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: rgba(255, 255, 255, 0.07); border-radius: 14px; overflow: hidden; margin-bottom: 30px; }
.stat { background: rgba(10, 16, 28, 0.9); padding: 18px 14px; display: flex; flex-direction: column; gap: 8px; }
.stat span { font-size: 10px; letter-spacing: 0.24em; color: rgba(255, 255, 255, 0.35); }
.stat b { font-size: 22px; font-weight: 500; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; color: var(--accent); }

.flash {
  position: absolute; inset: 0; z-index: 40; pointer-events: none; opacity: 0;
  mix-blend-mode: screen;
}
.fade {
  position: absolute; inset: 0; z-index: 50; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, #0a1730 0%, #04060d 62%);
}

@media (max-width: 820px) {
  .hud-top { padding: 18px 18px 0; }
  .brand { display: none; }
  .level-chip { top: 16px; min-width: 220px; }
  .level-name { font-size: 17px; }
  .shard-bar { width: 170px; }
  .timer { font-size: 15px; }
  .hint { display: none; }
  .title-screen { padding: 0 24px 6vh; background: linear-gradient(180deg, rgba(3,5,12,0.2) 0%, rgba(3,5,12,0.82) 46%, rgba(3,5,12,0.96) 100%); }
  .title-screen h1 { font-size: clamp(46px, 13vw, 76px); }
  .desc { margin: 22px 0 26px; font-size: 12.5px; }
  .keys { display: none; }
  .title-meta { display: none; }
  .card { padding: 34px 26px 30px; }
  .card h2 { font-size: 24px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat b { font-size: 18px; }
}
