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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --border: #2a2a38;
  --accent: #6c63ff;
  --accent-hover: #857dff;
  --text: #e8e8f0;
  --muted: #888899;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 3rem;
}

header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #6c63ff, #ff6584);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: var(--muted);
  margin-top: 0.5rem;
  font-size: 1.05rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  max-width: 900px;
  margin: 0 auto;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(108, 99, 255, 0.2);
}

.game-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.game-info h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.game-info p {
  font-size: 0.88rem;
  color: var(--muted);
}

/* Shared game page styles (used by each game's HTML) */
.game-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1rem;
}

.game-page header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 520px;
  margin-bottom: 0;
}

.game-page header h1 {
  font-size: 1.6rem;
  background: linear-gradient(135deg, #6c63ff, #ff6584);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}

.back-link:hover { color: var(--text); }

.score-bar {
  display: flex;
  gap: 2rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.score-bar span { color: var(--text); font-weight: 700; }

canvas {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: var(--accent-hover); }

.status-msg {
  font-size: 1rem;
  color: var(--muted);
  min-height: 1.4rem;
  text-align: center;
}

/* Touch / D-pad controls */
.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.dpad-row {
  display: flex;
  gap: 4px;
}

.dpad-btn {
  width: 76px;
  height: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.08s;
}

.dpad-btn:active { background: #2a2a3e; }
.dpad-center { visibility: hidden; }

.touch-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  user-select: none;
}

.ctrl-btn {
  width: 66px;
  height: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.1s;
}

.ctrl-btn:active { background: #2a2a3e; }
