/* ==========================================================================
   邪恶奶龙·恶魔许愿机 — Galgame / Visual Novel UI Stylesheet
   Palette: Deep Obsidian-Wine Lacquer + Burnished Antique Gold + Velvet Crimson
   ========================================================================== */

:root {
  --bg-deep: #11090e;
  --surface-lacquer: rgba(18, 10, 16, 0.87);
  --surface-lacquer-solid: #160c13;
  --surface-elevated: rgba(30, 17, 25, 0.94);

  --gold-bright: #f5da94;
  --gold-main: #d6a954;
  --gold-dim: rgba(214, 169, 84, 0.35);
  --gold-hairline: rgba(235, 198, 122, 0.42);

  --crimson-bright: #ea4859;
  --crimson-main: #b4263a;
  --crimson-dark: #691421;

  --emerald-bright: #5ce0a8;
  --emerald-bg: rgba(18, 72, 54, 0.46);

  --amber-bright: #f6ba54;
  --amber-bg: rgba(94, 58, 12, 0.48);

  --text-ivory: #fbf4e8;
  --text-champagne: #d4c3a8;
  --text-muted: #9b8875;

  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --ease-vn: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-ivory);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Full-Viewport Galgame Stage & Layered Scenic Backdrop
   ========================================================================== */
.vn-stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  animation: stageFadeIn 0.7s var(--ease-vn) both;
}

@keyframes stageFadeIn {
  from {
    opacity: 0;
    filter: brightness(0.6);
  }
  to {
    opacity: 1;
    filter: brightness(1);
  }
}

.bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-image {
  position: absolute;
  inset: -24px;
  background-image: url("./assets/bg_shrine.jpg");
  background-size: cover;
  background-position: center 42%;
  transform: scale(1.03);
  transition: transform 0.6s var(--ease-vn), filter 0.6s ease;
  filter: brightness(0.86) contrast(1.04);
}

body[data-mood="scheming"] .bg-image {
  filter: brightness(0.72) contrast(1.12) saturate(1.15);
  transform: scale(1.06);
}

body[data-mood="cornered"] .bg-image {
  filter: brightness(0.96) contrast(1.04) saturate(1.1);
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 68% 62% at 50% 42%, transparent 25%, rgba(12, 5, 10, 0.72) 100%),
    linear-gradient(to bottom, rgba(12, 6, 11, 0.72) 0%, transparent 18%, transparent 66%, rgba(10, 5, 9, 0.88) 100%);
}

.bg-mood-wash {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.45s ease, background 0.45s ease;
}

body[data-mood="scheming"] .bg-mood-wash {
  opacity: 1;
  background: radial-gradient(circle at 50% 42%, rgba(190, 26, 52, 0.2), rgba(75, 6, 18, 0.42) 85%);
}

body[data-mood="cornered"] .bg-mood-wash {
  opacity: 1;
  background: radial-gradient(circle at 50% 38%, rgba(255, 222, 130, 0.24), rgba(20, 48, 86, 0.25) 85%);
}

body[data-mood="confused"] .bg-mood-wash {
  opacity: 1;
  background: radial-gradient(circle at 50% 42%, rgba(100, 145, 210, 0.14), rgba(14, 18, 34, 0.35) 85%);
}

/* Anime Impact Speedlines Flash */
.bg-speedlines {
  position: absolute;
  inset: -15%;
  opacity: 0;
  background: repeating-conic-gradient(
    from 0deg at 50% 44%,
    rgba(255, 232, 175, 0.22) 0deg 1.4deg,
    transparent 1.4deg 8.5deg
  );
  mask-image: radial-gradient(circle at 50% 44%, transparent 24%, black 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 44%, transparent 24%, black 75%);
  pointer-events: none;
}

.bg-speedlines.flash-crimson {
  background: repeating-conic-gradient(
    from 0deg at 50% 44%,
    rgba(245, 62, 82, 0.34) 0deg 1.6deg,
    transparent 1.6deg 8deg
  );
  animation: speedlineBurst 0.65s ease-out;
}

.bg-speedlines.flash-gold {
  background: repeating-conic-gradient(
    from 0deg at 50% 44%,
    rgba(255, 224, 132, 0.42) 0deg 1.8deg,
    transparent 1.8deg 9deg
  );
  animation: speedlineBurst 0.85s ease-out;
}

@keyframes speedlineBurst {
  0% {
    opacity: 0.95;
    transform: scale(0.92) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.12) rotate(10deg);
  }
}

.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   Layer 1: Top Galgame Contract HUD
   ========================================================================== */
.top-hud {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: linear-gradient(to bottom, rgba(16, 8, 14, 0.92), rgba(16, 8, 14, 0.62));
  border-bottom: 1px solid var(--gold-dim);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  flex-shrink: 0;
}

.game-emblem {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.emblem-gem {
  color: var(--gold-bright);
  font-size: 1.05rem;
  text-shadow: 0 0 10px rgba(245, 218, 148, 0.7);
}

.emblem-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.game-title {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
}

.game-subtitle {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--text-champagne);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.game-subtitle::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-main);
}

.game-subtitle.live::before {
  background: var(--emerald-bright);
  box-shadow: 0 0 6px var(--emerald-bright);
}

.round-tracker {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.3rem 0.75rem;
  background: rgba(255, 240, 200, 0.05);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
}

.round-seals {
  display: flex;
  gap: 0.35rem;
}

.seal {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(214, 169, 84, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.3s var(--ease-vn);
}

.seal.active {
  border-color: var(--gold-bright);
  background: rgba(214, 169, 84, 0.24);
  color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(245, 218, 148, 0.4);
}

.seal.tricked {
  border-color: var(--crimson-bright);
  background: rgba(180, 38, 58, 0.55);
  color: #fff;
}

.seal.won {
  border-color: var(--emerald-bright);
  background: rgba(34, 138, 98, 0.65);
  color: #fff;
  box-shadow: 0 0 10px rgba(92, 224, 168, 0.5);
}

.round-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-ivory);
  white-space: nowrap;
}

/* Cumulative Conditions Bar */
.hud-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.75rem;
  background: rgba(10, 5, 9, 0.52);
  border: 1px solid rgba(214, 169, 84, 0.22);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.conditions-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-main);
  white-space: nowrap;
  flex-shrink: 0;
}

.conditions-list {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 1px;
  padding-right: 12px;
  mask-image: linear-gradient(to right, black 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 92%, transparent 100%);
}

.conditions-list::-webkit-scrollbar {
  display: none;
}

.condition-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
}

.condition-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.52rem;
  font-size: 0.74rem;
  color: var(--text-ivory);
  background: rgba(214, 169, 84, 0.14);
  border: 1px solid rgba(214, 169, 84, 0.42);
  border-radius: 3px;
  white-space: nowrap;
  max-width: 175px;
  flex-shrink: 0;
  animation: chipPop 0.35s var(--ease-vn);
}

.condition-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.condition-chip-idx {
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.68rem;
}

@keyframes chipPop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Galgame System Menu Buttons */
.hud-menu {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.sys-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.32rem 0.62rem;
  background: rgba(28, 16, 24, 0.75);
  border: 1px solid rgba(214, 169, 84, 0.32);
  border-radius: var(--radius-sm);
  color: var(--text-champagne);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  transition: all 0.2s ease;
}

.sys-btn:hover,
.sys-btn:focus-visible {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  background: rgba(214, 169, 84, 0.16);
  outline: none;
}

.sys-key {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-main);
}

.sys-btn.active .sys-key {
  color: var(--gold-bright);
}

.sys-btn-accent {
  border-color: rgba(234, 72, 89, 0.55);
  background: rgba(130, 24, 40, 0.42);
}

.sys-btn-accent:hover {
  border-color: var(--crimson-bright);
  background: rgba(180, 38, 58, 0.68);
  color: #fff;
}

/* ==========================================================================
   Layer 2: Center Stage — Giant Evil Nailong Standing Sprite (立绘)
   ========================================================================== */
.character-stage {
  position: relative;
  z-index: 10;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.sprite-anchor {
  position: relative;
  width: min(56vh, 470px);
  height: min(74vh, 625px, calc(100% + 52px));
  max-height: calc(100% + 52px);
  margin-bottom: -58px; /* Tuck lower torso behind the Galgame dialogue box like authentic VN framing */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.nailong-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  transform-origin: center 82%;
  animation: nailongBreath 4.2s ease-in-out infinite;
  transition: transform 0.35s var(--ease-vn), filter 0.35s ease;
}

.nailong-wrapper:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: -8px;
  border-radius: 50%;
}

.nailong-sprite {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  opacity: 0;
  transition: opacity 0.22s ease;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.62));
  pointer-events: none;
}

.nailong-sprite.active {
  opacity: 1;
}

/* Sprite Behavioral Animations */
@keyframes nailongBreath {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-6px) scale(1.008, 0.994);
  }
}

/* Leaning in while player types */
.nailong-wrapper.watching {
  animation: none;
  transform: translateY(4px) scale(1.04) rotate(-1deg);
  filter: drop-shadow(0 0 22px rgba(245, 218, 148, 0.22));
}

/* Thinking suspense pulse */
.nailong-wrapper.thinking {
  animation: nailongThink 0.9s ease-in-out infinite;
}

@keyframes nailongThink {
  0%, 100% {
    transform: translateY(0) scale(1.02) rotate(-1.5deg);
  }
  50% {
    transform: translateY(-5px) scale(1.045) rotate(1.5deg);
  }
}

/* Scheming pop-in */
.nailong-wrapper.anim-scheming {
  animation: nailongSchemePop 0.55s var(--ease-vn), nailongBreath 3.2s ease-in-out 0.55s infinite;
}

@keyframes nailongSchemePop {
  0% { transform: scale(0.94) translateY(14px); }
  45% { transform: scale(1.07) translateY(-10px); }
  100% { transform: scale(1) translateY(0); }
}

/* Cornered breakdown shiver */
.nailong-wrapper.anim-cornered {
  animation: nailongShiver 0.55s linear 2, nailongBreath 2.6s ease-in-out 1.1s infinite;
}

@keyframes nailongShiver {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-8px, -3px) rotate(-2deg); }
  30% { transform: translate(8px, 2px) rotate(2deg); }
  45% { transform: translate(-6px, -2px) rotate(-1.5deg); }
  60% { transform: translate(6px, 2px) rotate(1.5deg); }
  75% { transform: translate(-4px, 0) rotate(-1deg); }
}

/* Confused tilt */
.nailong-wrapper.anim-confused {
  animation: nailongTilt 0.5s var(--ease-vn), nailongBreath 4s ease-in-out 0.5s infinite;
}

@keyframes nailongTilt {
  0% { transform: rotate(0deg) translateY(8px); }
  50% { transform: rotate(-5deg) translateY(-6px); }
  100% { transform: rotate(0deg) translateY(0); }
}

/* Squishy poke bounce */
.nailong-wrapper.poked {
  animation: nailongPoke 0.42s var(--ease-vn);
}

@keyframes nailongPoke {
  0% { transform: scale(1, 1); }
  25% { transform: scale(1.08, 0.91) translateY(10px); }
  60% { transform: scale(0.96, 1.05) translateY(-8px); }
  100% { transform: scale(1, 1) translateY(0); }
}

/* Floating Anime Reaction Stamp */
.reaction-stamp {
  position: absolute;
  top: 8%;
  right: -6%;
  z-index: 25;
  padding: 0.35rem 0.9rem;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 1.08rem;
  letter-spacing: 0.12em;
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: scale(1.8) rotate(12deg);
  pointer-events: none;
  white-space: nowrap;
}

.reaction-stamp.show {
  animation: stampSlam 2.4s var(--ease-vn) forwards;
}

.reaction-stamp.stamp-scheming {
  color: #fff6e5;
  background: linear-gradient(135deg, #c92038, #7d0f22);
  border: 2px solid var(--gold-bright);
  box-shadow: 0 8px 24px rgba(190, 20, 48, 0.55);
}

.reaction-stamp.stamp-cornered {
  color: #1c1004;
  background: linear-gradient(135deg, #ffe799, #e5a93c);
  border: 2px solid #fff8dc;
  box-shadow: 0 8px 28px rgba(245, 200, 90, 0.6);
}

.reaction-stamp.stamp-confused {
  color: #eef6ff;
  background: linear-gradient(135deg, #3c5f9e, #243866);
  border: 2px solid #9ec5ff;
  box-shadow: 0 8px 22px rgba(45, 85, 160, 0.5);
}

@keyframes stampSlam {
  0% {
    opacity: 0;
    transform: scale(2.1) rotate(16deg);
  }
  14% {
    opacity: 1;
    transform: scale(0.96) rotate(-5deg);
  }
  22% {
    transform: scale(1.03) rotate(-4deg);
  }
  80% {
    opacity: 1;
    transform: scale(1) rotate(-4deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.95) translateY(-10px) rotate(-4deg);
  }
}

/* Cheeky Poke Bubble */
.poke-bubble {
  position: absolute;
  top: 4%;
  left: -8%;
  z-index: 25;
  max-width: 240px;
  padding: 0.45rem 0.8rem;
  background: rgba(18, 10, 16, 0.92);
  border: 1px solid var(--gold-main);
  border-radius: var(--radius-md);
  color: var(--gold-bright);
  font-size: 0.78rem;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s var(--ease-vn);
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.poke-bubble.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Layer 3: Classic Galgame Bottom Dialogue & Wish Console
   ========================================================================== */
.vn-console-wrap {
  position: relative;
  z-index: 30;
  width: 100%;
  padding: 0 1.25rem 1.05rem;
  display: flex;
  justify-content: center;
}

.vn-console {
  position: relative;
  width: 100%;
  max-width: 960px;
  background: linear-gradient(180deg, rgba(22, 12, 19, 0.91) 0%, rgba(14, 8, 13, 0.95) 100%);
  border: 1px solid var(--gold-hairline);
  border-radius: var(--radius-md);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.72),
    inset 0 0 0 3px rgba(214, 169, 84, 0.08),
    inset 0 1px 0 rgba(245, 218, 148, 0.24);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 1.15rem 1.5rem 1rem;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

body[data-mood="scheming"] .vn-console {
  border-color: rgba(234, 72, 89, 0.62);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.76),
    0 0 28px rgba(180, 38, 58, 0.24),
    inset 0 1px 0 rgba(255, 160, 170, 0.22);
}

body[data-mood="cornered"] .vn-console {
  border-color: rgba(245, 218, 148, 0.78);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.72),
    0 0 32px rgba(245, 218, 148, 0.24),
    inset 0 1px 0 rgba(255, 240, 190, 0.35);
}

/* Ornamental Gold Corners */
.corner {
  position: absolute;
  width: 11px;
  height: 11px;
  border-color: var(--gold-bright);
  border-style: solid;
  pointer-events: none;
}

.corner.tl { top: 4px; left: 4px; border-width: 1.5px 0 0 1.5px; }
.corner.tr { top: 4px; right: 4px; border-width: 1.5px 1.5px 0 0; }
.corner.bl { bottom: 4px; left: 4px; border-width: 0 0 1.5px 1.5px; }
.corner.br { bottom: 4px; right: 4px; border-width: 0 1.5px 1.5px 0; }

/* Perched Character Nameplate */
.nameplate-row {
  position: absolute;
  top: -19px;
  left: 1.35rem;
  right: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.nameplate {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  padding: 0.3rem 1.05rem;
  background: linear-gradient(90deg, #4b1220 0%, #2b0f1b 75%, #1d0c16 100%);
  border: 1px solid var(--gold-main);
  border-radius: 3px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
}

.nameplate-gem {
  color: var(--gold-bright);
  font-size: 0.78rem;
}

.nameplate-main {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
}

.nameplate-divider {
  color: rgba(214, 169, 84, 0.4);
  font-size: 0.78rem;
}

.nameplate-mood {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-champagne);
}

.dialogue-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(16, 8, 14, 0.85);
  padding: 0.18rem 0.6rem;
  border: 1px solid rgba(214, 169, 84, 0.2);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.dialogue-hint.visible {
  opacity: 1;
}

/* Dialogue Text Area */
.dialogue-body {
  min-height: 82px;
  padding: 0.35rem 0.15rem 0.65rem;
  cursor: pointer;
  outline: none;
}

.dialogue-text {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  line-height: 1.72;
  letter-spacing: 0.03em;
  color: var(--text-ivory);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.65);
  user-select: text;
}

.typing-cursor {
  display: inline-block;
  margin-left: 0.35rem;
  color: var(--gold-bright);
  font-size: 0.85rem;
  vertical-align: middle;
  animation: cursorBlink 1s ease-in-out infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.25; transform: translateY(2px); }
}

/* Two-Layer Loophole Evidence Ribbon */
.loophole-ribbon {
  margin-top: 0.65rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--crimson-bright);
  background: linear-gradient(90deg, rgba(168, 32, 52, 0.28), rgba(40, 12, 22, 0.28));
  animation: ribbonReveal 0.38s var(--ease-vn);
}

.loophole-ribbon.is-victory {
  border-left-color: var(--emerald-bright);
  background: linear-gradient(90deg, var(--emerald-bg), rgba(14, 42, 34, 0.24));
}

.loophole-ribbon.is-confused {
  border-left-color: var(--amber-bright);
  background: linear-gradient(90deg, var(--amber-bg), rgba(45, 28, 8, 0.24));
}

@keyframes ribbonReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loophole-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #ff99a4;
  white-space: nowrap;
  flex-shrink: 0;
}

.loophole-ribbon.is-victory .loophole-tag {
  color: var(--emerald-bright);
}

.loophole-ribbon.is-confused .loophole-tag {
  color: var(--amber-bright);
}

.loophole-detail {
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-ivory);
  user-select: text;
}

/* Integrated Wish Input Dock */
.wish-dock {
  border-top: 1px solid rgba(214, 169, 84, 0.2);
  padding-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.quick-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.quick-chips-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.quick-chip {
  padding: 0.22rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  color: var(--text-champagne);
  background: rgba(255, 240, 200, 0.06);
  border: 1px solid rgba(214, 169, 84, 0.28);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-chip:hover,
.quick-chip:focus-visible {
  background: rgba(214, 169, 84, 0.2);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  transform: translateY(-1px);
  outline: none;
}

.wish-form {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
}

.input-shell {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(8, 4, 8, 0.78);
  border: 1px solid rgba(214, 169, 84, 0.36);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.75rem;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.input-shell:focus-within {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(245, 218, 148, 0.16);
}

.input-prefix {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold-main);
  padding: 0.16rem 0.45rem;
  background: rgba(214, 169, 84, 0.12);
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.wish-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-ivory);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.48rem 0;
  outline: none;
  user-select: text;
}

.wish-input::placeholder {
  color: rgba(201, 184, 156, 0.46);
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 1.35rem;
  background: linear-gradient(180deg, #c62c42 0%, #8e192b 100%);
  border: 1px solid var(--gold-main);
  border-radius: var(--radius-sm);
  color: #fff8eb;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(155, 25, 46, 0.45);
  transition: all 0.2s var(--ease-vn);
}

.submit-btn:hover:not(:disabled),
.submit-btn:focus-visible:not(:disabled) {
  background: linear-gradient(180deg, #df364e 0%, #a51e32 100%);
  border-color: var(--gold-bright);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(200, 35, 60, 0.55);
  outline: none;
}

.submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.submit-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Ending CTA Row */
.ending-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
}

.ending-btn {
  padding: 0.62rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-serif);
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ending-btn.primary {
  background: linear-gradient(180deg, #e5ba62 0%, #b88530 100%);
  border: 1px solid #fff2c4;
  color: #1c0f06;
  box-shadow: 0 6px 20px rgba(214, 169, 84, 0.35);
}

.ending-btn.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.ending-btn.secondary {
  background: rgba(34, 18, 28, 0.85);
  border: 1px solid var(--gold-hairline);
  color: var(--gold-bright);
}

.ending-btn.secondary:hover {
  background: rgba(214, 169, 84, 0.16);
  border-color: var(--gold-bright);
}

/* ==========================================================================
   Modals (Summary CG Card, Backlog, Rules, Settings)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 4, 9, 0.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeIn 0.22s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 86dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1d1018 0%, #130a10 100%);
  border: 1px solid var(--gold-main);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.8), inset 0 0 0 3px rgba(214, 169, 84, 0.08);
  animation: modalRise 0.28s var(--ease-vn);
}

.modal-summary {
  max-width: 700px;
}

@keyframes modalRise {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(214, 169, 84, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-champagne);
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  background: rgba(214, 169, 84, 0.16);
}

.modal-eyebrow,
.summary-eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--gold-main);
  margin-bottom: 0.35rem;
}

.modal-title,
.summary-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--gold-bright);
  margin-bottom: 1rem;
}

/* Summary Wax Stamp */
.summary-header {
  position: relative;
  border-bottom: 1px solid var(--gold-dim);
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
}

.wax-stamp {
  position: absolute;
  top: 0.25rem;
  right: 2.6rem;
  padding: 0.3rem 0.85rem;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 0.92rem;
  letter-spacing: 0.1em;
  border-radius: 4px;
  transform: rotate(-7deg);
  border: 2px solid currentColor;
}

.wax-stamp.victory {
  color: var(--gold-bright);
  background: rgba(40, 118, 80, 0.35);
  box-shadow: 0 0 18px rgba(245, 218, 148, 0.3);
}

.wax-stamp.defeat {
  color: #ff98a4;
  background: rgba(168, 28, 48, 0.42);
  box-shadow: 0 0 18px rgba(200, 36, 62, 0.3);
}

.summary-timeline,
.log-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timeline-item {
  padding: 0.85rem 1rem;
  background: rgba(255, 245, 220, 0.04);
  border: 1px solid rgba(214, 169, 84, 0.22);
  border-radius: var(--radius-sm);
  user-select: text;
}

.timeline-round {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold-main);
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.timeline-wish {
  font-size: 0.92rem;
  color: var(--text-ivory);
  margin-bottom: 0.45rem;
}

.timeline-result {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  color: var(--gold-bright);
  margin-bottom: 0.35rem;
  line-height: 1.55;
}

.timeline-loophole {
  font-size: 0.8rem;
  color: #ff9ba6;
}

.timeline-loophole.won {
  color: var(--emerald-bright);
}

.summary-footer,
.settings-footer {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.modal-btn {
  padding: 0.56rem 1.15rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-btn.primary {
  background: linear-gradient(180deg, #c62c42 0%, #8e192b 100%);
  border: 1px solid var(--gold-main);
  color: #fff;
}

.modal-btn.primary:hover {
  border-color: var(--gold-bright);
  filter: brightness(1.08);
}

.modal-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--gold-hairline);
  color: var(--gold-bright);
}

.modal-btn.secondary:hover {
  background: rgba(214, 169, 84, 0.16);
}

/* Rules List */
.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.rules-list li {
  padding: 0.68rem 0.85rem;
  background: rgba(255, 245, 220, 0.04);
  border-left: 2px solid var(--gold-main);
  border-radius: 3px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-champagne);
}

.rules-list strong {
  color: var(--gold-bright);
}

/* Settings Modal */
.mode-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.mode-option {
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card {
  height: 100%;
  padding: 0.8rem 0.9rem;
  background: rgba(255, 245, 220, 0.04);
  border: 1px solid rgba(214, 169, 84, 0.25);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.mode-card strong {
  font-size: 0.88rem;
  color: var(--text-ivory);
}

.mode-card span {
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.mode-option input:checked + .mode-card {
  border-color: var(--gold-bright);
  background: rgba(214, 169, 84, 0.14);
}

.mode-option input:checked + .mode-card strong {
  color: var(--gold-bright);
}

.api-fields {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.85rem;
  background: rgba(8, 4, 8, 0.45);
  border: 1px solid rgba(214, 169, 84, 0.2);
  border-radius: var(--radius-sm);
}

.server-key-note {
  font-size: 0.78rem;
  color: var(--emerald-bright);
  line-height: 1.45;
}

.server-key-note.warn {
  color: var(--amber-bright);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-group label {
  font-size: 0.78rem;
  color: var(--text-champagne);
}

.field-group input,
.field-group select {
  padding: 0.52rem 0.75rem;
  background: rgba(16, 10, 15, 0.9);
  border: 1px solid rgba(214, 169, 84, 0.35);
  border-radius: var(--radius-sm);
  color: var(--text-ivory);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  user-select: text;
}

.field-group input:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--gold-bright);
}

/* Toast */
.toast {
  position: fixed;
  top: 4.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 150;
  padding: 0.5rem 1.15rem;
  background: rgba(24, 13, 20, 0.95);
  border: 1px solid var(--gold-bright);
  border-radius: 999px;
  color: var(--gold-bright);
  font-size: 0.84rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--ease-vn);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Responsive Design (Tablet & Mobile)
   ========================================================================== */
@media (max-width: 1024px) {
  .top-hud {
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 0.55rem 0.85rem;
  }

  .hud-center {
    order: 3;
    flex-basis: 100%;
  }

  .sprite-anchor {
    width: min(50vh, 390px);
    height: min(64vh, 520px);
    margin-bottom: -44px;
  }
}

@media (max-width: 640px) {
  .game-title {
    font-size: 0.9rem;
  }

  .round-label {
    display: none;
  }

  .sys-text {
    display: none;
  }

  .sprite-anchor {
    width: min(44vh, 300px);
    height: min(54vh, 410px);
    margin-bottom: -36px;
  }

  .vn-console-wrap {
    padding: 0 0.65rem 0.7rem;
  }

  .vn-console {
    padding: 1.05rem 0.95rem 0.85rem;
  }

  .dialogue-text {
    font-size: 0.98rem;
    line-height: 1.62;
  }

  .wish-form {
    flex-direction: column;
  }

  .submit-btn {
    padding: 0.62rem 1rem;
  }

  .mode-toggle-group {
    grid-template-columns: 1fr;
  }

  .wax-stamp {
    position: static;
    display: inline-block;
    margin-top: 0.35rem;
    transform: rotate(-3deg);
  }
}
