* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #08091a;
  color: #fff;
  overflow: hidden;
}

/* ── Screens ── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── GAP Logo ── */
.gap-logo {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 8px;
  color: #fff;
  background: #0055a5;
  padding: 10px 28px;
  border-radius: 8px;
  margin-bottom: 24px;
  user-select: none;
}
.gap-logo.small { font-size: 26px; letter-spacing: 5px; padding: 7px 18px; margin-bottom: 16px; }
.gap-logo.tiny  { font-size: 18px; letter-spacing: 4px; padding: 4px 12px; margin-bottom: 0; }

/* ── Welcome ── */
.welcome-icon {
  font-size: 80px;
  margin-bottom: 16px;
  animation: bounce 2s infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.welcome-title {
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 900;
  text-align: center;
  background: linear-gradient(135deg, #7c3aed, #2563eb, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
}
.welcome-sub {
  font-size: 18px;
  color: #94a3b8;
  text-align: center;
  max-width: 440px;
  line-height: 1.6;
  margin-bottom: 36px;
}

/* ── Buttons ── */
.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border: none;
  padding: 14px 32px;
  border-radius: 50px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(124, 58, 237, 0.5); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary.big-btn { font-size: 20px; padding: 18px 48px; }

.btn-secondary {
  background: transparent;
  color: #94a3b8;
  border: 2px solid #334155;
  padding: 12px 28px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: #64748b; color: #e2e8f0; }

.nav-row {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  align-items: center;
}

/* ── Pick Screen ── */
.pick-title {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 800;
  margin-bottom: 20px;
  text-align: center;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 4px;
}

@media (max-width: 480px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
}

.game-card {
  background: #131630;
  border: 2px solid #1e2a4a;
  border-radius: 16px;
  padding: 18px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  user-select: none;
}
.game-card:hover { transform: translateY(-3px); border-color: #4f46e5; }
.game-card.selected {
  border-color: #7c3aed;
  background: #1e1b4b;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.35);
}
.game-card-emoji { font-size: 36px; }
.game-card-name { font-size: 13px; font-weight: 700; color: #e2e8f0; text-align: center; }
.game-card-desc { font-size: 11px; color: #64748b; text-align: center; line-height: 1.4; }

/* Card color accents per type */
.game-card[data-id="car-racing"]    { --accent: #f97316; }
.game-card[data-id="dino-jump"]     { --accent: #22c55e; }
.game-card[data-id="space-shooter"] { --accent: #8b5cf6; }
.game-card[data-id="balloon-pop"]   { --accent: #ec4899; }
.game-card[data-id="virtual-pet"]   { --accent: #eab308; }
.game-card[data-id="math-battle"]   { --accent: #ef4444; }
.game-card[data-id="typing-racer"]  { --accent: #06b6d4; }
.game-card[data-id="obstacle-run"]  { --accent: #10b981; }
.game-card[data-id="magic"]         { --accent: #a855f7; }

.game-card.selected { border-color: var(--accent, #7c3aed); box-shadow: 0 0 20px color-mix(in srgb, var(--accent, #7c3aed) 40%, transparent); }
.game-card-emoji { filter: drop-shadow(0 2px 6px rgba(255,255,255,0.1)); }

/* ── Custom / Magic ── */
.step-sub {
  font-size: 15px;
  color: #94a3b8;
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}
.magic-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 500px;
}
.magic-row { display: flex; flex-direction: column; gap: 6px; }
.magic-row label { font-size: 13px; font-weight: 600; color: #94a3b8; }
.magic-row input {
  background: #131630;
  border: 2px solid #1e2a4a;
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.magic-row input:focus { border-color: #7c3aed; }
.magic-row input::placeholder { color: #334155; }

.magic-preview {
  margin-top: 12px;
  padding: 14px 18px;
  background: #0f172a;
  border: 1px solid #1e2a4a;
  border-radius: 12px;
  font-size: 14px;
  color: #a78bfa;
  font-style: italic;
  min-height: 48px;
  line-height: 1.5;
  text-align: center;
  max-width: 500px;
  width: 100%;
}

/* ── Generating ── */
#generatingScreen {
  padding: 16px;
  justify-content: flex-start;
  padding-top: 24px;
}
.gen-header {
  text-align: center;
  margin-bottom: 16px;
}
.gen-icon {
  font-size: 48px;
  animation: spin-slow 3s linear infinite;
}
@keyframes spin-slow {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}
#genTitle {
  font-size: 22px;
  font-weight: 800;
  margin: 10px 0 6px;
}
.gen-status {
  font-size: 14px;
  color: #7c3aed;
  font-weight: 600;
  min-height: 20px;
  transition: opacity 0.3s;
}

/* Terminal */
.code-terminal {
  width: 100%;
  max-width: 700px;
  background: #020617;
  border-radius: 12px;
  border: 1px solid #1e293b;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 230px);
}
.terminal-bar {
  background: #0f172a;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.terminal-dot.red    { background: #ef4444; }
.terminal-dot.yellow { background: #eab308; }
.terminal-dot.green  { background: #22c55e; }
.terminal-label {
  font-size: 12px;
  color: #475569;
  margin-left: 8px;
  font-family: monospace;
}
.code-display {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 11.5px;
  line-height: 1.6;
  color: #4ade80;
  white-space: pre;
  min-height: 0;
}

.gen-stats {
  display: flex;
  gap: 24px;
  margin-top: 10px;
  font-size: 12px;
  color: #475569;
  font-family: monospace;
}

.gen-error {
  text-align: center;
  margin-top: 16px;
}
.gen-error p { color: #f87171; font-size: 15px; margin-bottom: 16px; }

/* ── Play Screen ── */
#playScreen {
  padding: 0;
  justify-content: flex-start;
  align-items: stretch;
}
.play-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: #0a0e27;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.play-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: #e2e8f0;
}
.btn-new-game {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s;
  white-space: nowrap;
}
.btn-new-game:hover { transform: scale(1.04); }

.game-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}
