/* =====================================================================
   THE BOY'S DYNASTY: GAUNTLET OF THE FALLEN — retro chrome
   Chunky monospace pixel styling, CRT scanlines + aperture grille,
   medieval parchment popups, cinematic letterboxed vignettes.
   All UI overlays are absolutely positioned inside #game-wrap so they
   scale with the canvas. Engine sets #game-wrap size on resize.
   ===================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background:
    radial-gradient(ellipse at 50% 40%, #0d0a18 0%, #060509 55%, #020203 100%);
  overflow: hidden;
  font-family: "Courier New", Courier, monospace;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- the TV ---------- */
#game-wrap {
  position: relative;
  width: 960px;   /* engine rescales via style.width/height, keeps 3:2 */
  height: 640px;
  background: #000;
  border-radius: 8px;
  box-shadow:
    0 0 80px rgba(120, 40, 200, 0.28),
    0 0 22px rgba(255, 200, 80, 0.08),
    0 0 8px #000,
    0 0 0 6px #0b0b10,
    0 0 0 8px #1a1a24;
}

/* screen curvature shadow (above everything, inert) */
#game-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 42;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.55),
    inset 0 0 18px rgba(0, 0, 0, 0.6);
}

/* glass glare sweep */
#game-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 41;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(115deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.015) 28%,
    rgba(255, 255, 255, 0) 48%);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: inherit;
}

/* ---------- CRT overlay: scanlines + aperture grille + flicker ---------- */
#scanlines {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  border-radius: inherit;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0)    0px,
      rgba(0, 0, 0, 0)    2px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0)    4px
    );
  mix-blend-mode: multiply;
  animation: crt-flicker 5s steps(1) infinite;
}
#scanlines::before { /* faint RGB aperture grille */
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to right,
    rgba(255, 0, 60, 0.030) 0px, rgba(255, 0, 60, 0.030) 1px,
    rgba(0, 255, 90, 0.020) 1px, rgba(0, 255, 90, 0.020) 2px,
    rgba(0, 80, 255, 0.030) 2px, rgba(0, 80, 255, 0.030) 3px);
}
#scanlines::after { /* phosphor vignette at the edges */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
              rgba(0,0,0,0) 58%, rgba(0,0,0,0.38) 100%);
}

@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  3%  { opacity: 0.92; }
  4%  { opacity: 1; }
  37% { opacity: 0.97; }
  38% { opacity: 1; }
  71% { opacity: 0.95; }
  72% { opacity: 1; }
}

/* ---------- UI overlay root ---------- */
#ui-root {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none; /* children opt back in */
  font-family: "Courier New", Courier, monospace;
}
#ui-root > * { pointer-events: auto; }

/* ---------- shared modal scrim ---------- */
.ui-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ui-fadein 120ms steps(4) both;
}

@keyframes ui-fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui-blink { 50% { opacity: 0.25; } }

/* ---------- parchment popup (Easter egg receipts) ---------- */
.parchment {
  position: relative;
  width: 600px;
  max-width: 86%;
  max-height: 80%;
  overflow: auto;
  background:
    radial-gradient(ellipse at 16% 10%, rgba(110, 75, 35, 0.20), transparent 34%),
    radial-gradient(ellipse at 86% 82%, rgba(110, 75, 35, 0.25), transparent 32%),
    radial-gradient(ellipse at 68% 26%, rgba(91, 58, 23, 0.10), transparent 26%),
    radial-gradient(ellipse at 30% 88%, rgba(91, 58, 23, 0.12), transparent 24%),
    linear-gradient(160deg, #f0e2b6 0%, #e6d09a 45%, #d6bd7e 100%);
  color: #2a1c0a;
  border: 4px solid #5b3a17;
  outline: 2px solid #2a1c0a;
  box-shadow:
    0 14px 0 rgba(0, 0, 0, 0.5),
    0 0 50px rgba(0, 0, 0, 0.5),
    inset 0 0 46px rgba(91, 58, 23, 0.4);
  padding: 22px 28px 18px;
  transform: rotate(-0.6deg);
  image-rendering: pixelated;
  animation: parch-in 180ms steps(5) both;
}
@keyframes parch-in {
  from { opacity: 0; transform: rotate(-0.6deg) scale(0.92); }
  to   { opacity: 1; transform: rotate(-0.6deg) scale(1); }
}
.parchment::before, .parchment::after { /* torn edge nubs */
  content: "";
  position: absolute;
  left: 12px; right: 12px;
  height: 6px;
  background: repeating-linear-gradient(90deg,
    #5b3a17 0 10px, transparent 10px 20px);
  opacity: 0.5;
}
.parchment::before { top: 4px; }
.parchment::after  { bottom: 4px; }

.parchment .p-icon {
  font-size: 40px;
  line-height: 1;
  text-align: center;
  margin-bottom: 6px;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.4));
}
.parchment .p-name {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: bold;
  font-size: 20px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  border-bottom: 2px solid #5b3a17;
  box-shadow: 0 4px 0 -2px rgba(91, 58, 23, 0.35); /* thin double rule */
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.parchment .p-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.parchment .p-footer {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 3px;
  color: #5b3a17;
  animation: ui-blink 1s steps(2) infinite;
}
.parchment .p-receipt-tag { /* wax-red stamp */
  position: absolute;
  top: -14px; right: -10px;
  background: linear-gradient(160deg, #a01818 0%, #8e1313 55%, #6e0e0e 100%);
  color: #ffd27a;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 4px 10px;
  border: 2px solid #2a1c0a;
  transform: rotate(4deg);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.5), inset 0 0 8px rgba(0,0,0,0.35);
}

/* ---------- plain dialog box ---------- */
.dialog-box {
  width: 620px;
  max-width: 88%;
  background: #101024;
  color: #e8e8ff;
  border: 4px solid #e8e8ff;
  outline: 3px solid #101024;
  box-shadow: 0 8px 0 rgba(0,0,0,0.6), 0 0 30px rgba(0,0,0,0.5);
  padding: 18px 24px 14px;
  font-size: 16px;
  line-height: 1.55;
  animation: ui-pop 140ms steps(4) both;
}
@keyframes ui-pop {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.dialog-box .d-text { white-space: pre-wrap; }
.dialog-box .d-footer {
  margin-top: 12px;
  text-align: right;
  font-size: 12px;
  letter-spacing: 3px;
  color: #8c8cd0;
  animation: ui-blink 1s steps(2) infinite;
}

/* ---------- choice dialog (door toll etc.) ---------- */
.choice-box {
  width: 640px;
  max-width: 90%;
  background:
    radial-gradient(ellipse at 80% 0%, rgba(176, 138, 60, 0.10), transparent 50%),
    #1a1408;
  color: #f4e3b0;
  border: 4px solid #b08a3c;
  outline: 3px solid #1a1408;
  box-shadow: 0 10px 0 rgba(0,0,0,0.65), 0 0 36px rgba(0,0,0,0.5);
  padding: 20px 26px;
  animation: ui-pop 140ms steps(4) both;
}
.choice-box .c-text {
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-bottom: 18px;
}
.choice-box .c-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.choice-box button {
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 2px;
  background: #2a2010;
  color: #f4e3b0;
  border: 3px solid #b08a3c;
  padding: 10px 26px;
  cursor: pointer;
}
.choice-box button.sel {
  background: #b08a3c;
  color: #1a1408;
  box-shadow: 0 0 0 3px #f4e3b0;
  animation: sel-pulse 900ms steps(2) infinite;
}
@keyframes sel-pulse {
  50% { box-shadow: 0 0 0 3px #f4e3b0, 0 0 16px rgba(244, 227, 176, 0.55); }
}
.choice-box .c-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 2px;
  color: #9a7f47;
}

/* ---------- narrator (JayGee) box ---------- */
.narrator-box {
  position: absolute;
  left: 24px; right: 24px; bottom: 20px;
  display: flex;
  gap: 14px;
  background: rgba(8, 8, 24, 0.94);
  border: 3px solid #caa84a;
  outline: 3px solid #08081a;
  box-shadow:
    0 8px 0 rgba(0,0,0,0.6),
    0 0 24px rgba(0,0,0,0.45),
    inset 0 0 26px rgba(20, 20, 60, 0.6);
  padding: 14px 18px;
  color: #e8e8ff;
  animation: narr-in 160ms steps(4) both;
}
@keyframes narr-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.narrator-box .n-portrait {
  flex: 0 0 64px;
  width: 64px; height: 64px;
  border: 2px solid #caa84a;
  box-shadow: 0 0 0 2px #08081a, 0 0 10px rgba(255, 210, 122, 0.25);
  image-rendering: pixelated;
  background: #15151f;
}
.narrator-box .n-portrait canvas, .narrator-box .n-portrait img {
  width: 100%; height: 100%;
  image-rendering: pixelated;
  display: block;
}
.narrator-box .n-body { flex: 1; min-width: 0; }
.narrator-box .n-name {
  display: inline-block;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 3px;
  color: #ffd27a;
  background: rgba(255, 210, 122, 0.10);
  border: 1px solid rgba(255, 210, 122, 0.4);
  padding: 2px 8px;
  margin-bottom: 7px;
}
.narrator-box .n-text {
  font-size: 16px;
  line-height: 1.5;
  min-height: 48px;
  white-space: pre-wrap;
}
.narrator-box .n-cursor { animation: ui-blink 0.8s steps(2) infinite; }
.narrator-box .n-footer {
  text-align: right;
  font-size: 11px;
  letter-spacing: 3px;
  color: #8c8cd0;
  animation: ui-blink 1s steps(2) infinite;
}

/* ---------- vignette (full screen cinematic still) ----------
   Letterbox bars iris in, the art drifts (slow Ken Burns), the serif
   title lands with tightening tracking, then the caption fades up.
   The photoreal-vs-pixels whiplash IS the joke — keep it cinematic. */
.vignette {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 35;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: ui-fadein 600ms ease both;
}
.vignette::before, .vignette::after { /* letterbox bars */
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 54px;
  background: #000;
  z-index: 3;
}
.vignette::before { top: 0;    transform-origin: top;    animation: letterbox-in 900ms ease-out both; }
.vignette::after  { bottom: 0; transform-origin: bottom; animation: letterbox-in 900ms ease-out both; }
@keyframes letterbox-in {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
.vignette .v-art {
  position: absolute;
  inset: -7%;
  background-size: cover;
  background-position: center;
  animation:
    v-art-in 1400ms ease both,
    kenburns 32s ease-in-out infinite alternate;
  image-rendering: auto; /* vignettes are the photoreal contrast joke */
}
@keyframes v-art-in {
  from { opacity: 0; filter: brightness(0.35) saturate(0.8); }
  to   { opacity: 1; filter: brightness(1) saturate(1); }
}
@keyframes kenburns {
  from { transform: scale(1.04) translate(0, 0); }
  to   { transform: scale(1.16) translate(-2.2%, 1.6%); }
}
.vignette .v-art img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.vignette .v-grade { /* cinematic grade */
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(to bottom,
      rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 18%,
      rgba(0,0,0,0) 64%, rgba(0,0,0,0.92) 100%);
  pointer-events: none;
}
.vignette .v-caption-wrap {
  position: relative;
  z-index: 4;
  text-align: center;
  padding: 0 60px 84px; /* clears the bottom letterbox bar */
}
.vignette .v-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
  font-weight: bold;
  letter-spacing: 6px;
  color: #f3e6c2;
  text-shadow: 0 4px 18px #000, 0 0 40px rgba(255,200,80,0.4);
  margin-bottom: 12px;
  animation: v-title-in 1200ms ease 250ms both;
}
@keyframes v-title-in {
  from { opacity: 0; letter-spacing: 16px; transform: translateY(10px); }
  to   { opacity: 1; letter-spacing: 6px;  transform: none; }
}
.vignette .v-caption {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.6;
  color: #d8d2bd;
  text-shadow: 0 2px 8px #000;
  max-width: 760px;
  margin: 0 auto;
  animation: v-fade-up 900ms ease 850ms both;
}
.vignette .v-loading { /* post-credits: "2026 SEASON: LOADING…" */
  margin-top: 18px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 5px;
  color: #ffd27a;
  text-shadow: 0 2px 8px #000;
  animation:
    v-fade-up 700ms ease 1500ms both,
    ui-blink 1.1s steps(2) 2.4s infinite;
}
.vignette .v-footer {
  margin-top: 16px;
  font-size: 11px;
  letter-spacing: 4px;
  color: #9a8f6f;
  animation:
    v-fade-up 600ms ease 1800ms both,
    ui-blink 1.2s steps(2) 2.6s infinite;
}
@keyframes v-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- league photo card (modal poster gags / title cards) ---------- */
.photo-card {
  position: relative;
  width: 560px;
  max-width: 84%;
  max-height: 86%;
  overflow: auto;
  background:
    radial-gradient(ellipse at 80% 0%, rgba(176, 138, 60, 0.10), transparent 50%),
    #14101e;
  color: #f0e8cf;
  border: 4px solid #b08a3c;
  outline: 3px solid #0b0814;
  box-shadow: 0 12px 0 rgba(0,0,0,0.6), 0 0 40px rgba(0,0,0,0.55);
  padding: 18px 22px 14px;
  text-align: center;
  animation: ui-pop 160ms steps(4) both;
}
.photo-card .pc-tag {
  position: absolute;
  top: -14px; right: -10px;
  background: linear-gradient(160deg, #a01818 0%, #8e1313 55%, #6e0e0e 100%);
  color: #ffd27a;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 4px 10px;
  border: 2px solid #2a1c0a;
  transform: rotate(4deg);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.5);
  z-index: 2;
}
.photo-card .pc-frame {
  position: relative;
  width: 100%;
  height: 300px;
  background: #08080f;
  border: 3px solid #5b4a17;
  outline: 2px solid #08080f;
  overflow: hidden;
  margin-bottom: 12px;
}
.photo-card .pc-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  animation: pc-develop 700ms ease both;
}
@keyframes pc-develop {
  from { filter: brightness(0.2) saturate(0.4); }
  to   { filter: brightness(1) saturate(1); }
}
.photo-card .pc-frame.pc-missing { display: flex; align-items: center; justify-content: center; }
.photo-card .pc-missing-label { color: #44445f; font-size: 13px; letter-spacing: 3px; }
.photo-card .pc-title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: bold;
  font-size: 20px;
  letter-spacing: 2px;
  color: #ffd27a;
  margin-bottom: 8px;
}
.photo-card .pc-caption {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.photo-card .p-footer {
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 3px;
  color: #9a7f47;
  animation: ui-blink 1s steps(2) infinite;
}

/* ---------- photo cut-in (non-modal corner panel) ---------- */
.cut-in {
  position: absolute;
  top: 38px;
  right: 16px;
  width: 250px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(8, 8, 24, 0.94);
  border: 3px solid #caa84a;
  outline: 2px solid #08081a;
  box-shadow: 0 6px 0 rgba(0,0,0,0.55), 0 0 18px rgba(0,0,0,0.45);
  padding: 8px 10px;
  z-index: 33;
  pointer-events: none;
  animation: cutin-in 240ms steps(5) both;
}
.cut-in.left { right: auto; left: 16px; }
.cut-in.out { animation: cutin-out 360ms steps(5) both; }
@keyframes cutin-in {
  from { opacity: 0; transform: translateX(30px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes cutin-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateX(30px) scale(0.94); }
}
.cut-in img {
  flex: 0 0 64px;
  width: 64px; height: 64px;
  object-fit: cover;
  border: 2px solid #caa84a;
  display: block;
}
.cut-in .ci-body { flex: 1; min-width: 0; }
.cut-in .ci-title {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #ffd27a;
  margin-bottom: 4px;
}
.cut-in .ci-text {
  font-size: 11px;
  line-height: 1.4;
  color: #e8e8ff;
}

/* ---------- toast (non-modal banner) ---------- */
.ui-toast {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 8, 24, 0.92);
  color: #ffd27a;
  border: 3px solid #ffd27a;
  box-shadow: 0 4px 0 rgba(0,0,0,0.5);
  padding: 8px 22px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  z-index: 32;
  pointer-events: none;
  animation: toast-pop 2.6s steps(12) both;
}
@keyframes toast-pop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  8%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  82%  { opacity: 1; }
  100% { opacity: 0; }
}
