:root {
  --bg-obsidian: #070606;
  --bg-ink: #120f0e;
  --text-parchment: #f4ece1;
  --text-muted: #b8aa99;
  --accent-vermilion: #b82924;
  --accent-vermilion-bright: #df3a32;
  --accent-gold: #c89d54;
  --accent-gold-soft: rgba(200, 157, 84, 0.35);
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-obsidian);
  color: var(--text-parchment);
  font-family: var(--font-sans);
  user-select: none;
  -webkit-user-select: none;
}

#app-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, #1c1512 0%, #070606 72%);
  overflow: hidden;
}

#phone-frame {
  position: relative;
  width: min(100vw, calc(100dvh * 390 / 844));
  height: min(100dvh, calc(100vw * 844 / 390));
  max-width: 100vw;
  max-height: 100dvh;
  background: #060505;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(200, 157, 84, 0.18);
}

#phone-frame.fx-shake {
  animation: screenShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@media (max-width: 450px) {
  #phone-frame {
    width: 100vw;
    height: 100dvh;
    box-shadow: none;
  }
}

.hidden {
  display: none !important;
}

/* Top HUD */
#top-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 8px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 6, 6, 0.78) 0%, rgba(7, 6, 6, 0) 100%);
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.hud-tag {
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(244, 236, 225, 0.78);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

.hud-btn {
  appearance: none;
  border: 1px solid rgba(200, 157, 84, 0.35);
  background: rgba(14, 11, 10, 0.74);
  color: var(--text-parchment);
  font-size: 12px;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.hud-btn.active-toggle {
  border-color: var(--accent-gold);
  color: #ffe7b8;
  background: rgba(66, 44, 22, 0.75);
}

.hud-btn.icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.hud-btn:hover {
  background: rgba(34, 24, 20, 0.9);
  border-color: var(--accent-gold);
}

.hud-btn:active {
  transform: scale(0.95);
}

/* Remember Echo Toast */
#echo-toast {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(200, 157, 84, 0.6);
  background: rgba(16, 11, 9, 0.88);
  color: #f3d7a3;
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.75);
  opacity: 0;
  pointer-events: none;
}

#echo-toast.show {
  animation: echoPop 1.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.echo-diamond {
  color: var(--accent-vermilion-bright);
  font-size: 11px;
}

@keyframes echoPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  16% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
}

/* Stage & Camera Layers */
#bg-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #040404;
  transition: filter 0.6s ease;
}

#bg-stage.grayscale {
  filter: grayscale(100%) contrast(1.18) brightness(0.7);
}

.bg-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.35s ease;
  overflow: hidden;
  --base-scale: 1;
}

.bg-layer.active {
  opacity: 1;
}

.bg-layer.black-bg {
  background: #040404;
}

.bg-layer.black-bg > * {
  display: none;
}

.bg-back,
.bg-front {
  position: absolute;
  inset: -6%;
  background-size: cover;
  background-position: center;
  will-change: transform, filter;
}

/* Default non-character: single full image on bg-front, back hidden */
.bg-layer:not(.char-parallax) .bg-back {
  display: none;
}

/* Character 2-layer parallax: blurred atmospheric rear + masked/offset front moving independently */
.bg-layer.char-parallax .bg-back {
  display: block;
  filter: blur(5px) brightness(0.68) saturate(0.9);
  transform: scale(calc(var(--base-scale) * 1.12));
  animation: parallaxBack 9s ease-in-out infinite alternate;
}

.bg-layer.char-parallax .bg-front {
  -webkit-mask-image: radial-gradient(ellipse 72% 84% at 50% 48%, #000 58%, transparent 100%);
  mask-image: radial-gradient(ellipse 72% 84% at 50% 48%, #000 58%, transparent 100%);
}

@keyframes parallaxBack {
  0% { transform: scale(calc(var(--base-scale) * 1.1)) translate3d(-1.4%, 0.6%, 0); }
  100% { transform: scale(calc(var(--base-scale) * 1.15)) translate3d(1.6%, -0.8%, 0); }
}

.bg-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

/* Subtle artistic backlit figure silhouette when character fallback uses scene bg */
.bg-silhouette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
}

.bg-silhouette.sil-maid {
  opacity: 1;
  background:
    radial-gradient(ellipse 24% 16% at 52% 28%, rgba(8, 12, 11, 0.72) 0%, transparent 72%),
    radial-gradient(ellipse 46% 52% at 52% 66%, rgba(10, 18, 16, 0.74) 0%, transparent 72%);
}

.bg-silhouette.sil-boy {
  opacity: 1;
  background:
    radial-gradient(ellipse 28% 18% at 54% 34%, rgba(14, 11, 9, 0.68) 0%, transparent 74%),
    radial-gradient(ellipse 52% 50% at 54% 72%, rgba(16, 13, 11, 0.74) 0%, transparent 74%);
}

.bg-silhouette.sil-emperor {
  opacity: 1;
  background:
    radial-gradient(ellipse 30% 18% at 50% 24%, rgba(14, 10, 4, 0.78) 0%, transparent 72%),
    radial-gradient(ellipse 64% 62% at 50% 68%, rgba(18, 12, 4, 0.82) 0%, transparent 74%);
}

.bg-silhouette.sil-consort {
  opacity: 1;
  background:
    linear-gradient(120deg, rgba(160, 110, 42, 0.16) 0%, transparent 45%, rgba(18, 8, 8, 0.65) 100%);
}

/* === 8 Camera Languages (applied to .bg-front) === */
.cam-pushIn .bg-front {
  animation: camPushIn 9s ease-out forwards;
}
.cam-pullOut .bg-front {
  animation: camPullOut 9s ease-out forwards;
}
.cam-panL .bg-front {
  animation: camPanL 9s ease-in-out forwards;
}
.cam-panR .bg-front {
  animation: camPanR 9s ease-in-out forwards;
}
.cam-tiltUp .bg-front {
  animation: camTiltUp 8s ease-out forwards;
}
.cam-whip .bg-front {
  animation: camWhip 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards, camTiltSlow 7s 0.3s ease-out forwards;
}
.cam-focus .bg-front {
  animation: camFocus 1.4s ease-out forwards, camPushIn 9s 1.4s ease-out forwards;
}
.cam-slamIn .bg-front {
  animation: camSlamIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes camPushIn {
  from { transform: scale(var(--base-scale)) translate3d(0, 0, 0); }
  to { transform: scale(calc(var(--base-scale) * 1.13)) translate3d(0, -1.2%, 0); }
}

@keyframes camPullOut {
  from { transform: scale(calc(var(--base-scale) * 1.15)) translate3d(0, -1%, 0); }
  to { transform: scale(var(--base-scale)) translate3d(0, 0, 0); }
}

@keyframes camPanL {
  from { transform: scale(calc(var(--base-scale) * 1.1)) translate3d(3.2%, 0, 0); }
  to { transform: scale(calc(var(--base-scale) * 1.1)) translate3d(-3.2%, 0, 0); }
}

@keyframes camPanR {
  from { transform: scale(calc(var(--base-scale) * 1.1)) translate3d(-3.2%, 0, 0); }
  to { transform: scale(calc(var(--base-scale) * 1.1)) translate3d(3.2%, 0, 0); }
}

@keyframes camTiltUp {
  from { transform: scale(calc(var(--base-scale) * 1.1)) translate3d(0, 3.6%, 0); }
  to { transform: scale(calc(var(--base-scale) * 1.13)) translate3d(0, -2.2%, 0); }
}

@keyframes camWhip {
  0% { transform: scale(calc(var(--base-scale) * 1.12)) translate3d(18%, 0, 0); filter: blur(8px); }
  100% { transform: scale(calc(var(--base-scale) * 1.06)) translate3d(0, 0, 0); filter: blur(0px); }
}

@keyframes camTiltSlow {
  from { transform: scale(calc(var(--base-scale) * 1.06)) translate3d(0, 1.8%, 0); }
  to { transform: scale(calc(var(--base-scale) * 1.14)) translate3d(0, -1.4%, 0); }
}

@keyframes camFocus {
  0% { filter: blur(11px) brightness(0.8); transform: scale(calc(var(--base-scale) * 1.08)); }
  100% { filter: blur(0px) brightness(1); transform: scale(var(--base-scale)); }
}

@keyframes camSlamIn {
  0% { transform: scale(var(--base-scale)); }
  100% { transform: scale(calc(var(--base-scale) * 1.25)); }
}

/* Special Motion FX modifiers on layer */
.bg-layer.fx-swirl .bg-front {
  animation: camFocus 1.3s ease-out forwards, soupSwirl 4.2s ease-in-out infinite alternate;
}

@keyframes soupSwirl {
  0% { transform: scale(calc(var(--base-scale) * 1.08)) rotate(-3.5deg); }
  100% { transform: scale(calc(var(--base-scale) * 1.15)) rotate(4.2deg); }
}

.bg-layer.fx-wobble .bg-front {
  animation: bowlWobble 2.8s ease-in-out infinite alternate;
}

@keyframes bowlWobble {
  0% { transform: scale(calc(var(--base-scale) * 1.05)) translate3d(-1.4%, 0.8%, 0) rotate(-0.9deg); }
  100% { transform: scale(calc(var(--base-scale) * 1.08)) translate3d(1.4%, -0.8%, 0) rotate(0.9deg); }
}

.bg-layer.fx-slideRight {
  animation: slideFromRight 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes slideFromRight {
  0% { transform: translate3d(38%, 0, 0); opacity: 0.2; }
  100% { transform: translate3d(0, 0, 0); opacity: 1; }
}

@keyframes screenShake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-7px, 4px, 0); }
  30% { transform: translate3d(7px, -5px, 0); }
  45% { transform: translate3d(-6px, -3px, 0); }
  60% { transform: translate3d(5px, 4px, 0); }
  75% { transform: translate3d(-3px, 2px, 0); }
}

/* Candlelight Flicker Overlay */
#fx-candle {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle at 36% 32%, rgba(255, 162, 68, 0.19) 0%, rgba(210, 92, 24, 0.08) 38%, rgba(0, 0, 0, 0) 74%);
  mix-blend-mode: screen;
  transition: opacity 0.14s ease;
}

/* Rain Canvas Overlay */
#fx-rain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

#bg-vignette {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(6, 5, 5, 0.42) 0%,
    rgba(6, 5, 5, 0.05) 26%,
    rgba(6, 5, 5, 0.16) 54%,
    rgba(6, 5, 5, 0.9) 88%,
    rgba(5, 4, 4, 0.98) 100%
  );
}

#fx-heartbeat {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  box-shadow: inset 0 0 95px rgba(155, 18, 16, 0.85), inset 0 0 180px rgba(0, 0, 0, 0.85);
  animation: heartbeatVignette 0.72s ease-in-out infinite;
}

@keyframes heartbeatVignette {
  0%, 100% { opacity: 0.45; }
  22% { opacity: 1; }
  45% { opacity: 0.58; }
  65% { opacity: 0.9; }
}

#timer-vignette {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  box-shadow: inset 0 0 75px rgba(205, 36, 30, 0.8);
  animation: pulseDanger 0.65s ease-in-out infinite alternate;
}

@keyframes pulseDanger {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

#fx-flash {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
}

#fx-flash.flash-white {
  background: #fff7eb;
  animation: flashBurst 0.34s ease-out forwards;
}

#fx-flash.flash-red {
  background: rgba(195, 22, 18, 0.78);
  animation: flashBurst 0.42s ease-out forwards;
}

@keyframes flashBurst {
  0% { opacity: 0.92; }
  100% { opacity: 0; }
}

/* Timeout Steward's Hand Reaching In */
#steward-hand-overlay {
  position: absolute;
  inset: 0;
  z-index: 38;
  pointer-events: none;
  overflow: hidden;
  background: rgba(12, 4, 4, 0.36);
}

.steward-sleeve {
  position: absolute;
  right: -100%;
  top: 28%;
  width: 92%;
  max-width: 420px;
  pointer-events: none;
  transform: rotate(-4deg) scale(1.04);
  transform-origin: right center;
}

.steward-hand-img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(-14px 18px 26px rgba(0, 0, 0, 0.88));
  user-select: none;
  -webkit-user-drag: none;
}

#steward-hand-overlay.reach .steward-sleeve {
  animation: handLunge 0.62s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes handLunge {
  0% { right: -96%; opacity: 0.25; transform: rotate(-7deg) scale(0.96); }
  62% { right: -2%; opacity: 1; transform: rotate(-2deg) scale(1.06); }
  100% { right: -4%; opacity: 1; transform: rotate(-3deg) scale(1.04); }
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* Title Screen */
#screen-title {
  justify-content: flex-end;
  padding: 20px 20px 28px;
}

.title-spacer {
  flex: 1;
}

.title-card {
  text-align: center;
  padding: 18px 14px 8px;
}

.title-ep-badge {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold-soft);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(12, 9, 8, 0.65);
  margin-bottom: 14px;
}

.title-main {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 31px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-parchment);
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.95);
}

.title-dot {
  color: var(--accent-vermilion-bright);
  margin: 0 2px;
}

.title-sub {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.title-sub-actions {
  display: flex;
  gap: 10px;
}

.title-sub-actions > button {
  flex: 1;
}

/* Shared Buttons (>= 48px height guaranteed) */
.btn-primary,
.btn-secondary,
.choice-btn {
  appearance: none;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn-primary {
  border: 1px solid rgba(235, 92, 82, 0.65);
  background: linear-gradient(180deg, #b82924 0%, #861815 100%);
  color: #fff6ee;
  box-shadow: 0 6px 20px rgba(155, 24, 20, 0.45);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #cf342e 0%, #991c18 100%);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  border: 1px solid rgba(200, 157, 84, 0.4);
  background: rgba(18, 14, 13, 0.85);
  color: var(--text-parchment);
  font-size: 14px;
}

.btn-secondary:hover {
  border-color: var(--accent-gold);
  background: rgba(34, 26, 22, 0.92);
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* Gameplay Screen */
#screen-game {
  justify-content: flex-end;
}

#tap-advance-area {
  position: absolute;
  inset: 0;
  z-index: 11;
  cursor: pointer;
}

#bottom-panel {
  position: relative;
  z-index: 15;
  padding: 0 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

#bottom-panel > * {
  pointer-events: auto;
}

/* Incense Timer */
#incense-wrap {
  background: rgba(16, 10, 9, 0.86);
  border: 1px solid rgba(223, 58, 50, 0.55);
  border-radius: 10px;
  padding: 8px 12px 9px;
}

.incense-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}

.incense-label {
  color: #f3a29c;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.incense-seconds {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  color: #ff6b61;
}

.incense-track {
  position: relative;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  display: flex;
  align-items: center;
  padding-left: 16px;
}

.incense-holder {
  position: absolute;
  left: 0;
  width: 18px;
  height: 10px;
  background: linear-gradient(90deg, #6e351c, #9c522c);
  border-radius: 999px 2px 2px 999px;
}

.incense-stick {
  position: relative;
  height: 6px;
  width: 100%;
  background: linear-gradient(90deg, #8b6a3e 0%, #c8a26a 85%, #d6492a 100%);
  border-radius: 0 999px 999px 0;
}

.incense-ember {
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3b0 0%, #ff5722 55%, rgba(255, 87, 34, 0) 100%);
  box-shadow: 0 0 10px #ff5722;
}

/* Single-Sentence Subtitle Box */
#dialogue-box {
  background: rgba(10, 8, 7, 0.72);
  border: 1px solid rgba(200, 157, 84, 0.24);
  border-radius: 12px;
  padding: 13px 15px 11px;
  backdrop-filter: blur(5px);
}

#speaker-row {
  min-height: 20px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#speaker-badge {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-gold);
  border-left: 3px solid var(--accent-vermilion-bright);
  padding-left: 7px;
}

.auto-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-gold);
  opacity: 0.75;
  animation: autoBlink 1.2s ease-in-out infinite;
}

@keyframes autoBlink {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

#dialogue-text {
  margin: 0;
  min-height: 29px;
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.45;
  color: var(--text-parchment);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

.tap-hint {
  margin-top: 6px;
  text-align: right;
  font-size: 11px;
  color: rgba(200, 157, 84, 0.78);
  letter-spacing: 0.12em;
}

/* Standard Choices */
#choices-container {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.choice-btn {
  min-height: 50px;
  border: 1px solid rgba(200, 157, 84, 0.5);
  background: rgba(19, 14, 12, 0.9);
  color: #f8efe4;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.12em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

.choice-btn:hover {
  background: rgba(145, 32, 27, 0.9);
  border-color: #ef8a7a;
}

.choice-btn:active {
  transform: scale(0.98);
}

/* Timed Gesture Control Dock */
#gesture-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  touch-action: none;
}

.gesture-swipe-zone {
  position: relative;
  min-height: 58px;
  border-radius: 12px;
  border: 1px solid rgba(200, 157, 84, 0.45);
  background: rgba(16, 11, 10, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.gesture-swipe-zone:active {
  cursor: grabbing;
}

.gesture-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 700;
  color: #f4e6d4;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  z-index: 2;
}

.gesture-chip.armed {
  background: rgba(184, 41, 36, 0.85);
  color: #fff;
  transform: scale(1.06);
}

.g-arrow {
  color: var(--accent-gold);
  font-size: 16px;
}

.gesture-puck {
  position: relative;
  min-width: 82px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(200, 157, 84, 0.7);
  background: radial-gradient(circle at 50% 35%, #3d281f, #1c120e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #f1d49c;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
  transition: transform 0.08s ease-out;
  z-index: 3;
}

.gesture-hold-btn {
  position: relative;
  appearance: none;
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid rgba(223, 58, 50, 0.55);
  background: rgba(24, 11, 10, 0.92);
  color: #ffd9d2;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}

.gesture-hold-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(184, 41, 36, 0.82), rgba(228, 70, 56, 0.95));
  pointer-events: none;
}

.gesture-hold-text {
  position: relative;
  z-index: 2;
}

.gesture-key-hint {
  text-align: center;
  font-size: 11px;
  color: rgba(200, 157, 84, 0.65);
  letter-spacing: 0.06em;
}

/* Death Seal Stamp */
#death-seal-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(8, 4, 4, 0.25);
}

#death-seal-stamp {
  width: 148px;
  height: 148px;
  border: 6px solid #c92620;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 92px;
  font-weight: 900;
  color: #d62822;
  background: rgba(20, 4, 4, 0.45);
  box-shadow: 0 0 36px rgba(201, 38, 32, 0.55), inset 0 0 18px rgba(201, 38, 32, 0.35);
  transform: rotate(-8deg) scale(2.4);
  opacity: 0;
}

#death-seal-overlay.slam #death-seal-stamp {
  animation: stampSlam 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes stampSlam {
  0% { transform: rotate(-16deg) scale(2.6); opacity: 0; }
  70% { transform: rotate(-7deg) scale(0.94); opacity: 1; }
  100% { transform: rotate(-8deg) scale(1); opacity: 1; }
}

/* Modals */
.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(6, 5, 5, 0.93);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  padding: 14px 16px 18px;
  overflow: hidden;
}

.death-modal-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.death-card-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding-top: 2px;
}

#death-card-canvas,
#death-card-img {
  max-height: 100%;
  max-width: 100%;
  width: auto;
  height: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  border: 1px solid rgba(200, 157, 84, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.85);
  object-fit: contain;
}

.death-save-tip {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
}

.death-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.death-sub-actions {
  display: flex;
  gap: 8px;
}

.death-sub-actions > button {
  flex: 1;
}

/* Survival Ending Screen */
#screen-ending {
  justify-content: flex-end;
  padding: 20px 18px 26px;
}

.ending-card {
  background: rgba(11, 9, 8, 0.86);
  border: 1px solid rgba(200, 157, 84, 0.45);
  border-radius: 14px;
  padding: 20px 18px 18px;
  text-align: center;
  backdrop-filter: blur(6px);
}

.ending-seal {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border: 2px solid var(--accent-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 26px;
  color: var(--accent-gold);
}

.ending-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-parchment);
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.ending-summary {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.6;
  color: #efe2d1;
  text-align: center;
}

.ending-stats {
  font-size: 12px;
  color: var(--accent-gold);
  margin-bottom: 16px;
  letter-spacing: 0.08em;
}

.ending-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Death Compendium Modal (2x5 grid fits 390x844 zero scroll) */
.compendium-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compendium-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.compendium-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: 0.12em;
  color: var(--text-parchment);
}

.compendium-progress {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--accent-gold);
}

.compendium-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 7px;
}

.comp-item {
  position: relative;
  border-radius: 9px;
  border: 1px solid rgba(200, 157, 84, 0.24);
  background: rgba(20, 16, 15, 0.9);
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, transform 0.12s ease;
}

.comp-item.unlocked {
  border-color: rgba(184, 41, 36, 0.65);
  background-size: cover;
  background-position: center;
}

.comp-item.unlocked::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 6, 6, 0.56) 0%, rgba(10, 6, 6, 0.92) 100%);
  z-index: 0;
}

.comp-item > * {
  position: relative;
  z-index: 1;
}

.comp-item:active {
  transform: scale(0.97);
}

.comp-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comp-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--accent-gold);
}

.comp-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(184, 41, 36, 0.85);
  color: #fff;
}

.comp-badge.locked {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.comp-name {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-parchment);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comp-sub {
  font-size: 10px;
  line-height: 1.3;
  color: #d8c8b6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.compendium-footer {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(24, 18, 16, 0.88);
  border: 1px solid rgba(200, 157, 84, 0.25);
}

.compendium-hint-bar {
  display: block;
  font-size: 11.5px;
  line-height: 1.4;
  color: #e6d7c3;
}
