/* =========================================================
   FRIV ARCADE DESIGN SYSTEM — Vibrant, tactile, human-centric
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root, [data-theme="friv-bright"] {
  --bg-page: #f0f4fc;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --pink: #ff3d8b;
  --pink-light: #fff1f6;
  --cyan: #0284c7;
  --cyan-light: #e0f2fe;
  --teal: #06d6a0;
  --yellow: #ffb703;
  --orange: #ff6b35;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
  --shadow-bounce: 0 12px 30px rgba(255, 61, 139, 0.25);

  --font-display: 'Fredoka', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="midnight-arcade"] {
  --bg-page: #090d16;
  --bg-surface: #131b2e;
  --bg-surface-2: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --border: #1e293b;
  --border-strong: #334155;

  --pink: #ec4899;
  --pink-light: #371b2d;
  --cyan: #38bdf8;
  --cyan-light: #082f49;
  --teal: #2dd4bf;
  --yellow: #facc15;
  --orange: #fb923c;
  --purple: #a855f7;
  --purple-light: #3b0764;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
  --shadow-bounce: 0 12px 30px rgba(236, 72, 153, 0.35);
}

[data-theme="retro-pixel"] {
  --bg-page: #dcfce7;
  --bg-surface: #ffffff;
  --bg-surface-2: #f0fdf4;
  --text-main: #14532d;
  --text-muted: #166534;
  --text-light: #4ade80;
  --border: #86efac;
  --border-strong: #4ade80;

  --pink: #15803d;
  --pink-light: #dcfce7;
  --cyan: #0284c7;
  --cyan-light: #e0f2fe;
  --teal: #059669;
  --yellow: #ca8a04;
  --orange: #c2410c;
  --purple: #6b21a8;
  --purple-light: #f3e8ff;

  --shadow-sm: 0 2px 8px rgba(20, 83, 45, 0.08);
  --shadow-md: 0 8px 24px rgba(20, 83, 45, 0.12);
  --shadow-lg: 0 16px 40px rgba(20, 83, 45, 0.18);
  --shadow-bounce: 0 12px 30px rgba(21, 128, 61, 0.3);
}

[data-theme="candy-pop"] {
  --bg-page: #fdf4ff;
  --bg-surface: #ffffff;
  --bg-surface-2: #fae8ff;
  --text-main: #581c87;
  --text-muted: #86198f;
  --text-light: #c084fc;
  --border: #f0abfc;
  --border-strong: #e879f9;

  --pink: #d946ef;
  --pink-light: #fdf4ff;
  --cyan: #06b6d4;
  --cyan-light: #ecfeff;
  --teal: #10b981;
  --yellow: #f59e0b;
  --orange: #f97316;
  --purple: #9333ea;
  --purple-light: #faf5ff;

  --shadow-sm: 0 2px 8px rgba(88, 28, 135, 0.08);
  --shadow-md: 0 8px 24px rgba(88, 28, 135, 0.12);
  --shadow-lg: 0 16px 40px rgba(88, 28, 135, 0.18);
  --shadow-bounce: 0 12px 30px rgba(217, 70, 239, 0.3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--bg-page);
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(255, 61, 139, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(2, 132, 199, 0.06) 0%, transparent 40%),
    radial-gradient(#e2e8f0 1.2px, transparent 1.2px);
  background-size: 100% 100%, 100% 100%, 24px 24px;
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 0.4em; line-height: 1.2; font-weight: 700; }
p { margin: 0 0 1em; color: var(--text-muted); }
.mono { font-family: var(--font-mono); }

:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; } }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ---------- HEADER & TOP BAR ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.site-header .bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; max-width: 1240px; margin: 0 auto;
}

.logo {
  font-family: var(--font-display); font-weight: 700; font-size: 24px;
  display: flex; align-items: center; gap: 10px; color: var(--text-main);
  text-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.logo .icon-badge {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, var(--pink), #ff6b35);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; box-shadow: 0 4px 12px rgba(255,61,139,0.35);
  transform: rotate(-6deg);
}

.search-box {
  flex: 1; max-width: 340px; position: relative;
}
.search-box input {
  width: 100%; background: var(--bg-surface-2); border: 2px solid var(--border);
  color: var(--text-main); padding: 10px 16px 10px 38px; border-radius: var(--radius-full);
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  transition: all 0.2s ease;
}
.search-box input:focus {
  background: #fff; border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255,61,139,0.15);
}
.search-box .search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-light); pointer-events: none;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.btn-roulette {
  background: linear-gradient(135deg, #7c3aed, #ff3d8b);
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 14px;
  padding: 9px 18px; border-radius: var(--radius-full); border: none;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-roulette:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 18px rgba(124, 58, 237, 0.45); }
.btn-roulette:active { transform: translateY(1px); }

.sound-toggle, .fav-toggle-btn {
  width: 40px; height: 40px; border-radius: var(--radius-full); border: 2px solid var(--border);
  background: var(--bg-surface); color: var(--text-main); font-size: 18px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.15s ease;
}
.sound-toggle:hover, .fav-toggle-btn:hover { border-color: var(--pink); transform: scale(1.08); }

.theme-select-dropdown {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}
.theme-select-dropdown:hover, .theme-select-dropdown:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 61, 139, 0.15);
}

/* ---------- CATEGORY PILL BAR ---------- */
.cat-pill-bar {
  padding: 16px 0 10px; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.cat-pill-bar::-webkit-scrollbar { display: none; }
.cat-pills { display: flex; gap: 10px; align-items: center; }

.cat-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-full);
  background: var(--bg-surface); border: 2px solid var(--border);
  color: var(--text-main); font-family: var(--font-display); font-size: 14px; font-weight: 600;
  white-space: nowrap; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}
.cat-pill:hover { border-color: var(--pink); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.cat-pill.active {
  background: var(--text-main); color: #ffffff; border-color: var(--text-main);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
}

/* ---------- FRIV MEGA MOSAIC GRID ---------- */
.friv-grid-section { padding: 16px 0 40px; }
.grid-meta-bar {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.grid-title { font-size: 22px; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.grid-count-badge {
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  background: var(--pink-light); color: var(--pink); padding: 4px 12px; border-radius: var(--radius-full);
}

.friv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
}

.friv-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 3px solid var(--border);
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  user-select: none;
}
.friv-card:hover {
  transform: translateY(-6px) scale(1.05);
  box-shadow: var(--shadow-bounce);
  border-color: var(--card-accent, var(--pink));
  z-index: 10;
}

.friv-card .art-container {
  width: 60%; height: 60%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease;
}
.friv-card:hover .art-container { transform: scale(1.12); }
.friv-card .art-container svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1)); }

.friv-card .card-title {
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  color: var(--text-main); text-align: center; padding: 4px 6px;
  width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.friv-card .playable-tag {
  position: absolute; top: 6px; right: 6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--teal); color: #fff; font-size: 10px;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  box-shadow: 0 2px 6px rgba(6, 214, 160, 0.4);
}

.friv-card .rating-tag {
  position: absolute; top: 6px; left: 6px;
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  color: #fff; background: rgba(15, 23, 42, 0.75);
  padding: 1px 6px; border-radius: var(--radius-full);
}

.friv-card .hover-play-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 61, 139, 0.88), rgba(124, 58, 237, 0.92));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: #ffffff; opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
}
.friv-card:hover .hover-play-overlay { opacity: 1; pointer-events: auto; }
.hover-play-overlay .play-icon { font-size: 24px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3)); }
.hover-play-overlay .play-text { font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 0.05em; }

/* ---------- INSTANT PLAY THEATER MODAL ---------- */
#game-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
#game-modal.active { display: flex; animation: modalFadeIn 0.2s ease-out; }

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-stage-wrapper {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 4px solid var(--text-main);
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  width: 100%; max-width: 920px; max-height: 94vh;
  display: flex; flex-direction: column; overflow: hidden;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--bg-surface-2); border-bottom: 2px solid var(--border);
}
.modal-game-info { display: flex; align-items: center; gap: 10px; }
.modal-game-info h2 { font-size: 18px; margin: 0; color: var(--text-main); }
.modal-cat-badge {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: var(--radius-full); background: var(--pink-light); color: var(--pink);
}

.modal-actions { display: flex; align-items: center; gap: 8px; }
.modal-action-btn {
  background: var(--bg-surface); border: 2px solid var(--border); color: var(--text-main);
  padding: 6px 12px; border-radius: var(--radius-full); font-family: var(--font-display);
  font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s ease;
}
.modal-action-btn:hover { border-color: var(--pink); color: var(--pink); transform: translateY(-1px); }
.modal-close-btn {
  width: 34px; height: 34px; border-radius: 50%; background: #fee2e2; color: #ef4444;
  border: none; font-size: 16px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.modal-close-btn:hover { background: #ef4444; color: #fff; }

.modal-iframe-container {
  flex: 1; min-height: 440px; background: #0f111a; position: relative;
}
.modal-iframe-container iframe {
  width: 100%; height: 100%; border: none; display: block;
}

.modal-footer {
  padding: 12px 18px; background: #ffffff; border-top: 2px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
}
.modal-desc { font-size: 13px; color: var(--text-muted); max-width: 600px; margin: 0; line-height: 1.4; }

/* ---------- STATIC / LEGAL & CATEGORY PAGES ---------- */
.content-box {
  background: #ffffff; border: 2px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px; box-shadow: var(--shadow-md); margin: 30px 0 50px;
}
.content-box h1 { font-size: 32px; margin-bottom: 8px; color: var(--text-main); }
.content-box h2 { font-size: 20px; margin-top: 28px; color: var(--text-main); }
.content-box p, .content-box li { font-size: 15px; color: var(--text-muted); line-height: 1.6; }
.crumbs {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 16px;
}
.crumbs a { color: var(--cyan); }
.crumbs a:hover { text-decoration: underline; }

/* ---------- AD SLOTS (ADSENSE COMPLIANT) ---------- */
.ad-slot {
  background: var(--bg-surface); border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md); color: var(--text-light);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.02);
}
.ad-header-banner { height: 90px; max-width: 970px; margin: 16px auto; }
.ad-in-content { min-height: 100px; margin: 24px 0; }
.ad-sidebar { min-height: 250px; }
.ad-footer-leaderboard { height: 90px; max-width: 728px; margin: 0 auto 24px; }

/* ---------- ARCADE BUDDY MASCOT ---------- */
#mascot-widget {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: flex; align-items: flex-end; gap: 10px; pointer-events: none;
}
#mascot-bubble {
  background: #ffffff; border: 2px solid var(--text-main); border-radius: 16px 16px 4px 16px;
  padding: 10px 14px; max-width: 220px; font-family: var(--font-display); font-size: 13px;
  color: var(--text-main); font-weight: 600; box-shadow: var(--shadow-md);
  pointer-events: auto; transform-origin: bottom right; animation: bubblePop 0.3s ease-out;
}
#mascot-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--yellow), var(--orange));
  border: 3px solid var(--text-main); display: flex; align-items: center; justify-content: center;
  font-size: 26px; box-shadow: var(--shadow-md); cursor: pointer; pointer-events: auto;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#mascot-avatar:hover { transform: scale(1.15) rotate(10deg); }

@keyframes bubblePop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- COOKIE BANNER ---------- */
#cookie-banner {
  position: fixed; left: 20px; right: 20px; bottom: 20px; z-index: 90;
  max-width: 540px; margin: 0 auto; background: #ffffff; border: 2px solid var(--text-main);
  border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-wrap: wrap;
  gap: 14px; align-items: center; box-shadow: var(--shadow-lg);
}
#cookie-banner p { margin: 0; font-size: 13px; color: var(--text-muted); flex: 1; min-width: 220px; }
#cookie-banner .actions { display: flex; gap: 8px; }
#cookie-banner button {
  font-family: var(--font-display); font-weight: 700; font-size: 13px; padding: 8px 16px;
  border-radius: var(--radius-full); border: 2px solid var(--border); background: var(--bg-surface-2);
  color: var(--text-main); cursor: pointer;
}
#cookie-banner button.accept {
  background: var(--pink); border-color: var(--pink); color: #ffffff; box-shadow: 0 4px 12px rgba(255,61,139,0.3);
}

/* ---------- SITE FOOTER ---------- */
.site-footer {
  background: #ffffff; border-top: 2px solid var(--border);
  padding: 40px 0 30px; margin-top: 50px;
}
.foot-grid {
  display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 30px;
}
.foot-grid h4 {
  font-family: var(--font-display); font-size: 14px; text-transform: uppercase;
  color: var(--text-main); margin-bottom: 12px;
}
.foot-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.foot-grid ul a { color: var(--text-muted); transition: color 0.15s ease; }
.foot-grid ul a:hover { color: var(--pink); }

.site-footer .bottom {
  margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  font-size: 13px; color: var(--text-light); font-family: var(--font-body);
}

/* ---------- RESPONSIVE BREAKPOINTS ---------- */
@media (max-width: 990px) {
  .friv-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .friv-grid { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 8px; }
  .search-box { display: none; }
  .foot-grid { grid-template-columns: 1fr; }
  .modal-iframe-container { min-height: 360px; }
}
