:root {
  --pg-bg: #0a0818;
  --pg-neon: #00f0ff;
  --pg-pink: #ff40a0;
  --pg-grid: #1a1830;
}

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

body {
  font-family: 'Share Tech Mono', monospace;
  background: var(--pg-bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255, 64, 160, 0.22) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 240, 255, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, #12102a 0%, #070512 100%);
  min-height: 100vh;
  color: #c8d0ff;
}

#pg-app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  text-align: center;
}

.pg-brand {
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: var(--pg-pink);
  opacity: 0.8;
  text-shadow: 0 0 12px rgba(255, 64, 160, 0.5);
}

.pg-header h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.1rem, 4.5vw, 1.55rem);
  color: var(--pg-neon);
  text-shadow:
    0 0 12px rgba(0, 240, 255, 0.8),
    0 0 36px rgba(0, 240, 255, 0.45),
    0 0 72px rgba(255, 64, 160, 0.25);
  margin: 8px 0;
  animation: pg-title-glow 2.8s ease-in-out infinite;
}

@keyframes pg-title-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

.pg-tagline {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-bottom: 16px;
}

.pg-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 10px;
  font-size: 0.72rem;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 8px;
}

.pg-seed {
  opacity: 0.65;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

.pg-status strong { color: var(--pg-neon); }

.pg-board-wrap {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(0, 240, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(255, 64, 160, 0.25),
    0 0 40px rgba(0, 240, 255, 0.25),
    0 0 80px rgba(255, 64, 160, 0.12),
    inset 0 0 60px rgba(0, 0, 0, 0.4);
}

.pg-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #080616;
}

.pg-grid--hit {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: none;
  margin: 0;
}

.pg-hit {
  cursor: pointer;
  background: transparent;
}

.pg-hit--dead {
  cursor: default;
}

.pg-hit:not(.pg-hit--dead):hover {
  background: rgba(0, 240, 255, 0.08);
  box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.15);
}

.pg-grid--loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 22, 0.92);
  z-index: 2;
}

.pg-generating {
  font-size: 0.75rem;
  color: var(--pg-neon);
  animation: pg-pulse 1.2s ease-in-out infinite;
}

@keyframes pg-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.pg-tile {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: linear-gradient(145deg, #1a1730 0%, #0e0c1c 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: background 0.15s, box-shadow 0.2s, transform 0.12s, border-color 0.15s;
  user-select: none;
  overflow: visible;
}

.pg-tile:hover:not(.pg-fixed) {
  background: linear-gradient(145deg, #262248 0%, #161230 100%);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.35);
  border-color: rgba(0, 240, 255, 0.4);
  transform: scale(1.04);
}

.pg-tile.pg-live {
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.75), inset 0 0 16px rgba(0, 240, 255, 0.12);
  background: linear-gradient(145deg, rgba(0, 240, 255, 0.22), rgba(0, 100, 140, 0.18));
  border-color: rgba(0, 240, 255, 0.55);
  animation: pg-live-pulse 1.4s ease-in-out infinite;
}

@keyframes pg-live-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(0, 240, 255, 0.55), inset 0 0 12px rgba(0, 240, 255, 0.1); }
  50% { box-shadow: 0 0 24px rgba(0, 240, 255, 0.9), inset 0 0 20px rgba(0, 240, 255, 0.18); }
}

.pg-icon {
  position: relative;
  z-index: 1;
  line-height: 1;
}

.pg-port {
  position: absolute;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  z-index: 0;
  pointer-events: none;
}

.pg-port-live {
  background: var(--pg-neon);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.85);
}

.pg-port-n {
  top: -2px;
  left: 50%;
  width: 5px;
  height: 42%;
  transform: translateX(-50%);
}

.pg-port-e {
  right: -2px;
  top: 50%;
  width: 42%;
  height: 5px;
  transform: translateY(-50%);
}

.pg-port-s {
  bottom: -2px;
  left: 50%;
  width: 5px;
  height: 42%;
  transform: translateX(-50%);
}

.pg-port-w {
  left: -2px;
  top: 50%;
  width: 42%;
  height: 5px;
  transform: translateY(-50%);
}

.pg-tile.pg-fixed { cursor: default; }

.pg-tile.pg-source {
  background: linear-gradient(145deg, rgba(255, 64, 160, 0.35), rgba(120, 20, 80, 0.25));
  border-color: rgba(255, 64, 160, 0.5);
  box-shadow: 0 0 16px rgba(255, 64, 160, 0.35);
}

.pg-tile.pg-target {
  background: linear-gradient(145deg, rgba(255, 200, 64, 0.28), rgba(120, 80, 20, 0.2));
  border-color: rgba(255, 200, 64, 0.45);
  box-shadow: 0 0 14px rgba(255, 200, 64, 0.25);
}

.pg-msg {
  font-size: 0.75rem;
  margin: 14px 0;
  opacity: 0.85;
  min-height: 2.5em;
}

.pg-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.pg-actions button {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 10px 18px;
  border: 1px solid var(--pg-neon);
  background: transparent;
  color: var(--pg-neon);
  border-radius: 6px;
  cursor: pointer;
}

.pg-actions button:hover {
  background: rgba(0, 240, 255, 0.15);
}

.pg-actions .pg-muted {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.5);
}

.pg-win {
  position: fixed;
  inset: 0;
  background: rgba(4, 2, 12, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.pg-win[hidden] { display: none !important; }

.pg-win h2 {
  font-family: 'Orbitron', sans-serif;
  color: var(--pg-neon);
  text-shadow: 0 0 24px rgba(0, 240, 255, 0.6);
}

.pg-win button {
  font-family: inherit;
  padding: 12px 28px;
  background: var(--pg-pink);
  border: none;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.pg-exit {
  position: fixed;
  top: 12px;
  right: 12px;
  font-size: 0.75rem;
  color: rgba(200, 208, 255, 0.6);
  text-decoration: none;
}

.pg-exit:hover { color: var(--pg-neon); }
