/* ===========================================================================
   Buck Labs Arcade — portal styles
   Kid-friendly: big colorful cards, large touch targets, responsive grid.
   =========================================================================== */

:root {
  --bg-1: #5b2bd9;
  --bg-2: #2b9fd9;
  --card-radius: 22px;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  /* Prevent the page from feeling tiny on hi-dpi tablets */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: #fff;
  /* Slowly shifting purple→blue gradient (keeps the theme, adds motion) */
  background: linear-gradient(160deg, #4a1fb0, #5b2bd9, #6a2fd0, #2b6fd9, #2b9fd9);
  background-size: 300% 300%;
  background-attachment: fixed;
  animation: bgShift 24s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Keep all page content above the moving background */
.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
}

@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Drifting blurred orbs behind the content (lava-lamp feel, purple palette) */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-orbs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.5;
  animation: drift 20s ease-in-out infinite alternate;
}

.bg-orbs span:nth-child(1) { width: 340px; height: 340px; left: 4%;  top: 12%; background: radial-gradient(circle, #b072ff, transparent 70%); animation-duration: 19s; }
.bg-orbs span:nth-child(2) { width: 280px; height: 280px; left: 62%; top: 6%;  background: radial-gradient(circle, #7b3fe4, transparent 70%); animation-duration: 24s; animation-delay: -5s; }
.bg-orbs span:nth-child(3) { width: 380px; height: 380px; left: 30%; top: 55%; background: radial-gradient(circle, #5b2bd9, transparent 70%); animation-duration: 27s; animation-delay: -10s; }
.bg-orbs span:nth-child(4) { width: 240px; height: 240px; left: 78%; top: 58%; background: radial-gradient(circle, #c061d8, transparent 70%); animation-duration: 22s; animation-delay: -3s; }
.bg-orbs span:nth-child(5) { width: 300px; height: 300px; left: 12%; top: 78%; background: radial-gradient(circle, #3f6fe4, transparent 70%); animation-duration: 25s; animation-delay: -8s; }
.bg-orbs span:nth-child(6) { width: 220px; height: 220px; left: 50%; top: 35%; background: radial-gradient(circle, #9a5bff, transparent 70%); animation-duration: 18s; animation-delay: -6s; }

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, -24px) scale(1.12); }
  100% { transform: translate(-26px, 18px) scale(1.05); }
}

/* ---- Header --------------------------------------------------------------- */
.site-header {
  text-align: center;
  padding: 28px 16px 12px;
  position: relative;
}

.site-title {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.4rem);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.site-subtitle {
  margin: 6px 0 0;
  font-size: clamp(1rem, 3vw, 1.4rem);
  opacity: 0.92;
}

/* Live online badge */
.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: bold;
}

.online-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #45e06a;
  box-shadow: 0 0 0 0 rgba(69, 224, 106, 0.7);
  animation: pulse 1.8s infinite;
}

/* "Playing as" name chip — lets anyone set/change the name on their high scores */
.name-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 0 8px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.name-chip:hover { background: rgba(0, 0, 0, 0.4); }
.name-chip:active { transform: scale(0.97); }
#playerName { text-decoration: underline; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(69, 224, 106, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(69, 224, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(69, 224, 106, 0); }
}

/* ---- Game grid ------------------------------------------------------------ */
main {
  flex: 1;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px;
}

.game-grid {
  display: grid;
  /* Auto-fit cards: as many as fit, each at least 240px wide */
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 10px 0 30px;
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 1.3rem;
  opacity: 0.9;
}

/* ---- Game card ------------------------------------------------------------ */
.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: #222;
  background: #fff;
  border-radius: var(--card-radius);
  padding: 26px 18px 22px;
  box-shadow: var(--shadow);
  /* The big tappable target — whole card is the link */
  min-height: 220px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  /* Colored top accent set inline per-game via --accent */
  border-top: 10px solid var(--accent, #888);
  position: relative;
  overflow: hidden; /* clips the corner ribbon to the card */
}

/* Diagonal corner ribbon, e.g. "In Development" */
.card-ribbon {
  position: absolute;
  top: 16px;
  right: -42px;
  transform: rotate(45deg);
  background: #ff6b6b;
  color: #fff;
  font-weight: bold;
  font-size: 0.66rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 5px 46px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.28);
  outline: none;
}

.game-card:active {
  transform: translateY(-2px) scale(0.99);
}

.game-card__emoji {
  font-size: 4.2rem;
  line-height: 1;
  margin-bottom: 10px;
}

.game-card__title {
  margin: 0 0 6px;
  font-size: 1.5rem;
  color: #222;
}

.game-card__desc {
  margin: 0 0 14px;
  font-size: 0.98rem;
  color: #555;
  flex: 1;
}

.game-card__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
}

.badge {
  background: #f0f0f5;
  color: #444;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: bold;
}

.badge--score {
  background: #fff4d6;
  color: #8a6d00;
}

.play-pill {
  margin-top: 14px;
  background: var(--accent, #5b2bd9);
  color: #fff;
  font-weight: bold;
  padding: 10px 26px;
  border-radius: 999px;
  font-size: 1.05rem;
}

/* ---- Leaderboard module --------------------------------------------------- */
.lb-module {
  max-width: 820px;
  margin: 8px auto 36px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--card-radius);
  padding: 18px 18px 22px;
}

/* The games window is wider than the leaderboard so it can fit up to 5 cards. */
.games-module {
  max-width: 1320px;
}

.lb-module__heading {
  text-align: center;
  margin: 0 0 14px;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
}

/* The game-name tabs */
.lb-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.lb-tab {
  font-family: var(--font);
  font-weight: bold;
  font-size: 1rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.22);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 44px; /* comfy touch target */
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.lb-tab:hover {
  background: rgba(0, 0, 0, 0.32);
}

.lb-tab:active {
  transform: scale(0.97);
}

.lb-tab.is-active {
  background: #fff;
  color: #5b2bd9;
  box-shadow: var(--shadow);
}

/* The selected game's scores live here */
.lb-panel {
  background: #fff;
  color: #222;
  border-radius: 16px;
  padding: 8px 14px;
  min-height: 70px;
}

.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 1.05rem;
}

.lb-row:nth-child(odd) {
  background: #f6f5fb;
}

.lb-row__rank {
  width: 2.1rem;
  text-align: center;
  font-weight: bold;
  flex-shrink: 0;
}

.lb-row__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-row__score {
  font-weight: bold;
  color: #5b2bd9;
}

.lb-empty {
  color: #777;
  font-style: italic;
  padding: 6px;
}

/* ---- Footer --------------------------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 18px;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  .game-card,
  .online-dot,
  body,
  .bg-orbs span {
    transition: none;
    animation: none;
  }
}
