:root {
  --bg: #0a0f1a;
  --bg-card: #141b28;
  --bg-card-hover: #1b2433;
  --border: #283446;
  --text: #f4f7fb;
  --text-dim: #93a3b8;
  --accent: #38bdf8;
  --accent-dim: #38bdf833;
  --accent-fg: #06121e;
  --radius: 12px;
  --max-width: 1240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
}

/* Ambient depth: faint brand-yellow glows that drift very slowly behind all
   content. Fixed + z-index:-1 sits above the html base color but below body
   content. Opacity is kept low so text contrast is unaffected. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 78% -8%, rgba(56, 189, 248, 0.06), transparent 70%),
    radial-gradient(55% 45% at 12% 112%, rgba(56, 189, 248, 0.045), transparent 70%);
  animation: bg-drift 32s ease-in-out infinite alternate;
}
@keyframes bg-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(0, -2%, 0) scale(1.06); }
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }

/* ---- a11y utilities ---- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10001;
  transform: translateY(-150%);
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  transition: transform 140ms ease;
}
.skip-link:focus {
  transform: translateY(0);
  color: var(--accent-fg);
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ---- keyboard focus ---- */

.card:focus-visible,
.pill:focus-visible,
.hero:focus-visible,
.recent-card:focus-visible,
.sort-select:focus-visible,
.surprise-btn:focus-visible,
.empty-reset:focus-visible,
.back-to-top:focus-visible,
.submit-btn:focus-visible,
.search-clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- header ---- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(14, 14, 20, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.site-logo .dot { color: var(--accent); }

.logo-mark {
  height: 24px;
  width: auto;
  flex: none;
  display: block;
  overflow: visible;
}
.logo-mark .play-tri {
  fill: var(--accent);
  stroke: var(--accent);
  transform-box: fill-box;
  transform-origin: center;
  animation: logo-press 4s ease-in-out infinite;
}
.logo-mark .play-ring {
  fill: none;
  stroke: var(--accent);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: logo-ripple 4s ease-out infinite;
}
.site-logo:hover .logo-mark { filter: brightness(1.12); }

/* Every few seconds the mark "plays": it dips like a pressed button, pops back
   with a little overshoot, and sends a ripple ring outward. It rests as the
   plain triangle (ring invisible), so the reduced-motion fallback is fine. */
@keyframes logo-press {
  0%, 62%   { transform: scale(1); }
  72%       { transform: scale(0.82); }
  84%       { transform: scale(1.09); }
  94%, 100% { transform: scale(1); }
}
@keyframes logo-ripple {
  0%, 66%  { transform: scale(0.5); opacity: 0; }
  74%      { opacity: 0.5; }
  100%     { transform: scale(1.7); opacity: 0; }
}

.tagline {
  color: var(--text-dim);
  font-size: 14px;
  flex: 1;
  display: none;
}
@media (min-width: 720px) {
  .tagline { display: block; }
}

.submit-btn {
  margin-left: auto;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.submit-btn:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ---- container ---- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 20px 56px;
}

/* ---- search ---- */

.search-form {
  position: relative;
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration { display: none; }

.search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.search-clear:hover { color: var(--text); background: var(--border); }

/* ---- catalog controls (sort / surprise / count) ---- */

.catalog-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.result-count {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.surprise-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 120ms ease, color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.surprise-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.surprise-icon { width: 15px; height: 15px; display: block; transition: transform 200ms ease; }
.surprise-btn:hover .surprise-icon { transform: rotate(-18deg) scale(1.08); }
.surprise-btn:active .surprise-icon { transform: rotate(10deg) scale(0.95); }

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sort-label {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}
.sort-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 30px 8px 12px;
  background-color: var(--bg-card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%239a9aa0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 120ms ease;
}
.sort-select:hover { border-color: var(--accent-dim); }
.sort-select:focus { outline: none; border-color: var(--accent); }

/* ---- recently played ---- */

.recent { margin-bottom: 24px; }
.recent-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.recent-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.recent-row::-webkit-scrollbar { display: none; }
.recent-card {
  flex: 0 0 auto;
  width: 132px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.recent-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}
.recent-thumb {
  aspect-ratio: 1 / 1;
  background: #0a0a12;
  overflow: hidden;
}
.recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.recent-name {
  padding: 8px 10px 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- hero (featured game) ---- */

#hero { margin-bottom: 24px; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  background: linear-gradient(135deg, #1a1a1f 0%, #131318 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
}
/* Slow brand-yellow sheen in the top-right corner so the featured slot subtly
   breathes. Sits above the gradient but the children paint over it. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 85% at 100% 0, rgba(56, 189, 248, 0.10), transparent 55%);
  animation: hero-glow 9s ease-in-out infinite alternate;
}
@keyframes hero-glow {
  from { opacity: 0.4; }
  to   { opacity: 0.85; }
}

/* Game player chrome: fade the back-link, header, and frame in on load
   instead of popping. Reuses card-rise; harmless on pages without #root. */
#root > * { animation: card-rise 360ms ease backwards; }
#root > *:nth-child(2) { animation-delay: 60ms; }
#root > *:nth-child(3) { animation-delay: 120ms; }
.hero:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px -12px var(--accent-dim);
  color: var(--text);
}
.hero:active { transform: translateY(0); }

.hero-image {
  aspect-ratio: 16 / 9;
  background: #0a0a12;
  overflow: hidden;
  position: relative;
}
.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-body {
  padding: 20px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero-tag {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 0;
}

.hero-by {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  margin: -2px 0 0;
}

.hero-desc {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.hero-cta {
  margin-top: 4px;
  align-self: flex-start;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

@media (min-width: 720px) {
  .hero {
    grid-template-columns: 1.2fr 1fr;
    align-items: stretch;
  }
  .hero-image { aspect-ratio: auto; height: 100%; min-height: 240px; }
  .hero-body { padding: 28px 28px 30px; gap: 12px; justify-content: center; }
  .hero-title { font-size: 32px; }
  .hero-desc { font-size: 16px; }
}

/* ---- category pills ---- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

/* On narrow screens the pills scroll horizontally with an edge fade instead
   of wrapping, keeping the row to a single line. */
@media (max-width: 639px) {
  .pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  }
  .pills::-webkit-scrollbar { display: none; }
  .pill {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }
}

.pill {
  display: inline-block;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
  text-transform: capitalize;
}
.pill:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 4px 14px -6px var(--accent-dim);
}

/* Favorites pill: heart + optional count badge. */
.pill-fav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill-fav .heart-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.pill-fav.active .heart-icon { fill: var(--accent-fg); stroke: var(--accent-fg); }
.pill-fav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.pill-fav.active .pill-fav-count {
  background: rgba(10, 10, 14, 0.25);
  color: var(--accent-fg);
}

/* ---- grid + cards ---- */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px -18px var(--accent-dim);
}
.card:active { transform: translateY(0); }

/* Staggered fade-up entrance. `backwards` fill hides cards during their delay
   and reverts to the base transform when done, so :hover lift still works.
   Skeletons are excluded; reduced-motion collapses this to an instant appear. */
.grid .card:not(.skeleton) {
  animation: card-rise 320ms ease backwards;
}
.grid .card:not(.skeleton):nth-child(1) { animation-delay: 0ms; }
.grid .card:not(.skeleton):nth-child(2) { animation-delay: 30ms; }
.grid .card:not(.skeleton):nth-child(3) { animation-delay: 60ms; }
.grid .card:not(.skeleton):nth-child(4) { animation-delay: 90ms; }
.grid .card:not(.skeleton):nth-child(5) { animation-delay: 120ms; }
.grid .card:not(.skeleton):nth-child(6) { animation-delay: 150ms; }
.grid .card:not(.skeleton):nth-child(7) { animation-delay: 180ms; }
.grid .card:not(.skeleton):nth-child(8) { animation-delay: 210ms; }
.grid .card:not(.skeleton):nth-child(n+9) { animation-delay: 240ms; }

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

.card-thumb {
  aspect-ratio: 1 / 1;
  background: #0a0a12;
  overflow: hidden;
  position: relative;
}

/* Diagonal light sweep across the thumbnail on hover. */
.card-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.13) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform 650ms ease;
  pointer-events: none;
  z-index: 1;
}
.card:hover .card-thumb::after { transform: translateX(120%); }
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.new-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 4px 9px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1;
  box-shadow: 0 2px 10px -2px rgba(56, 189, 248, 0.45);
  animation: badge-pulse 2.6s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 2px 10px -2px rgba(56, 189, 248, 0.45); }
  50%      { box-shadow: 0 2px 16px 0 rgba(56, 189, 248, 0.75); }
}

/* Favorite heart, top-right of the thumb (NEW badge sits top-left). */
.fav-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(10, 10, 14, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
  transition: background 120ms ease, transform 120ms ease;
}
.fav-btn:hover { background: rgba(10, 10, 14, 0.8); }
.fav-btn:active { transform: scale(0.9); }
.fav-btn .heart-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  transition: fill 120ms ease, stroke 120ms ease, transform 120ms ease;
}
.fav-btn.is-fav { background: rgba(10, 10, 14, 0.65); }
.fav-btn.is-fav .heart-icon { fill: var(--accent); stroke: var(--accent); }
.fav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes heart-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.fav-btn.is-fav .heart-icon { animation: heart-pop 280ms ease; }

.card-body {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-by {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}

.card-desc {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.play-stat {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
}
.play-stat.has-count { display: inline-flex; }

.card-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 2px;
}
.card-meta-row:not(:has(.has-rating, .has-count)) {
  display: none;
}

.card-rating {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 1;
}
.card-rating.has-rating { display: inline-flex; }

.stars {
  position: relative;
  display: inline-block;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.32);
}
.stars-empty { display: inline-block; }
.stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--accent);
  pointer-events: none;
}

.rating-num {
  color: var(--text);
  font-weight: 700;
}
.rating-count {
  color: var(--text-dim);
  font-weight: 500;
}

.hero-rating .stars,
.game-rating .stars { font-size: 15px; }
.hero-rating,
.game-rating { font-size: 14px; }

.play-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}

.card-stats {
  font-size: 15px;
  margin-top: 2px;
}
.card-stats .play-icon { width: 13px; height: 13px; }

.hero-stats {
  font-size: 16px;
  margin-top: 4px;
}
.hero-stats .play-icon { width: 15px; height: 15px; }

.game-plays {
  font-size: 17px;
  margin: 10px 0 0;
}
.game-plays .play-icon { width: 16px; height: 16px; }

.empty {
  grid-column: 1 / -1;
  color: var(--text-dim);
  text-align: center;
  padding: 72px 20px;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-icon {
  width: 40px;
  height: 40px;
  color: var(--border);
}
.empty-msg { margin: 0; }
.empty-reset {
  margin-top: 4px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.empty-reset:hover { background: var(--accent); color: var(--accent-fg); }

/* ---- skeleton (first-paint placeholder) ---- */

.skeleton { pointer-events: none; }
.skeleton .card-thumb,
.skeleton .sk-line {
  background: linear-gradient(100deg, #1a1a20 30%, #24242c 50%, #1a1a20 70%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.3s ease-in-out infinite;
}
.skeleton .card-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 14px 18px;
}
.sk-line {
  display: block;
  height: 11px;
  border-radius: 5px;
}
.sk-line-title { width: 65%; }
.sk-line-desc { width: 92%; }
.sk-line-meta { width: 40%; }
@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---- back to top ---- */

.back-to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  padding: 0;
  z-index: 20;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(22, 22, 26, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.6);
  transition: border-color 140ms ease, color 140ms ease, transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.back-to-top[hidden] { display: none; }
.back-to-top:hover { border-color: var(--accent); color: var(--accent); }
.back-to-top:active { transform: scale(0.94); }
.back-to-top svg { width: 22px; height: 22px; display: block; }

/* ---- game page ---- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--accent); }

.game-header {
  margin-bottom: 18px;
}
.game-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.game-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.game-meta {
  color: var(--text-dim);
  font-size: 13px;
  margin: 8px 0 6px;
  line-height: 1.5;
}
.game-meta a {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}
.game-meta a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.game-meta .meta-name { color: var(--text); }
.game-meta .meta-sep { margin: 0 6px; opacity: 0.5; }

.game-desc {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  margin: 6px 0 4px;
}
.game-controls {
  color: var(--text-dim);
  font-size: 13px;
}
.game-controls strong { color: var(--text); }

.game-frame-wrap {
  position: relative;
  margin: 0 auto 22px;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.game-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.fs-toggle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 38px;
  height: 38px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0.55;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.fs-toggle:hover,
.fs-toggle:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
  outline: none;
}
@media (hover: none) {
  .fs-toggle { opacity: 0.7; }
}
.fs-toggle:active { transform: scale(0.94); }
.fs-toggle .fs-icon { width: 20px; height: 20px; }
.fs-toggle .fs-icon-exit { display: none; }
.game-frame-wrap.fullscreen .fs-toggle .fs-icon-enter { display: none; }
.game-frame-wrap.fullscreen .fs-toggle .fs-icon-exit { display: block; }

.game-frame-wrap.fullscreen {
  position: fixed;
  inset: 0;
  margin: 0;
  z-index: 9999;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  max-width: none !important;
  aspect-ratio: auto !important;
  border-radius: 0;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Preserve the game's native aspect inside the fullscreen wrap — letter or
   pillarbox with the wrap's black background instead of stretching. */
.game-frame-wrap.fullscreen .game-frame {
  max-width: calc(100dvh * var(--game-w) / var(--game-h));
  max-height: calc(100dvw * var(--game-h) / var(--game-w));
}
.game-frame-wrap.fullscreen .fs-toggle {
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
}
body.game-fs { overflow: hidden; }

/* ---- rating toast (non-blocking) ---- */
/* Docked at the bottom edge above the fullscreen game (z-index 9999), only the
   bar itself is interactive, so it can never cover the play area or swallow
   input mid-game. */
.rate-toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  padding: 10px 12px 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  box-shadow: 0 16px 44px -16px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: transform 260ms cubic-bezier(0.2, 0.9, 0.3, 1), opacity 260ms ease;
  -webkit-tap-highlight-color: transparent;
}
.rate-toast.show { transform: translate(-50%, 0); opacity: 1; }
.rate-toast-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.rate-toast-stars { display: inline-flex; gap: 2px; }
.rate-toast-close {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 999px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.rate-toast-close:hover { color: var(--text); }

/* Shared star buttons (toast + inline header widget). */
.rate-star,
.rate-istar {
  background: none;
  border: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.32);
  padding: 2px;
  transition: color 100ms ease, transform 100ms ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.rate-star:hover, .rate-star.active, .rate-star:focus-visible,
.rate-istar:hover, .rate-istar.active, .rate-istar:focus-visible {
  color: var(--accent);
  outline: none;
}
.rate-star:hover, .rate-istar:hover { transform: scale(1.14); }
.rate-star:active, .rate-istar:active { transform: scale(0.94); }
.rate-star:disabled, .rate-istar:disabled { cursor: default; transform: none; }

/* Inline "rate it" stars in the game header. */
.game-rating.is-interactive {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rate-inline-label { color: var(--text-dim); font-size: 13px; font-weight: 500; }
.rate-inline-stars { display: inline-flex; }
.rate-inline-stars .rate-istar { font-size: 18px; }
.rating-thanks { color: var(--accent); font-size: 13px; font-weight: 600; }

/* ---- copy-link toast ---- */
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  z-index: 10001;
  max-width: calc(100vw - 24px);
  padding: 9px 16px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  box-shadow: 0 16px 44px -16px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1), opacity 220ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.copy-toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---- game header actions: share + play another ---- */
.game-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.game-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms ease, color 120ms ease;
}
.game-action-btn:hover { border-color: var(--accent); color: var(--accent); }
.game-action-btn svg { width: 15px; height: 15px; display: block; }
.game-action-btn .heart-icon { fill: none; stroke: currentColor; stroke-width: 2; }
.fav-toggle.is-fav { border-color: var(--accent); color: var(--accent); }
.fav-toggle.is-fav .heart-icon { fill: var(--accent); stroke: var(--accent); animation: heart-pop 280ms ease; }

/* ---- related games ---- */
.related { margin: 28px auto 0; max-width: var(--max-width); }
.related-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}
.related-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) { .related-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .related-grid { grid-template-columns: repeat(6, 1fr); } }
.related-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.related-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.related-thumb { aspect-ratio: 1 / 1; background: #0a0a12; overflow: hidden; }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.related-name {
  padding: 7px 9px 9px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- footer ---- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.site-footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px 32px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}
.site-footer a {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}
.site-footer a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.not-found {
  text-align: center;
  padding: 80px 20px;
}
.not-found h1 {
  font-size: 28px;
  margin: 0 0 12px;
}
.not-found p {
  color: var(--text-dim);
  margin: 0 0 20px;
}

/* ---- reduced motion: stop ambient loops cleanly ---- */
/* The global rule above already neutralizes transitions/animations, but these
   infinite loops are pinned off explicitly so they rest in a sensible state
   rather than flickering through one fast cycle. */
@media (prefers-reduced-motion: reduce) {
  .logo-mark .play-tri,
  .logo-mark .play-ring,
  body::before,
  .new-badge,
  .hero::before {
    animation: none !important;
  }
  body::before { transform: none; }
  .hero::before { opacity: 0.6; }
}
