:root {
  color-scheme: dark;
  --bg: #08090b;
  --fg: #ece8df;
  --muted: #a8aaa1;
  --line: rgba(236, 232, 223, 0.16);
  --panel: rgba(15, 17, 20, 0.74);
  --accent: #e0c36a;
  --cold: #4f9fa8;
  --pulse: #c44958;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: auto;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 18px;
  position: relative;
}

#veil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage {
  width: min(1040px, 100%);
  min-height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 500px);
  grid-template-rows: auto auto auto auto auto auto;
  gap: 14px;
  padding: clamp(18px, 3vw, 28px);
  position: relative;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(8, 9, 11, 0.82), rgba(20, 14, 16, 0.52));
  backdrop-filter: blur(14px);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.topbar {
  display: contents;
}

.topbar > div:first-child {
  grid-column: 1 / -1;
  grid-row: 2;
}

.eyebrow,
.memory-strip span,
.stats-strip span {
  margin: 0 0 7px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 500;
}

h1 {
  margin: 0;
  max-width: none;
  font-size: clamp(42px, 5.8vw, 76px);
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0;
}

.meters {
  display: grid;
  grid-template-columns: repeat(6, minmax(max-content, 1fr));
  gap: 8px;
  align-items: center;
  grid-column: 1 / -1;
  grid-row: 1;
  padding: 7px;
  border: 1px solid rgba(79, 159, 168, 0.28);
  background: linear-gradient(90deg, rgba(79, 159, 168, 0.12), rgba(236, 232, 223, 0.035), rgba(224, 195, 106, 0.08));
  overflow-x: auto;
}

.meters span,
.meters button {
  min-height: 38px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.meters button {
  cursor: pointer;
}

.meters button[aria-pressed="true"] {
  border-color: rgba(79, 159, 168, 0.82);
  color: #d9fbff;
  background: rgba(79, 159, 168, 0.14);
}

.meters span::before,
.meters button::before {
  content: "";
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  background: currentColor;
  opacity: 0.86;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

#turnMeter::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v6l4 2'/%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v6l4 2'/%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3C/svg%3E");
}

#tensionMeter::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22c4 0 7-3 7-7 0-5-4-8-6-13-1 4-5 6-5 11 0 3 2 5 4 5 2 0 3-1 3-3 0-2-2-4-3-5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22c4 0 7-3 7-7 0-5-4-8-6-13-1 4-5 6-5 11 0 3 2 5 4 5 2 0 3-1 3-3 0-2-2-4-3-5'/%3E%3C/svg%3E");
}

#scoreMeter::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2l3 7h7l-5.5 4.5L18 21l-6-4-6 4 1.5-7.5L2 9h7z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2l3 7h7l-5.5 4.5L18 21l-6-4-6 4 1.5-7.5L2 9h7z'/%3E%3C/svg%3E");
}

#playerCookieTop::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
}

#sourceMeter::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='5' width='14' height='14' rx='2'/%3E%3Cpath d='M9 1v4M15 1v4M9 19v4M15 19v4M1 9h4M1 15h4M19 9h4M19 15h4'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='5' width='14' height='14' rx='2'/%3E%3Cpath d='M9 1v4M15 1v4M9 19v4M15 19v4M1 9h4M1 15h4M19 9h4M19 15h4'/%3E%3C/svg%3E");
}

#soundToggle::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z'/%3E%3Cpath d='M15 9a5 5 0 0 1 0 6M18 6a9 9 0 0 1 0 12'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z'/%3E%3Cpath d='M15 9a5 5 0 0 1 0 6M18 6a9 9 0 0 1 0 12'/%3E%3C/svg%3E");
}

.ai-guide {
  grid-column: 2;
  grid-row: 3;
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  justify-self: end;
  width: min(500px, 100%);
  padding: 14px;
  border: 1px solid rgba(79, 159, 168, 0.42);
  background: linear-gradient(135deg, rgba(8, 16, 20, 0.82), rgba(18, 13, 17, 0.62));
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
  perspective: 900px;
}

.story {
  grid-column: 1;
  grid-row: 3;
}

.vision,
.controls,
.decision-form,
.stats-strip,
.memory-strip {
  grid-column: 1 / -1;
}

.ai-portrait {
  position: relative;
  width: 156px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(79, 159, 168, 0.58);
  border-radius: 50%;
  background: rgba(79, 159, 168, 0.1);
  transform-style: preserve-3d;
  animation: aiHeadIdle 5.2s ease-in-out infinite;
}

.ai-portrait canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: block;
}

.ai-portrait img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(1.12) contrast(1.08) brightness(1.06);
  transform: translateZ(18px) scale(1.07);
  opacity: 0.96;
}

.ai-portrait::before {
  content: "";
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  z-index: 2;
  border: 1px solid rgba(224, 195, 106, 0.28);
  animation: aiHalo 4.6s linear infinite;
}

.ai-scan {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: linear-gradient(180deg, transparent 0 34%, rgba(113, 231, 255, 0.14) 50%, transparent 66%);
  mix-blend-mode: screen;
  animation: aiScan 3.2s ease-in-out infinite;
}

.ai-eyes {
  display: none;
  position: absolute;
  left: 29%;
  top: 37%;
  width: 43%;
  height: 8%;
  z-index: 3;
  background:
    radial-gradient(circle at 18% 50%, rgba(160, 242, 255, 0.78), transparent 17%),
    radial-gradient(circle at 82% 50%, rgba(160, 242, 255, 0.78), transparent 17%);
  filter: blur(1px) drop-shadow(0 0 7px rgba(96, 230, 255, 0.68));
  animation: aiEyes 4.8s ease-in-out infinite;
}

.ai-mouth {
  display: none;
  position: absolute;
  left: 42%;
  top: 61%;
  z-index: 4;
  width: 16%;
  height: 3%;
  border-radius: 999px;
  background: rgba(32, 12, 14, 0.9);
  box-shadow: 0 0 7px rgba(224, 195, 106, 0.16);
  transform: translateZ(36px) scaleY(var(--mouth-open, 0.42));
  transform-origin: center;
  opacity: 0.86;
  transition: transform 90ms ease, width 120ms ease;
}

.ai-guide[data-speaking="true"] .ai-mouth {
  animation: aiSpeak 260ms ease-in-out infinite;
}

.ai-guide[data-emotion="worried"] .ai-portrait {
  border-color: rgba(224, 195, 106, 0.72);
}

.ai-guide[data-emotion="critical"] .ai-portrait {
  border-color: rgba(196, 73, 88, 0.82);
  box-shadow: 0 0 34px rgba(196, 73, 88, 0.22);
}

.ai-guide[data-emotion="critical"] .ai-eyes {
  background:
    radial-gradient(circle at 18% 50%, rgba(255, 124, 114, 0.88), transparent 18%),
    radial-gradient(circle at 82% 50%, rgba(255, 124, 114, 0.88), transparent 18%);
  filter: blur(1px) drop-shadow(0 0 8px rgba(255, 94, 88, 0.8));
}

.ai-message span {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
}

.ai-message p {
  margin: 0;
  color: var(--fg);
  font-size: 15px;
  line-height: 1.35;
}

.ai-message button {
  margin-top: 8px;
  border: 1px solid rgba(79, 159, 168, 0.58);
  background: rgba(79, 159, 168, 0.12);
  color: #d9fbff;
  padding: 6px 9px;
  font-size: 12px;
  cursor: pointer;
}

.ai-message button[aria-pressed="false"] {
  border-color: var(--line);
  background: rgba(236, 232, 223, 0.06);
  color: var(--muted);
}

.ai-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 9px;
}

.ai-actions .ai-action {
  width: 100%;
  margin: 0;
  border-color: rgba(224, 195, 106, 0.38);
  background: rgba(224, 195, 106, 0.08);
  color: var(--fg);
  text-align: left;
}

.ai-actions .ai-action[aria-pressed="true"] {
  border-color: rgba(224, 195, 106, 0.86);
  background: rgba(224, 195, 106, 0.18);
  color: #fff1b8;
}

#tensionMeter {
  position: relative;
}

.meter-improves {
  animation: blinkImprove 900ms ease-in-out 3;
}

.meter-worsens {
  animation: blinkWorsen 900ms ease-in-out 3;
}

.meter-stable {
  animation: blinkStable 900ms ease-in-out 2;
}

@keyframes blinkImprove {
  50% {
    border-color: rgba(78, 214, 141, 0.95);
    background: rgba(78, 214, 141, 0.18);
    color: #d8ffe8;
  }
}

@keyframes blinkWorsen {
  50% {
    border-color: rgba(230, 79, 91, 0.95);
    background: rgba(230, 79, 91, 0.2);
    color: #ffe1e4;
  }
}

@keyframes blinkStable {
  50% {
    border-color: rgba(224, 195, 106, 0.95);
    background: rgba(224, 195, 106, 0.18);
  }
}

@keyframes aiHalo {
  to {
    transform: rotate(360deg);
  }
}

@keyframes aiScan {
  0% {
    transform: translateY(-62%);
    opacity: 0;
  }

  24%,
  72% {
    opacity: 1;
  }

  100% {
    transform: translateY(62%);
    opacity: 0;
  }
}

@keyframes aiHeadIdle {
  0%,
  100% {
    transform: rotateX(0deg) rotateY(-4deg) translateZ(0);
  }

  50% {
    transform: rotateX(2deg) rotateY(5deg) translateZ(10px);
  }
}

@keyframes aiEyes {
  0%,
  86%,
  100% {
    opacity: 0.86;
    transform: scaleY(1);
  }

  90% {
    opacity: 0.36;
    transform: scaleY(0.18);
  }
}

@keyframes aiSpeak {
  0% {
    width: 13%;
    transform: translateZ(36px) scaleY(0.35);
  }

  45% {
    width: 18%;
    transform: translateZ(36px) scaleY(2.1);
  }

  100% {
    width: 15%;
    transform: translateZ(36px) scaleY(0.7);
  }
}

.story {
  align-self: stretch;
  max-width: 880px;
  overflow: auto;
  padding-right: 8px;
}

.scene {
  margin: 0;
  max-width: 820px;
  font-size: clamp(18px, 1.9vw, 25px);
  line-height: 1.28;
  font-weight: 400;
}

.whisper {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.vision {
  position: relative;
  margin: 0;
  min-height: 150px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: rgba(236, 232, 223, 0.06);
  --danger-sky: 0.22;
  --clear-sky: 0.5;
  --vision-brightness: 0.86;
  --vision-saturation: 0.86;
  --water-opacity: 0.76;
  --water-tint: rgba(112, 218, 242, 0.48);
}

.vision img {
  width: 100%;
  height: clamp(160px, 25vh, 230px);
  display: block;
  object-fit: cover;
  object-position: center 58%;
  filter: saturate(var(--vision-saturation)) brightness(var(--vision-brightness)) contrast(1.08);
  transform: scale(1.005);
  transition: filter 350ms ease;
}

.water-canvas {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  width: 100%;
  height: 31%;
  pointer-events: none;
  opacity: 0.7;
  mix-blend-mode: normal;
  filter: saturate(var(--vision-saturation)) brightness(var(--vision-brightness)) contrast(1.08);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.16) 14%, #000 42%);
  mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.16) 14%, #000 42%);
}

.vision::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 58% 44%, rgba(150, 255, 192, 0.34), transparent 18%),
    linear-gradient(180deg, rgba(65, 155, 230, var(--clear-sky)), transparent 48%),
    linear-gradient(180deg, rgba(198, 42, 32, var(--danger-sky)), rgba(84, 10, 18, calc(var(--danger-sky) * 0.7)) 74%, transparent);
  mix-blend-mode: screen;
  opacity: 0.86;
  animation: refugePulse 6s ease-in-out infinite;
}

.vision::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 57% 86%, rgba(165, 255, 214, 0.28), transparent 25%),
    radial-gradient(ellipse at 42% 92%, rgba(118, 219, 255, 0.16), transparent 32%),
    linear-gradient(90deg, rgba(8, 9, 11, 0.52), rgba(8, 9, 11, 0.06) 48%, rgba(8, 9, 11, 0.44)),
    linear-gradient(0deg, rgba(8, 9, 11, 0.48), transparent 46%);
  animation: waterGlow 4.8s ease-in-out infinite;
}

.bird-flock {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: var(--bird-opacity, 0.9);
  transition: opacity 600ms ease;
}

.bird {
  position: absolute;
  left: var(--bird-x);
  top: var(--bird-y);
  width: 18px;
  height: 8px;
  transform: translate3d(0, 0, 0) scale(var(--bird-scale));
  animation: birdCircle var(--bird-duration) ease-in-out infinite;
  animation-delay: var(--bird-delay);
}

.bird::before,
.bird::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 10px;
  height: 5px;
  border-top: 2px solid rgba(10, 22, 28, 0.92);
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.22));
  animation: wingBeat 720ms ease-in-out infinite;
}

.bird::before {
  left: 0;
  border-radius: 100% 0 0 0;
  transform-origin: right center;
}

.bird::after {
  right: 0;
  border-radius: 0 100% 0 0;
  transform-origin: left center;
  animation-delay: -120ms;
}

.bird-flock[data-risk="uneasy"] .bird {
  animation-name: birdScatter;
}

.bird-flock[data-risk="scattered"] .bird {
  animation-name: birdEscape;
}

.water-motion {
  display: none;
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: -13%;
  z-index: 3;
  height: 40%;
  pointer-events: none;
  opacity: var(--water-opacity);
  background:
    linear-gradient(180deg, transparent 0 18%, rgba(35, 100, 118, 0.16) 52%, rgba(4, 18, 24, 0.24) 100%),
    url("assets/future-vision.png");
  background-size: 100% 192%, cover;
  background-position: center 100%, center 92%;
  mix-blend-mode: normal;
  filter: saturate(1.2) brightness(1.08) blur(0.25px);
  overflow: hidden;
  transform: translate3d(0, 0, 0);
  clip-path: polygon(0 24%, 12% 29%, 26% 23%, 40% 30%, 58% 23%, 75% 29%, 100% 24%, 100% 100%, 0 100%);
  animation: waterSurface 4.6s ease-in-out infinite;
}

.water-motion::before,
.water-motion::after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -8%;
  height: 78%;
  pointer-events: none;
}

.water-motion::before {
  background:
    radial-gradient(ellipse at 28% 42%, rgba(212, 250, 255, 0.32), transparent 24%),
    radial-gradient(ellipse at 58% 50%, rgba(104, 220, 244, 0.22), transparent 29%),
    radial-gradient(ellipse at 78% 38%, rgba(255, 255, 255, 0.22), transparent 20%);
  mix-blend-mode: screen;
  filter: blur(3px);
  animation: waterReflections 5.8s ease-in-out infinite;
}

.water-motion::after {
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  opacity: 0.46;
  background:
    linear-gradient(180deg, transparent 0 20%, rgba(84, 190, 218, 0.16) 54%, rgba(6, 22, 28, 0.3) 100%);
  mix-blend-mode: screen;
  animation: waterShade 3.7s ease-in-out infinite;
}

.vision figcaption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  z-index: 4;
  color: var(--fg);
  font-size: 14px;
  line-height: 1.35;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.88);
}

.vision[data-risk="low"] img {
  transform: scale(1.005);
}

.vision[data-risk="low"]::after {
  background:
    radial-gradient(ellipse at 57% 86%, rgba(176, 255, 224, 0.34), transparent 26%),
    radial-gradient(ellipse at 42% 92%, rgba(133, 229, 255, 0.22), transparent 34%),
    linear-gradient(90deg, rgba(8, 9, 11, 0.38), rgba(8, 9, 11, 0.02) 48%, rgba(8, 9, 11, 0.34)),
    linear-gradient(0deg, rgba(8, 9, 11, 0.34), transparent 46%);
}

.vision[data-risk="low"] .water-motion {
  --water-opacity: 0.84;
  --water-tint: rgba(112, 218, 242, 0.56);
}

.vision[data-risk="critical"] img {
  transform: scale(1.005);
}

.vision[data-risk="critical"]::after {
  background:
    radial-gradient(ellipse at 57% 86%, rgba(255, 142, 86, 0.18), transparent 25%),
    radial-gradient(ellipse at 42% 92%, rgba(255, 83, 64, 0.12), transparent 34%),
    linear-gradient(90deg, rgba(8, 9, 11, 0.7), rgba(80, 12, 18, 0.2) 50%, rgba(8, 9, 11, 0.68)),
    linear-gradient(0deg, rgba(8, 9, 11, 0.68), transparent 38%);
}

.vision[data-risk="critical"] .water-motion {
  --water-opacity: 0.66;
  --water-tint: rgba(255, 103, 86, 0.42);
}

@keyframes refugePulse {
  50% {
    opacity: 0.96;
  }
}

@keyframes waterGlow {
  50% {
    opacity: 0.72;
    filter: saturate(1.15);
  }
}

@keyframes birdCircle {
  0% {
    opacity: 0.96;
    transform: translate3d(0, 0, 0) scale(var(--bird-scale)) rotate(0deg);
  }

  28% {
    transform: translate3d(calc(var(--bird-spread) * 0.18), -13px, 0) scale(var(--bird-scale)) rotate(4deg);
  }

  56% {
    transform: translate3d(calc(var(--bird-spread) * -0.14), 5px, 0) scale(var(--bird-scale)) rotate(-5deg);
  }

  100% {
    opacity: 0.96;
    transform: translate3d(0, 0, 0) scale(var(--bird-scale)) rotate(0deg);
  }
}

@keyframes birdScatter {
  0% {
    opacity: 0.78;
    transform: translate3d(0, 0, 0) scale(var(--bird-scale)) rotate(0deg);
  }

  45% {
    transform: translate3d(calc(var(--bird-spread) * var(--bird-phase) * 0.45), -22px, 0) scale(calc(var(--bird-scale) * 0.92)) rotate(calc(var(--bird-phase) * 8deg));
  }

  100% {
    opacity: 0.64;
    transform: translate3d(calc(var(--bird-spread) * var(--bird-phase) * 0.22), 3px, 0) scale(var(--bird-scale)) rotate(0deg);
  }
}

@keyframes birdEscape {
  0% {
    opacity: 0.62;
    transform: translate3d(0, 0, 0) scale(var(--bird-scale));
  }

  70% {
    opacity: 0.34;
  }

  100% {
    opacity: 0;
    transform: translate3d(calc(var(--bird-spread) * var(--bird-phase) * 0.72), -42px, 0) scale(calc(var(--bird-scale) * 0.68));
  }
}

@keyframes wingBeat {
  50% {
    transform: rotate(calc(var(--bird-phase) * 14deg)) translateY(-1px);
  }
}

@keyframes waterSurface {
  0% {
    background-position: center 100%, center 92%;
    transform: translate3d(-1.2%, 0, 0) scale(1.015, 1);
    clip-path: polygon(0 24%, 12% 29%, 26% 23%, 40% 30%, 58% 23%, 75% 29%, 100% 24%, 100% 100%, 0 100%);
  }

  50% {
    background-position: center 100%, 52% 94%;
    transform: translate3d(1.2%, 2px, 0) scale(1.025, 1.035);
    clip-path: polygon(0 30%, 12% 23%, 28% 31%, 44% 24%, 60% 32%, 78% 24%, 100% 31%, 100% 100%, 0 100%);
  }

  100% {
    background-position: center 100%, center 92%;
    transform: translate3d(-1.2%, 0, 0) scale(1.015, 1);
    clip-path: polygon(0 24%, 12% 29%, 26% 23%, 40% 30%, 58% 23%, 75% 29%, 100% 24%, 100% 100%, 0 100%);
  }
}

@keyframes waterReflections {
  0% {
    transform: translate3d(-2.5%, 0, 0) scaleX(1);
    opacity: 0.72;
  }

  50% {
    transform: translate3d(2.5%, -3px, 0) scaleX(1.08);
    opacity: 0.94;
  }

  100% {
    transform: translate3d(-2.5%, 0, 0) scaleX(1);
    opacity: 0.72;
  }
}

@keyframes waterShade {
  50% {
    opacity: 0.64;
    transform: translate3d(0, -2px, 0);
  }
}

.vision[data-profile="guardian"] {
  border-color: rgba(96, 188, 138, 0.36);
}

.vision[data-profile="truth"] {
  border-color: rgba(224, 195, 106, 0.45);
}

.vision[data-profile="builder"] {
  border-color: rgba(79, 159, 168, 0.5);
}

.vision[data-profile="rebel"] {
  border-color: rgba(196, 73, 88, 0.52);
}

.extinction-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 245, 192, 0.98) 0 7%, rgba(255, 151, 61, 0.88) 11%, rgba(188, 30, 28, 0.72) 24%, rgba(5, 5, 6, 0.96) 68%),
    #050506;
  animation: nukeFlash 1.9s ease-out both;
}

.extinction-overlay[hidden] {
  display: none;
}

.nuke-core {
  position: absolute;
  width: 42vmin;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 18%, #ffd06c 24%, rgba(255, 74, 42, 0.52) 44%, transparent 70%);
  filter: blur(4px);
  animation: nukeBloom 2.8s ease-out infinite alternate;
}

.extinction-panel {
  position: relative;
  z-index: 2;
  width: min(520px, calc(100% - 32px));
  border: 1px solid rgba(255, 214, 118, 0.76);
  background: rgba(10, 8, 8, 0.84);
  padding: 24px;
  text-align: center;
  box-shadow: 0 0 80px rgba(255, 76, 42, 0.38);
}

.extinction-panel p {
  margin: 0 0 8px;
  color: #ffdd7a;
  letter-spacing: 0;
}

.extinction-panel h2 {
  margin: 0 0 10px;
  font-size: clamp(34px, 7vw, 64px);
  font-weight: 500;
}

.extinction-panel span {
  display: block;
  color: var(--muted);
}

.extinction-panel button {
  margin-top: 18px;
  border: 1px solid rgba(255, 214, 118, 0.82);
  background: rgba(255, 214, 118, 0.14);
  color: var(--fg);
  padding: 12px 18px;
  cursor: pointer;
}

body.extinction-ended {
  overflow: hidden;
}

body.extinction-ended .vision {
  animation: visionShock 780ms ease-in-out infinite;
}

@keyframes nukeFlash {
  0% {
    opacity: 0;
    filter: brightness(2.2);
  }

  20% {
    opacity: 1;
    filter: brightness(2.8);
  }

  100% {
    filter: brightness(1);
  }
}

@keyframes nukeBloom {
  to {
    transform: scale(1.25);
    opacity: 0.74;
  }
}

@keyframes visionShock {
  50% {
    filter: saturate(0.55) brightness(1.35) contrast(1.4);
  }
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.choice {
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(236, 232, 223, 0.08);
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.choice:hover,
.choice:focus-visible,
.choice[aria-pressed="true"] {
  transform: translateY(-2px);
  border-color: rgba(211, 179, 95, 0.72);
  background: rgba(211, 179, 95, 0.12);
}

.choice:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.decision-form {
  display: grid;
  gap: 12px;
}

.decision-form label {
  color: var(--accent);
  font-weight: 500;
}

.decision-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  border: 1px solid var(--line);
  background: rgba(236, 232, 223, 0.08);
  color: var(--fg);
  padding: 13px 14px;
  font: inherit;
}

.decision-form textarea:focus-visible {
  outline: 2px solid rgba(211, 179, 95, 0.72);
  outline-offset: 2px;
}

.decision-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.decision-actions p {
  margin: 0;
  color: var(--muted);
}

.decision-actions button {
  border: 1px solid rgba(211, 179, 95, 0.72);
  background: rgba(211, 179, 95, 0.16);
  color: var(--fg);
  padding: 11px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 174px;
  min-height: 46px;
}

.decision-actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.decision-actions button[data-loading]::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(236, 232, 223, 0.22);
  border-top-color: var(--accent);
  animation: buttonSpin 760ms linear infinite;
}

@keyframes buttonSpin {
  to {
    transform: rotate(360deg);
  }
}

.stats-strip,
.memory-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.memory-strip {
  grid-template-columns: 1fr 1fr;
}

.stats-strip div,
.memory-strip div {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.stats-strip p,
.memory-strip p {
  margin: 0;
  color: var(--muted);
}

.stats-strip p {
  color: var(--fg);
}

.stats-strip {
  padding: 8px 0 2px;
}

.stats-strip div {
  border: 1px solid rgba(236, 232, 223, 0.11);
  background: rgba(236, 232, 223, 0.045);
  padding: 8px 10px;
}

.stats-strip span {
  margin-bottom: 4px;
  font-size: 11px;
}

.stats-strip p {
  font-size: 14px;
  line-height: 1.25;
}

.cookie-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  width: min(720px, calc(100% - 28px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid rgba(224, 195, 106, 0.45);
  background: rgba(12, 13, 16, 0.96);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner h2 {
  margin: 0 0 5px;
  font-size: 17px;
  font-weight: 600;
}

.cookie-banner p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.cookie-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.cookie-actions button {
  border: 1px solid var(--line);
  background: rgba(236, 232, 223, 0.08);
  color: var(--fg);
  padding: 10px 13px;
  cursor: pointer;
}

.cookie-actions button:last-child {
  border-color: rgba(211, 179, 95, 0.78);
  background: rgba(211, 179, 95, 0.18);
}

.cookie-actions button:focus-visible {
  outline: 2px solid rgba(211, 179, 95, 0.72);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .shell {
    min-height: 100svh;
    padding: 14px;
  }

  .stage {
    min-height: auto;
    padding: 18px;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(31px, 11vw, 46px);
  }

  .scene {
    font-size: 18px;
  }

  .vision img {
    height: 160px;
  }

  .controls,
  .stats-strip,
  .memory-strip,
  .decision-actions {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    display: contents;
  }

  .topbar > div:first-child,
  .meters,
  .story,
  .ai-guide,
  .vision,
  .controls,
  .decision-form,
  .stats-strip,
  .memory-strip {
    grid-column: 1;
    grid-row: auto;
  }

  .meters {
    justify-content: start;
    grid-column: auto;
    grid-row: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .ai-guide {
    grid-column: auto;
    grid-row: auto;
    justify-self: stretch;
    width: 100%;
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .ai-portrait {
    width: 104px;
  }

  .cookie-banner {
    display: grid;
    bottom: 12px;
  }

  .cookie-actions {
    justify-content: end;
  }
}
