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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  animation: palaceIn 1.8s ease forwards;
}

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

body.closing {
  animation: palaceOut 1.2s ease forwards;
}

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

#palace-gif,
#palace-gif2 {
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
  filter: contrast(1.1) brightness(0.95);
}

#anarchy-label {
  font-family: var(--font-body2);
  font-size: 32px;
  letter-spacing: 0em;
  color: rgba(255, 255, 255, 1);
  text-transform: uppercase;
  margin-top: 28px;
  user-select: none;
}

#palace-exit {
  position: fixed;
  top: 18px;
  right: 24px;
  font-family: monospace;
  font-size: 22px;
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: color 0.3s;
  z-index: 10;
  user-select: none;
}
#palace-exit:hover { color: rgba(255, 255, 255, 0.55); }


/* truth */

#truth-layer {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
  display: none;
  pointer-events: none;
}

#truth-bg {
  position: absolute;
  inset: -10%;
  background-image: url('../stuff/truth2.webp');
  background-size: cover;
  background-position: center;
  animation: truthBgDrift 20s ease-in-out infinite alternate;
  opacity: 0.85;
}

#truth-bg2 {
  position: absolute;
  inset: -10%;
  background-image: url('../stuff/truth2.webp');
  background-size: cover;
  background-position: center;
  animation: truthBgDrift 20s ease-in-out infinite alternate,
             ghostSwim 6s ease-in-out infinite;
  opacity: 0.38;
  mix-blend-mode: screen;
}

@keyframes ghostSwim {
  0%   { transform: translate(0px,    0px)   rotate(0deg);    }
  20%  { transform: translate(12px,  -8px)   rotate(0.4deg);  }
  40%  { transform: translate(-8px,  14px)   rotate(-0.6deg); }
  60%  { transform: translate(16px,   6px)   rotate(0.3deg);  }
  80%  { transform: translate(-12px, -10px)  rotate(-0.4deg); }
  100% { transform: translate(0px,    0px)   rotate(0deg);    }
}

@keyframes ghostShake {
  0%   { transform: translate(0px,   0px);  }
  20%  { transform: translate(3px,  -2px);  }
  40%  { transform: translate(-2px,  3px);  }
  60%  { transform: translate(4px,   1px);  }
  80%  { transform: translate(-3px, -2px);  }
  100% { transform: translate(0px,   0px);  }
}

@keyframes truthBgDrift {
  0%   { transform: scale(1.0)  translate(0%,    0%);   }
  25%  { transform: scale(1.06) translate(1.5%,  1%);   }
  50%  { transform: scale(1.1)  translate(-1%,   1.5%); }
  75%  { transform: scale(1.06) translate(-1.5%, -1%);  }
  100% { transform: scale(1.0)  translate(1%,   -1.5%);}
}

#truth-layer.open {
  display: block;
  pointer-events: all;
  animation: truthIn 1.4s ease forwards;
}

#truth-layer.closing {
  animation: truthOut 1.0s ease forwards;
}

@keyframes truthIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes truthOut { from { opacity: 1; } to { opacity: 0; } }

#truth-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 51;
}

.truth-box {
  position: absolute;
  left: var(--x);
  top:  var(--y);
  width: var(--w);
}

.truth-box .truth-text {
  width: 100%;
  min-height: 80px;
  background: #000;
  color: #ffffff;
  border: 2px solid #000000;
  border-radius: 0;
  font-family: 'Microsoft JhengHei', 'SimSun', sans-serif;
  font-size: 32px;
  line-height: 1.5;
  padding: 6px 8px;
  box-shadow: none;
  overflow: hidden;
  word-break: break-word;
  pointer-events: none;
  user-select: none;
}

.truth-box:nth-child(3n) .truth-text { animation: fuckingBoxFlicker 7s infinite; }
.truth-box:nth-child(5n) .truth-text { animation: fuckingBoxFlicker 4.3s infinite 1.2s; }
.truth-box:nth-child(7n) .truth-text { animation: fuckingBoxFlicker 9s infinite 0.5s; }

@keyframes fuckingBoxFlicker {
  0%, 95%, 100% { opacity: 1;   }
  96%            { opacity: 0.4; }
  97%            { opacity: 1;   }
  98%            { opacity: 0.2; }
  99%            { opacity: 0.9; }
}

@keyframes tbardrift {
  0%   { transform: translateX(0px); }
  50%  { transform: translateX(var(--w, 80px)); }
  100% { transform: translateX(0px); }
}

.stretch-box {
  display: none;
  position: fixed;
  width: 18px;
  background: #000000;
  border: 1px solid #111;
  opacity: 1;
  pointer-events: none;
  z-index: 48;
  animation: tbardrift var(--dur, 8s) ease-in-out infinite;
}

body.truth-open .stretch-box {
  display: block;
}

.shake-letter {
  display: inline-block;
  animation: text_lettershake 3s infinite;
  animation-timing-function: ease-in-out;
}

@keyframes text_lettershake {
  0%   { transform: translateY(0px);   }
  25%  { transform: translateY(-0.5px);}
  50%  { transform: translateY(0.5px); }
  75%  { transform: translateY(-0.5px);}
  100% { transform: translateY(0px);   }
}

#truth-exit {
  position: fixed;
  top: 18px;
  right: 24px;
  font-family: monospace;
  font-size: 22px;
  color: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: color 0.3s;
  z-index: 100;
  user-select: none;
}
#truth-exit:hover { color: rgba(255, 255, 255, 0.7); }

.truth-box[onclick] {
  cursor: pointer;
}

.truth-box[onclick] .truth-text {
  cursor: pointer;
}

#trigger-warning {
  transition: opacity 0.6s ease;
}