/* Gallery styles for games.cryptobyte.dev.
   Individual games have their OWN styles inside their own folder - this file is
   only for the gallery (the root index.html). */

:root {
  --bg: #0f0f16;
  --panel: #1b1b24;
  --btn: #23232e;
  --btn-hover: #2e2e3d;
  --border: #33333f;
  --fg: #e8e8f0;
  --muted: #9a9ab0;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd4;

  /* Feed the GameKit UI widget the same palette so it blends in. */
  --gk-bg: var(--bg);
  --gk-panel: var(--panel);
  --gk-btn: var(--btn);
  --gk-btn-hover: var(--btn-hover);
  --gk-border: var(--border);
  --gk-fg: var(--fg);
  --gk-muted: var(--muted);
  --gk-accent: var(--accent);
  --gk-accent-hover: var(--accent-hover);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 15, 22, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}
.brand .dot { color: var(--accent); }
.brand small {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Back-to-arcade link, shared with the game pages. The label collapses to just
   the arrow on small screens (handy for the installed PWA). */
.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.back:hover { color: var(--fg); }
@media (max-width: 680px) {
  .back-label { display: none; }
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 3rem);
}

.intro { margin-bottom: 2.5rem; }
.intro h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.03em;
}
.intro p {
  color: var(--muted);
  margin: 0;
  max-width: none; /* span the full width of the games grid below (shorter, wider) */
}

/* The games grid. Add <a class="game-card"> children - see index.html. */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}
.game-card.soon {
  pointer-events: none;
  opacity: 0.55;
}
/* The title link is stretched to cover the whole card, so clicking anywhere
   opens the game. Interactive children (the username link) opt back out with a
   higher z-index. */
.card-link {
  color: inherit;
  text-decoration: none;
}
.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
/* Playable elsewhere but not on this device: greyed, still clickable (the game
   page explains where to play). */
.game-card.unavailable {
  opacity: 0.5;
  filter: grayscale(0.7);
}
.game-card.unavailable:hover {
  transform: none;
  border-color: var(--border);
  opacity: 0.65;
}

.game-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  background: linear-gradient(135deg, #2a2a3a, #1a1a26);
}
/* Current version, tucked in the thumbnail corner. */
.game-version {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  font-family: "Courier New", monospace;
  font-size: 0.68rem;
  color: #e8e8f0;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  backdrop-filter: blur(2px);
}

/* Trophy progress badge (top-left of the thumbnail). Gold when all earned. */
.game-trophies {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #e8e8f0;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  backdrop-filter: blur(2px);
  font-variant-numeric: tabular-nums;
}
.game-trophies .gt-icon { font-size: 0.8rem; line-height: 1; }
.game-trophies.complete {
  color: #ffd166;
  background: rgba(255, 209, 102, 0.16);
  border-color: rgba(255, 209, 102, 0.55);
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.25);
}

/* Release-stage badge (bottom-right of the thumbnail). */
.game-stage {
  position: absolute;
  bottom: 0.55rem;
  right: 0.55rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.14rem 0.45rem;
  border-radius: 6px;
  backdrop-filter: blur(2px);
}
.game-stage.alpha {
  color: #ffc196;
  background: rgba(255, 120, 40, 0.22);
  border: 1px solid rgba(255, 140, 60, 0.55);
}
.game-stage.beta {
  color: #aebdff;
  background: rgba(90, 120, 255, 0.22);
  border: 1px solid rgba(110, 140, 255, 0.55);
}

/* flex:1 so the score footer aligns to the bottom across cards of a row. */
.game-body { flex: 1; padding: 1rem 1.1rem 1.2rem; }
.game-body h3 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.game-body p { margin: 0; font-size: 0.9rem; color: var(--muted); }

/* Footer: overall high score + holder. */
.game-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 1.1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}
.game-score .score-main {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.game-score .score-trophy { font-size: 0.95rem; }
.game-score .score-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.game-score a.score-user {
  position: relative;
  z-index: 2; /* sits above the stretched card link so it's clickable */
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-score a.score-user:hover {
  color: var(--fg);
  text-decoration: underline;
}
.game-score.empty { color: var(--muted); }

/* Second footer row: the signed-in user's own best. Deliberately distinct from
   the overall high above (accent tint + dashed divider + accent value). */
.game-score.you {
  border-top: 1px dashed var(--border);
  padding-top: 0.5rem;
  padding-bottom: 0.75rem;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.game-score.you .score-you-icon { font-size: 0.9rem; }
.game-score.you .score-you-label {
  color: var(--muted);
  font-size: 0.82rem;
}
.game-score .you-value { color: var(--accent); }

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.8rem;
}
.game-tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--btn);
  color: var(--muted);
  border: 1px solid var(--border);
}
.game-tag.soon {
  color: #ffd166;
  border-color: #5a4a1a;
  background: #2a2416;
}
.game-tag.platform {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 16px;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.site-footer a:hover {
  color: var(--fg);
}

/* ============================================================
   Shared stats components (used by the game details page and the
   profile): panels, the small scale/filter select, and trophy cards.
   ============================================================ */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.2rem 1.2rem;
  margin-bottom: 1.5rem;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.panel-title {
  font-weight: 600;
  font-size: 1.05rem;
}
.panel-sub {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}
.scale-select {
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}
.scale-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* ---- trophies ---- */
.trophy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem;
}
.trophy {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}
.trophy.earned {
  border-color: rgba(255, 209, 102, 0.4);
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.07), transparent);
}
.trophy.locked .trophy-icon,
.trophy.unearned .trophy-icon {
  filter: grayscale(1);
  opacity: 0.55;
}
.trophy-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  background: var(--panel);
  border: 1px solid var(--border);
}
.trophy.earned .trophy-icon {
  background: rgba(255, 209, 102, 0.14);
  border-color: rgba(255, 209, 102, 0.4);
}
.trophy-icon img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.trophy-body {
  min-width: 0;
  flex: 1;
}
.trophy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.trophy-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.trophy-pill {
  flex: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  color: var(--muted);
  border: 1px solid var(--border);
}
.trophy.earned .trophy-pill {
  color: #ffd166;
  background: rgba(255, 209, 102, 0.13);
  border-color: rgba(255, 209, 102, 0.32);
}
.trophy-desc {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.2rem 0 0.5rem;
}
.trophy-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: hidden;
}
.trophy-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.trophy.earned .trophy-bar > span {
  background: #ffd166;
}
.trophy-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.trophy-empty {
  color: var(--muted);
  padding: 1.5rem 0.5rem;
}
