:root {
  --bg: #08080f;
  --panel: rgba(10, 12, 24, 0.88);
  --panel-strong: rgba(12, 15, 32, 0.96);
  --cyan: #00f5ff;
  --magenta: #ff006e;
  --yellow: #ffe600;
  --green: #00ff88;
  --ink: #f7fbff;
  --muted: #aab4cf;
  --line: rgba(255, 255, 255, 0.13);
  --danger: #ff2d55;
  --pad-size: min(30vw, 25vh, 178px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(0, 245, 255, 0.15), transparent 24%),
    radial-gradient(circle at 78% 80%, rgba(255, 0, 110, 0.15), transparent 28%),
    linear-gradient(135deg, #050711 0%, #0b0d19 48%, #050611 100%);
  color: var(--ink);
  font-family: Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
}

body::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%);
}

body::after {
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
  opacity: 0.25;
}

.back-link {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid rgba(0, 245, 255, 0.28);
  border-radius: 8px;
  background: rgba(7, 8, 20, 0.72);
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  backdrop-filter: blur(14px);
  box-shadow: 0 0 28px rgba(0, 245, 255, 0.28);
}

.game-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  padding: max(66px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.hud {
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(4, minmax(76px, auto));
  gap: 8px;
}

.hud-chip {
  min-width: 76px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 8, 20, 0.68);
  text-align: center;
  backdrop-filter: blur(14px);
}

.hud-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
}

.hud-chip strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-family: Orbitron, sans-serif;
  font-size: clamp(0.9rem, 2vw, 1.15rem);
}

.playfield {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 12px 0;
}

.aurora {
  position: absolute;
  width: min(78vmin, 680px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    conic-gradient(from 20deg, rgba(0, 245, 255, 0.3), rgba(255, 0, 110, 0.24), rgba(255, 230, 0, 0.2), rgba(0, 255, 136, 0.26), rgba(0, 245, 255, 0.3));
  filter: blur(30px);
  opacity: 0.42;
  animation: rotateAurora 18s linear infinite;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: var(--pad-size) var(--pad-size) var(--pad-size);
  grid-template-rows: var(--pad-size) var(--pad-size) var(--pad-size);
  gap: clamp(10px, 2.2vmin, 18px);
  align-items: center;
  justify-items: center;
}

.pad,
.touch-pad {
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  font: 800 0.78rem Orbitron, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pad {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025));
  box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.05), 0 16px 44px rgba(0, 0, 0, 0.32);
  transition: transform 120ms ease, filter 120ms ease, border-color 120ms ease;
}

.pad::before {
  position: absolute;
  inset: 9px;
  border-radius: 6px;
  content: "";
  opacity: 0.35;
  transition: opacity 120ms ease, box-shadow 120ms ease;
}

.pad-up {
  grid-column: 2;
  grid-row: 1;
}

.pad-right {
  grid-column: 3;
  grid-row: 2;
}

.pad-down {
  grid-column: 2;
  grid-row: 3;
}

.pad-left {
  grid-column: 1;
  grid-row: 2;
}

.pad-up::before {
  background: var(--cyan);
  box-shadow: 0 0 28px rgba(0, 245, 255, 0.7);
}

.pad-right::before {
  background: var(--magenta);
  box-shadow: 0 0 28px rgba(255, 0, 110, 0.7);
}

.pad-down::before {
  background: var(--yellow);
  box-shadow: 0 0 28px rgba(255, 230, 0, 0.65);
}

.pad-left::before {
  background: var(--green);
  box-shadow: 0 0 28px rgba(0, 255, 136, 0.68);
}

.pad .arrow {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.65);
}

.pad.active,
.pad.hit {
  transform: scale(1.04);
  border-color: rgba(255, 255, 255, 0.56);
  filter: brightness(1.5);
}

.pad.active::before,
.pad.hit::before {
  opacity: 0.95;
}

.pad.wrong {
  animation: wrongFlash 340ms ease;
}

.core {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  display: grid;
  place-items: center;
  width: min(25vw, 22vh, 158px);
  min-width: 106px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(8, 8, 15, 0.82) 62%);
  box-shadow: 0 0 44px rgba(0, 245, 255, 0.28), inset 0 0 28px rgba(255, 255, 255, 0.08);
}

.charge-ring {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  background: conic-gradient(var(--charge-color, var(--green)) var(--charge-angle, 360deg), rgba(255, 255, 255, 0.12) 0);
  filter: drop-shadow(0 0 16px rgba(0, 255, 136, 0.28));
}

.charge-ring::after {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: rgba(7, 8, 20, 0.94);
  content: "";
}

.charge-fill {
  display: none;
}

.core-orbit {
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(0, 245, 255, 0.42);
  border-radius: 50%;
  animation: rotateAurora 8s linear infinite reverse;
}

.core-text {
  position: relative;
  z-index: 1;
  text-align: center;
}

.core-text span,
.core-text strong {
  display: block;
  font-family: Orbitron, sans-serif;
}

.core-text span {
  color: var(--cyan);
  font-size: clamp(0.62rem, 2vw, 0.82rem);
  font-weight: 800;
}

.core-text strong {
  margin-top: 5px;
  color: var(--ink);
  font-size: clamp(1rem, 4vw, 1.45rem);
}

.status-line {
  position: absolute;
  bottom: 0;
  width: min(560px, 100%);
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 2.5vw, 0.95rem);
  font-weight: 800;
  text-align: center;
}

.controls {
  display: none;
  justify-self: center;
  width: min(360px, 100%);
  gap: 8px;
}

.touch-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.touch-pad {
  min-height: 44px;
  border: 1px solid rgba(0, 245, 255, 0.22);
  background: rgba(7, 8, 20, 0.7);
  color: var(--cyan);
  backdrop-filter: blur(12px);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 78px 18px 24px;
  background: rgba(3, 4, 12, 0.42);
  backdrop-filter: blur(7px);
}

.panel {
  width: min(520px, 100%);
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-strong), rgba(7, 8, 20, 0.9));
  box-shadow: 0 0 34px rgba(0, 245, 255, 0.26), 0 30px 90px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.title,
.over-title {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: clamp(2.2rem, 9vw, 4rem);
  font-weight: 800;
  line-height: 0.95;
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(0, 245, 255, 0.42);
}

.over-title {
  color: var(--magenta);
  font-size: clamp(2rem, 8vw, 3.4rem);
  text-shadow: 0 0 22px rgba(255, 0, 110, 0.45);
}

.subtitle,
.over-game-name,
.hint,
.share-feedback {
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.subtitle,
.over-game-name {
  color: var(--yellow);
  font-size: 0.86rem;
}

.best-row,
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 22px 0;
}

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

.best-row > div,
.stats > div,
.score-block {
  min-width: 0;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.best-row span,
.score-label,
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.best-row strong,
.score-value,
.stat-value {
  display: block;
  margin-top: 4px;
  font-family: Orbitron, sans-serif;
  font-size: clamp(1.25rem, 5vw, 2rem);
  color: var(--ink);
}

.score-block {
  margin-top: 20px;
}

.score-value {
  color: var(--green);
  font-size: clamp(2.2rem, 11vw, 4rem);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #02040a;
  font: 800 0.82rem Orbitron, sans-serif;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 0 30px rgba(0, 245, 255, 0.32);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--yellow), #ff9f1c);
}

.hidden {
  display: none !important;
}

.shake {
  animation: shake 320ms ease;
}

@keyframes rotateAurora {
  to {
    transform: rotate(360deg);
  }
}

@keyframes wrongFlash {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.8);
    border-color: var(--danger);
    box-shadow: 0 0 36px rgba(255, 45, 85, 0.55);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-8px);
  }

  75% {
    transform: translateX(8px);
  }
}

@media (max-width: 760px) {
  :root {
    --pad-size: min(31vw, 20vh, 140px);
  }

  .game-shell {
    padding-top: max(60px, env(safe-area-inset-top));
  }

  .hud {
    justify-self: stretch;
    grid-template-columns: repeat(4, 1fr);
  }

  .hud-chip {
    min-width: 0;
    padding: 8px 5px;
  }

  .hud-chip span {
    font-size: 0.5rem;
  }

  .controls {
    display: grid;
  }

  .status-line {
    bottom: -2px;
  }

  .back-link {
    font-size: 0.76rem;
  }
}

@media (max-width: 430px) {
  :root {
    --pad-size: min(30vw, 17vh, 116px);
  }

  .panel {
    padding: 22px 14px;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .best-row,
  .stats {
    gap: 8px;
  }

  .pad {
    font-size: 0.62rem;
  }
}
