/* ============================================================
   FunGames — portal styles
   Dark, modern games-portal look. No build step, no deps.
   ============================================================ */

:root {
  /* Light pastel theme — soft, friendly, easy on the eyes. */
  --bg:        #f7f4fc;   /* airy lavender-tinted off-white */
  --bg-2:      #efeaf9;   /* slightly deeper panel/well */
  --panel:     #ffffff;   /* cards */
  --panel-2:   #f2ecfb;   /* secondary surfaces */
  --line:      #e6def4;   /* soft lavender hairline */
  --text:      #423b5e;   /* dark slate (not harsh black) */
  --muted:     #8a83a6;   /* muted lavender-grey */
  --brand:     #8b7fe8;   /* lavender */
  --brand-2:   #b79cf0;   /* lilac */
  --accent:    #f5a97e;   /* peach */
  --hot:       #ff8fa3;   /* pastel rose */
  --new:       #7fd6a8;   /* mint */
  --updated:   #8fc5ee;   /* sky */
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 12px 30px rgba(139,127,232,.14);
  --sidebar-w: 240px;
  --header-h:  64px;
  --font:      'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display:   'Space Grotesk', var(--font);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(183,156,240,.22), transparent 60%),
    radial-gradient(1000px 500px at 0% 0%, rgba(143,197,238,.18), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

/* ---------- Layout shell ---------- */
.layout {
  display: grid;
  /* minmax(0, 1fr) — without the 0 minimum the content column keeps a
     min-content floor and blows the page wider than the viewport. */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  grid-column: 1 / -1;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.brand .logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.brand .fun { color: var(--text); }
.brand .games { color: var(--brand); }

.search {
  flex: 1;
  min-width: 0;              /* allow the search (and its input) to shrink on mobile */
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 42px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within {
  border-color: var(--brand);
}
.search svg { flex: none; opacity: .6; }
.search input {
  flex: 1;
  min-width: 0;              /* without this the input's intrinsic width overflows the header */
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: .95rem;
  outline: none;
}
.search input::placeholder { color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.btn {
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: .9rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--brand); }
.btn.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 18px rgba(139,127,232,.35);
}
.btn.ghost { background: transparent; }

.account-chip { display: inline-flex; align-items: center; gap: 10px; }
.account-chip .acct-name {
  font-weight: 600; font-size: .9rem; color: var(--text);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.auth-note { color: var(--muted); font-size: .85rem; align-self: center; }

.menu-toggle {
  display: none;
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 1.1rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 16px 12px 40px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(242,236,251,.7), transparent);
}
.sidebar h4 {
  margin: 18px 12px 8px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item .ic { width: 22px; text-align: center; font-size: 1.05rem; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(139,127,232,.16), rgba(183,156,240,.16));
  color: var(--brand);
  font-weight: 600;
}

/* ---------- Main ---------- */
.main { padding: 26px 30px 70px; min-width: 0; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 40px 44px;
  margin-bottom: 34px;
  background:
    radial-gradient(560px 280px at 88% 18%, rgba(245,169,126,.35), transparent 62%),
    radial-gradient(620px 320px at 0% 100%, rgba(143,197,238,.30), transparent 60%),
    linear-gradient(120deg, #efe7fb, #e6f1fb 60%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero .eyebrow {
  font-size: .78rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent);
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
  margin: 10px 0 12px;
  letter-spacing: -.02em;
  max-width: 16ch;
}
.hero p { color: var(--muted); max-width: 52ch; margin: 0 0 22px; font-size: 1.02rem; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .art {
  position: absolute; right: 34px; bottom: -10px;
  font-size: 9rem; filter: drop-shadow(0 12px 24px rgba(139,127,232,.28));
  opacity: .9; pointer-events: none;
  animation: bob 4s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-14px) rotate(3deg); } }

/* ---------- Sections ---------- */
.section { margin-bottom: 40px; }
.section-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.section-head h2 {
  font-family: var(--display);
  font-size: 1.3rem; letter-spacing: -.01em; margin: 0;
}
.section-head .count { color: var(--muted); font-size: .9rem; }
.section-head .spacer { flex: 1; }

/* ---------- Game grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}
.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--brand);
  box-shadow: 0 16px 34px rgba(139,127,232,.22);
}
.card .thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid; place-items: center;
  font-size: 3.4rem;
  overflow: hidden;
}
.card .thumb::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.35));
}
.card .thumb .emoji {
  position: relative; z-index: 1;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.35));
  transition: transform .2s;
}
.card:hover .thumb .emoji { transform: scale(1.12) rotate(-4deg); }
.card .body { padding: 12px 14px 14px; }
.card .title { font-weight: 600; font-size: .98rem; letter-spacing: -.01em; }
.card .meta { margin-top: 4px; color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: 6px; }

.badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  font-size: .68rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px;
  color: #4a3a4f;
  box-shadow: 0 4px 10px rgba(66,59,94,.12);
}
.badge.hot     { background: var(--hot); }
.badge.new     { background: var(--new); }
.badge.updated { background: var(--updated); }

.card .play-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center;
  background: rgba(66,59,94,.38);
  opacity: 0; transition: opacity .16s;
}
.card:hover .play-overlay { opacity: 1; }
.play-overlay .play-btn {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: .92rem;
  padding: 10px 18px; border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 18px rgba(139,127,232,.4);
}

.card.soon { cursor: default; }
.card.soon:hover { transform: none; border-color: var(--line); box-shadow: none; }
.card.soon .thumb { filter: grayscale(.35) brightness(.8); }
.card.soon .play-overlay { background: rgba(66,59,94,.5); }
.card.soon .play-overlay .soon-tag {
  font-weight: 700; font-size: .85rem; color: var(--text);
  padding: 8px 16px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
}

/* ---------- Empty state ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}
.empty .big { font-size: 3rem; margin-bottom: 10px; }

/* ---------- SEO intro ---------- */
.about {
  margin: 8px 0 10px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.about h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  margin: 0 0 10px;
}
.about p { color: var(--muted); font-size: .95rem; line-height: 1.65; margin: 0; }
.about strong { color: var(--text); font-weight: 600; }

/* ---------- Footer ---------- */
.footer {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding: 26px 30px;
  color: var(--muted);
  font-size: .88rem;
  display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center;
}
.footer .spacer { flex: 1; }
.footer-link {
  cursor: pointer;
  font-family: var(--font);
  font-size: .88rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
}
.footer-link:hover { color: var(--text); }

/* ---------- Suggest-a-game modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
}
.modal-backdrop.show { display: flex; }
.modal {
  position: relative;
  width: 100%; max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 26px 24px;
}
.modal h2 {
  font-family: var(--display);
  font-size: 1.4rem; margin: 0 0 6px; letter-spacing: -.01em;
}
.modal .modal-sub { color: var(--muted); font-size: .92rem; margin: 0 0 18px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
}
.modal-close:hover { color: var(--text); border-color: var(--muted); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.field > span em { color: var(--muted); font-weight: 400; font-style: normal; }
.field textarea, .field input {
  width: 100%;
  font-family: var(--font); font-size: .95rem;
  color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none; resize: vertical;
  transition: border-color .15s;
}
.field textarea:focus, .field input:focus { border-color: var(--brand); }
.field textarea::placeholder, .field input::placeholder { color: var(--muted); }

.modal .btn.primary { width: 100%; margin-top: 4px; padding: 12px; }
.form-status { font-size: .88rem; margin: 12px 0 0; min-height: 1.1em; text-align: center; }
.form-status.ok  { color: var(--new); }
.form-status.err { color: var(--hot); }

/* auth modal extras */
.google-signin {
  min-height: 44px;
  display: flex;
  justify-content: center;
  color: var(--muted);
  font-size: .88rem;
}
.google-signin > div { width: 100% !important; }
.google-signin iframe { max-width: 100% !important; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-switch { text-align: center; color: var(--muted); font-size: .9rem; margin: 14px 0 0; }
.linkbtn { background: none; border: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- Sidebar mobile backdrop ---------- */
.backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 45;
  background: rgba(0,0,0,.5);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .header { min-width: 0; }
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 50;
    height: 100vh; width: 260px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    background: var(--bg-2);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop.show { display: block; }
  .header .brand .txt { display: none; }
}
@media (max-width: 560px) {
  .main { padding: 18px 16px 60px; }
  .hero { padding: 28px 24px; }
  .hero .art { display: none; }
  .header-actions .btn.ghost { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}
