:root {
  --page-bg: #070d16;
  --panel-bg: rgba(16, 25, 39, 0.88);
  --panel-border: rgba(120, 164, 204, 0.28);
  --panel-shadow: 0 26px 60px rgba(0, 0, 0, 0.42);
  --text-main: #e8f2ff;
  --text-soft: rgba(156, 182, 211, 0.92);
  --accent: #4ea8f5;
  --accent-strong: #ffc072;
  --accent-moss: #78d9b1;
  --chip-bg: rgba(78, 168, 245, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 8% -10%, rgba(78, 168, 245, 0.2), transparent 34%),
    radial-gradient(circle at 88% -18%, rgba(255, 192, 114, 0.14), transparent 32%),
    linear-gradient(180deg, #0e1725 0%, #070d16 58%, #050910 100%);
  color: var(--text-main);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

body {
  padding: 20px 16px 40px;
}

.prehistoric-shell {
  width: min(1220px, 100%);
  margin: 0 auto;
}

.hud-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.hud-left,
.hud-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip,
.btn {
  border-radius: 999px;
  border: 1px solid rgba(137, 190, 235, 0.28);
  background: var(--chip-bg);
  box-shadow: inset 0 1px 0 rgba(216, 236, 255, 0.08);
  color: var(--text-main);
}

.chip {
  padding: 10px 14px;
  font-size: 0.92rem;
}

.chip strong {
  color: #fff7dd;
}

.btn {
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(137, 190, 235, 0.52);
}

.btn.primary {
  background: linear-gradient(130deg, #2c88d2, #44ace9);
  color: #f5faff;
}

.btn.ghost {
  background: rgba(120, 217, 177, 0.12);
}

.btn.donate {
  background: rgba(255, 192, 114, 0.16);
  color: #ffe7c4;
}

.stage-shell {
  position: relative;
  overflow: hidden;
  min-height: 540px;
  border-radius: 32px;
  border: 1px solid rgba(120, 164, 204, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 18%),
    linear-gradient(180deg, rgba(11, 18, 32, 0.84), rgba(7, 13, 22, 0.94));
  box-shadow: var(--panel-shadow);
}

#gameStage {
  position: relative;
  z-index: 1;
  width: 100%;
  touch-action: none;
}

#gameStage canvas {
  display: block;
  touch-action: none;
  outline: none;
}

.overlay-card {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 22px 22px 20px;
  border-radius: 28px;
  border: 1px solid var(--panel-border);
  background:
    radial-gradient(circle at top right, rgba(78, 168, 245, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(16, 25, 39, 0.94), rgba(9, 16, 26, 0.96)),
    var(--panel-bg);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  transform: translate(-50%, -50%);
}

.overlay-card.hidden {
  display: none;
}

.overlay-tag {
  margin: 0 0 12px;
  color: #8fd9ff;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 700;
}

.overlay-card h1,
.overlay-card h2,
.info-card h2 {
  margin: 0;
  font-family: "Cinzel", "Georgia", serif;
  line-height: 1.02;
}

.overlay-card h1 {
  font-size: clamp(2.8rem, 4vw, 4rem);
}

.overlay-card h2 {
  font-size: clamp(2.2rem, 3vw, 3rem);
}

.overlay-copy {
  margin: 14px 0 18px;
  color: var(--text-soft);
  line-height: 1.6;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.saved-run {
  margin: 0 0 14px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.overlay-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.overlay-kpis span,
.mini-board,
.info-card {
  border: 1px solid rgba(120, 164, 204, 0.16);
  background: rgba(8, 15, 24, 0.72);
  box-shadow: inset 0 1px 0 rgba(216, 236, 255, 0.06);
}

.overlay-kpis span {
  padding: 12px 14px;
  border-radius: 18px;
  color: var(--text-soft);
}

.overlay-kpis strong {
  color: #f5fbff;
}

.mini-board {
  border-radius: 22px;
  padding: 18px;
}

.mini-board h2 {
  margin: 0 0 10px;
  font-size: 1.5rem;
}

.mini-board ol {
  margin: 0;
  padding-left: 18px;
  color: var(--text-soft);
  line-height: 1.7;
}

.mini-board strong {
  color: #9bd2ff;
}

.donate-link {
  display: inline-block;
  margin-top: 14px;
  color: #ffd08e;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.info-card {
  padding: 20px 20px 18px;
  border-radius: 24px;
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}

.info-card p,
.info-card li,
.info-card th,
.info-card td {
  color: var(--text-soft);
}

.info-card ul {
  margin: 12px 0 0;
  padding-left: 20px;
  line-height: 1.65;
}

.info-card table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
}

.info-card th,
.info-card td {
  text-align: left;
  padding: 10px 0;
  border-bottom: 1px solid rgba(120, 164, 204, 0.12);
}

.portal-game-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 22px;
  padding: 18px 20px;
  border-radius: 22px;
  border: 1px solid rgba(120, 164, 204, 0.16);
  background: rgba(8, 15, 24, 0.74);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-links a,
.donate-link {
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 1024px) {
  body {
    padding-inline: 12px;
  }

  .hud-bar,
  .portal-game-footer {
    flex-direction: column;
  }

  .overlay-card {
    width: min(400px, calc(100% - 24px));
    padding: 22px 20px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .hud-left,
  .hud-right,
  .overlay-actions {
    width: 100%;
  }

  .btn {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }

  .overlay-kpis {
    grid-template-columns: 1fr;
  }

  .stage-shell {
    min-height: 420px;
  }

  .overlay-card h1 {
    font-size: 2.6rem;
  }
}
