:root {
  --primary: #34d399; /* main green */
  --secondary: #06b6d4; /* teal accent */
  --dark: #03363b; /* deep background/nav */
  --muted: #6b7280; /* secondary text */
  --light: #f8fafc; /* page background */
  --glass: rgba(255, 255, 255, 0.6);
  --accent: #f59e0b; /* warm accent */
  --danger: #ef4444;
  --text: #0f172a;
  --card-shadow: 0 8px 24px rgba(2, 6, 23, 0.08);
  --soft-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
  --radius: 12px;
  --transition: 240ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
}
body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, "Helvetica Neue",
    Arial;
  background: radial-gradient(
      1200px 400px at 10% 10%,
      rgba(6, 182, 212, 0.06),
      transparent 8%
    ),
    radial-gradient(
      800px 300px at 90% 90%,
      rgba(52, 211, 153, 0.04),
      transparent 8%
    ),
    var(--light);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  gap: 1rem;
  padding: 1rem 0;
}

/* Navigation Bar */
nav {
  background: linear-gradient(
    90deg,
    rgba(3, 54, 59, 0.98),
    rgba(3, 54, 59, 0.9)
  );
  color: white;
  padding: 0.75rem 1rem;
  box-shadow: var(--card-shadow);
  border-radius: 14px;
  max-width: 1200px;
  margin: 0 auto;
  width: calc(100% - 2rem);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}

.logo-icon {
  height: 34px;
  width: 34px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(52, 211, 153, 0.15),
    inset 0 -6px 16px rgba(255, 255, 255, 0.06);
  transform-origin: center;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-2px) scale(1.02);
  }
}

.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  transition: all var(--transition);
  font-weight: 600;
  font-size: 0.95rem;
}

.nav-links a:hover {
  transform: translateY(-2px);
  box-shadow: var(--soft-shadow);
  color: white;
  background: rgba(255, 255, 255, 0.03);
}

/* Main Content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem;
  gap: 1.25rem;
  width: calc(100% - 2rem);
  max-width: 1200px;
  margin: 0 auto;
}

.game-title {
  text-align: center;
}

.game-title h1 {
  font-size: 1.6rem;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.game-sub {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Game Container with framed border and subtle glow */
.game-container {
  position: relative;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0.55)
  );
  padding: 18px;
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(6, 54, 55, 0.06);
  display: inline-block;
}

/* Canvas styling — responsive and centered */
#game-canvas {
  display: block;
  background: repeating-linear-gradient(
      45deg,
      rgba(0, 0, 0, 0.01) 0 6px,
      transparent 6px 12px
    ),
    #ffffff;
  border-radius: 10px;
  border: 2px solid transparent;
  box-shadow: 0 10px 30px rgba(3, 54, 59, 0.08);
  width: min(720px, 92vw);
  height: auto;
  max-height: 80vh;
  aspect-ratio: 1 / 1; /* keep square canvas area visually */
  object-fit: cover;
}

/* Fancy gradient border using pseudo-element */
.game-container::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: calc(var(--radius));
  padding: 2px;
  background: linear-gradient(
    120deg,
    rgba(52, 211, 153, 0.08),
    rgba(6, 182, 212, 0.06)
  );
  pointer-events: none;
  z-index: 0;
}

/* overlay */
.game-overlay {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.6), rgba(2, 6, 23, 0.5));
  color: white;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  transform: scale(0.98);
  z-index: 5;
  backdrop-filter: blur(6px) saturate(120%);
}

.game-overlay.visible {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

.game-overlay h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}
.game-overlay p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
}

/* Controls and buttons — nicer buttons with depth */
.game-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
  z-index: 3;
}

.score-display {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.7)
  );
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  box-shadow: var(--soft-shadow);
}

.button {
  background: linear-gradient(180deg, var(--primary), #2bbf93);
  color: white;
  border: none;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.15);
  transition: transform var(--transition), box-shadow var(--transition),
    filter var(--transition);
}

.button:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.12);
  filter: brightness(1.03);
}

.button:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.08);
}

/* Instruction card with glass look */
.instructions {
  width: 100%;
  max-width: 760px;
  padding: 1.25rem;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0.55)
  );
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(3, 54, 59, 0.04);
}

.instructions h2 {
  color: var(--dark);
  margin-bottom: 0.5rem;
}
.instructions p,
.instructions li {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}
.instructions ul {
  margin-left: 1rem;
}

/* Mobile Controls — more modern grid and spacing */
.mobile-controls {
  display: none;
  gap: 0.5rem;
  margin-top: 0.75rem;
  width: min(320px, 86vw);
  justify-items: center;
  align-items: center;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.control-btn {
  background: linear-gradient(180deg, var(--secondary), #0891b2);
  color: white;
  border: none;
  padding: 0.8rem;
  font-size: 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 18px rgba(6, 182, 212, 0.12);
  transition: transform var(--transition), box-shadow var(--transition);
}

.control-btn:active {
  transform: translateY(1px) scale(0.995);
  box-shadow: 0 6px 14px rgba(6, 182, 212, 0.08);
}

.up-btn {
  grid-column: 2;
  grid-row: 1;
}
.left-btn {
  grid-column: 1;
  grid-row: 2;
}
.right-btn {
  grid-column: 3;
  grid-row: 2;
}
.down-btn {
  grid-column: 2;
  grid-row: 3;
}

/* Footer */
footer {
  background: linear-gradient(
    90deg,
    rgba(3, 54, 59, 0.98),
    rgba(3, 54, 59, 0.9)
  );
  color: rgba(255, 255, 255, 0.95);
  padding: 1rem;
  text-align: center;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin: 0 auto;
  width: calc(100% - 2rem);
  max-width: 1200px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 0.6rem 0;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition), transform var(--transition);
}
.footer-links a:hover {
  color: var(--primary);
  transform: translateY(-2px);
}

.copyright {
  font-size: 0.875rem;
  opacity: 0.85;
  color: rgba(255, 255, 255, 0.88);
}

/* Accessibility focus */
a:focus,
.button:focus,
.control-btn:focus {
  outline: 3px solid rgba(52, 211, 153, 0.22);
  outline-offset: 4px;
  border-radius: 10px;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.06);
}

/* Responsive */
@media (max-width: 900px) {
  .nav-links {
    display: none;
  }
  .game-container {
    width: 100%;
    padding: 14px;
  }
  .instructions {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .mobile-controls {
    display: grid;
  }
  #game-canvas {
    width: min(560px, 92vw);
    aspect-ratio: 1/1;
  }
  .game-title h1 {
    font-size: 1.2rem;
  }
  .logo {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .nav-container {
    flex-direction: row;
    gap: 0.5rem;
    justify-content: space-between;
  }
  .game-container {
    padding: 12px;
    border-radius: 10px;
  }
  #game-canvas {
    width: 92vw;
    aspect-ratio: 1/1;
  }
  .instructions {
    padding: 0.85rem;
    border-radius: 10px;
  }
}
