:root {
  --ink: #0a1218;
  --ink-2: #12202b;
  --fog: #8aa0b0;
  --paper: #e8f0f4;
  --north: #4ec4e8;
  --north-deep: #1a7fa0;
  --south: #e89a4e;
  --south-deep: #b85f1a;
  --iron: #9aa7b2;
  --danger: #e85a5a;
  --field: rgba(78, 196, 232, 0.18);
  --ok: #6dd6a2;
}

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

html,
body {
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
}

body {
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 55% at 15% 10%, rgba(78, 196, 232, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 85%, rgba(232, 154, 78, 0.12), transparent 50%),
    linear-gradient(165deg, #0c1620 0%, #0a1218 45%, #101820 100%);
  pointer-events: none;
  z-index: 0;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.015) 3px,
    rgba(255, 255, 255, 0.015) 4px
  );
  opacity: 0.7;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1008px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.top {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: rise 0.7s ease-out both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 18px;
  height: 36px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--north) 0 50%, var(--south) 50% 100%);
  box-shadow: 0 0 24px rgba(78, 196, 232, 0.35);
  animation: pulse-mark 2.4s ease-in-out infinite;
}

.brand h1 {
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 0.95;
}

.tag {
  color: var(--fog);
  font-size: 1.05rem;
  font-weight: 500;
  max-width: 36ch;
}

.stage-wrap {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(138, 160, 176, 0.18),
    0 30px 80px rgba(0, 0, 0, 0.45);
  animation: rise 0.85s 0.08s ease-out both;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  background: #0d1822;
  cursor: crosshair;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(78, 196, 232, 0.16), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(232, 154, 78, 0.14), transparent 40%),
    rgba(8, 14, 20, 0.82);
  backdrop-filter: blur(4px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  width: min(420px, calc(100% - 48px));
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.2, 1.1) both;
}

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--north);
}

.overlay-card h2 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.overlay-card p {
  color: var(--fog);
  line-height: 1.45;
  font-size: 1rem;
}

#overlayBtn {
  margin-top: 8px;
  border: 0;
  padding: 12px 28px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--north), #2a9bb8);
  color: #041018;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

#overlayBtn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

#overlayBtn:active {
  transform: translateY(0);
}

.controls {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  color: var(--fog);
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  animation: rise 1s 0.14s ease-out both;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.hud-block .label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog);
}

.hud-block span:last-child {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.polarity.north {
  color: var(--north);
}

.polarity.south {
  color: var(--south);
}

.hint span:last-child {
  font-weight: 500;
  color: var(--fog);
  font-size: 0.92rem;
  white-space: normal;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulse-mark {
  0%,
  100% {
    box-shadow: 0 0 18px rgba(78, 196, 232, 0.3);
  }
  50% {
    box-shadow: 0 0 28px rgba(232, 154, 78, 0.35);
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100%, calc(100% - 20px));
    padding-top: 18px;
  }

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

  .hint {
    grid-column: 1 / -1;
  }

  .tag {
    font-size: 0.95rem;
  }
}
