:root {
  --ink: #050a12;
  --ink-2: #0a1524;
  --mist: #9fb6c9;
  --paper: #e9f1f7;
  --amber: #ffcf7a;
  --amber-deep: #f2a23c;
  --mint: #8ef0d0;
  --line: rgba(190, 215, 235, 0.16);
  --panel: rgba(7, 15, 26, 0.72);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}

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

/* soft vignette + film grain feel without images */
.veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 12%, rgba(12, 30, 52, 0) 35%, rgba(3, 7, 13, 0.55) 100%),
    radial-gradient(70% 46% at 50% 108%, rgba(255, 176, 92, 0.10), transparent 70%);
  mix-blend-mode: normal;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(14px + env(safe-area-inset-top)) 18px 0;
  display: grid;
  gap: 10px;
  pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 3;
}

.hud__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-family: "Songti SC", "Noto Serif SC", "Songti TC", serif;
  font-size: 19px;
  letter-spacing: 0.32em;
  color: #f6ead6;
  text-shadow: 0 0 18px rgba(255, 190, 110, 0.35);
  line-height: 1.25;
}

.brand span {
  display: block;
  font-family: inherit;
  font-size: 9px;
  letter-spacing: 0.38em;
  color: rgba(190, 214, 231, 0.55);
  margin-top: 4px;
}

.icon-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(9, 18, 30, 0.55);
  color: #d6e6f2;
  font-size: 15px;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.icon-btn:hover { border-color: rgba(255, 207, 122, 0.5); color: var(--amber); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn[aria-pressed="false"] { color: rgba(190, 214, 231, 0.4); }

.meter {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.meter__label {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: rgba(190, 214, 231, 0.6);
  white-space: nowrap;
}

.meter__track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(190, 214, 231, 0.12);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(190, 214, 231, 0.06);
  max-width: 240px;
}

.meter__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb45c, #ffe6a8);
  box-shadow: 0 0 12px rgba(255, 190, 110, 0.8);
  transition: width 0.35s ease;
}

.meter__count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  color: rgba(255, 226, 170, 0.85);
  min-width: 44px;
  text-align: right;
}

.lamps {
  display: flex;
  gap: 7px;
  align-items: center;
  pointer-events: none;
}

.lamp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(190, 214, 231, 0.35);
  background: transparent;
  transition: background 0.5s ease, box-shadow 0.5s ease, border-color 0.5s ease;
}

.lamp.is-lit {
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 10px rgba(255, 190, 110, 0.9);
}

/* ---------- poem whisper ---------- */
.poem {
  position: absolute;
  top: calc(96px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  padding: 0 28px;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.poem__line {
  font-family: "Songti SC", "Noto Serif SC", "Songti TC", serif;
  font-size: clamp(15px, 4.3vw, 21px);
  line-height: 1.85;
  letter-spacing: 0.06em;
  color: #f4e8d4;
  text-shadow: 0 0 22px rgba(4, 9, 16, 0.95), 0 0 8px rgba(4, 9, 16, 0.9);
  margin: 0;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.9s ease, transform 1.1s ease;
}

.poem__line.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.poem__index {
  display: block;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.42em;
  color: rgba(255, 207, 122, 0.7);
  margin-bottom: 8px;
}

/* ---------- hint ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(200, 220, 235, 0.62);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.5s ease;
  text-shadow: 0 0 12px rgba(3, 7, 13, 0.9);
}

.hint kbd {
  font-family: inherit;
  border: 1px solid rgba(200, 220, 235, 0.28);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  margin: 0 1px;
}

/* ---------- controls ---------- */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 4;
}

.stick {
  pointer-events: auto;
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 1px solid rgba(200, 220, 235, 0.18);
  background: radial-gradient(circle at 50% 45%, rgba(140, 190, 220, 0.10), rgba(6, 12, 21, 0.28));
  backdrop-filter: blur(3px);
  touch-action: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  flex: 0 0 auto;
}

.stick.is-active { opacity: 1; }

.stick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 240, 205, 0.92), rgba(255, 183, 92, 0.72));
  box-shadow: 0 0 22px rgba(255, 183, 92, 0.45);
  will-change: transform;
}

.stick__hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  letter-spacing: 0.24em;
  color: rgba(200, 220, 235, 0.4);
  pointer-events: none;
}

.action {
  pointer-events: auto;
  margin-left: auto;
  min-width: 116px;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 207, 122, 0.42);
  background: linear-gradient(160deg, rgba(255, 196, 116, 0.22), rgba(255, 160, 70, 0.10));
  color: #ffe9c3;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.22em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 26px rgba(255, 170, 80, 0.14), inset 0 0 18px rgba(255, 190, 110, 0.10);
  transition: opacity 0.25s ease, transform 0.18s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.action.is-available {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.action:active { transform: scale(0.96); }

.action.is-short {
  color: rgba(220, 232, 240, 0.6);
  border-color: rgba(180, 205, 220, 0.22);
  background: rgba(10, 20, 32, 0.5);
  box-shadow: none;
  cursor: not-allowed;
}

.action.is-short:active { transform: none; }

.action:focus-visible,
.icon-btn:focus-visible,
.primary:focus-visible,
.ghost:focus-visible {
  outline: 2px solid rgba(255, 214, 150, 0.9);
  outline-offset: 3px;
}

/* ---------- overlays ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.7s ease, visibility 0.7s ease;
  background:
    radial-gradient(62% 48% at 50% 42%, rgba(4, 11, 20, 0.74), rgba(4, 11, 20, 0.18) 72%, rgba(3, 7, 13, 0.55)),
    radial-gradient(100% 80% at 50% 50%, rgba(3, 8, 14, 0.1), rgba(2, 5, 10, 0.72));
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.screen.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen__inner {
  width: min(420px, 100%);
  text-align: center;
  transform: translateY(14px);
  transition: transform 0.8s cubic-bezier(0.22, 0.9, 0.25, 1);
}

.screen.is-open .screen__inner { transform: translateY(0); }

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.5em;
  color: rgba(255, 207, 122, 0.72);
  margin: 0 0 18px;
  text-indent: 0.5em;
}

.title {
  font-family: "Songti SC", "Noto Serif SC", "Songti TC", serif;
  font-size: clamp(46px, 15vw, 72px);
  line-height: 1.06;
  letter-spacing: 0.16em;
  margin: 0;
  color: #fdf4e5;
  text-indent: 0.16em;
  text-shadow: 0 0 40px rgba(255, 186, 96, 0.35);
}

.subtitle {
  font-family: "Songti SC", "Noto Serif SC", "Songti TC", serif;
  font-size: clamp(13px, 3.7vw, 15px);
  line-height: 2;
  letter-spacing: 0.12em;
  color: rgba(216, 231, 242, 0.78);
  margin: 20px 0 0;
}

.controls-note {
  margin: 26px 0 0;
  display: grid;
  gap: 7px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: rgba(190, 214, 231, 0.55);
  line-height: 1.7;
}

.controls-note b {
  color: rgba(255, 220, 165, 0.9);
  font-weight: 500;
}

.primary {
  margin-top: 30px;
  min-height: 52px;
  padding: 14px 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 207, 122, 0.55);
  background: linear-gradient(160deg, rgba(255, 201, 124, 0.95), rgba(233, 158, 71, 0.9));
  color: #241505;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(255, 168, 72, 0.28);
  transition: transform 0.18s ease, box-shadow 0.25s ease, filter 0.2s ease;
}

.primary:hover { filter: brightness(1.06); box-shadow: 0 12px 40px rgba(255, 168, 72, 0.4); }
.primary:active { transform: scale(0.97); }

.ghost {
  margin-top: 12px;
  min-height: 44px;
  padding: 10px 26px;
  border-radius: 999px;
  border: 1px solid rgba(200, 220, 235, 0.22);
  background: transparent;
  color: rgba(220, 235, 245, 0.78);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.24em;
  cursor: pointer;
}

.poem-card {
  margin: 26px auto 0;
  display: grid;
  gap: 12px;
  padding: 0;
  list-style: none;
  text-align: left;
  max-height: 46vh;
  overflow-y: auto;
}

.poem-card li {
  font-family: "Songti SC", "Noto Serif SC", "Songti TC", serif;
  font-size: 14px;
  line-height: 1.8;
  letter-spacing: 0.05em;
  color: rgba(240, 230, 214, 0.9);
  padding-left: 18px;
  position: relative;
}

.poem-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 207, 122, 0.8);
  box-shadow: 0 0 8px rgba(255, 190, 110, 0.8);
}

.stats {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  gap: 28px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(190, 214, 231, 0.6);
}

.stats b {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: #ffe2ab;
  font-variant-numeric: tabular-nums;
}

/* touch-only vs keyboard hint */
.is-touch .hint { display: none; }
.is-desktop .stick { display: none; }

@media (max-height: 620px) {
  .poem-card { max-height: 34vh; }
  .title { font-size: clamp(38px, 11vw, 54px); }
  .controls-note { margin-top: 16px; }
  .primary { margin-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen__inner, .poem__line, .action { transition-duration: 0.01ms; }
}
