* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a1420;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #eaf6ff;
}

.hidden {
  display: none !important;
}

#back-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 30;
  background: rgba(6, 14, 22, 0.65);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  color: #eaf6ff;
  text-decoration: none;
}

#back-link:hover {
  background: rgba(6, 14, 22, 0.85);
}

#game-canvas {
  display: block;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: #0a1420;
  touch-action: none;
}

#menu, #complete-overlay, #leaderboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(20, 40, 60, 0.6), rgba(4, 10, 16, 0.9));
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
  text-align: left;
}

#leaderboard-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.panel {
  background: rgba(8, 18, 28, 0.75);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2rem 2.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 420px;
  width: min(90vw, 420px);
  max-height: 90vh;
  overflow-y: auto;
}

.panel h1 {
  margin: 0 0 0.25rem;
  background: linear-gradient(90deg, #34e89e, #3b9dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 1.25rem;
  color: #a7bdd1;
  font-size: 0.9rem;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.level-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.2rem;
  border-radius: 10px;
  border: 2px solid var(--accent);
  background: rgba(255, 255, 255, 0.04);
  color: #eaf6ff;
  cursor: pointer;
  font-size: 1rem;
}

.level-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.level-btn .level-name {
  font-weight: 700;
  color: var(--accent);
}

.level-btn .level-sub {
  font-size: 0.8rem;
  color: #a7bdd1;
}

.controls-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  text-align: left;
  font-size: 0.8rem;
  color: #c3d6e5;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 0.75rem 1rem;
}

#progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #34e89e, #3b9dff);
  transition: width 0.05s linear;
}

#hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: #c3d6e5;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: inherit;
  font-size: 1.1rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

button.primary {
  width: 100%;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #34e89e, #3b9dff);
  color: #04121c;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

button.primary:hover {
  filter: brightness(1.08);
}

button.secondary {
  width: 100%;
  padding: 0.6rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: transparent;
  color: #eaf6ff;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.6rem;
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}
