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

.game-container {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 500px; margin: 0 auto;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f0d1a; min-height: 100vh; color: #e2e8f0;
}

.game-header {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 12px 16px;
  background: linear-gradient(135deg, #1a1740, #0f0d2e);
  border-bottom: 1px solid rgba(99,102,241,0.2);
}
.game-title { font-size: 18px; font-weight: 700; color: #a5b4fc; }
.header-right { display: flex; gap: 10px; }
.stat-box { text-align: center; }
.stat-label { display: block; font-size: 9px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 18px; font-weight: 700; color: #e2e8f0; }
.stat-box.best .stat-value { color: #fbbf24; }

.canvas-wrapper {
  flex: 1; display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 8px;
}
#gameCanvas {
  background: #1a1740; border: 2px solid rgba(99,102,241,0.3); border-radius: 8px;
}

.game-over-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75); z-index: 10;
  justify-content: center; align-items: center;
}
.game-over-overlay.active { display: flex; }
.game-over-panel {
  background: linear-gradient(135deg, #1e1b4b, #0a0737);
  border: 1px solid rgba(99,102,241,0.3); border-radius: 16px;
  padding: 32px 28px; text-align: center; max-width: 320px; width: 90%;
}
.game-over-panel h2 { font-size: 28px; color: #ef4444; margin-bottom: 12px; }
.final-score { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.final-score span { color: #a5b4fc; }
.best-score { font-size: 14px; color: #94a3b8; margin-bottom: 20px; }
.best-score span { color: #fbbf24; }
.restart-btn {
  padding: 12px 36px; font-size: 16px; font-weight: 700;
  color: #fff; background: #6366f1; border: none; border-radius: 10px;
  cursor: pointer; transition: background 0.2s;
}
.restart-btn:hover { background: #4f46e5; }

.mobile-controls {
  display: none; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0 16px;
}
.d-pad-row { display: flex; gap: 40px; }
.d-pad-btn {
  width: 50px; height: 50px; font-size: 20px; color: #a5b4fc;
  background: #1a1740; border: 2px solid rgba(99,102,241,0.3); border-radius: 12px;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.d-pad-btn:active { background: #6366f1; color: #fff; }

/* Portrait */
@media (orientation: portrait) {
  #gameCanvas { width: min(92vw, 380px); height: min(92vw, 380px); }
}
/* Landscape */
@media (orientation: landscape) {
  .game-container { flex-direction: column; }
  #gameCanvas { width: min(60vh, 380px); height: min(60vh, 380px); }
  .mobile-controls { display: flex; }
}
@media (pointer: coarse) { .mobile-controls { display: flex; } }
