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

body {
  background: #1a1a2e;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  touch-action: none;
}

#cursor-canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
}

/* ─── Overlays ─────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(10, 10, 20, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.overlay.hidden,
.hidden {
  display: none;
}

.overlay-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255,255,255,0.04);
}

/* ─── Title Screen ─────────────────────────────────────────── */

.game-title {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #e94560 0%, #f5a623 50%, #e94560 100%);
  background-size: 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.game-subtitle {
  color: #8892a4;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 6px;
}

.game-desc {
  color: #c0c8d8;
  font-size: 1rem;
  line-height: 1.6;
  margin: 24px 0 32px;
}

/* ─── End Screen ───────────────────────────────────────────── */

.end-card {
  max-width: 520px;
}

.letter-sent {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f5a623, #e94560);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 28px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: #0d1b2a;
  border-radius: 10px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #e0e0e0;
}

.stat-label {
  font-size: 0.68rem;
  color: #8892a4;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fun-fact {
  color: #8892a4;
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 16px;
  min-height: 2.5em;
}


.end-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ─── Buttons ──────────────────────────────────────────────── */

.btn-primary {
  background: linear-gradient(135deg, #e94560, #c0392b);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: none;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(233, 69, 96, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: #8892a4;
  border: 1px solid #0f3460;
  border-radius: 10px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: none;
  transition: color 0.1s, border-color 0.1s;
}

.btn-secondary:hover {
  color: #c0c8d8;
  border-color: #3a5478;
}

/* ─── Game Over Screen ─────────────────────────────────────── */

.game-over-card {
  max-width: 400px;
}

.game-over-header {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #e94560;
  margin-bottom: 20px;
  text-shadow: 0 0 30px rgba(233, 69, 96, 0.5);
}

.game-over-message {
  color: #c0c8d8;
  font-size: 1.05rem;
  line-height: 1.5;
  margin-bottom: 16px;
  min-height: 2em;
}

.game-over-tries {
  color: #8892a4;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

/* ─── Responsive ───────────────────────────────────────────── */

@media (max-width: 480px) {
  .overlay-card {
    padding: 28px 20px;
  }
  .game-title {
    font-size: 2rem;
  }
}

@media (pointer: coarse) {
  /* Touch devices: restore normal cursor on interactive elements */
  .btn-primary,
  .btn-secondary {
    cursor: pointer;
  }

  /* Hide the custom mouse cursor on touch devices */
  #cursor-canvas {
    display: none;
  }
}
