/* FREE PEOPLE'S ASSEMBLY — Web 1.0 Shrine Theme
   blood-red / amber / black + relic UI
*/

:root{
  --bg: #050000;
  --panel: rgba(0,0,0,0.78);
  --panel2: rgba(18,0,0,0.72);
  --amber: #ffb000;
  --amber2: #ffd27a;
  --blood: #b00000;
  --blood2: #ff2a2a;
  --ink: #f3e6d0;
  --inkSoft: #d8c8b0;
  --link: #ffb000;
  --visited: #ff5a00;
  --borderA: rgba(255,176,0,0.75);
  --borderB: rgba(176,0,0,0.75);

  --bgimg: url("/img/tile.gif");
  --cursorCross: url("/img/sigil-cursor.png") 2 2;
  --cursorPointer: url("/img/sigil-cursor.png") 2 2;
  --foldClosed: url("/img/fold-rune-closed.gif");
  --foldOpen: url("/img/fold-rune-open.gif");
}

/* Old-school defaults */
html, body { height:100%; }
body{
  margin:0;
  font-family: Verdana, Arial, sans-serif;
  color: rgba(255,255,255,0.92);
  background-color: var(--bg);
  background-image: var(--bgimg);
  background-repeat: repeat;
  background-attachment: fixed;
cursor: var(--cursorCross), crosshair;
}

a{ color: var(--link); text-decoration: underline; }
a:visited{ color: var(--visited); }
a:hover{
  background: var(--amber);
  color:#000;
  text-decoration:none;
}

code, pre{ font-family: "Courier New", Courier, monospace; color: var(--amber2); }

.page{
  width: 920px;
  max-width: 95vw;
  margin: 16px auto 60px;
  border: 4px ridge var(--borderA);
  background: var(--panel);
  box-shadow: 0 0 0 4px #000, 0 0 28px rgba(255,176,0,0.16);
}

/* header */
.topbar{
  border-bottom: 4px ridge var(--borderA);
  padding: 10px 12px 8px;
  background:
    linear-gradient(180deg, rgba(176,0,0,0.45), rgba(0,0,0,0.75));
}

.sigil{
  display: table;
  width: 100%;
}
.sigil td{
  border: none;
  vertical-align: middle;
}
.sigil .dot{
  width:16px; height:16px;
  background: var(--blood2);
  border: 2px outset var(--amber2);
  box-shadow: 0 0 16px rgba(255,42,42,0.6);
  display:inline-block;
  margin-right: 10px;
}
h1{
  font-size: 18px;
  margin: 0;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--amber2);
}
.subtitle{
  font-size: 11px;
  color: var(--inkSoft);
  margin-top: 4px;
}

/* marquee */
.marqwrap{
  margin-top: 8px;
  border: 2px groove rgba(255,176,0,0.55);
  background: rgba(0,0,0,0.55);
  padding: 6px;
}
marquee{
  color: var(--amber);
  font-size: 12px;
  letter-spacing: 1px;
}

/* table layout like it's 2001 */
table.layout{
  width:100%;
  border-collapse: collapse;
}
td{
  border: 2px groove rgba(255,176,0,0.35);
  vertical-align: top;
}

/* left nav */
.nav{
  width: 230px;
  background: var(--panel2);
  padding: 10px;
}

.nav h2{
  margin:0 0 8px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--amber2);
  text-transform: uppercase;
}

.nav ul{
  margin:0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.65;
}

/* content */
.main{
  padding: 12px 14px;
  background: rgba(0,0,0,0.62);
}

/* boxes */
.box{
  border: 2px inset rgba(255,176,0,0.25);
  background: rgba(0,0,0,0.45);
  padding: 10px;
  margin: 10px 0;
}
.box h3{
  margin:0 0 6px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--blood2);
}
.tiny{
  font-size: 11px;
  color: var(--inkSoft);
  line-height: 1.55;
}
.hr{
  height: 1px;
  background: rgba(255,176,0,0.28);
  margin: 10px 0;
}

/* construction banner */
.construction{
  font-family: "Courier New", monospace;
  color: var(--amber2);
  background: rgba(255,176,0,0.08);
  border: 1px dashed rgba(255,176,0,0.65);
  padding: 8px;
}

/* stamps/buttons */
.stamp-row{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:8px;
}
.stamp{
  font-size: 10px;
  border: 1px solid rgba(255,176,0,0.25);
  padding: 4px 6px;
  background: rgba(10,0,0,0.8);
  color: var(--amber2);
}

/* blink (since <blink> is dead) */
.blink{ animation: blink 1.05s steps(2, end) infinite; }
@keyframes blink{ 50%{ opacity:0; } }

/* footer */
.footer{
  border-top: 4px ridge var(--borderA);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--inkSoft);
  background: rgba(0,0,0,0.85);
  display:flex;
  justify-content: space-between;
  gap:10px;
  flex-wrap: wrap;
}

/* subtle scanlines (optional vibe) */
.scanlines{
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.10;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,176,0,0.10),
    rgba(255,176,0,0.10) 1px,
    transparent 2px,
    transparent 4px
  );
}

/* --- Relic UI elements --- */
.divider{
  display:block;
  margin: 10px auto;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.button88{
  image-rendering: pixelated;
  border: 1px solid rgba(255,176,0,0.25);
  background: rgba(0,0,0,0.25);
}

.snippet{
  width: 100%;
  box-sizing: border-box;
  background: rgba(0,0,0,0.7);
  color: var(--amber2);
  border: 1px inset rgba(255,176,0,0.35);
  padding: 6px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  resize: none;
}


/* Cursor behavior */
a, button, input[type="button"], input[type="submit"]{
  cursor: var(--cursorPointer), pointer;
}

/* Amber selection highlight */
::selection{
  background: rgba(255,176,0,0.55);
  color: #000;
}

/* --- Mobile cleanup (keep the Web 1.0 vibe, make it readable) --- */
img, video, canvas{
  max-width: 100%;
  height: auto;
}
body{ overflow-x: hidden; }

/* Transmission player sizing (Drive iframe) */
#txWrap iframe{
  width: 100%;
  height: 150px;
  border: 0;
}

/* On small screens, stack the table layout so boxes align */
@media (max-width: 760px){
  /* Mobile gutters: keep the frame visually centered on iOS/Chrome */
  body{
    padding-left: 0;
    padding-right: 0;
    overflow-x: visible; /* prevent right-edge clipping that makes the frame look "squished" */
  }
  .page{
    box-sizing: border-box;
    width: auto;
    max-width: 920px;
    margin: 10px 8px 40px;
    margin-left: calc(8px + env(safe-area-inset-left));
    margin-right: calc(8px + env(safe-area-inset-right));
  }

/* Turn the table layout into a vertical stack */
  table.layout, table.layout tbody, table.layout tr, table.layout td{
    box-sizing: border-box;
    display: block;
    width: 100% !important;
  }

  /* Make borders look intentional when stacked */
  table.layout{ border-collapse: separate; }
  table.layout td{
    box-sizing: border-box;
    border-left: 2px groove rgba(255,176,0,0.35);
    border-right: 2px groove rgba(255,176,0,0.35);
  }

  .nav{
    width: auto !important;
    padding: 10px 10px 2px;
  }

  .main{ padding: 10px; }
  .topbar{ padding: 10px 10px 8px; }
  .topbar h1{ text-align: center; }
  .topbar .subtitle{ text-align: center; }

  h1{ font-size: 14px; letter-spacing: 1px; }
  .subtitle{ font-size: 10px; }

  .marqwrap{ padding: 4px; }
  marquee{ font-size: 11px; }

  /* Make the 468px divider not force overflow */
  .divider{ width: 100%; height: auto; }

  /* Mobile nav becomes a top link grid */
  .nav ul{
    list-style: none;
    padding-left: 0;
    margin: 6px 0 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav ul li{ margin: 0; }
  .nav ul a{
    display: inline-block;
    padding: 6px 8px;
    border: 1px solid rgba(255,176,0,0.45);
    background: rgba(0,0,0,0.55);
    text-decoration: none;
  }

  /* Hide the long copy/paste textarea on phones */
  .nav textarea.snippet{ display: none; }

  /* Give the Drive player enough vertical room (fix overlapping controls) */
  #txWrap iframe{ height: 180px; }

  /* Buttons are easier to tap */
  button, input, select, textarea{ font-size: 14px; }
}

/* Extra-small phones */
@media (max-width: 420px){
  .stamp-row{ gap: 4px; }
  .stamp{ font-size: 9px; }
  .nav ul a{ padding: 5px 7px; }
}


/* --- Mobile refinement: prevent right-edge overflow + keep content inside the border --- */
@media (max-width: 760px){
  /* Make the bordered frame truly contain everything */
  .page{
    width: 100%;
    max-width: 920px;
    box-sizing: border-box;
    overflow-y: visible;
  }

/* Prevent any long strings (URLs, code) from forcing horizontal scroll */
  .page, .nav, .main, .box, .tiny, p, li{
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  table.layout td{
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  a, code, pre{
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* If a link is extremely long, allow it to wrap cleanly */
  a{
    display: inline;
  }

  /* Media + embeds never exceed frame */
  iframe, img, textarea, input, button, select{
    max-width: 100%;
  }

  /* Keep marquee from pushing width */
  .marqwrap{ overflow: hidden; }

  /* Hide the big copy/paste textarea on phones (it’s the #1 overflow culprit on small screens) */
  .snippet{
    display: none;
  }
}


/* --- Collapsible sidebar (mobile-friendly, still Web 1.0) --- */

/* Rune icons for collapsible sidebar (sigil style) */
details.sidefold > summary{
  display: block;
}
details.sidefold > summary::before{
  content: " ";
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 7px;
  vertical-align: -3px;
  background-image: var(--foldClosed);
  background-repeat: no-repeat;
  background-size: 15px 15px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(255,176,0,0.35));
}
details.sidefold[open] > summary::before{
  background-image: var(--foldOpen);
  filter: drop-shadow(0 0 6px rgba(255,42,42,0.25));
}


details.sidefold{
  padding: 0;
}
details.sidefold > summary{
  list-style: none;
  cursor: pointer;
  user-select: none;
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--blood2);
}
details.sidefold > summary::-webkit-details-marker{ display:none; }

/* Add a little triangle indicator */
@media (max-width: 760px){
  details.sidefold > summary{
    font-size: 13px;
    padding: 4px 0;
  }
}


/* Sidefold header styling */
details.sidefold > summary{
  border-bottom: 1px dotted rgba(255,176,0,0.55);
  padding-bottom: 4px;
}
details.sidefold[open] > summary{
  border-bottom: 1px dotted rgba(176,0,0,0.55);
}


/* --- Header animated sigil/logo --- */
.headergif{
  display: block;
  image-rendering: pixelated;
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 0 10px rgba(255,176,0,0.25));
}
.topbar .sigil td{
  vertical-align: top;
}

/* Header banner refinement */
.topbar h1{ margin: 0; }
.headergif{
  margin: 0 auto;
}


/* --- Desktop alignment for banner header (compensate for left dot cell) --- */
@media (min-width: 761px){
  .topbar .sigil{
    width: 100%;
  }
  /* The left dot cell is 30px; shifting the content cell left by half centers the banner */
  .topbar .sigil td:nth-child(2){
    position: relative;
    left: -15px;
  }
  .topbar .subtitle{
    text-align: center;
  }
}


/* --- Remove top-left dot (banner header looks cleaner without it) --- */
.topbar .sigil .dot{
  display: none !important;
}
/* Collapse the empty cell that used to hold the dot */
.topbar .sigil td:first-child{
  width: 0 !important;
  padding: 0 !important;
}
/* Undo the earlier desktop shift now that the dot cell is collapsed */
@media (min-width: 761px){
  .topbar .sigil td:nth-child(2){
    left: 0 !important;
  }
}


/* --- Heaven theme (toggle via <html class="heaven">) --- */
html.heaven{
  --bg: #f5fbff;
  --panel: rgba(255,255,255,0.80);
  --panel2: rgba(235,246,255,0.90);
  --amber: #ffd66a;
  --amber2: #fff2c6;
  --blood: #2a5bd7;
  --blood2: #6aa7ff;
  --ink: #122656;
  --inkSoft: rgba(18,38,86,0.75);
  --link: #1a58d8;
  --visited: #7a4bd6;
  --borderA: rgba(255,215,90,0.85);
  --borderB: rgba(106,167,255,0.70);

  --bgimg: url("/img/tile-heaven.gif");
  --cursorCross: url("/img/heaven-cursor.png") 0 0;
  --cursorPointer: url("/img/heaven-cursor.png") 0 0;
  --foldClosed: url("/img/fold-rune-closed-heaven.gif");
  --foldOpen: url("/img/fold-rune-open-heaven.gif");
}



/* --- Heaven readability pass: keep boxes white, shift text to blues --- */
html.heaven{
  --ink: #10244a;        /* deep navy for body text */
  --inkSoft: #274274;    /* softer navy for secondary text */
  --link: #1a58d8;       /* clear blue link */
  --visited: #6a2bd8;    /* readable purple visited */
}
html.heaven .tiny,
html.heaven p,
html.heaven li,
html.heaven td{
  color: rgba(255,255,255,0.92);
}
html.heaven .box{
  color: rgba(255,255,255,0.92);
}
html.heaven h1, html.heaven h2, html.heaven h3{
  color: #1a58d8;
  text-shadow: none;
}
html.heaven a{
  color: var(--link);
}
html.heaven a:visited{
  color: var(--visited);
}

/* --- Heaven: footer should match the light palette (no dark bar) --- */
html.heaven .footer,
body.heaven .footer{
  background: rgba(255,255,255,0.78);
  color: var(--inkSoft);
}
html.heaven .footer a,
body.heaven .footer a{
  color: var(--link);
}



/* Make panels read well in heaven mode */
html.heaven body{
  text-shadow: none;
}
html.heaven .page{
  box-shadow: 0 0 0 4px rgba(255,255,255,0.55), 0 0 28px rgba(106,167,255,0.22);
}
html.heaven .topbar{
  background: linear-gradient(180deg, rgba(106,167,255,0.30), rgba(255,255,255,0.80));
}
html.heaven .main{
  background: rgba(255,255,255,0.70);
}
html.heaven .box{
  background: rgba(255,255,255,0.65);
}
html.heaven a:hover{
  background: rgba(255,215,90,0.85);
  color: #122656;
}
html.heaven ::selection{
  background: rgba(106,167,255,0.45);
  color: #0b1020;
}

/* Portal button: always looks like the *other* realm */
.portalWrap{ display:flex; justify-content: flex-end; }
.portalBtn{
  font-family: "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 2px outset rgba(255,215,90,0.85);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(160,210,255,0.65));
  color: #122656;
  box-shadow: 0 0 16px rgba(106,167,255,0.35);
}
.portalBtn:hover{
  filter: brightness(1.06);
}
html.heaven .portalBtn{
  border: 2px outset rgba(255,176,0,0.55);
  background: linear-gradient(180deg, rgba(35,0,0,0.92), rgba(120,0,0,0.70));
  color: #ffd27a;
  box-shadow: 0 0 16px rgba(255,42,42,0.20);
}


/* --- Portal flash transition (Heaven/Hell) --- */
.portalFlash{
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 9999;
  /* default (hell-ish) */
  background:
    radial-gradient(circle at 50% 50%, rgba(255,176,0,0.92) 0%, rgba(176,0,0,0.35) 28%, rgba(0,0,0,0) 65%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 3px, rgba(255,90,0,0.10) 4px);
  mix-blend-mode: screen;
  filter: blur(0px) saturate(1.25);
}

.portalFlash.flash-heaven{
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.95) 0%, rgba(160,210,255,0.55) 32%, rgba(0,0,0,0) 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0) 0px, rgba(255,255,255,0) 3px, rgba(255,215,120,0.12) 4px);
  mix-blend-mode: screen;
  filter: blur(0px) saturate(1.1);
}

.portalFlash.flash-hell{
  background:
    radial-gradient(circle at 50% 50%, rgba(255,176,0,0.92) 0%, rgba(255,42,42,0.35) 30%, rgba(0,0,0,0) 70%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 3px, rgba(255,90,0,0.12) 4px);
  mix-blend-mode: screen;
  filter: blur(0px) saturate(1.25);
}

@keyframes portalFlash{
  0%   { opacity: 0; transform: scale(0.98); }
  18%  { opacity: 1; transform: scale(1.00); }
  55%  { opacity: 0.85; transform: scale(1.01); }
  100% { opacity: 0; transform: scale(1.03); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .portalFlash{ display:none; }
}


/* --- Hidden rune gate + secret links --- */
.runeRow{
  margin-top: 6px;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.runeGate{
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--borderB);
  background: rgba(0,0,0,0.35);
  color: var(--amber2);
  text-decoration: none;
  letter-spacing: 1px;
  opacity: 0.55;
  filter: drop-shadow(0 0 6px rgba(255,176,0,0.18));
}
.runeGate:hover{
  opacity: 1;
  border-color: var(--borderA);
}
.secretLinks{
  opacity: 0.8;
}
.secretLinks a{
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px dotted rgba(255,176,0,0.35);
}
.secretLinks a:hover{ border-bottom-style: solid; }

/* --- Node gates: clickable commands --- */
.gateBtns{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.gateBtn{
  display: inline-block;
  padding: 3px 7px;
  border: 1px solid var(--borderB);
  background: rgba(0,0,0,0.28);
  color: var(--amber2);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.95;
}
.gateBtn:hover{
  border-color: var(--borderA);
  opacity: 1;
}

/* --- Hidden node: consolidated directory list --- */
.nodeDir{
  list-style: none;
  padding-left: 0;
  margin: 10px 0 8px;
}
.nodeDir li{
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0;
}
.nodeDir .gateBtn{
  padding: 6px 10px;
  font-size: 13px;
}


/* --- Rare notice toast (system errors / angelic compliance) --- */
#fpaToast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9997; /* under portalFlash, above everything else */
  max-width: min(560px, 92vw);
  padding: 10px 12px;
  border: 1px solid var(--borderA);
  background: rgba(0,0,0,0.88);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.45), 0 0 22px rgba(255,176,0,0.16);
  display: none;
}
#fpaToast.show{ display:block; animation: toastIn 220ms ease-out; }
#fpaToast .tTitle{
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: var(--amber2);
}
#fpaToast .tBody{ color: rgba(255,255,255,0.78); }
#fpaToast .tClose{
  float: right;
  margin-left: 10px;
  border: 1px solid var(--borderB);
  background: transparent;
  color: rgba(255,255,255,0.92);
  cursor: pointer;
  padding: 2px 6px;
  font-family: inherit;
}
#fpaToast .tClose:hover{ border-color: var(--borderA); }

@keyframes toastIn{
  from{ opacity: 0; transform: translateX(-50%) translateY(10px); }
  to{ opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Make toast more "heavenly" in heaven mode */
html.heaven #fpaToast{
  background: rgba(255,255,255,0.92);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.55), 0 0 22px rgba(106,167,255,0.20);
}
html.heaven #fpaToast .tTitle{ color: #1a58d8; }
html.heaven #fpaToast .tBody{ color: rgba(18,38,86,0.85); }

/* --- Shrine gallery --- */
.galleryGrid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.galItem{
  display: block;
  padding: 6px;
  border: 1px solid var(--borderA);
  background: var(--panel2);
  text-decoration: none;
}
.galItem img{
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.galCap{
  margin-top: 6px;
  font-size: 11px;
  color: var(--inkSoft);
  letter-spacing: 0.5px;
}

/* Visions page: smaller “old internet” icon grid */
.visionsGrid{
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
}
.visionsGrid .galItem{
  padding: 6px;
}
.visionsGrid .galCap{
  text-align: center;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.vThumbFrame{
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid rgba(255,176,0,0.45);
  background:
    linear-gradient(180deg, rgba(255,176,0,0.10), rgba(0,0,0,0.55));
}
html.heaven .vThumbFrame{
  border-color: rgba(80,150,255,0.35);
  background: linear-gradient(180deg, rgba(255,255,255,0.65), rgba(180,220,255,0.25));
}

.vThumbFrame img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.vThumbFallback{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", Courier, monospace;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0;
  color: var(--amber2);
  text-shadow: 0 1px 0 rgba(0,0,0,0.85);
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,176,0,0.12),
      rgba(255,176,0,0.12) 6px,
      rgba(176,0,0,0.14) 6px,
      rgba(176,0,0,0.14) 12px
    );
}
html.heaven .vThumbFallback{
  color: #1a58d8;
  text-shadow: 0 1px 0 rgba(255,255,255,0.75);
  background:
    repeating-linear-gradient(
      45deg,
      rgba(80,150,255,0.16),
      rgba(80,150,255,0.16) 6px,
      rgba(255,176,0,0.14) 6px,
      rgba(255,176,0,0.14) 12px
    );
}

.galItem.missing .vThumbFallback{ opacity: 1; }
.galItem.missing img{ opacity: 0; }

.visionsGrid .galItem:hover{
  box-shadow: 0 0 0 2px rgba(255,176,0,0.22), 0 0 16px rgba(255,176,0,0.10);
}
html.heaven .visionsGrid .galItem:hover{
  box-shadow: 0 0 0 2px rgba(80,150,255,0.18), 0 0 16px rgba(80,150,255,0.10);
}

/* Overlay viewer */
#galleryOverlay{
  position: fixed;
  inset: 0;
  z-index: 9996;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.86);
}
#galleryOverlay.open{ display:flex; }
#galleryOverlay .galModal{
  width: min(760px, 92vw);
  border: 1px solid var(--borderA);
  background: rgba(0,0,0,0.92);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.5), 0 0 28px rgba(255,176,0,0.14);
  padding: 10px;
}
html.heaven #galleryOverlay{
  background: rgba(245,251,255,0.88);
}
html.heaven #galleryOverlay .galModal{
  background: rgba(255,255,255,0.94);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.55), 0 0 28px rgba(106,167,255,0.18);
}
#galleryOverlay .galTop{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
#galleryOverlay .galTitle{
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--amber2);
  text-transform: uppercase;
}
html.heaven #galleryOverlay .galTitle{ color: #1a58d8; }
#galleryOverlay .galClose{
  border: 1px solid var(--borderB);
  background: transparent;
  color: rgba(255,255,255,0.92);
  cursor: pointer;
  padding: 2px 8px;
  font-family: inherit;
}
#galleryOverlay .galClose:hover{ border-color: var(--borderA); }
#galleryOverlay .galImg{
  margin-top: 10px;
  text-align:center;
}
#galleryOverlay .galImg img{
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid rgba(255,176,0,0.35);
}
#galleryOverlay .galText{
  margin-top: 8px;
  font-size: 12px;
  color: var(--inkSoft);
}




/* Gallery overlay navigation (Visions next/prev) */
#galleryOverlay .galNav{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}
#galleryOverlay .galNavBtn{
  border: 1px solid var(--borderA);
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.92);
  cursor: pointer;
  padding: 4px 10px;
  font-family: inherit;
  letter-spacing: 1px;
  text-transform: uppercase;
}
#galleryOverlay .galNavBtn:hover{
  border-color: var(--borderB);
}
#galleryOverlay .galCount{
  font-size: 11px;
  color: var(--inkSoft);
  letter-spacing: 1px;
}
html.heaven #galleryOverlay .galNavBtn{
  background: rgba(255,255,255,0.55);
  border-color: rgba(80,150,255,0.35);
  color: rgba(18,38,86,0.92);
}
html.heaven #galleryOverlay .galNavBtn:hover{
  border-color: rgba(255,176,0,0.75);
}

/* Full-res should stay full-res in overlay */
#galleryOverlay .galImg img{
  image-rendering: auto;
  max-height: 70vh;
}

/* --- Ritual player (desktop): soften harsh default audio UI --- */
@media (min-width: 760px){
  #ritualPlayer{
    max-width: 100%;
    border: 1px solid var(--borderA);
    border-radius: 8px;
    padding: 4px;
    background: rgba(0,0,0,0.35);
  }
  /* Many desktop browsers render audio controls very bright; this gently darkens them for Hell mode. */
  html:not(.heaven) #ritualPlayer{
    filter: invert(1) hue-rotate(190deg) saturate(0.85) contrast(1.05);
  }
  /* Keep Heaven clean (no inversion), but slightly reduce glare. */
  html.heaven #ritualPlayer{
    filter: saturate(0.95) contrast(1.05);
    background: rgba(255,255,255,0.35);
    border-color: rgba(255, 208, 120, 0.9);
  }
}



/* --- Sidebar 88x31 link button --- */
.linkButton{
  image-rendering: pixelated;
  border: 1px solid rgba(255,176,0,0.6);
  box-shadow: 0 0 10px rgba(255,176,0,0.15);
}
html.heaven .linkButton{
  border-color: rgba(255, 208, 120, 0.9);
  box-shadow: 0 0 10px rgba(106,167,255,0.12);
}



/* --- Visual polish: cooler glow + crisper panels (low-risk) --- */
.box{
  box-shadow: 0 0 0 1px rgba(255,176,0,0.12), 0 10px 24px rgba(0,0,0,0.55);
}
a:hover{
  text-shadow: 0 0 8px rgba(255,176,0,0.25);
}
html.heaven a:hover, body.heaven a:hover{
  text-shadow: 0 0 10px rgba(106,167,255,0.20);
}
.siteBanner{
  display:block;
  margin: 0 auto;
  filter: drop-shadow(0 0 10px rgba(255,176,0,0.12));
}
html.heaven .siteBanner, body.heaven .siteBanner{
  filter: drop-shadow(0 0 10px rgba(106,167,255,0.18));
}



/* --- Pixel tile sizing (keeps RPG-style tiling consistent on desktop + mobile) --- */
body{
  background-size: 256px 256px;
}



/* --- Pixel banner rendering --- */
.siteBanner, .banner img, .banner{
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}



/* --- FIELD REPORT ticker + SIGIL OF THE DAY --- */
.fieldReport .fieldLine{
  font-weight: bold;
  letter-spacing: 0.5px;
  padding: 6px 8px;
  border: 1px dashed rgba(255,176,0,0.55);
  background: rgba(0,0,0,0.25);
  margin-bottom: 6px;
}
.fieldReport .fieldSub{
  opacity: 0.92;
  padding: 4px 8px;
  border: 1px solid rgba(176,0,0,0.35);
  background: rgba(18,0,0,0.20);
}

html.heaven .fieldReport .fieldLine, body.heaven .fieldReport .fieldLine{
  border-color: rgba(255,208,120,0.8);
  background: rgba(255,255,255,0.55);
}
html.heaven .fieldReport .fieldSub, body.heaven .fieldReport .fieldSub{
  border-color: rgba(106,167,255,0.35);
  background: rgba(240,250,255,0.65);
}

.sigilDay{
  text-align: center;
}
.sigilGlyph{
  font-size: 28px;
  line-height: 1;
  margin: 6px 0 8px;
  text-shadow: 0 0 10px rgba(255,42,42,0.20);
}
.sigilText{
  opacity: 0.95;
  padding: 6px 8px;
  border-top: 1px solid rgba(255,176,0,0.25);
}
html.heaven .sigilGlyph, body.heaven .sigilGlyph{
  text-shadow: 0 0 10px rgba(106,167,255,0.22);
}
html.heaven .sigilText, body.heaven .sigilText{
  border-top-color: rgba(255,208,120,0.35);
}

/* --- CRT MODE (subtle, optional) --- */
.portalBtnSmall{
  margin-left: 8px;
  font-size: 12px;
  padding: 6px 10px;
  opacity: 0.95;
}

html.crt body, body.crt{
  /* tiny contrast bump without killing readability */
  filter: contrast(1.02) saturate(1.03);
}

body.crt::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0.00) 0px,
    rgba(0,0,0,0.00) 2px,
    rgba(0,0,0,0.08) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.35;
}

body.crt::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.25) 68%, rgba(0,0,0,0.45) 100%);
  opacity: 0.65;
}

/* Reduced intensity on small screens */
@media (max-width: 760px){
  body.crt::before{ opacity: 0.22; }
  body.crt::after{ opacity: 0.48; }
}



/* --- DISPLAY MODES (Cathometer-ish) --- */
/* These apply on top of Heaven/Hell, using overlay + filter. */

.portalBtnSmall{
  margin-left: 8px;
  font-size: 12px;
  padding: 6px 10px;
  opacity: 0.98;
  min-width: 108px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* baseline: no overlays */
body.display-off::before, body.display-off::after{ content:none !important; }

/* CRT */
body.display-crt{
  filter: contrast(1.08) saturate(1.08);
}
body.display-crt::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0.00) 0px,
    rgba(0,0,0,0.00) 2px,
    rgba(0,0,0,0.11) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.42;
}
body.display-crt::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.08) 0%, rgba(0,0,0,0.22) 68%, rgba(0,0,0,0.50) 100%),
    repeating-linear-gradient(90deg, rgba(255,0,0,0.02) 0px, rgba(255,0,0,0.02) 1px, rgba(0,255,255,0.02) 2px);
  mix-blend-mode: multiply;
  opacity: 0.78;
}

/* GBA / LCD */
body.display-gba{
  filter: contrast(1.12) saturate(1.18) brightness(1.03);
}
body.display-gba::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.08) 0px, rgba(0,0,0,0.08) 1px, rgba(0,0,0,0.00) 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.05) 0px, rgba(0,0,0,0.05) 1px, rgba(0,0,0,0.00) 4px);
  mix-blend-mode: multiply;
  opacity: 0.55;
}
body.display-gba::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.18) 70%, rgba(0,0,0,0.40) 100%);
  opacity: 0.70;
}

/* Apple II-ish (soft chroma + mild bleed) */
body.display-apple2{
  filter: contrast(1.12) saturate(0.92) sepia(0.18) hue-rotate(-12deg);
}
body.display-apple2::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.00) 0px, rgba(0,0,0,0.00) 5px, rgba(0,0,0,0.09) 6px),
    radial-gradient(circle at 20% 30%, rgba(255,208,120,0.07) 0%, rgba(0,0,0,0) 55%);
  mix-blend-mode: multiply;
  opacity: 0.55;
}
body.display-apple2::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.22) 70%, rgba(0,0,0,0.45) 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 2px, rgba(0,0,0,0.00) 3px);
  opacity: 0.75;
}

/* DOS terminal (amber phosphor) */
body.display-dos{
  filter: grayscale(1) sepia(1) hue-rotate(15deg) saturate(6) contrast(1.12);
}
body.display-dos::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0.00) 0px,
    rgba(0,0,0,0.00) 2px,
    rgba(0,0,0,0.14) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.42;
}
body.display-dos::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,176,0,0.11) 0%, rgba(0,0,0,0.22) 70%, rgba(0,0,0,0.55) 100%);
  opacity: 0.85;
}

/* Mobile: keep overlays lighter */
@media (max-width: 760px){
  body.display-crt::before{ opacity: 0.28; }
  body.display-crt::after{ opacity: 0.55; }
  body.display-gba::before{ opacity: 0.38; }
  body.display-gba::after{ opacity: 0.50; }
  body.display-apple2::before{ opacity: 0.36; }
  body.display-apple2::after{ opacity: 0.55; }
  body.display-dos::before{ opacity: 0.30; }
  body.display-dos::after{ opacity: 0.65; }
}



/* --- Button Wall (Vault) --- */
.buttonWall{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  align-items: center;
  justify-items: center;
  padding: 6px 2px;
}
.btn88{
  display: inline-block;
  width: 88px;
  height: 31px;
  border: 1px solid rgba(255,176,0,0.65);
  background: rgba(0,0,0,0.25);
  box-shadow: 0 0 0 1px rgba(176,0,0,0.35) inset;
}
html.heaven .btn88{
  border-color: rgba(255,208,120,0.80);
  box-shadow: 0 0 0 1px rgba(106,167,255,0.25) inset;
  background: rgba(255,255,255,0.55);
}
.btn88 img{
  width: 88px;
  height: 31px;
  image-rendering: pixelated;
  display: block;
}
.btn88Text{
  width: 88px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  border: 1px dashed rgba(255,176,0,0.65);
  background: rgba(18,0,0,0.25);
  color: rgba(255,255,255,0.92);
  font-size: 10px;
  line-height: 1.05;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.btn88Text:hover{
  filter: brightness(1.06);
}
html.heaven .btn88Text{
  border-color: rgba(255,208,120,0.80);
  background: rgba(240,250,255,0.70);
  color: #14305a;
}

/* --- Handout (Print-friendly) --- */
.handoutBox .handoutTitle{
  margin: 4px 0 6px;
  font-size: 28px;
  letter-spacing: 1px;
  text-align: center;
}
.handoutTag{
  text-align: center;
  opacity: 0.92;
  margin: 0 0 14px;
}
.handoutGrid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0 10px;
}
.handoutPanel{
  border: 1px solid rgba(255,176,0,0.40);
  background: rgba(0,0,0,0.18);
  padding: 10px;
}
html.heaven .handoutPanel{
  border-color: rgba(255,208,120,0.55);
  background: rgba(255,255,255,0.55);
}
.handoutPanel h4{
  margin: 0 0 8px;
  letter-spacing: 1px;
}
.handoutRule{
  margin-top: 10px;
  border-top: 1px solid rgba(255,176,0,0.25);
  padding-top: 10px;
  text-align: center;
}
html.heaven .handoutRule{
  border-top-color: rgba(255,208,120,0.35);
}
@media (max-width: 760px){
  .handoutGrid{ grid-template-columns: 1fr; }
}

/* Print rules: isolate the handout */
@media print{
  body{ background: #fff !important; color: #000 !important; filter: none !important; }
  body::before, body::after{ display: none !important; }
  .nav, .footer, .portalWrap, details.sidefold, #portalFlash, .printHide{ display: none !important; }
  a{ color: #000 !important; text-decoration: none !important; }
  .box{ background: #fff !important; border: 1px solid #000 !important; box-shadow: none !important; }
  .printOnly{ display: block !important; }
}




/* Optional: reduce eye strain in Heaven by slightly lowering brightness when Anti-Fun is on */
html.antifun.heaven body, body.antifun.heaven{
  filter: grayscale(1) contrast(1.04) brightness(0.98);
}

/* Ensure any display-mode overlays do not stack with Anti-Fun */
body.antifun::before,
body.antifun::after{
  content: none !important;
}

/* --- ANTI-FUN (Xerox / zine photocopy mode) --- */
.portalBtnSmall{
  margin-left: 8px;
  font-size: 12px;
  padding: 6px 10px;
  opacity: 0.98;
  min-width: 108px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* Override palette variables so Heaven/Hell become irrelevant while Anti-Fun is active */
html.antifun{
  --bg: #f6f2e9;
  --panel: rgba(255,255,255,0.72);
  --panel2: rgba(255,255,255,0.66);
  --amber: #111111;
  --amber2: #2a2a2a;
  --blood: #111111;
  --blood2: #2a2a2a;
  --ink: #121212;
  --inkSoft: #1f1f1f;
  --link: #0b0b0b;
  --visited: #2b2b2b;
  --borderA: rgba(0,0,0,0.65);
  --borderB: rgba(0,0,0,0.50);
}

/* Kill animated theme backgrounds and replace with paper */
html.antifun body,
body.antifun{
  background: #f6f2e9 !important;
  background-image: none !important;
  color: #141414;
  /* photocopy harshness */
  filter: grayscale(1) contrast(1.35) brightness(0.98);
}

/* Ensure any display-mode overlays do not stack with Anti-Fun */
body.antifun::before,
body.antifun::after{
  content: none !important;
}

/* Add Xerox grime overlays (paper fiber + dots + smudge) */
html.antifun body::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  /* paper fiber + faint smudges */
  background:
    radial-gradient(circle at 18% 22%, rgba(0,0,0,0.08) 0%, rgba(0,0,0,0) 42%),
    radial-gradient(circle at 76% 58%, rgba(0,0,0,0.07) 0%, rgba(0,0,0,0) 46%),
    radial-gradient(circle at 42% 86%, rgba(0,0,0,0.06) 0%, rgba(0,0,0,0) 40%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.02) 0px, rgba(0,0,0,0.02) 1px, rgba(0,0,0,0) 5px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.018) 0px, rgba(0,0,0,0.018) 1px, rgba(0,0,0,0) 7px);
  mix-blend-mode: multiply;
  opacity: 0.55;
}

html.antifun body::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  /* halftone-ish dot grid + vignette */
  background:
    radial-gradient(circle, rgba(0,0,0,0.10) 1px, rgba(0,0,0,0) 1.8px),
    radial-gradient(circle at 50% 50%, rgba(0,0,0,0.00) 0%, rgba(0,0,0,0.14) 70%, rgba(0,0,0,0.22) 100%);
  background-size: 6px 6px, cover;
  background-position: 0 0, center;
  mix-blend-mode: multiply;
  opacity: 0.45;
  animation: xeroxDrift 2.8s steps(2,end) infinite;
}

/* Slight jitter drift for that "copier walking" feel */
@keyframes xeroxDrift{
  0%{ transform: translate(0px,0px); }
  25%{ transform: translate(1px,0px); }
  50%{ transform: translate(1px,1px); }
  75%{ transform: translate(0px,1px); }
  100%{ transform: translate(0px,0px); }
}

@media (prefers-reduced-motion: reduce){
  html.antifun body::after{ animation: none; }
}

/* Make panels look like photocopied cutouts */
html.antifun .box{
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(0,0,0,0.70);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18) inset, 2px 2px 0 rgba(0,0,0,0.22);
}

/* Roughen inner borders and separators */
html.antifun hr{
  border: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(0,0,0,0.75) 0px, rgba(0,0,0,0.75) 6px, rgba(0,0,0,0) 10px);
  opacity: 0.85;
}

/* Links like a printed pamphlet */
html.antifun a{
  color: #0b0b0b !important;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
html.antifun a:hover{
  filter: contrast(1.2);
}

/* Pixelate + dirty up images/gifs (including banners/buttons/sigils) */
html.antifun img,
html.antifun video,
html.antifun canvas{
  image-rendering: pixelated;
  filter: grayscale(1) contrast(1.55) brightness(0.96);
}

/* Make text look slightly ink-bled */
html.antifun body,
html.antifun .box,
html.antifun p,
html.antifun li,
html.antifun td{
  text-shadow: 0.3px 0.4px 0 rgba(0,0,0,0.20), -0.2px 0 0 rgba(0,0,0,0.10);
}

/* Buttons become stamped labels */
html.antifun .portalBtn{
  background: rgba(255,255,255,0.85);
  color: #111;
  border: 1px solid rgba(0,0,0,0.80);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.25);
}
html.antifun .portalBtn:hover{
  filter: contrast(1.12);
}

/* Mobile: keep overlays lighter so it doesn't turn into mud */
@media (max-width: 760px){
  html.antifun body{ filter: grayscale(1) contrast(1.22) brightness(1.02); }
  html.antifun body::before{ opacity: 0.40; }
  html.antifun body::after{ opacity: 0.33; background-size: 7px 7px, cover; }
}



/* --- EGO-DEATH (kaleidoscope drift mode) --- */
html.egodeath{
  /* make existing theme variables less dominant */
  --borderA: rgba(255,255,255,0.38);
  --borderB: rgba(255,255,255,0.22);
}

html.egodeath body,
body.egodeath{
  background: #07080d !important;
  background-image: none !important;
  color: rgba(255,255,255,0.92);
  overflow-x: hidden;
}

/* Disable Anti-Fun paper overlays if both classes ever collide */
html.egodeath body::before,
html.egodeath body::after{
  content: "" !important;
}

/* Rainbow filter overlay (above everything) */
@property --egoHue{
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

/* One layer that color-shifts *everything* on the page */
html.egodeath body::before,
body.egodeath::before{
  content:"" !important;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100000;
  /* low-opacity rainbow tint (acts like a "lens") */
  background:
    conic-gradient(from 0deg,
      rgba(255,0,150,0.18),
      rgba(0,220,255,0.18),
      rgba(255,210,0,0.18),
      rgba(130,255,0,0.18),
      rgba(255,0,150,0.18)
    );
  mix-blend-mode: color;
  opacity: 0.68;
}

/* Prefer backdrop-filter: true hue-shift of the entire page behind the overlay */
@supports ((backdrop-filter: hue-rotate(0deg)) or (-webkit-backdrop-filter: hue-rotate(0deg))){
  html.egodeath body::before,
  body.egodeath::before{
    backdrop-filter: hue-rotate(var(--egoHue)) saturate(2.7) contrast(1.12) brightness(1.05);
    -webkit-backdrop-filter: hue-rotate(var(--egoHue)) saturate(2.7) contrast(1.12) brightness(1.05);
    animation: egoHueShift 1.35s linear infinite, egoFlash 0.72s steps(2,end) infinite;
  }

  @keyframes egoHueShift{ to{ --egoHue: 360deg; } }
}

/* Fallback if backdrop-filter isn't supported: animate the overlay itself */
@supports not ((backdrop-filter: hue-rotate(0deg)) or (-webkit-backdrop-filter: hue-rotate(0deg))){
  html.egodeath body::before,
  body.egodeath::before{
    filter: hue-rotate(0deg) saturate(1.8) contrast(1.08) brightness(1.05);
    animation: egoOverlayHue 1.35s linear infinite, egoFlash 0.72s steps(2,end) infinite;
  }

  @keyframes egoOverlayHue{
    0%{ filter: hue-rotate(0deg) saturate(1.8) contrast(1.08) brightness(1.05); }
    100%{ filter: hue-rotate(360deg) saturate(1.8) contrast(1.08) brightness(1.05); }
  }
}

/* Keep the second pseudo-layer free so other modes don't stack weirdly */
html.egodeath body::after,
body.egodeath::after{
  content: none !important;
}

@keyframes egoFlash{
  0%,100%{ opacity: 0.78; }
  50%{ opacity: 0.32; }
}


/* Floating boxes */
html.egodeath .box{
  background: rgba(0,0,0,0.30);
  border-color: rgba(255,255,255,0.30);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset, 0 8px 30px rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  transform: translate(var(--ego-x, 0px), var(--ego-y, 0px)) rotate(var(--ego-r, 0deg));
  animation: egoFloat var(--ego-d, 10s) ease-in-out infinite;
  animation-delay: var(--ego-delay, 0s);
}

@keyframes egoFloat{
  0%{ transform: translate(calc(var(--ego-x,0px) * -0.6), calc(var(--ego-y,0px) * -0.6)) rotate(calc(var(--ego-r,0deg) * -0.3)); }
  50%{ transform: translate(var(--ego-x,0px), var(--ego-y,0px)) rotate(var(--ego-r,0deg)); }
  100%{ transform: translate(calc(var(--ego-x,0px) * -0.6), calc(var(--ego-y,0px) * -0.6)) rotate(calc(var(--ego-r,0deg) * -0.3)); }
}

@keyframes egoSpin{ from{ transform: rotate(0deg) scale(1.00); } to{ transform: rotate(360deg) scale(1.00); } }
@keyframes egoSpin2{ from{ transform: rotate(0deg) scale(1.06); } to{ transform: rotate(360deg) scale(1.06); } }

@keyframes egoBreathe{
  0%,100%{ filter: blur(0.2px) saturate(1.35) hue-rotate(0deg); }
  50%{ filter: blur(0.6px) saturate(1.80) hue-rotate(40deg); }
}

/* Links become glowing and slightly "alive" */
html.egodeath a{
  color: rgba(255,255,255,0.96) !important;
  text-shadow: 0 0 10px rgba(255,255,255,0.15), 0 0 18px rgba(0,220,255,0.18);
}
html.egodeath a:hover{
  text-shadow: 0 0 10px rgba(255,255,255,0.22), 0 0 22px rgba(255,210,0,0.22);
}

/* Keep nav + footer readable */
html.egodeath .nav,
html.egodeath .footer{
  backdrop-filter: blur(6px);
}

/* Reduced motion: keep colors but stop drifting */
@media (prefers-reduced-motion: reduce){
  body.egodeath::before,
  body.egodeath::after{ animation: none !important; }
  html.egodeath .box{ animation: none !important; transform: none !important; }
}


/* Safety: if both somehow active, prefer EGO-DEATH visuals */
html.antifun.egodeath body{
  background:#07080d !important;
  /* undo photocopy harshness */
  filter: none !important;
}
html.antifun.egodeath img,
html.antifun.egodeath video,
html.antifun.egodeath canvas{
  filter: none !important;
  image-rendering: auto;
}
/* ============================================================
   FPA FUN PACK v9.23 — whispers, lamp, stamps, relic popups
   ============================================================ */

#whisperTip{
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  padding: 6px 8px;
  font-size: 12px;
  letter-spacing: 0.3px;
  border: 1px solid rgba(255,176,0,0.55);
  background: rgba(0,0,0,0.78);
  color: var(--amber2);
  max-width: 220px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.45);
}
html.heaven #whisperTip{
  border-color: rgba(219,178,88,0.65);
  background: rgba(255,255,255,0.86);
  color: #1d3b6d;
}
#whisperTip.on{
  opacity: 1;
  transform: translateY(0);
}

.signalLamp{
  display: inline-block;
  margin-left: 10px;
  padding: 2px 6px;
  font-size: 11px;
  letter-spacing: 0.8px;
  border: 1px solid rgba(255,176,0,0.55);
  background: rgba(0,0,0,0.55);
  color: var(--amber2);
  text-transform: uppercase;
}
html.heaven .signalLamp{
  border-color: rgba(219,178,88,0.65);
  background: rgba(255,255,255,0.78);
  color: #1d3b6d;
}
.signalLamp.sigFlick{
  animation: sigFlick 220ms steps(2,end);
}
@keyframes sigFlick{
  0%{ opacity: 1; }
  50%{ opacity: 0.55; }
  100%{ opacity: 1; }
}
.signalLamp.sigLive{ box-shadow: 0 0 12px rgba(255,176,0,0.14); }
.signalLamp.sigNoise{ box-shadow: 0 0 12px rgba(255,0,0,0.12); }
.signalLamp.sigAscend{ box-shadow: 0 0 12px rgba(220,255,255,0.14); }
.signalLamp.sigDegrade{ box-shadow: 0 0 12px rgba(255,90,0,0.14); }
.signalLamp.sigUnknown{ box-shadow: 0 0 12px rgba(255,255,255,0.08); }

.box{ position: relative; }
.sigilStamp{
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  padding: 0;
  font-family: "Courier New", monospace;
  font-size: 10px;
  line-height: 10px;
  opacity: 0.17;
  pointer-events: none;
  white-space: pre;
  color: var(--amber2);
  text-shadow: 0 0 10px rgba(255,176,0,0.08);
}
html.heaven .sigilStamp{
  opacity: 0.14;
  color: #2a4e85;
  text-shadow: 0 0 10px rgba(219,178,88,0.08);
}
html.antifun .sigilStamp{
  opacity: 0.22;
  color: rgba(0,0,0,0.75);
  text-shadow: none;
}

/* Pocket relic popups */
.relicPop{
  position: fixed;
  left: 16px;
  bottom: 16px;
  width: min(340px, calc(100vw - 32px));
  background: rgba(0,0,0,0.82);
  border: 1px solid rgba(255,176,0,0.68);
  box-shadow: 0 12px 28px rgba(0,0,0,0.55);
  z-index: 99990;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}
.relicPop.on{ transform: translateY(0); opacity: 1; }
.relicPop.bye{ transform: translateY(10px); opacity: 0; }

html.heaven .relicPop{
  background: rgba(255,255,255,0.90);
  border-color: rgba(219,178,88,0.70);
}
html.antifun .relicPop{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.75);
}

.relicHead{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,176,0,0.35);
}
html.heaven .relicHead{ border-bottom-color: rgba(219,178,88,0.35); }
html.antifun .relicHead{ border-bottom-color: rgba(0,0,0,0.25); }

.relicTitle{
  font-size: 12px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--amber2);
}
html.heaven .relicTitle{ color: #1d3b6d; }
html.antifun .relicTitle{ color: #111; }

.relicClose{
  font-size: 18px;
  line-height: 18px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255,176,0,0.45);
  background: rgba(0,0,0,0.45);
  color: var(--amber2);
  cursor: pointer;
}
html.heaven .relicClose{
  border-color: rgba(219,178,88,0.55);
  background: rgba(255,255,255,0.65);
  color: #1d3b6d;
}
html.antifun .relicClose{
  border-color: rgba(0,0,0,0.65);
  background: rgba(255,255,255,0.65);
  color: #111;
}

.relicBody{
  padding: 10px 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.92);
}
html.heaven .relicBody{ color: #1d3b6d; }
html.antifun .relicBody{ color: #111; }

.relicBody code{
  padding: 1px 4px;
  background: rgba(255,176,0,0.16);
  border: 1px solid rgba(255,176,0,0.22);
}
html.heaven .relicBody code{
  background: rgba(219,178,88,0.12);
  border-color: rgba(219,178,88,0.22);
}
html.antifun .relicBody code{
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.18);
}

.relicFoot{
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,176,0,0.25);
}
html.heaven .relicFoot{ border-top-color: rgba(219,178,88,0.25); }
html.antifun .relicFoot{ border-top-color: rgba(0,0,0,0.20); }

.relicOk{
  padding: 6px 10px;
  border: 1px solid rgba(255,176,0,0.55);
  background: rgba(0,0,0,0.55);
  color: var(--amber2);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 12px;
}
html.heaven .relicOk{
  border-color: rgba(219,178,88,0.55);
  background: rgba(255,255,255,0.70);
  color: #1d3b6d;
}
html.antifun .relicOk{
  border-color: rgba(0,0,0,0.65);
  background: rgba(255,255,255,0.70);
  color: #111;
}

/* Gallery overlay (visions) */
#galleryOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99980;
  padding: 18px;
}
#galleryOverlay.on{ display: flex; }
#galleryOverlay .galModal{
  width: min(860px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  background: rgba(0,0,0,0.86);
  border: 1px solid rgba(255,176,0,0.65);
  box-shadow: 0 18px 40px rgba(0,0,0,0.65);
  overflow: hidden;
}
html.heaven #galleryOverlay .galModal{
  background: rgba(255,255,255,0.92);
  border-color: rgba(219,178,88,0.70);
}
html.antifun #galleryOverlay .galModal{
  background: rgba(255,255,255,0.94);
  border-color: rgba(0,0,0,0.75);
}
#galleryOverlay .galTop{
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,176,0,0.35);
}
html.heaven #galleryOverlay .galTop{ border-bottom-color: rgba(219,178,88,0.35); }
html.antifun #galleryOverlay .galTop{ border-bottom-color: rgba(0,0,0,0.20); }
#galleryOverlay .galTitle{
  font-size: 12px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--amber2);
}
html.heaven #galleryOverlay .galTitle{ color: #1d3b6d; }
html.antifun #galleryOverlay .galTitle{ color: #111; }
#galleryOverlay .galClose{
  padding: 6px 10px;
  border: 1px solid rgba(255,176,0,0.55);
  background: rgba(0,0,0,0.55);
  color: var(--amber2);
  cursor:pointer;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 12px;
}
html.heaven #galleryOverlay .galClose{
  border-color: rgba(219,178,88,0.55);
  background: rgba(255,255,255,0.70);
  color: #1d3b6d;
}
html.antifun #galleryOverlay .galClose{
  border-color: rgba(0,0,0,0.65);
  background: rgba(255,255,255,0.70);
  color: #111;
}
#galleryOverlay .galImg{
  padding: 12px;
  text-align: center;
  overflow: auto;
  max-height: calc(100vh - 140px);
}
#galleryOverlay .galImg img{
  max-width: 100%;
  height: auto;
  image-rendering: auto;
}
#galleryOverlay .galText{
  padding: 0 12px 14px;
  font-size: 13px;
  opacity: 0.9;
  color: var(--inkSoft);
}
html.heaven #galleryOverlay .galText{ color: #355d96; }
html.antifun #galleryOverlay .galText{ color: #111; }

/* Glitch Lens */
html.glitchlens img,
html.glitchlens .main img{
  filter: saturate(1.55) contrast(1.35) hue-rotate(35deg) brightness(1.02);
}
html.heaven.glitchlens img{
  filter: saturate(1.25) contrast(1.25) hue-rotate(-25deg) brightness(1.02);
}
html.antifun.glitchlens img{
  filter: contrast(1.70) brightness(0.98);
}
@media (prefers-reduced-motion: no-preference){
  html.glitchlens img{
    animation: glitchHue 3.6s linear infinite;
  }
  @keyframes glitchHue{
    0%{ filter: saturate(1.55) contrast(1.35) hue-rotate(0deg) brightness(1.02); }
    50%{ filter: saturate(1.65) contrast(1.40) hue-rotate(60deg) brightness(1.05); }
    100%{ filter: saturate(1.55) contrast(1.35) hue-rotate(120deg) brightness(1.02); }
  }
  html.heaven.glitchlens img{
    animation: glitchHueHeaven 4.2s linear infinite;
  }
  @keyframes glitchHueHeaven{
    0%{ filter: saturate(1.20) contrast(1.22) hue-rotate(-10deg) brightness(1.02); }
    50%{ filter: saturate(1.30) contrast(1.25) hue-rotate(-45deg) brightness(1.04); }
    100%{ filter: saturate(1.20) contrast(1.22) hue-rotate(-80deg) brightness(1.02); }
  }
}

/* Small in-content Glitch button */
.glitchBtn{ margin-top: 6px; }


/* Terminal + Cipher pages */
.terminalBox .termScreen{
  height: 260px;
  overflow: auto;
  padding: 10px;
  border: 2px inset rgba(255,176,0,0.45);
  background: rgba(0,0,0,0.65);
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(255,255,255,0.92);
}
html.heaven .terminalBox .termScreen{
  background: rgba(255,255,255,0.82);
  border-color: rgba(219,178,88,0.55);
  color: #1d3b6d;
}
html.antifun .terminalBox .termScreen{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.75);
  color: #111;
}

.termLine{ margin: 2px 0; }
.termDim{ opacity: 0.75; }
.termInputRow{
  display:flex;
  gap: 8px;
  align-items:center;
  margin-top: 10px;
}
.termPrompt{
  font-family: "Courier New", monospace;
  font-size: 13px;
  opacity: 0.9;
}
.termInput{
  flex: 1;
  padding: 6px 8px;
  border: 2px inset rgba(255,176,0,0.45);
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.92);
  font-family: "Courier New", monospace;
}
html.heaven .termInput{
  background: rgba(255,255,255,0.78);
  border-color: rgba(219,178,88,0.55);
  color: #1d3b6d;
}
html.antifun .termInput{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.75);
  color: #111;
}

.termBtn{
  padding: 6px 10px;
  border: 2px outset rgba(255,176,0,0.55);
  background: rgba(0,0,0,0.55);
  color: var(--amber2);
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
html.heaven .termBtn{
  border-color: rgba(219,178,88,0.55);
  background: rgba(255,255,255,0.70);
  color: #1d3b6d;
}
html.antifun .termBtn{
  border-color: rgba(0,0,0,0.75);
  background: rgba(255,255,255,0.70);
  color: #111;
}

.cipherPre{
  margin: 6px 0;
  padding: 10px;
  border: 2px inset rgba(255,176,0,0.45);
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.92);
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
}
html.heaven .cipherPre{
  background: rgba(255,255,255,0.82);
  border-color: rgba(219,178,88,0.55);
  color: #1d3b6d;
}
html.antifun .cipherPre{
  background: rgba(255,255,255,0.92);
  border-color: rgba(0,0,0,0.75);
  color: #111;
}

/* ============================================================
   Transmission sidebar player (desktop cleanup)
   - Mobile keeps the Google Drive embed
   - Desktop uses a custom player with stacked seek + volume
   ============================================================ */

#txWrap .tx-custom{
  display:none;
  margin-top: 2px;
  padding: 8px;
  border: 1px solid var(--borderA);
  background: var(--panel2);
  color: rgba(255,255,255,0.92);
}

#txWrap .tx-row{ display:flex; align-items:center; gap:8px; }
#txWrap .tx-row-top{ justify-content:space-between; }
#txWrap .tx-row-vol{ margin-top:8px; }

#txWrap .tx-time{
  font-size: 11px;
  opacity: .85;
  white-space: nowrap;
}

#txWrap .tx-label{
  font-size: 10px;
  opacity: .85;
  letter-spacing: .8px;
}

#txWrap .tx-btn{
  font-family: "Courier New", monospace;
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--borderA);
  background: var(--panel);
  color: rgba(255,255,255,0.92);
  cursor: pointer;
  user-select: none;
}
#txWrap .tx-btn:hover{ filter: brightness(1.05); }

#txWrap .tx-range{
  width: 100%;
  accent-color: var(--link);
}

#txWrap .tx-seek{ margin-top: 6px; }

@media (min-width: 761px){
  /* Desktop: show custom player, hide the narrow Drive iframe */
  #txWrap .tx-custom{ display:block; }
  #txWrap iframe#txFrame{ display:none; }
}

/* Overlay fallback when Drive blocks direct media playback */
#txOverlay{
  position: fixed;
  inset: 0;
  z-index: 9997;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.86);
}
html.heaven #txOverlay{
  background: rgba(245,251,255,0.88);
}
#txOverlay.open{ display:flex; }

#txOverlay .txModal{
  width: min(720px, 92vw);
  border: 1px solid var(--borderA);
  background: var(--panel2);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  padding: 10px;
}
#txOverlay .txModalBar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 8px;
}
#txOverlay .txModalTitle{
  font-family: "Courier New", monospace;
  letter-spacing: 1px;
  font-size: 12px;
  opacity: .9;
}
#txOverlay .txModalClose{
  font-family: "Courier New", monospace;
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--borderA);
  background: var(--panel);
  color: rgba(255,255,255,0.92);
  cursor:pointer;
}
#txOverlay .txModalClose:hover{ filter: brightness(1.05); }

#txOverlay .txModalFrame{
  width: 100%;
  height: 200px;
  border: 0;
  background: transparent;
}


/* --------------------------------------------
   CHARACTER FORGE (Konami mini-game)
   -------------------------------------------- */
#charForgeOverlay{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(0,0,0,0.78);
  z-index: 99999;
}
#charForgeOverlay.open{ display:flex; }
#charForgePanel{
  width: min(920px, 100%);
  max-height: min(92vh, 760px);
  /* Prevent tiny layout overflow from creating a horizontal scrollbar inside the frame */
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--borderA);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  padding: 14px;
}

/* Heaven fix: prevent animated heaven background from bleeding into the forge panel */
body.heaven #charForgePanel{
  background: rgba(255,255,255,0.92);
}

#charForgePanel .cfHeader{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 8px;
}
#charForgePanel .cfTitle{
  font-family: "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 1px;
}
#charForgePanel .cfLeft{ display:flex; flex-direction:column; gap: 8px; }
#charForgePanel .cfRight{ display:flex; flex-direction:column; gap: 10px; }

#charForgeCanvas{
  width: 100%;
  height: auto;
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--borderB);
  border-radius: 8px;
  image-rendering: pixelated;
}
.cfHint{ margin-top: 2px; opacity: 0.82; }
.cfHint .cfKeys{ opacity: 0.9; }

.cfRow{
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: center;
}
.cfRow .cfLabel{
  font-size: 12px;
  letter-spacing: 1px;
  opacity: 0.85;
}
.cfInput, .cfSelect{
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--borderB);
  background: rgba(0,0,0,0.28);
  color: rgba(255,255,255,0.92);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.cfInput:focus, .cfSelect:focus{
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06);
}
html.heaven .cfInput, html.heaven .cfSelect{
  background: rgba(255,255,255,0.70);
  color: rgba(255,255,255,0.92);
}

.cfCycler{
  display: flex;
  align-items: center;
  gap: 6px;
}
.cfSwatch{
  width: 26px;
  height: 16px;
  border: 1px solid var(--borderB);
  border-radius: 4px;
  display: inline-block;
}
.cfActions{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* v2 polish: frame + color tuner + layout */
#charForgePanel{
  position: relative;
  background-image: url("img/tile.gif");
  background-size: 140px 140px;
  background-blend-mode: multiply;
}
html.heaven #charForgePanel{
  background-image: url("img/tile-heaven.gif");
}

/* Heaven: keep the forge panel *static* (no animated tile bleed)
   The site-wide heaven tile is animated; users reported it showing inside the forge box.
   Make the panel background fully opaque + static while preserving borders/frames. */
html.heaven #charForgePanel{
  background-image: none !important;
  background: #F6FCFF !important;
  background-blend-mode: normal !important;
}

/* Heaven: Character Forge readability (make controls/text legible on light panel) */
html.heaven #charForgePanel{
  color: rgba(255,255,255,0.92);
}
html.heaven #charForgePanel .cfTitle,
html.heaven #charForgePanel .cfPickerTitle{
  color: rgba(255,255,255,0.92);
}
html.heaven #charForgePanel .cfLabel,
html.heaven #charForgePanel .cfHint,
html.heaven #charForgePanel .cfPickerLbl{
  color: var(--inkSoft);
  opacity: 1;
}
html.heaven #charForgePanel .gateBtn{
  color: rgba(255,255,255,0.92);
  background: rgba(106,167,255,0.18);
  border-color: rgba(106,167,255,0.55);
}
html.heaven #charForgePanel .gateBtn:hover{
  border-color: var(--borderA);
}

#charForgePanel:before{
  content:"";
  position:absolute;
  inset: 6px;
  border: 1px dashed var(--borderB);
  border-radius: 8px;
  pointer-events:none;
  opacity: 0.75;
}
#charForgePanel:after{
  content:"";
  position:absolute;
  inset: 0px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  pointer-events:none;
}
.cfStack{
  display:flex;
  flex-direction:column;
  gap: 6px;
}
.cfSwatch{
  cursor: pointer;
}
.cfPicker{
  display: none;
  padding: 10px;
  border: 1px solid var(--borderA);
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
}
html.heaven .cfPicker{
  background: rgba(255,255,255,0.60);
}
.cfPicker.open{ display:block; }
.cfPickerTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 8px;
}
.cfPickerTitle{
  font-family: "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 1px;
}
.cfPickerBody{ display:flex; flex-direction:column; gap: 6px; }
.cfPickerRow{
  display:grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items:center;
}
.cfPickerLbl{
  text-align:right;
  opacity: 0.85;
}
.cfPickerSwatch{
  width: 30px;
  height: 20px;
  border: 1px solid var(--borderB);
  border-radius: 4px;
  display:inline-block;
}
.cfPickerActions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.cfSlider{ width: 100%; }
.cfHue{
  background: linear-gradient(to right,
    #ff0000,#ffff00,#00ff00,#00ffff,#0000ff,#ff00ff,#ff0000);
}

@media (max-width: 760px){
  #charForgePanel{
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   MOBILE FRAME CENTERING — FINAL OVERRIDE
   Fixes iOS/Chrome "right gutter missing" caused by tiny
   horizontal overflow + clipping. Uses body padding gutters
   (safe-area aware) so the frame is always symmetrical.
   ========================================================= */
@media (max-width: 760px){
  body{
    /* Symmetrical gutters live on the body so width:100% frames never overflow */
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
    overflow-x: visible; /* keep layout honest; we also prevent overflow below */
  }

  .page{
    box-sizing: border-box;
    width: 100%;
    max-width: 920px;
    margin: 10px auto 40px;
  }

  /* Make sure table layout never exceeds the frame */
  table.layout{ width: 100%; }
  table.layout, table.layout tbody, table.layout tr, table.layout td{
    box-sizing: border-box;
    max-width: 100%;
  }

  /* Force long runs of characters to wrap instead of pushing width */
  .page, .nav, .main, .box, .tiny, p, li, pre, code, marquee{
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  iframe, img, video, canvas, textarea, input, button, select{
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Header: true centering on mobile (dot cell removed so the header doesn't "lean") */
  .topbar table.sigil{ width: 100%; }
  .topbar table.sigil td:first-child{ display: none; }
  .topbar table.sigil td{ text-align: center; }

  /* Marquee wrapper shouldn't create horizontal overflow */
  .marqwrap{ max-width: 100%; overflow: hidden; }
}


/* =========================================================
   HEAVEN READABILITY — FINAL OVERRIDE (v2)
   Fixes washed-out/obscured text when Heaven is engaged.
   Sets proper ink colors and increases panel opacity.
   ========================================================= */
html.heaven body{
  color: rgba(16,36,74,0.94);
}
html.heaven .page,
html.heaven .nav,
html.heaven .main{
  color: rgba(16,36,74,0.94);
}

/* Core typography (was mistakenly white) */
html.heaven p,
html.heaven li,
html.heaven td,
html.heaven .box{
  color: rgba(16,36,74,0.94) !important;
}
html.heaven .tiny{
  color: rgba(39,66,116,0.88) !important;
}

/* Headings + section titles */
html.heaven .nav h2{
  color: #1a58d8;
}

/* Panels: less transparent so the cloud tile can't fight the text */
html.heaven .nav{
  background: rgba(235,246,255,0.94);
}
html.heaven .main{
  background: rgba(255,255,255,0.92);
}
html.heaven .box{
  background: rgba(255,255,255,0.90);
}

/* Links remain readable */
html.heaven a{
  color: var(--link);
}
html.heaven a:hover{
  background: rgba(255,215,90,0.90);
  color: rgba(16,36,74,0.98);
}


/* =========================================================
   HEAVEN READABILITY — LINK/ACCENT COLOR OVERRIDE
   Many accents were gold/yellow; in Heaven they wash out.
   This forces heaven-mode accents to readable blues.
   ========================================================= */
html.heaven a,
html.heaven a:visited{
  color: rgba(30, 95, 255, 0.98) !important;
  text-shadow: none !important;
}

html.heaven a:hover,
html.heaven a:focus{
  color: rgba(10, 70, 255, 1) !important;
  text-shadow: 0 0 6px rgba(30,95,255,0.35) !important;
}

/* Common "gold" utility / accent classes */
html.heaven .gold,
html.heaven .gild,
html.heaven .accent,
html.heaven .sigil,
html.heaven .rune,
html.heaven .warn,
html.heaven .glow,
html.heaven .link,
html.heaven .nav a,
html.heaven .nav a:visited,
html.heaven .tiny a,
html.heaven .tiny a:visited{
  color: rgba(30, 95, 255, 0.98) !important;
}

/* Headings and marquee text can also pick up gold */
html.heaven h1,
html.heaven h2,
html.heaven h3,
html.heaven h4,
html.heaven h5,
html.heaven h6,
html.heaven marquee{
  color: rgba(15, 75, 230, 0.98) !important;
  text-shadow: none !important;
}

