/**
 * End Game Screen CSS
 * Victory (gold) and Game Over (red/glitch) aesthetics
 */

.end-screen-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Courier New", monospace;
}

.end-card {
  width: 600px;
  max-width: 90vw;
  padding: 40px;
  text-align: center;
  border: 4px solid;
}

/* --- FAILURE MODE (Red/Glitch) --- */
.failure-mode {
  background: #000;
  color: #f00;
}

.failure-mode .end-card {
  border-color: #f00;
  background: #100;
  box-shadow: 0 0 50px rgba(255, 0, 0, 0.5);
}

.failure-mode .restart-btn {
  border: 1px solid #f00;
  color: #f00;
  background: transparent;
}

.failure-mode .restart-btn:hover {
  background: #f00;
  color: #000;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
}

/* --- VICTORY MODE (Gold/Ascendant) --- */
.victory-mode {
  background: #050500;
  color: #ffd700;
}

.victory-mode .end-card {
  border-color: #ffd700;
  background: #111100;
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.5);
}

.glow-gold {
  color: #ffd700;
  text-shadow:
    0 0 10px #ffd700,
    0 0 20px #ffd700,
    0 0 30px #ffd700;
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    text-shadow:
      0 0 10px #ffd700,
      0 0 20px #ffd700,
      0 0 30px #ffd700;
  }
  to {
    text-shadow:
      0 0 20px #ffd700,
      0 0 30px #ffd700,
      0 0 40px #ffd700,
      0 0 50px #ffd700;
  }
}

.gold-val {
  font-size: 1.5rem;
  font-weight: bold;
  text-shadow: 0 0 10px #ffd700;
  color: #ffd700;
}

.victory-mode .restart-btn {
  border: 1px solid #ffd700;
  color: #000;
  background: #ffd700;
  font-weight: bold;
}

.victory-mode .restart-btn:hover {
  background: #fff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
  transform: scale(1.05);
}

/* --- SHARED --- */
.end-header {
  margin-bottom: 20px;
}

.end-header h1 {
  margin: 0;
  font-size: 2rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.end-reason {
  margin-bottom: 30px;
  font-size: 1.1rem;
}

.end-reason p {
  margin: 0;
}

.stat-summary {
  margin: 30px 0;
  border-top: 1px dashed currentColor;
  border-bottom: 1px dashed currentColor;
  padding: 20px 0;
}

.stat-summary h3 {
  margin: 0 0 15px 0;
  font-size: 1.2rem;
  text-transform: uppercase;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.narrative-box {
  font-style: italic;
  margin-bottom: 30px;
  opacity: 0.8;
  font-size: 1rem;
  line-height: 1.6;
}

.narrative-box p {
  margin: 0;
}

.restart-btn {
  padding: 20px 40px;
  font-size: 1.2rem;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.3s;
  font-family: "Courier New", monospace;
  letter-spacing: 1px;
}

.restart-btn:hover {
  transform: scale(1.05);
}

/* GLITCH ANIMATION */
.glitch-text {
  animation: shake 0.5s infinite;
  position: relative;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch-text::before {
  left: 2px;
  text-shadow: -2px 0 #f00;
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim-1 0.5s infinite linear alternate-reverse;
}

.glitch-text::after {
  left: -2px;
  text-shadow:
    -2px 0 #0f0,
    2px 2px #00f;
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim-2 0.5s infinite linear alternate-reverse;
}

@keyframes shake {
  0% {
    transform: translate(1px, 1px) rotate(0deg);
  }
  10% {
    transform: translate(-1px, -2px) rotate(-1deg);
  }
  20% {
    transform: translate(-3px, 0px) rotate(1deg);
  }
  30% {
    transform: translate(3px, 2px) rotate(0deg);
  }
  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }
  50% {
    transform: translate(-1px, 2px) rotate(-1deg);
  }
  60% {
    transform: translate(-3px, 1px) rotate(0deg);
  }
  70% {
    transform: translate(3px, 1px) rotate(-1deg);
  }
  80% {
    transform: translate(-1px, -1px) rotate(1deg);
  }
  90% {
    transform: translate(1px, 2px) rotate(0deg);
  }
  100% {
    transform: translate(1px, -2px) rotate(-1deg);
  }
}

@keyframes glitch-anim-1 {
  0% {
    clip: rect(31px, 9999px, 94px, 0);
  }
  20% {
    clip: rect(54px, 9999px, 66px, 0);
  }
  40% {
    clip: rect(28px, 9999px, 84px, 0);
  }
  60% {
    clip: rect(92px, 9999px, 98px, 0);
  }
  80% {
    clip: rect(2px, 9999px, 8px, 0);
  }
  100% {
    clip: rect(76px, 9999px, 79px, 0);
  }
}

@keyframes glitch-anim-2 {
  0% {
    clip: rect(65px, 9999px, 100px, 0);
  }
  20% {
    clip: rect(52px, 9999px, 74px, 0);
  }
  40% {
    clip: rect(12px, 9999px, 36px, 0);
  }
  60% {
    clip: rect(85px, 9999px, 15px, 0);
  }
  80% {
    clip: rect(42px, 9999px, 62px, 0);
  }
  100% {
    clip: rect(8px, 9999px, 98px, 0);
  }
}
