:root {
  --bg: #08080f;
  --panel: #10101d;
  --panel-2: #171727;
  --cyan: #00f5ff;
  --magenta: #ff006e;
  --yellow: #ffe600;
  --green: #00ff88;
  --danger: #ff3158;
  --ink: #f6fbff;
  --muted: #a6adc7;
  --line: rgba(255, 255, 255, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 18%, rgba(0, 245, 255, 0.16), transparent 32%),
    radial-gradient(circle at 82% 16%, rgba(255, 0, 110, 0.13), transparent 30%),
    linear-gradient(135deg, #08080f 0%, #11111f 58%, #070710 100%);
}

button {
  font: inherit;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.032) 50%, transparent 50%);
  background-size: 100% 4px;
  mix-blend-mode: overlay;
  opacity: 0.3;
}

.back-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 70;
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 10px 12px;
  border: 1px solid rgba(0, 245, 255, 0.35);
  background: rgba(8, 8, 15, 0.84);
  box-shadow: 0 0 18px rgba(0, 245, 255, 0.18);
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 72px 0 28px;
}

.hud,
.arena,
.achievements {
  border: 1px solid var(--line);
  background: rgba(15, 15, 26, 0.88);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.eyebrow,
.stat span,
.result-stats span {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  letter-spacing: 0;
}

h1 {
  margin-top: 8px;
  color: var(--cyan);
  font-size: clamp(1.15rem, 4vw, 2.25rem);
  text-shadow: 0 0 20px rgba(0, 245, 255, 0.45);
}

.stats,
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 10px;
}

.stat,
.result-stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.stat strong,
.result-stats strong {
  display: block;
  margin-top: 6px;
  color: var(--yellow);
  font-family: "Press Start 2P", monospace;
  font-size: 0.9rem;
}

.arena {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 320px;
  gap: 18px;
  margin-top: 18px;
  padding: 18px;
}

#game {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border: 1px solid rgba(0, 245, 255, 0.35);
  background: rgba(3, 4, 12, 0.78);
  box-shadow: inset 0 0 34px rgba(0, 245, 255, 0.13), 0 0 42px rgba(0, 245, 255, 0.14);
}

.forge-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}

.forge-meter {
  height: 12px;
  border: 1px solid rgba(0, 245, 255, 0.45);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#integrity-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--yellow), var(--green), var(--cyan));
  box-shadow: 0 0 18px rgba(0, 245, 255, 0.65);
  transform-origin: left center;
}

.message {
  min-height: 76px;
  margin: 0;
  color: #dce7ff;
  line-height: 1.45;
  font-weight: 800;
}

.forge-button {
  width: 100%;
  min-height: 160px;
  border: 2px solid rgba(0, 245, 255, 0.62);
  background:
    radial-gradient(circle, rgba(255, 230, 0, 0.16), transparent 48%),
    linear-gradient(135deg, rgba(0, 245, 255, 0.18), rgba(255, 0, 110, 0.15));
  color: var(--ink);
  font-family: "Press Start 2P", monospace;
  font-size: 1rem;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  box-shadow: 0 0 24px rgba(0, 245, 255, 0.2), inset 0 0 24px rgba(255, 255, 255, 0.06);
}

.forge-button.is-down {
  border-color: rgba(255, 230, 0, 0.82);
  transform: translateY(1px);
  box-shadow: 0 0 34px rgba(255, 230, 0, 0.28), inset 0 0 34px rgba(255, 230, 0, 0.12);
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
}

.actions button {
  min-height: 44px;
  border: 1px solid rgba(0, 245, 255, 0.44);
  background: rgba(0, 245, 255, 0.12);
  color: var(--ink);
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.actions button:hover,
.actions button:focus-visible,
.forge-button:hover,
.forge-button:focus-visible {
  outline: none;
  background-color: rgba(0, 245, 255, 0.2);
}

.achievements {
  margin-top: 18px;
  padding: 16px;
}

.achievements h2 {
  font-size: 0.9rem;
  color: var(--green);
}

.achievement-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.badge {
  min-height: 48px;
  padding: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.unlocked {
  color: var(--ink);
  border-color: rgba(0, 255, 136, 0.46);
  background: rgba(0, 255, 136, 0.1);
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.12);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 60;
  transform: translate(-50%, 80px);
  padding: 11px 16px;
  background: var(--cyan);
  color: #001015;
  font-weight: 900;
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 4, 10, 0.78);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.result-card {
  width: min(520px, 100%);
  padding: 22px;
  border: 1px solid rgba(0, 245, 255, 0.38);
  background: #10101d;
  box-shadow: 0 0 50px rgba(0, 245, 255, 0.18);
}

.result-card h2 {
  margin-top: 10px;
  color: var(--cyan);
  font-size: 1.2rem;
}

.result-card p:not(.eyebrow) {
  color: #dce7ff;
  line-height: 1.5;
}

.result-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0;
}

@media (max-width: 880px) {
  .shell {
    width: min(100vw - 18px, 760px);
    padding-top: 66px;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .arena {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .forge-button {
    min-height: 118px;
  }
}

@media (max-width: 560px) {
  .back-link {
    top: 8px;
    left: 8px;
    padding: 8px 10px;
    font-size: 0.74rem;
  }

  .shell {
    width: calc(100vw - 12px);
    padding-top: 56px;
  }

  h1 {
    font-size: 1rem;
  }

  .hud,
  .arena,
  .achievements {
    padding: 10px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat {
    padding: 9px;
  }

  .stat span,
  .result-stats span {
    font-size: 0.62rem;
  }

  .stat strong,
  .result-stats strong {
    font-size: 0.78rem;
  }

  .actions,
  .result-stats {
    grid-template-columns: 1fr;
  }

  .achievement-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
