/* Game over / victory overlay */

body.game-end-open {
  overflow: hidden;
}

body.game-end-open .toolbar,
body.game-end-open .map-stage,
body.game-end-open canvas,
body.game-end-open .sim-date-bar,
body.game-end-open .perf-hud,
body.game-end-open .resource-hud,
body.game-end-open .right-hud-stack,
body.game-end-open .system-context-menu {
  visibility: hidden;
  pointer-events: none;
}

.game-end[hidden] {
  display: none !important;
}

.game-end {
  --end-cyan: #3ec8ff;
  --end-cyan-dim: rgba(62, 200, 255, 0.45);
  --end-accent-line: rgba(120, 210, 255, 0.35);
  --end-card-bg: rgba(4, 16, 36, 0.88);
  --end-card-border: rgba(90, 190, 255, 0.38);

  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vh, 40px);
  color: #f4f9ff;
  font-family: Rajdhani, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(8, 40, 80, 0.35) 0%, transparent 70%),
    linear-gradient(180deg, rgba(2, 8, 22, 0.92) 0%, rgba(2, 10, 28, 0.96) 100%);
  user-select: none;
}

.game-end::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(62, 200, 255, 0.1);
  box-shadow: inset 0 0 100px rgba(0, 40, 80, 0.4);
}

.game-end--victory {
  --end-cyan: #5ee8a8;
  --end-cyan-dim: rgba(94, 232, 168, 0.45);
  --end-accent-line: rgba(120, 240, 180, 0.35);
  --end-card-border: rgba(90, 220, 160, 0.42);
}

.game-end--defeat {
  --end-cyan: #ff6b6b;
  --end-cyan-dim: rgba(255, 107, 107, 0.4);
  --end-accent-line: rgba(255, 140, 120, 0.35);
  --end-card-border: rgba(220, 100, 90, 0.42);
}

.game-end__card {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  padding: clamp(28px, 4vh, 40px) clamp(24px, 4vw, 36px);
  border: 1px solid var(--end-card-border);
  border-radius: 2px;
  background: var(--end-card-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 12px 48px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(0, 0, 0, 0.25);
}

.game-end__title {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 32px var(--end-cyan-dim);
}

.game-end--victory .game-end__title {
  color: #e8fff4;
  text-shadow: 0 0 36px rgba(94, 232, 168, 0.35);
}

.game-end--defeat .game-end__title {
  color: #ffe8e8;
  text-shadow: 0 0 36px rgba(255, 107, 107, 0.3);
}

.game-end__subtitle {
  margin: 12px 0 0;
  font-size: clamp(0.95rem, 1.4vw, 1.05rem);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-align: center;
  color: rgba(180, 210, 240, 0.88);
  line-height: 1.45;
}

.game-end__stats {
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.game-end__stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 8px 12px;
  border: 1px solid rgba(62, 200, 255, 0.12);
  border-radius: 2px;
  background: rgba(2, 10, 24, 0.55);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.game-end__stat-label {
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(160, 190, 220, 0.9);
  flex-shrink: 0;
}

.game-end__stat-value {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-align: right;
}

.game-end__actions {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

.game-end__btn {
  min-width: 200px;
  min-height: 48px;
  padding: 0 28px;
  border: 1px solid var(--end-card-border);
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(12, 32, 58, 0.65) 0%, rgba(4, 14, 32, 0.9) 100%);
  color: #eef6ff;
  font-family: Rajdhani, sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 4px 24px rgba(0, 0, 0, 0.35);
}

.game-end__btn:hover,
.game-end__btn:focus-visible {
  border-color: var(--end-cyan);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 24px var(--end-cyan-dim),
    0 6px 28px rgba(0, 0, 0, 0.4);
  outline: none;
}

.game-end__btn:active {
  transform: translateY(1px);
}

@media (prefers-reduced-motion: reduce) {
  .game-end__btn {
    transition-duration: 0.01ms;
  }

  .game-end__btn:active {
    transform: none;
  }
}
