:root {
  --bg-deep: #03080f;
  --ink: rgba(4, 10, 18, 0.9);
  --panel-border-strong: rgba(233, 196, 126, 0.62);
  --panel-border-soft: rgba(233, 196, 126, 0.22);
  --text: #f1e6cc;
  --text-muted: rgba(226, 214, 186, 0.68);
  --gold: #e9c47e;
  --gold-bright: #ffe4a6;
  --verm: #b82c1c;
  --jade: #8fd0b0;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", "STSong", "Palatino Linotype", Georgia, serif;
  --font-xing: "Xingkai SC", "STXingkai", "Kaiti SC", "STKaiti", "Palatino Linotype", Georgia, serif;
  --font-en: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

html[lang="en"] body,
html[lang="en"] .veil-btn {
  font-family: var(--font-en);
  letter-spacing: 0.04em;
}

html[lang="en"] .clear-kicker {
  letter-spacing: 0.22em;
}

html[lang="en"] .clear-poem h2 {
  font-family: var(--font-en);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-kai);
  overflow: hidden;
}

#app,
.stage-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(40, 90, 96, 0.35) 0%, rgba(3, 8, 15, 0) 60%),
    radial-gradient(circle at 50% 50%, #0a1a24 0%, #03070d 100%);
  overflow: hidden;
}

.viewport-frame {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
  box-shadow:
    0 30px 100px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(233, 196, 126, 0.28),
    0 0 0 6px rgba(10, 18, 24, 0.9),
    0 0 0 7px rgba(233, 196, 126, 0.16);
  overflow: hidden;
  background: #06111d;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

.hidden {
  display: none !important;
}

/* ==================== Stage Clear · 幕落卷轴 ==================== */
.clear-veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 50%, rgba(6, 18, 28, 0.55), rgba(2, 5, 10, 0.9));
  backdrop-filter: blur(5px) saturate(0.85);
  z-index: 30;
  animation: veil-in 0.5s ease both;
}

@keyframes veil-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scroll-open {
  from { transform: scaleX(0.04); opacity: 0.2; }
  60% { opacity: 1; }
  to { transform: scaleX(1); opacity: 1; }
}

.clear-poem {
  position: relative;
  min-width: 460px;
  text-align: center;
  padding: 40px 72px 34px;
  background:
    linear-gradient(180deg, rgba(255, 240, 200, 0.05), rgba(0, 0, 0, 0) 40%),
    radial-gradient(ellipse at 50% 0%, rgba(80, 150, 140, 0.22), rgba(0, 0, 0, 0) 70%),
    rgba(5, 14, 22, 0.94);
  border-top: 1px solid var(--panel-border-strong);
  border-bottom: 1px solid var(--panel-border-strong);
  box-shadow:
    inset 0 0 0 4px rgba(5, 14, 22, 0.94),
    inset 0 0 0 5px var(--panel-border-soft),
    0 30px 80px rgba(0, 0, 0, 0.85);
  animation: scroll-open 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* scroll rollers */
.clear-poem::before,
.clear-poem::after {
  content: "";
  position: absolute;
  top: -10px;
  bottom: -10px;
  width: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #3a1a0e, #8a4a26 45%, #3a1a0e);
  box-shadow: 0 0 0 1px rgba(233, 196, 126, 0.55), 0 6px 18px rgba(0, 0, 0, 0.6);
}

.clear-poem::before { left: -7px; }
.clear-poem::after { right: -7px; }

.clear-kicker {
  display: inline-block;
  font-size: 13px;
  letter-spacing: 0.38em;
  color: #ffe8ad;
  background: linear-gradient(180deg, rgba(18, 46, 56, 0.92), rgba(7, 20, 28, 0.96));
  padding: 5px 14px 5px 18px;
  border-radius: 3px;
  border: 1px solid rgba(233, 196, 126, 0.68);
  box-shadow:
    inset 0 0 0 3px rgba(7, 20, 28, 0.9),
    inset 0 0 0 4px rgba(233, 196, 126, 0.28),
    0 6px 18px rgba(0, 0, 0, 0.45);
  margin-bottom: 16px;
}

.clear-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 16px;
}

.star-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 3px;
  border: 1px solid rgba(233, 196, 126, 0.25);
  background: rgba(8, 20, 30, 0.72);
  color: rgba(215, 205, 182, 0.55);
}

.star-pill.earned {
  border-color: rgba(255, 224, 152, 0.75);
  background: rgba(46, 36, 16, 0.72);
  color: #ffe8ad;
  box-shadow: 0 0 14px rgba(255, 206, 110, 0.22);
}

.star-pill .star-icon {
  font-size: 15px;
}

.clear-poem h2 {
  font-family: var(--font-xing);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff3cc 0%, #f0c878 55%, #b98a3e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.7));
  margin-bottom: 12px;
}

.clear-poem p {
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 26px;
}

.clear-poem p::before,
.clear-poem p::after {
  content: "◆";
  font-size: 8px;
  color: var(--gold);
  margin: 0 12px;
  vertical-align: middle;
}

.clear-links {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.veil-btn {
  position: relative;
  padding: 9px 26px;
  border: 1px solid var(--panel-border-strong);
  background: rgba(10, 26, 36, 0.85);
  color: var(--text);
  font-family: var(--font-kai);
  font-size: 15px;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: inset 0 0 0 3px rgba(5, 14, 22, 0.9), inset 0 0 0 4px rgba(233, 196, 126, 0.15);
}

.veil-btn:hover {
  background: rgba(233, 196, 126, 0.18);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 3px rgba(5, 14, 22, 0.9), inset 0 0 0 4px rgba(233, 196, 126, 0.4), 0 0 18px rgba(233, 196, 126, 0.25);
}

.veil-btn.primary {
  background: linear-gradient(180deg, rgba(64, 96, 86, 0.92), rgba(20, 46, 48, 0.96));
  border-color: rgba(244, 212, 142, 0.86);
  color: #fff3cf;
  box-shadow:
    inset 0 0 0 3px rgba(10, 26, 30, 0.86),
    inset 0 0 0 4px rgba(244, 212, 142, 0.42),
    0 0 22px rgba(233, 196, 126, 0.22);
}

.veil-btn.primary:hover {
  background: linear-gradient(180deg, rgba(84, 124, 108, 0.95), rgba(28, 62, 62, 0.98));
  border-color: #ffe8ad;
  color: #fff9e6;
  box-shadow:
    inset 0 0 0 3px rgba(10, 26, 30, 0.82),
    inset 0 0 0 4px rgba(255, 228, 166, 0.62),
    0 0 28px rgba(255, 224, 152, 0.34);
}

/* ==================== Optional Tuning Drawer · 灯影调参阁 ==================== */
.lab-drawer {
  position: absolute;
  top: 56px;
  right: 18px;
  width: 280px;
  max-height: calc(100% - 135px);
  display: flex;
  flex-direction: column;
  background: rgba(4, 12, 20, 0.94);
  border: 1px solid var(--panel-border-strong);
  box-shadow: inset 0 0 0 3px rgba(4, 12, 20, 0.94), inset 0 0 0 4px var(--panel-border-soft), 0 20px 56px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  z-index: 25;
}

.lab-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--panel-border-soft);
}

.lab-header h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
}

.lab-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.lab-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}

.lab-close:hover {
  color: var(--gold-bright);
}

.lab-body {
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lab-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lab-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.lab-row-top strong {
  color: var(--gold-bright);
  font-weight: 600;
}

.lab-row input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.lab-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.lab-toggle input {
  accent-color: var(--gold);
}

.lab-footer {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--panel-border-soft);
  display: flex;
  justify-content: flex-end;
}
