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

:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --accent: #e94560;
  --accent-light: #ff6b81;
  --text: #eee;
  --text-muted: #aaa;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Game container fills viewport */
#game-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* HUD overlay */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  z-index: 10;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-label {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Overlay screens (menu, game over) */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  text-align: center;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.overlay-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 12px;
}

.overlay-subtitle {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.overlay-score {
  font-size: 64px;
  font-weight: 800;
  color: var(--accent-light);
  margin-bottom: 8px;
}

.overlay-highscore {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.btn {
  display: inline-block;
  padding: 14px 36px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.95);
  background: var(--accent-light);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-muted);
  margin-top: 12px;
  padding: 10px 28px;
  font-size: 14px;
}

.btn-secondary:active {
  background: rgba(255,255,255,0.1);
}

/* Landing page styles */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  padding-top: max(40px, env(safe-area-inset-top));
  overflow-y: auto;
}

.landing-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.landing-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 500px;
}

.game-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s;
  border: 2px solid transparent;
}

.game-card:active {
  transform: scale(0.96);
  border-color: var(--accent);
}

.game-card-icon {
  font-size: 48px;
  margin-bottom: 8px;
  line-height: 1;
}

.game-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.game-card-highscore {
  font-size: 12px;
  color: var(--text-muted);
}
