/* ===========================
   Games Hub — full stylesheet
   =========================== */

/* Page layout */
.games-hub { padding: 2rem 1rem; }
.games-hub__header { max-width: 900px; margin: 0 auto 2rem; text-align: center; }

/* Flexbox layout (no CSS Grid, no gap) */
.games-hub__grid {
  display: flex;
  flex-wrap: wrap;
  margin: -0.75rem; /* creates gutters with child margins */
}
.games-hub__card {
  flex: 1 1 320px;         /* min width 320px, grows to fill */
  max-width: 560px;        /* keep cards reasonable on large screens */
  margin: 0.75rem;
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.07);
}
.games-hub__desc { margin-top: .75rem; opacity: .85; }

/* Game container + HUD */
.mini-game {
  position: relative;
  display: block;
  width: 100%;
  max-width: 520px;        /* cap canvas on laptops/desktops to avoid scrolling */
  margin: 0 auto;          /* center inside the card */
}
.mini-game canvas {
  width: 100%;             /* responsive display; intrinsic size from width/height attrs */
  height: auto;
  border-radius: 12px;
  background: #0e0f12;     /* shows before first draw */
  display: block;
  touch-action: none;      /* smooth gestures on touch devices */
}
.mini-game__hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .5rem;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Controls (no 'gap' used) */
.mini-game__controls { display: flex; }

/* Space buttons without universal selector */
.mini-game__controls .mini-game__btn + .mini-game__btn { margin-left: .5rem; }

.mini-game__btn {
  padding: .4rem .7rem;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #f6f7f8;
  cursor: pointer;
}
.mini-game__btn:hover { background: #eef0f2; }
.mini-game__score { opacity: .85; }

/* Dark mode (optional) */
@media (prefers-color-scheme: dark) {
  .games-hub__card { background: #16181d; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
  .games-hub__desc, .mini-game__score { color: #d9dee7; }
  .mini-game__btn { background: #22252b; border-color: #2d323a; color: #e6e9ee; }
  .mini-game__btn:hover { background: #2b2f36; }
}

/* Slightly smaller caps on very wide layouts */
@media (min-width: 1200px) {
  .mini-game { max-width: 480px; }
}

/* Mobile layout */
@media (max-width: 480px) {
  .games-hub { padding: 1rem .75rem; }
  .games-hub__card { padding: .75rem; border-radius: 12px; }

  /* Stack HUD vertically on small screens */
  .mini-game__hud {
    flex-direction: column;
    align-items: stretch;
  }

  .mini-game__controls { display: flex; }
  .mini-game__controls .mini-game__btn + .mini-game__btn { margin-left: .5rem; }

  /* Easier to tap */
  .mini-game__btn {
    padding: .6rem .8rem;
    font-size: 15px;
  }

  /* Nudge score below controls */
  .mini-game__score { margin-top: .5rem; }
}

/* ===========================
   D-Pad (touch controls)
   =========================== */
.mini-game__dpad {
  margin-top: .6rem;
  display: none;               /* hidden by default, enabled on small screens */
}
.dpad-grid { 
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dpad-row {
  display: flex;
  margin: .4rem 0;
}
.dpad { 
  min-width: 56px; 
  min-height: 48px;
  font-size: 18px;
  line-height: 1;
}

/* Show D-Pad on mobile-sized screens */
@media (max-width: 640px) {
  .mini-game__dpad { display: block; }
}

/* Optional: always show D-Pad for Snake even on desktop */
.mini-game[data-game="snake"] .mini-game__dpad { display: block; }

/* Space left/right buttons without 'gap' */
.dpad-row .dpad + .dpad { margin-left: .5rem; }

