/* games.css — TinkyGames overlay + hub + per-game UI.
 *
 * Namespace: .tg-* — all rules scoped, won't bleed into board-builder or
 * kiosk UI. AAC-first: minimum 80px tap targets on game controls (board
 * is 48dp/64dp because users tap rapidly; games are tappable once per
 * direction so the larger target wins).
 *
 * Color-blind safety: blues + yellows + purples; never red+green-only as
 * the only signal.
 */

/* ─── Fullscreen overlay (single-game) ───────────────────────── */
.tg-overlay {
  position: fixed;
  inset: 0;
  background: #050816;
  z-index: 99998;
  display: flex;
  flex-direction: column;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.tg-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  overflow: hidden;
  min-height: 0;
}
.tg-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.2);
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10;
}
.tg-close:hover, .tg-close:focus {
  background: rgba(255, 255, 255, 0.2);
  outline: 2px solid #ffd54f;
}

/* ─── HUD ────────────────────────────────────────────────────── */
.tg-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 60px 8px 12px; /* right padding clears close button */
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 18px;
}
.tg-hud-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.tg-hud-item b {
  font-size: 22px;
  color: #ffd54f;
}

/* ─── Canvas container ──────────────────────────────────────── */
.tg-canvas-box {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0e1a2b;
  border-radius: 8px;
  overflow: hidden;
}
.tg-canvas {
  display: block;
  image-rendering: pixelated;
  max-width: 100%;
  max-height: 100%;
}

/* ─── D-pad / control row ───────────────────────────────────── */
.tg-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
}
.tg-dpad-row {
  display: flex;
  gap: 8px;
}
.tg-dpad-btn {
  min-width: 80px;
  min-height: 80px;
  font-size: 32px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.tg-dpad-btn:active {
  background: rgba(255, 213, 79, 0.3);
  border-color: #ffd54f;
}
.tg-dpad-btn.tg-fire {
  min-width: 120px;
  background: rgba(239, 83, 80, 0.2);
  border-color: rgba(239, 83, 80, 0.5);
}

/* ─── Game-Over panel ───────────────────────────────────────── */
.tg-gameover {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(92%, 480px);
  height: fit-content;
  align-self: center;
  background: #1a2332;
  border: 2px solid #ffd54f;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
  z-index: 20;
  top: 50%;
  transform: translateY(-50%);
}
.tg-gameover-title { font-size: 32px; font-weight: 700; color: #ffd54f; }
.tg-gameover-sub   { font-size: 18px; color: #cfd8dc; }
.tg-btn {
  min-height: 56px;
  padding: 0 24px;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.tg-btn-primary {
  background: #ffd54f;
  color: #050816;
  border-color: #ffd54f;
}
.tg-btn:active { transform: translateY(1px); }

/* ─── Spelling Bee ───────────────────────────────────────────── */
.tg-spell-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px;
  overflow-y: auto;
}
.tg-spell-emoji { font-size: 80px; line-height: 1; }
.tg-spell-slots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tg-spell-slot {
  width: 56px;
  height: 64px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
}
.tg-spell-slot-filled {
  background: #2196f3;
  border-color: #2196f3;
}
.tg-spell-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tg-spell-letter {
  min-width: 56px;
  min-height: 56px;
  font-size: 22px;
  font-weight: 700;
  background: #1a2332;
  color: #fff;
  border: 2px solid #2196f3;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.tg-spell-letter:active { background: #2196f3; }

/* ─── Math Adventure ─────────────────────────────────────────── */
.tg-math-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px;
  overflow-y: auto;
}
.tg-math-emoji { font-size: 64px; line-height: 1; }
.tg-math-story { font-size: 16px; color: #cfd8dc; text-align: center; max-width: 420px; }
.tg-math-expr  { font-size: 40px; font-weight: 700; color: #ffd54f; }
.tg-math-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(100%, 420px);
}
.tg-math-choice {
  min-height: 80px;
  font-size: 28px;
  font-weight: 700;
  background: #1a2332;
  color: #fff;
  border: 2px solid #2196f3;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.tg-math-choice:active { background: #2196f3; }
.tg-math-right { background: #ffd54f !important; color: #050816 !important; border-color: #ffd54f !important; }
.tg-math-wrong { background: #ab47bc !important; color: #fff !important; border-color: #ab47bc !important; }

/* ─── Games Hub launcher ─────────────────────────────────────── */
.tg-hub {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 22, 0.96);
  z-index: 99997;
  display: flex;
  flex-direction: column;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.tg-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tg-hub-title { font-size: 24px; font-weight: 700; }
.tg-hub-close { position: static; }
.tg-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}
.tg-hub-card {
  background: linear-gradient(160deg, #1a2332 0%, #2a3a55 100%);
  color: #fff;
  border: 2px solid rgba(33, 150, 243, 0.4);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  min-height: 180px;
  touch-action: manipulation;
}
.tg-hub-card:hover, .tg-hub-card:focus {
  border-color: #ffd54f;
  outline: none;
}
.tg-hub-card-icon { font-size: 56px; line-height: 1; }
.tg-hub-card-name { font-size: 18px; font-weight: 600; text-align: center; }
.tg-hub-card-play {
  margin-top: auto;
  background: #2196f3;
  padding: 8px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.tg-hub-empty { padding: 40px; text-align: center; color: #cfd8dc; }
