:root {
  --bg: #041018;
  --cyan: #1ec8e0;
  --glow: #e8fffb;
  --text: rgba(232, 255, 251, 0.92);
  --muted: rgba(232, 255, 251, 0.55);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#stage.is-dragging {
  cursor: grabbing;
}

#stage.smash-mode,
#stage.smash-mode.is-dragging {
  cursor: none; /* custom hammer drawn on canvas */
}

.hud {
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0
    max(16px, env(safe-area-inset-left));
  pointer-events: none;
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px 18px;
  max-width: min(520px, 58vw);
}

.brand-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.brand strong {
  font-size: clamp(18px, 3.2vw, 28px);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  text-shadow: 0 0 24px rgba(30, 200, 224, 0.35);
}

.brand span {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.brand-feature {
  margin-top: 2px;
  font-style: normal;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.28em;
  color: rgba(30, 200, 224, 0.92);
  text-shadow: 0 0 16px rgba(30, 200, 224, 0.35);
}

.brand-tagline {
  margin: 0;
  padding-left: 14px;
  border-left: 1px solid rgba(30, 200, 224, 0.28);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "PingFang SC", serif;
  font-size: clamp(13px, 2.1vw, 16px);
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.55;
  color: rgba(232, 255, 251, 0.78);
}

@media (max-width: 640px) {
  .brand {
    flex-direction: column;
    align-items: flex-start;
    max-width: min(280px, 70vw);
    gap: 8px;
  }

  .brand-tagline {
    padding-left: 0;
    border-left: none;
    padding-top: 6px;
    border-top: 1px solid rgba(30, 200, 224, 0.22);
    letter-spacing: 0.08em;
    font-size: 12px;
  }
}

#reset {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(30, 200, 224, 0.45);
  background: rgba(4, 16, 24, 0.55);
  color: var(--glow);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#reset:hover,
#hand-toggle:hover,
#mode-toggle:hover,
#bg-toggle:hover,
#music-toggle:hover,
#record-toggle:hover,
#avatar-toggle:hover,
#shatter-toggle:hover,
#size-toggle:hover,
#underlay-toggle:hover,
#ending-toggle:hover {
  border-color: var(--cyan);
  background: rgba(30, 200, 224, 0.12);
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#hand-toggle,
#mode-toggle,
#bg-toggle,
#music-toggle,
#record-toggle,
#avatar-toggle,
#shatter-toggle,
#size-toggle,
#underlay-toggle,
#ending-toggle {
  appearance: none;
  border: 1px solid rgba(30, 200, 224, 0.45);
  background: rgba(4, 16, 24, 0.55);
  color: var(--glow);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#hand-toggle[aria-pressed="true"],
#record-toggle[aria-pressed="true"] {
  border-color: var(--cyan);
  background: rgba(30, 200, 224, 0.18);
}

#record-toggle[aria-pressed="true"] {
  border-color: #ff5a6a;
  background: rgba(255, 90, 106, 0.2);
  color: #ffd0d5;
}

#stage.hand-mode {
  cursor: none;
}

#bg-panel,
#music-panel,
#avatar-panel,
#record-panel,
#size-panel,
#underlay-panel,
#mode-panel,
#ending-edit-panel {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(2, 8, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#bg-panel[hidden],
#music-panel[hidden],
#avatar-panel[hidden],
#record-panel[hidden],
#size-panel[hidden],
#underlay-panel[hidden],
#mode-panel[hidden],
#ending-edit-panel[hidden] {
  display: none !important;
}

.bg-panel-inner {
  width: min(420px, 100%);
  background: rgba(4, 16, 24, 0.95);
  border: 1px solid rgba(30, 200, 224, 0.35);
  border-radius: 16px;
  padding: 20px;
  color: var(--text);
}

.bg-panel-inner h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.bg-note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.shatter-upload {
  margin-bottom: 12px;
  border-color: rgba(255, 140, 170, 0.45) !important;
  background: rgba(255, 80, 120, 0.08);
}

.bg-slot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(30, 200, 224, 0.2);
  border-radius: 12px;
  cursor: pointer;
}

.bg-slot span {
  grid-column: 1 / -1;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.bg-slot input[type="file"] {
  width: 100%;
  font-size: 12px;
  color: var(--muted);
}

.bg-reset,
#bg-close,
#music-close,
#avatar-panel-close,
#record-panel-close,
#size-panel-close,
#underlay-panel-close,
#mode-close,
#ending-edit-close,
.music-controls button {
  appearance: none;
  border: 1px solid rgba(30, 200, 224, 0.35);
  background: transparent;
  color: var(--glow);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

#bg-close,
#music-close,
#avatar-panel-close,
#record-panel-close,
#size-panel-close,
#underlay-panel-close,
#mode-close,
#ending-edit-close {
  margin-top: 16px;
  width: 100%;
}

.underlay-swatches {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.play-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.play-mode-btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border: 1px solid rgba(30, 200, 224, 0.3);
  background: rgba(4, 16, 24, 0.55);
  color: #e8fffb;
  border-radius: 12px;
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
}

.play-mode-btn strong {
  font-size: 15px;
  font-weight: 650;
}

.play-mode-btn small {
  font-size: 12px;
  line-height: 1.35;
  opacity: 0.72;
}

.play-mode-btn.is-active {
  border-color: #1ec8e0;
  background: rgba(30, 200, 224, 0.16);
}

.underlay-swatch {
  appearance: none;
  border: 1px solid rgba(30, 200, 224, 0.3);
  background: rgba(4, 24, 32, 0.85);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.underlay-swatch.is-active {
  border-color: var(--cyan);
  background: rgba(30, 200, 224, 0.16);
}

.swatch-chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.underlay-custom input[type="color"] {
  width: 48px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.size-fit-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.size-fit-btn {
  appearance: none;
  flex: 1;
  min-width: 90px;
  border: 1px solid rgba(30, 200, 224, 0.35);
  background: rgba(4, 24, 32, 0.8);
  color: var(--glow);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.size-fit-btn.is-active {
  border-color: var(--cyan);
  background: rgba(30, 200, 224, 0.18);
}

#size-scale-val {
  font-style: normal;
  color: var(--cyan);
  margin-left: 4px;
}

.record-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.record-mode-btn {
  appearance: none;
  border: 1px solid rgba(30, 200, 224, 0.35);
  background: rgba(4, 24, 32, 0.8);
  color: var(--text);
  border-radius: 14px;
  padding: 16px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.record-mode-btn:hover {
  border-color: var(--cyan);
  background: rgba(30, 200, 224, 0.12);
}

.record-mode-btn strong {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.record-mode-btn small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.record-mode-icon {
  border: 2px solid rgba(30, 200, 224, 0.7);
  border-radius: 4px;
  background: rgba(30, 200, 224, 0.12);
}

.record-mode-icon.portrait {
  width: 28px;
  height: 48px;
}

.record-mode-icon.landscape {
  width: 48px;
  height: 28px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.music-controls {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.music-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.music-preset {
  appearance: none;
  border: 1px solid rgba(30, 200, 224, 0.35);
  background: rgba(4, 16, 24, 0.55);
  color: #e8fffb;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.music-preset:hover {
  border-color: rgba(30, 200, 224, 0.75);
  background: rgba(30, 200, 224, 0.12);
}

.music-preset.is-active {
  border-color: #1ec8e0;
  background: rgba(30, 200, 224, 0.22);
}

.music-url-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
}

.music-url-row input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(30, 200, 224, 0.28);
  background: rgba(4, 16, 24, 0.7);
  color: #e8fffb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.music-volume,
.music-loop {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 13px;
  color: var(--muted);
}

.music-volume input {
  flex: 1;
}

.music-seek-row {
  align-items: center;
}

.music-seek-row span {
  min-width: 7.5em;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

#music-seek {
  accent-color: #1ec8e0;
}

#hand-panel {
  position: fixed;
  z-index: 2;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(180px, 36vw);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#hand-panel.is-on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.cam-frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(30, 200, 224, 0.45);
  box-shadow: 0 0 0 1px rgba(4, 16, 24, 0.5), 0 12px 28px rgba(0, 0, 0, 0.35);
}

#hand-video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
  transform: scaleX(-1);
  filter: saturate(0.85) brightness(0.9);
}

.cam-privacy {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

#privacy-face.cam-privacy-face {
  flex: 1.4;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 8px 8px;
  pointer-events: auto;
  cursor: pointer;
  border: none;
  appearance: none;
  background:
    linear-gradient(180deg, rgba(255, 236, 245, 0.72) 0%, rgba(210, 245, 255, 0.55) 50%, rgba(4, 16, 24, 0.35) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px dashed rgba(255, 160, 190, 0.45);
}

.hood {
  display: none;
  position: relative;
  width: 62%;
  aspect-ratio: 1;
  margin-bottom: 2px;
}

.cam-privacy[data-style="bunny"] .hood-bunny,
.cam-privacy[data-style="cat"] .hood-cat,
.cam-privacy[data-style="bear"] .hood-bear,
.cam-privacy[data-style="chick"] .hood-chick,
.cam-privacy[data-style="fox"] .hood-fox,
.cam-privacy[data-style="custom"] .hood-custom {
  display: block;
  animation: hood-pop 0.35s ease;
}

@keyframes hood-pop {
  from {
    transform: scale(0.86);
    opacity: 0.5;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.face-plate {
  position: absolute;
  inset: 18% 10% 8% 10%;
  border-radius: 48% 48% 42% 42%;
  background: linear-gradient(180deg, #fff7fb 0%, #ffe8f2 100%);
  box-shadow: inset 0 -6px 12px rgba(255, 150, 180, 0.18), 0 4px 10px rgba(0, 0, 0, 0.12);
}

.eye {
  position: absolute;
  top: 38%;
  width: 11%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #2a2430;
  box-shadow: 2px -2px 0 1px #fff inset;
}

.eye.e-l {
  left: 26%;
}
.eye.e-r {
  right: 26%;
}

.blush {
  position: absolute;
  top: 52%;
  width: 16%;
  height: 10%;
  border-radius: 50%;
  background: rgba(255, 130, 160, 0.45);
  filter: blur(1px);
}
.blush.b-l {
  left: 12%;
}
.blush.b-r {
  right: 12%;
}

.nose {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 10%;
  height: 7%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #ff8fb3;
}

.mouth {
  position: absolute;
  left: 50%;
  top: 64%;
  width: 18%;
  height: 10%;
  transform: translateX(-50%);
  border: 2px solid #e07098;
  border-top: none;
  border-radius: 0 0 14px 14px;
  background: transparent;
}

.hood-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: rgba(80, 40, 70, 0.75);
  background: rgba(255, 255, 255, 0.55);
  padding: 2px 8px;
  border-radius: 999px;
}

/* —— Bunny —— */
.hood-bunny .ear {
  position: absolute;
  top: -6%;
  width: 22%;
  height: 42%;
  background: linear-gradient(180deg, #fff 0%, #ffd6e8 100%);
  border-radius: 50% 50% 40% 40%;
  box-shadow: inset 0 0 0 3px #ffb7d5;
}
.hood-bunny .ear-l {
  left: 14%;
  transform: rotate(-12deg);
}
.hood-bunny .ear-r {
  right: 14%;
  transform: rotate(12deg);
}
.hood-bunny .ear::after {
  content: "";
  position: absolute;
  inset: 18% 28%;
  background: #ff9ec4;
  border-radius: 50%;
}

/* —— Cat —— */
.hood-cat .face-plate {
  background: linear-gradient(180deg, #fff9ef 0%, #ffe6c8 100%);
}
.hood-cat .ear {
  position: absolute;
  top: 2%;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 22px solid #f2c48a;
}
.hood-cat .ear-l {
  left: 16%;
  transform: rotate(-8deg);
}
.hood-cat .ear-r {
  right: 16%;
  transform: rotate(8deg);
}
.hood-cat .ear::after {
  content: "";
  position: absolute;
  left: -7px;
  top: 8px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid #ffb4c8;
}
.hood-cat .nose {
  width: 12%;
  height: 8%;
  background: #ff7aa2;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  border-radius: 0;
}
.hood-cat .mouth {
  width: 22%;
  height: 8%;
  border-width: 1.5px;
  border-color: #d07090;
}
.hood-cat .whisker {
  position: absolute;
  top: 58%;
  width: 18%;
  height: 1.5px;
  background: rgba(80, 50, 40, 0.45);
}
.hood-cat .w1 {
  left: 4%;
  transform: rotate(12deg);
}
.hood-cat .w2 {
  left: 4%;
  top: 64%;
  transform: rotate(-8deg);
}
.hood-cat .w3 {
  right: 4%;
  transform: rotate(-12deg);
}
.hood-cat .w4 {
  right: 4%;
  top: 64%;
  transform: rotate(8deg);
}

/* —— Bear —— */
.hood-bear .face-plate {
  background: linear-gradient(180deg, #f3e0c8 0%, #e8c49a 100%);
  border-radius: 46%;
}
.hood-bear .ear {
  position: absolute;
  top: 4%;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #d9a874;
  box-shadow: inset 0 0 0 5px #c48850;
}
.hood-bear .ear-l {
  left: 6%;
}
.hood-bear .ear-r {
  right: 6%;
}
.hood-bear .snout {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 36%;
  height: 28%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #f7e8d4;
}
.hood-bear .nose {
  top: 56%;
  width: 14%;
  height: 10%;
  background: #4a3428;
  z-index: 1;
}
.hood-bear .mouth {
  top: 70%;
  border-color: #8a5a48;
  width: 14%;
  height: 8%;
}

/* —— Chick —— */
.hood-chick .face-plate {
  inset: 12% 8% 6% 8%;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff4a8 0%, #ffd56a 100%);
}
.hood-chick .tuft {
  position: absolute;
  left: 50%;
  top: 0;
  width: 10%;
  height: 18%;
  transform: translateX(-50%);
  background: #ffb020;
  border-radius: 40% 40% 20% 20%;
  box-shadow: -8px 4px 0 #ffc84a, 8px 4px 0 #ffc84a;
}
.hood-chick .beak {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 22%;
  height: 14%;
  transform: translateX(-50%);
  background: #ff8a3a;
  clip-path: polygon(0 40%, 50% 100%, 100% 40%, 50% 0);
}
.hood-chick .eye {
  top: 36%;
}

/* —— Fox —— */
.hood-fox .face-plate {
  background: linear-gradient(180deg, #ffd3a8 0%, #ff9f6b 100%);
}
.hood-fox .ear {
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 26px solid #ff8a4a;
}
.hood-fox .ear-l {
  left: 14%;
  transform: rotate(-16deg);
}
.hood-fox .ear-r {
  right: 14%;
  transform: rotate(16deg);
}
.hood-fox .ear::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 10px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #ffe0c8;
}
.hood-fox .nose {
  background: #3a2a28;
  width: 12%;
}
.hood-fox .mouth {
  border-color: #c45a40;
}

/* —— Custom avatar —— */
.hood-custom {
  display: none;
  width: 68%;
  aspect-ratio: 1;
}
.hood-custom .avatar-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 4px;
  background: linear-gradient(135deg, #ff9ec4, #7ad7ff, #ffe56b);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.hood-custom #privacy-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  background: #fff;
  transform: scaleX(-1);
}

.cam-privacy-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 0 8px 4px;
  pointer-events: auto;
}

.avatar-upload-btn,
.avatar-clear-btn {
  appearance: none;
  border: 1px solid rgba(255, 160, 190, 0.55);
  background: rgba(255, 255, 255, 0.7);
  color: rgba(80, 40, 70, 0.9);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.avatar-clear-btn {
  border-color: rgba(30, 200, 224, 0.45);
}

.cam-privacy-hands {
  flex: 0.65;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(255, 200, 220, 0.85);
  background: linear-gradient(180deg, transparent, rgba(40, 20, 40, 0.28));
}

#hand-status {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: right;
}

#record-badge {
  position: fixed;
  z-index: 4;
  top: max(64px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(180, 20, 40, 0.85);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.2em;
  font-weight: 700;
  animation: rec-blink 1.1s ease-in-out infinite;
}

#record-badge[hidden] {
  display: none !important;
}

@keyframes rec-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

#hint {
  position: fixed;
  z-index: 2;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(4, 16, 24, 0.55);
  border: 1px solid rgba(30, 200, 224, 0.28);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#hint.hide {
  opacity: 0;
}

#ending {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px 24px;
  pointer-events: auto;
  animation: ending-in 1.4s ease both;
}

#ending[hidden] {
  display: none !important;
}

.ending-veil,
.ending-line {
  /* Text is drawn on canvas for recording; HTML only keeps dismiss button */
  opacity: 0 !important;
  pointer-events: none !important;
}

.ending-dismiss {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 1px solid rgba(232, 255, 251, 0.35);
  background: rgba(4, 16, 24, 0.45);
  color: rgba(232, 255, 251, 0.85);
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  animation: ending-line-in 1.2s ease 0.9s both;
}

.ending-dismiss:hover {
  border-color: rgba(30, 200, 224, 0.65);
  color: #e8fffb;
}

.ending-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.ending-edit textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 84px;
  border: 1px solid rgba(30, 200, 224, 0.28);
  background: rgba(4, 16, 24, 0.7);
  color: #e8fffb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "PingFang SC", serif;
  letter-spacing: 0.06em;
}

.ending-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.ending-preset {
  appearance: none;
  border: 1px solid rgba(30, 200, 224, 0.28);
  background: rgba(4, 16, 24, 0.45);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.ending-preset:hover {
  border-color: rgba(30, 200, 224, 0.65);
  color: #e8fffb;
}

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

@keyframes ending-line-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 16, 24, 0.72);
  border: 3px dashed rgba(30, 200, 224, 0.75);
  pointer-events: none;
}

#drop-overlay[hidden] {
  display: none !important;
}

.drop-overlay-inner {
  text-align: center;
  padding: 28px 36px;
  border-radius: 18px;
  background: rgba(4, 24, 32, 0.9);
  border: 1px solid rgba(30, 200, 224, 0.45);
  color: var(--glow);
}

.drop-overlay-inner strong {
  display: block;
  font-size: 22px;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.drop-overlay-inner span {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
