/* ========================================================================
   WSX Five Funs — Global Stylesheet
   Author: wsx-pages
   SPEC: SPEC.md §4 (Visual)
   ======================================================================== */

/* ------------------------------------------------------------------------
   0. Font Imports (Google Fonts)
   ------------------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&display=swap');

/* ------------------------------------------------------------------------
   1. CSS Reset & Base
   ------------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg,
video,
canvas,
iframe {
  display: block;
  max-width: 100%;
  height: auto;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-primary-dark);
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

ul,
ol {
  list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Fredoka One', 'Nunito', sans-serif;
  font-weight: 400;
  line-height: 1.25;
  color: var(--color-text);
}

h1 {
  font-size: 28px;
}
h2 {
  font-size: 22px;
}
h3 {
  font-size: 18px;
}
h4 {
  font-size: 16px;
}

/* ------------------------------------------------------------------------
   2. CSS Custom Properties (Design Tokens)
   ------------------------------------------------------------------------ */
:root {
  /* Brand Colors */
  --color-primary: #ff6b9d;
  --color-primary-dark: #e25a8a;
  --color-primary-light: #ffb3ce;
  --color-secondary: #6c5ce7;
  --color-secondary-dark: #5849c2;
  --color-secondary-light: #a29bfe;
  --color-accent: #fdcb6e;
  --color-success: #00b894;
  --color-warning: #fdcb6e;
  --color-danger: #d63031;
  --color-info: #74b9ff;

  /* Surfaces */
  --color-bg: #fff5f8;
  --color-bg-2: #f0e6ff;
  --color-surface: #ffffff;
  --color-surface-2: #fafafa;
  --color-surface-3: #f4f4f8;
  --color-overlay: rgba(0, 0, 0, 0.55);
  --color-overlay-light: rgba(255, 255, 255, 0.6);

  /* Text */
  --color-text: #2d3436;
  --color-text-2: #636e72;
  --color-text-3: #b2bec3;
  --color-text-inverse: #ffffff;

  /* Border */
  --color-border: #ffe3ec;
  --color-border-2: #e0d6f5;

  /* Category Colors */
  --color-cat-arcade: #ff7675;
  --color-cat-puzzle: #74b9ff;
  --color-cat-skill: #fdcb6e;
  --color-cat-adventure: #00b894;
  --color-cat-racing: #e17055;
  --color-cat-music: #a29bfe;
  --color-cat-relaxing: #55efc4;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(255, 107, 157, 0.08);
  --shadow-md: 0 6px 18px rgba(108, 92, 231, 0.12);
  --shadow-lg: 0 12px 32px rgba(255, 107, 157, 0.18);
  --shadow-xl: 0 20px 48px rgba(108, 92, 231, 0.22);
  --shadow-inset: inset 0 0 0 2px rgba(255, 255, 255, 0.6);

  /* Gradients */
  --grad-hero: linear-gradient(135deg, #ff6b9d 0%, #6c5ce7 50%, #a29bfe 100%);
  --grad-pink-purple: linear-gradient(135deg, #ff6b9d 0%, #6c5ce7 100%);
  --grad-sunshine: linear-gradient(135deg, #fdcb6e 0%, #ff6b9d 100%);
  --grad-mint: linear-gradient(135deg, #55efc4 0%, #74b9ff 100%);
  --grad-cta: linear-gradient(135deg, #ff6b9d 0%, #ff8e53 100%);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;
  --r-circle: 50%;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 56px;
  --sp-10: 72px;

  /* Layout */
  --app-max-width: 480px;
  --bottom-nav-height: 64px;
  --header-height: 56px;

  /* Motion */
  --t-fast: 0.15s ease;
  --t-base: 0.25s ease;
  --t-slow: 0.4s ease;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index scale */
  --z-particles: 1;
  --z-content: 2;
  --z-sticky: 50;
  --z-nav: 80;
  --z-modal: 100;
  --z-loader: 200;
}

/* ------------------------------------------------------------------------
   3. App Frame (Mobile-first container, centered on desktop)
   ------------------------------------------------------------------------ */
.app-frame {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: var(--color-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: var(--z-content);
}

.app-frame__inner {
  position: relative;
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  flex: 1;
  padding-bottom: calc(var(--bottom-nav-height) + var(--sp-6));
}

.app-frame__content {
  position: relative;
  z-index: var(--z-content);
  padding: 0 var(--sp-4);
}

.app-frame--no-nav .app-frame__inner {
  padding-bottom: var(--sp-6);
}

/* Page transition fade-in */
.app-frame {
  animation: pageFadeIn 0.5s ease both;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ------------------------------------------------------------------------
   4. Loader (ball-pulse style, full-screen overlay)
   ------------------------------------------------------------------------ */
.loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-hero);
  flex-direction: column;
  gap: var(--sp-4);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader__ball {
  width: 60px;
  height: 60px;
  border-radius: var(--r-circle);
  background: var(--color-text-inverse);
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
  animation: pulse-ball 1.2s var(--ease-bounce) infinite;
}

.loader__text {
  font-family: 'Fredoka One', sans-serif;
  font-size: 22px;
  color: var(--color-text-inverse);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.loader__dot {
  display: inline-block;
  animation: loaderDotBlink 1.2s infinite;
}
.loader__dot:nth-child(2) {
  animation-delay: 0.15s;
}
.loader__dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes loaderDotBlink {
  0%, 80%, 100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

/* ------------------------------------------------------------------------
   5. Particle Background (floating dots)
   ------------------------------------------------------------------------ */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-particles);
  overflow: hidden;
}

.particles__item {
  position: absolute;
  bottom: -20px;
  display: block;
  font-size: 20px;
  opacity: 0.7;
  will-change: transform, opacity;
  animation: particle-rise linear infinite;
}

.particles__item--emoji {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.particles__item--dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-circle);
  background: var(--color-primary-light);
  box-shadow: 0 0 8px rgba(255, 107, 157, 0.6);
}

@keyframes particle-rise {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  50% {
    transform: translate3d(20px, -50vh, 0) rotate(180deg);
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translate3d(-20px, -110vh, 0) rotate(360deg);
    opacity: 0;
  }
}

/* ------------------------------------------------------------------------
   6. Hero Section
   ------------------------------------------------------------------------ */
.hero {
  position: relative;
  padding: var(--sp-7) var(--sp-5) var(--sp-8);
  background: var(--grad-hero);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  color: var(--color-text-inverse);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  isolation: isolate;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
      circle at 20% 20%,
      rgba(255, 255, 255, 0.25) 0%,
      transparent 35%
    ),
    radial-gradient(
      circle at 80% 60%,
      rgba(255, 255, 255, 0.18) 0%,
      transparent 40%
    );
  pointer-events: none;
  z-index: 0;
}

.hero__inner {
  position: relative;
  z-index: 1;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: var(--sp-3);
}

.hero__eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-circle);
  background: var(--color-accent);
  animation: pulse-ball 1.4s ease-in-out infinite;
}

.hero__title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 34px;
  line-height: 1.1;
  margin-bottom: var(--sp-2);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.hero__title-accent {
  display: inline-block;
  background: linear-gradient(90deg, #fdcb6e 0%, #ffeaa7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 3s linear infinite;
  background-size: 200% 100%;
}

.hero__subtitle {
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.95;
  max-width: 36ch;
  margin-bottom: var(--sp-5);
}

.hero__stats {
  display: flex;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.hero__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero__stat-value {
  font-family: 'Fredoka One', sans-serif;
  font-size: 22px;
  line-height: 1;
}

.hero__stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.85;
}

.hero__floating-emoji {
  position: absolute;
  font-size: 40px;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.hero__floating-emoji--1 {
  top: 18%;
  right: 8%;
  animation: float 4s ease-in-out infinite;
}
.hero__floating-emoji--2 {
  top: 55%;
  right: 14%;
  animation: float 5s ease-in-out infinite 0.6s;
  font-size: 32px;
}
.hero__floating-emoji--3 {
  top: 30%;
  right: 28%;
  animation: float 6s ease-in-out infinite 1.2s;
  font-size: 28px;
}
.hero__floating-emoji--4 {
  bottom: 12%;
  right: 6%;
  animation: float 4.5s ease-in-out infinite 0.3s;
  font-size: 36px;
}

/* ------------------------------------------------------------------------
   7. Section / Block heading
   ------------------------------------------------------------------------ */
.section {
  margin: var(--sp-6) 0;
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
  gap: var(--sp-3);
}

.section__title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 20px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.section__title-icon {
  font-size: 22px;
  animation: spin-slow 12s linear infinite;
  display: inline-block;
}

.section__more {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.section__more::after {
  content: '›';
  font-size: 18px;
  line-height: 1;
  transition: transform var(--t-fast);
}

.section__more:hover {
  color: var(--color-primary-dark);
}

.section__more:hover::after {
  transform: translateX(2px);
}

.section__sub {
  font-size: 13px;
  color: var(--color-text-2);
  margin-top: -4px;
  margin-bottom: var(--sp-3);
}

/* ------------------------------------------------------------------------
   8. Game Card (2-column grid)
   ------------------------------------------------------------------------ */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base), box-shadow var(--t-base);
  text-decoration: none;
  color: inherit;
  isolation: isolate;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.game-card__thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-pink-purple);
  font-size: 56px;
  line-height: 1;
  overflow: hidden;
}

.game-card__thumb::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.3) 0%,
    transparent 50%
  );
}

.game-card__thumb-emoji {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
  transition: transform var(--t-base);
}

.game-card:hover .game-card__thumb-emoji {
  transform: scale(1.1) rotate(-3deg);
}

.game-card__badge {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  background: var(--color-accent);
  color: var(--color-text);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.game-card__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(108, 92, 231, 0.4);
  opacity: 0;
  transition: opacity var(--t-base);
  z-index: 2;
}

.game-card:hover .game-card__play,
.game-card:focus-visible .game-card__play {
  opacity: 1;
}

.game-card__play-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-circle);
  background: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.game-card__body {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.game-card__title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 14px;
  line-height: 1.2;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 11px;
  color: var(--color-text-2);
  font-weight: 700;
}

.game-card__rating {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--color-warning);
}

.game-card__rating-star {
  font-size: 11px;
  line-height: 1;
}

.game-card__plays {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--color-text-2);
}

.game-card__category {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--color-bg-2);
  color: var(--color-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  align-self: flex-start;
}

/* Horizontal list variant */
.game-card--horizontal {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: var(--sp-3);
}

.game-card--horizontal .game-card__thumb {
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
}

.game-card--horizontal .game-card__body {
  padding: var(--sp-2) var(--sp-3) var(--sp-2) 0;
  justify-content: center;
}

.game-card--horizontal .game-card__title {
  font-size: 15px;
  -webkit-line-clamp: 2;
}

.game-card--list {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--sp-3);
  padding: var(--sp-3);
}

.game-card--list .game-card__thumb {
  border-radius: var(--r-md);
}

.game-card--list .game-card__body {
  padding: 0;
  justify-content: center;
}

/* ------------------------------------------------------------------------
   9. Pill Tabs (horizontal scroll category tabs)
   ------------------------------------------------------------------------ */
.pill-tabs {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: var(--sp-2) 0;
  margin: 0 calc(-1 * var(--sp-4));
  padding-left: var(--sp-4);
  padding-right: var(--sp-4);
  scroll-snap-type: x mandatory;
}

.pill-tabs::-webkit-scrollbar {
  display: none;
}

.pill-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-surface);
  color: var(--color-text-2);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background var(--t-fast), color var(--t-fast),
    box-shadow var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
}

.pill-tab:hover {
  background: var(--color-surface-2);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.pill-tab.is-active {
  background: var(--grad-pink-purple);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.3);
}

.pill-tab__icon {
  font-size: 14px;
  line-height: 1;
}

/* Category chip variant (used on list.html for color-coded filters) */
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--color-surface);
  color: var(--color-text-2);
  border: 1.5px solid var(--color-border);
  transition: all var(--t-fast);
}

.category-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.category-chip.is-active {
  color: var(--color-text-inverse);
  border-color: transparent;
}

.category-chip--arcade.is-active { background: var(--color-cat-arcade); }
.category-chip--puzzle.is-active { background: var(--color-cat-puzzle); }
.category-chip--skill.is-active { background: var(--color-cat-skill); }
.category-chip--adventure.is-active { background: var(--color-cat-adventure); }
.category-chip--racing.is-active { background: var(--color-cat-racing); }
.category-chip--music.is-active { background: var(--color-cat-music); }
.category-chip--relaxing.is-active { background: var(--color-cat-relaxing); }

.category-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-circle);
  background: currentColor;
}

/* ------------------------------------------------------------------------
   10. Bottom Navigation
   ------------------------------------------------------------------------ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--bottom-nav-height);
  padding: 0 var(--sp-2);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  /* Center within app-frame on desktop via max-width */
  max-width: var(--app-max-width);
  margin: 0 auto;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  color: var(--color-text-3);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  position: relative;
  transition: color var(--t-fast);
}

.bottom-nav__item:hover,
.bottom-nav__item.is-active {
  color: var(--color-primary);
}

.bottom-nav__icon {
  font-size: 22px;
  line-height: 1;
  transition: transform var(--t-fast);
}

.bottom-nav__item:hover .bottom-nav__icon,
.bottom-nav__item.is-active .bottom-nav__icon {
  transform: translateY(-2px);
}

.bottom-nav__item.is-active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 var(--r-xs) var(--r-xs);
  background: var(--color-primary);
  animation: navIndicatorSlide 0.3s var(--ease-bounce);
}

@keyframes navIndicatorSlide {
  from {
    width: 0;
  }
  to {
    width: 28px;
  }
}

/* ------------------------------------------------------------------------
   11. Star Rating
   ------------------------------------------------------------------------ */
.star-rating {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
}

.star-rating__star {
  color: var(--color-text-3);
  font-size: 14px;
  line-height: 1;
  transition: color var(--t-fast);
}

.star-rating__star.is-filled {
  color: var(--color-warning);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.star-rating--lg .star-rating__star {
  font-size: 22px;
}

.star-rating__value {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--color-text);
}

/* ------------------------------------------------------------------------
   12. Search Bar
   ------------------------------------------------------------------------ */
.search {
  position: relative;
  width: 100%;
}

.search__input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--r-pill);
  font-size: 14px;
  color: var(--color-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.search__input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.12);
}

.search__input::placeholder {
  color: var(--color-text-3);
}

.search__icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--color-text-3);
  pointer-events: none;
}

.search__clear {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: var(--r-circle);
  background: var(--color-surface-3);
  color: var(--color-text-2);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.search__clear.is-visible {
  display: flex;
}

/* Sort dropdown */
.sort {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--color-surface);
  padding: 6px 10px 6px 12px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--color-border);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-2);
  cursor: pointer;
}

.sort__icon {
  font-size: 14px;
  color: var(--color-primary);
}

.sort__select {
  border: none;
  background: transparent;
  font: inherit;
  color: var(--color-text);
  cursor: pointer;
  padding: 4px 24px 4px 4px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23b2bec3' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 4px center;
}

.sort__select:focus {
  outline: none;
}

/* ------------------------------------------------------------------------
   13. Ad Slot Containers (AdSense)
   ------------------------------------------------------------------------ */
.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: var(--sp-5) auto;
  padding: 0;
  background: var(--color-surface-3);
  border-radius: var(--r-md);
  min-height: 60px;
  position: relative;
  overflow: hidden;
}

.ad-slot::before {
  content: 'Ad';
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 1;
}

.ad-slot--responsive {
  min-height: 100px;
}

.ad-slot > div[id^='div-gpt-ad-'] {
  margin: 0 auto;
}

/* ------------------------------------------------------------------------
   14. Comment Item
   ------------------------------------------------------------------------ */
.comment-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.comment-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--color-surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.comment-item__avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-circle);
  background: var(--grad-mint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.comment-item__body {
  flex: 1;
  min-width: 0;
}

.comment-item__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.comment-item__name {
  font-weight: 800;
  font-size: 14px;
  color: var(--color-text);
}

.comment-item__date {
  font-size: 11px;
  color: var(--color-text-3);
}

.comment-item__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-2);
  word-wrap: break-word;
}

.comment-item__rating {
  margin-left: auto;
}

/* ------------------------------------------------------------------------
   15. Tags
   ------------------------------------------------------------------------ */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  background: var(--color-bg-2);
  color: var(--color-secondary);
  border-radius: var(--r-pill);
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
}

.tag:hover {
  background: var(--color-secondary);
  color: var(--color-text-inverse);
}

/* ------------------------------------------------------------------------
   16. Buttons
   ------------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 12px 22px;
  border-radius: var(--r-pill);
  font-family: 'Fredoka One', sans-serif;
  font-size: 15px;
  letter-spacing: 0.3px;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast),
    background var(--t-fast);
  border: 2px solid transparent;
  white-space: nowrap;
}

.btn--primary {
  background: var(--grad-cta);
  color: var(--color-text-inverse);
  box-shadow: 0 4px 0 var(--color-primary-dark), var(--shadow-sm);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 0 var(--color-primary-dark), var(--shadow-md);
  color: var(--color-text-inverse);
}

.btn--primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--color-primary-dark), var(--shadow-sm);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.btn--secondary:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--color-secondary);
  border-color: var(--color-border-2);
}

.btn--ghost:hover {
  background: var(--color-bg-2);
  border-color: var(--color-secondary);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn--lg {
  padding: 16px 28px;
  font-size: 17px;
}

/* ------------------------------------------------------------------------
   17. Forms
   ------------------------------------------------------------------------ */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-4);
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.form-label__required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--r-sm);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

.form-help {
  font-size: 12px;
  color: var(--color-text-2);
}

.form-error {
  font-size: 12px;
  color: var(--color-danger);
  display: none;
}

.form-field--error .form-input,
.form-field--error .form-textarea {
  border-color: var(--color-danger);
}

.form-field--error .form-error {
  display: block;
}

/* ------------------------------------------------------------------------
   18. Page Header (used on inner pages, sticky)
   ------------------------------------------------------------------------ */
.page-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  min-height: var(--header-height);
}

.page-header__back {
  width: 36px;
  height: 36px;
  border-radius: var(--r-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-3);
  color: var(--color-text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  transition: background var(--t-fast);
}

.page-header__back:hover {
  background: var(--color-bg-2);
  color: var(--color-secondary);
}

.page-header__title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 18px;
  color: var(--color-text);
  flex: 1;
  text-align: center;
  padding-right: 36px;
}

/* ------------------------------------------------------------------------
   19. Footer
   ------------------------------------------------------------------------ */
.site-footer {
  margin-top: var(--sp-8);
  padding: var(--sp-6) var(--sp-4) var(--sp-7);
  background: var(--color-surface-3);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  text-align: center;
}

.site-footer__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.site-footer__logo {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--grad-pink-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-inverse);
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px;
}

.site-footer__brand-text {
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px;
  color: var(--color-text);
}

.site-footer__tagline {
  font-size: 12px;
  color: var(--color-text-2);
  margin-bottom: var(--sp-4);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2) var(--sp-4);
  margin-bottom: var(--sp-4);
}

.site-footer__link {
  font-size: 12px;
  color: var(--color-text-2);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--t-fast);
}

.site-footer__link:hover {
  color: var(--color-primary);
}

.site-footer__legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--color-border);
}

.site-footer__copy {
  font-size: 11px;
  color: var(--color-text-3);
  width: 100%;
  margin-top: var(--sp-3);
}

/* ------------------------------------------------------------------------
   20. Article / Long-form (Privacy, Terms)
   ------------------------------------------------------------------------ */
.article {
  max-width: 100%;
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text);
}

.article h1 {
  font-family: 'Fredoka One', sans-serif;
  font-size: 28px;
  margin-bottom: var(--sp-2);
  color: var(--color-text);
}

.article h2 {
  font-family: 'Fredoka One', sans-serif;
  font-size: 19px;
  margin-top: var(--sp-6);
  margin-bottom: var(--sp-2);
  color: var(--color-primary);
  position: relative;
  padding-left: var(--sp-3);
}

.article h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: var(--r-xs);
  background: var(--grad-pink-purple);
}

.article h3 {
  font-size: 16px;
  font-weight: 800;
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-2);
  color: var(--color-secondary);
}

.article p {
  margin-bottom: var(--sp-3);
}

.article ul,
.article ol {
  padding-left: var(--sp-5);
  margin-bottom: var(--sp-3);
}

.article ul {
  list-style: disc;
}

.article ol {
  list-style: decimal;
}

.article li {
  margin-bottom: 6px;
}

.article a {
  color: var(--color-primary);
  text-decoration: underline;
}

.article strong {
  color: var(--color-text);
  font-weight: 800;
}

.article .last-updated {
  display: inline-block;
  font-size: 12px;
  color: var(--color-text-2);
  background: var(--color-bg-2);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  margin-bottom: var(--sp-4);
}

/* ------------------------------------------------------------------------
   21. Play Page
   ------------------------------------------------------------------------ */
.play {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.play__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  z-index: 2;
}

.play__back {
  width: 36px;
  height: 36px;
  border-radius: var(--r-circle);
  background: var(--color-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.play__back:hover {
  background: var(--color-bg-2);
  color: var(--color-secondary);
}

.play__title {
  flex: 1;
  min-width: 0;
}

.play__name {
  font-family: 'Fredoka One', sans-serif;
  font-size: 17px;
  color: var(--color-text);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play__meta {
  font-size: 11px;
  color: var(--color-text-2);
  font-weight: 700;
}

.play__fullscreen {
  width: 36px;
  height: 36px;
  border-radius: var(--r-circle);
  background: var(--color-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  font-size: 16px;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}

.play__fullscreen:hover {
  background: var(--color-bg-2);
  color: var(--color-secondary);
}

.play__stage {
  position: relative;
  flex: 1;
  background: #0f0f1e;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}

.play__iframe {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: 0;
  background: #0f0f1e;
  display: block;
}

.play__loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  color: var(--color-text-inverse);
  background: linear-gradient(135deg, #2d1b4e 0%, #1a1a2e 100%);
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.play__loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.play__loading-ball {
  width: 40px;
  height: 40px;
  border-radius: var(--r-circle);
  background: var(--color-primary);
  animation: pulse-ball 1.2s var(--ease-bounce) infinite;
}

.play__loading-text {
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.9);
}

.play__footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.play__related-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.play__related-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

/* ------------------------------------------------------------------------
   22. 404 Page
   ------------------------------------------------------------------------ */
.notfound {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-9) var(--sp-5);
  min-height: 60vh;
}

.notfound__emoji {
  font-size: 80px;
  line-height: 1;
  margin-bottom: var(--sp-4);
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.1));
}

.notfound__code {
  font-family: 'Fredoka One', sans-serif;
  font-size: 64px;
  line-height: 1;
  background: var(--grad-pink-purple);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: var(--sp-2);
}

.notfound__title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 24px;
  color: var(--color-text);
  margin-bottom: var(--sp-2);
}

.notfound__desc {
  font-size: 14px;
  color: var(--color-text-2);
  max-width: 32ch;
  margin: 0 auto var(--sp-5);
}

.notfound__actions {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* ------------------------------------------------------------------------
   23. Keyframe Library
   ------------------------------------------------------------------------ */
@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-12px) rotate(2deg);
  }
}

@keyframes pulse-ball {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 0 14px rgba(255, 255, 255, 0);
  }
}

@keyframes spin-slow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

@keyframes particle-rise {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  100% {
    transform: translate3d(0, -110vh, 0) rotate(360deg);
    opacity: 0;
  }
}

/* Additional utility keyframes */
@keyframes bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  60% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-3deg);
  }
  75% {
    transform: rotate(3deg);
  }
}

/* ------------------------------------------------------------------------
   24. Utility Classes
   ------------------------------------------------------------------------ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center {
  text-align: center;
}

.mt-0 {
  margin-top: 0 !important;
}
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }

.text-muted {
  color: var(--color-text-2);
}

.text-primary {
  color: var(--color-primary);
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.no-scroll {
  overflow: hidden;
  height: 100vh;
}

/* ------------------------------------------------------------------------
   25. Responsive — Desktop / Tablet
   SPEC §4.3: max-width 480px, centered on PC
   ------------------------------------------------------------------------ */
@media (min-width: 481px) {
  body {
    background: linear-gradient(135deg, #ffeef6 0%, #ece4ff 50%, #e0f7ff 100%);
    min-height: 100vh;
  }

  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      radial-gradient(circle at 10% 20%, rgba(255, 107, 157, 0.08) 0%, transparent 30%),
      radial-gradient(circle at 80% 60%, rgba(108, 92, 231, 0.08) 0%, transparent 30%);
    pointer-events: none;
    z-index: 0;
  }

  .app-frame {
    max-width: var(--app-max-width);
    margin: 0 auto;
    min-height: 100vh;
    box-shadow: 0 0 60px rgba(108, 92, 231, 0.15),
      0 0 0 1px rgba(255, 255, 255, 0.6);
    background: var(--color-bg);
    position: relative;
  }

  .app-frame__inner {
    padding-bottom: calc(var(--bottom-nav-height) + var(--sp-6));
  }

  .bottom-nav {
    border-radius: 0;
  }

  .play {
    max-width: var(--app-max-width);
    margin: 0 auto;
  }
}

@media (min-width: 768px) {
  .game-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero__title {
    font-size: 40px;
  }
}

@media (min-width: 1024px) {
  .app-frame {
    max-width: 480px;
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    border-radius: var(--r-xl);
    overflow: hidden;
  }

  .bottom-nav {
    border-radius: 0 0 var(--r-xl) var(--r-xl);
  }
}

/* ------------------------------------------------------------------------
   26. 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;
  }
}

/* ------------------------------------------------------------------------
   27. Print
   ------------------------------------------------------------------------ */
@media print {
  .bottom-nav,
  .particles,
  .loader,
  .ad-slot,
  .hero__floating-emoji {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app-frame {
    box-shadow: none;
  }
}
