/* ===== Tokens ===== */
:root{
  --ink: #17172B;
  --muted: #6B7280;
  --line: #E7E7EF;
  --bg: #FFFFFF;
  --bg-soft: #F7F7FB;
  --marquee: #FFB800;
  --cherry: #FF4B6E;
  --mint: #16B383;
  --sky: #2C8CE0;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --topbar-h: 60px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
body{
  margin:0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  padding-top: var(--topbar-h);
  -webkit-font-smoothing: antialiased;
  animation: pageIn .45s ease both;
}
@keyframes pageIn{
  from{ opacity:0; transform: translateY(6px); }
  to{ opacity:1; transform: translateY(0); }
}
img{ max-width:100%; display:block; }
a{ color:inherit; text-decoration:none; }
h1,h2,h3{ font-family: var(--font-display); margin:0; font-weight:600; }
p{ margin:0; }

:focus-visible{ outline: 2px solid var(--sky); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ===== Top bar ===== */
.topbar{
  position: fixed;
  top:0; left:0; right:0;
  height: var(--topbar-h);
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 0 8px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}
.icon-btn{
  width:44px; height:44px;
  display:flex; align-items:center; justify-content:center;
  background: transparent;
  border: none;
  color: var(--ink);
  border-radius: 12px;
  cursor:pointer;
  transition: background .15s ease, transform .12s ease;
}
.icon-btn:hover{ background: var(--bg-soft); }
.icon-btn:active{ transform: scale(0.9); }
.topbar-logo{ display:flex; align-items:center; gap:8px; }
.topbar-logo img{ height: 30px; }
.topbar-spacer{ width:44px; }

/* ===== Drawer ===== */
.drawer{
  position: fixed;
  top:0; bottom:0; left:0;
  width: 270px;
  transform: translateX(-100%);
  background: var(--bg);
  z-index: 60;
  padding: 18px 16px 24px;
  display:flex;
  flex-direction:column;
  gap: 2px;
  transition: transform .28s ease, box-shadow .28s ease;
  overflow-y:auto;
}
.drawer.open{ transform: translateX(0); box-shadow: 2px 0 24px rgba(23,23,43,0.08); }
.drawer-top{ display:flex; align-items:center; justify-content:space-between; margin-bottom: 14px; }
.drawer-logo{ height:36px; }
.drawer a{ padding: 13px 10px; border-radius: var(--radius-sm); color: var(--ink); font-weight:600; }
.drawer a:hover{ background: var(--bg-soft); }
.drawer-backdrop{
  position: fixed; inset:0;
  background: rgba(23,23,43,0.35);
  opacity:0; pointer-events:none;
  transition: opacity .25s ease;
  z-index: 50;
}
.drawer-backdrop.open{ opacity:1; pointer-events:auto; }

/* ===== Hero (compact — games come first) ===== */
.hero{ padding: 22px 16px 6px; text-align:center; }
.hero h1{ font-size: 1.5rem; line-height:1.25; margin-bottom: 6px; }
.hero p{ color: var(--muted); font-size: 0.94rem; max-width: 44ch; margin: 0 auto; }

/* ===== Category pills ===== */
.pillrow{
  display:flex; gap: 8px;
  padding: 16px 14px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pillrow::-webkit-scrollbar{ display:none; }
.pill{
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .15s ease;
}
.pill:active{ transform: scale(0.94); }
.pill-active{ background: var(--ink); color: #fff; border-color: var(--ink); animation: popIn .25s ease; }
.pill:hover:not(.pill-active){ color: var(--ink); }
@keyframes popIn{
  0%{ transform: scale(0.9); }
  60%{ transform: scale(1.05); }
  100%{ transform: scale(1); }
}

/* ===== Search ===== */
.searchrow{
  display:flex; align-items:center; gap:8px;
  margin: 14px 14px 0;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.searchrow:focus-within{ border-color: var(--sky); box-shadow: 0 0 0 3px rgba(44,140,224,0.12); }
.searchrow svg{ flex: 0 0 auto; }
.searchrow input{
  flex:1; min-width:0;
  border:none; outline:none; background:transparent;
  font-family: var(--font-body); font-size: 0.92rem; color: var(--ink);
}
.searchrow input::placeholder{ color: #B7B7C6; }

.empty-state{
  grid-column: 1 / -1;
  text-align:center;
  color: var(--muted);
  padding: 36px 16px;
  font-size: 0.94rem;
}

/* ===== Sections ===== */
.section{ padding: 22px 14px 0; }
.section-head{ display:flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2{ font-size: 1.1rem; }
.section-link{ color: var(--sky); font-weight: 700; font-size: 0.85rem; }

/* ===== Game cards ===== */
.grid{ display:grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.card{
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding-bottom: 10px;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease;
  animation: cardIn .4s ease both;
}
.card:hover{ transform: translateY(-4px) scale(1.015); box-shadow: 0 12px 26px rgba(23,23,43,0.1); }
.card:active{ transform: translateY(-1px) scale(0.99); }
@keyframes cardIn{
  from{ opacity:0; transform: translateY(10px) scale(0.98); }
  to{ opacity:1; transform: translateY(0) scale(1); }
}
.grid .card:nth-child(1){ animation-delay: .02s; }
.grid .card:nth-child(2){ animation-delay: .05s; }
.grid .card:nth-child(3){ animation-delay: .08s; }
.grid .card:nth-child(4){ animation-delay: .11s; }
.grid .card:nth-child(5){ animation-delay: .14s; }
.grid .card:nth-child(6){ animation-delay: .17s; }
.grid .card:nth-child(n+7){ animation-delay: .2s; }
.card-art{ display:block; aspect-ratio: 1 / 1; background: var(--bg-soft); overflow:hidden; position:relative; }
.card-art img{ width:100%; height:100%; object-fit: cover; transition: transform .25s ease; }
.card:hover .card-art img{ transform: scale(1.06); }
.card-art.img-fallback::after{
  content:"🎮";
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size: 2.2rem;
  background: var(--bg-soft);
}
.card-tag{
  position: absolute; top: 8px; left: 8px;
  font-size: 0.66rem; font-weight: 800;
  padding: 3px 9px; border-radius: 999px;
  color: #fff; background: var(--sky);
}
.chip-tag{
  position: static; display:inline-flex; align-items:center;
  font-size: 0.72rem; font-weight: 800;
  padding: 4px 11px; border-radius: 999px;
  color: #fff; background: var(--sky);
}
.tag-action{ background: var(--cherry); }
.tag-arcade{ background: var(--marquee); color: var(--ink); }
.tag-casual{ background: var(--mint); }
.tag-sport{ background: var(--sky); }
.tag-match3{ background: #8C6FE0; }

.card-name{ display:block; padding: 10px 10px 0; font-family: var(--font-display); font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
.card-rating{ display:flex; align-items:center; gap:4px; padding: 4px 10px 0; color: var(--muted); font-size: 0.78rem; font-weight:700; }
.card-rating svg{ flex:0 0 auto; }
.card-rating-muted{ color: #C7C7D6; font-weight:600; font-style: italic; }

/* ===== Brand mark (SVG logo + wordmark, no image files needed) ===== */
.brand{ display:flex; align-items:center; gap:8px; }
.brand-mark{ flex: 0 0 auto; display:block; transition: transform .25s ease; }
.brand:hover .brand-mark{ animation: wiggle .5s ease; }
@keyframes wiggle{
  0%, 100%{ transform: rotate(0deg) scale(1); }
  25%{ transform: rotate(-8deg) scale(1.06); }
  75%{ transform: rotate(8deg) scale(1.06); }
}
.brand-word{ font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; color: var(--ink); white-space:nowrap; }
.brand-word span{ color: var(--cherry); }

/* ===== Sort tabs ===== */
.sortrow{ display:flex; gap: 6px; padding: 4px 14px 0; }
.sort-tab{
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display:inline-flex; align-items:center; gap:5px;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .15s ease;
}
.sort-tab:active{ transform: scale(0.94); }
.sort-tab:hover{ color: var(--ink); }
.sort-tab.active{ background: var(--ink); color:#fff; border-color: var(--ink); animation: popIn .25s ease; }

/* ===== New / Popular badges on cards ===== */
.card-badge{
  position:absolute; top:8px; right:8px;
  font-size: 0.62rem; font-weight:800;
  padding: 3px 8px; border-radius: 999px;
  color:#fff; background: var(--marquee); color: var(--ink);
  letter-spacing:0.02em;
}
.badge-new{ background: var(--mint); color:#fff; animation: badgePulse 1.8s ease-in-out infinite; }
.badge-popular{ background: var(--cherry); color:#fff; }
@keyframes badgePulse{
  0%, 100%{ box-shadow: 0 0 0 0 rgba(22,179,131,0.5); }
  50%{ box-shadow: 0 0 0 5px rgba(22,179,131,0); }
}

/* ===== Footer ===== */
.site-footer{ margin-top: 36px; border-top: 1px solid var(--line); padding: 26px 16px 100px; }
.footer-inner{ max-width: 1100px; margin: 0 auto; }
.footer-logo{ height: 30px; margin-bottom: 14px; }
.footer-links{ display:flex; gap: 18px; flex-wrap:wrap; margin-bottom: 14px; }
.footer-links a{ color: var(--muted); font-weight:600; font-size: 0.88rem; }
.footer-links a:hover{ color: var(--ink); }
.footer-copy{ color: #B7B7C6; font-size: 0.8rem; }

/* ===== Breadcrumb (detail page) ===== */
.crumbs{ padding: 16px 16px 0; font-size: 0.82rem; color: var(--muted); }
.crumbs a:hover{ color: var(--ink); }
.crumbs span{ margin: 0 4px; }

/* ===== Game detail header ===== */
.detail-head{ padding: 16px 16px 0; display:flex; gap:14px; align-items:flex-start; }
.detail-icon{ width: 84px; height:84px; border-radius: var(--radius-md); overflow:hidden; flex:0 0 auto; border: 1px solid var(--line); position:relative; }
.detail-icon img{ width:100%; height:100%; object-fit:cover; }
.detail-icon.img-fallback::after{
  content:"🎮";
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size: 2rem;
  background: var(--bg-soft);
}
.detail-title{ flex:1; min-width:0; }
.detail-title h1{ font-size: 1.3rem; line-height:1.2; margin-bottom: 6px; }
.detail-meta{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.detail-rating{ display:flex; align-items:center; gap:5px; font-weight:700; font-size:0.88rem; }
.detail-rating svg{ flex:0 0 auto; }
.stars{ display:inline-flex; gap:1px; }

.play-cta{ padding: 16px; }
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding: 13px 22px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 600; font-size: 0.98rem;
  border: none; cursor:pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn-primary{
  background: var(--cherry); color: #fff;
  position: relative; overflow: hidden;
  animation: btnGlow 2.2s ease-in-out infinite;
}
.btn-primary:hover{ background: #ff2f57; transform: translateY(-2px); }
.btn-primary:active{ transform: translateY(0) scale(0.97); }
.btn-primary::after{
  content:"";
  position:absolute; top:0; left:-60%;
  width: 40%; height:100%;
  background: linear-gradient(115deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg);
  animation: btnShine 3.2s ease-in-out infinite;
}
@keyframes btnShine{
  0%{ left:-60%; }
  35%{ left:130%; }
  100%{ left:130%; }
}
@keyframes btnGlow{
  0%, 100%{ box-shadow: 0 0 0 0 rgba(255,75,110,0.35); }
  50%{ box-shadow: 0 0 0 8px rgba(255,75,110,0); }
}
.btn-block{ width:100%; }

/* ===== Share buttons ===== */
.share-row{
  display:flex; align-items:center; gap:10px;
  padding: 0 16px 4px;
  flex-wrap: wrap;
}
.share-label{ font-size: 0.85rem; color: var(--muted); font-weight:700; margin-right: 2px; }
.share-btn{
  width:38px; height:38px;
  display:flex; align-items:center; justify-content:center;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor:pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.share-btn:hover{ transform: translateY(-2px); }
.share-btn:active{ transform: translateY(0) scale(0.92); }
.share-fb:hover{ background: #1877F2; color:#fff; border-color:#1877F2; }
.share-tw:hover{ background: #000; color:#fff; border-color:#000; }
.share-wa:hover{ background: #25D366; color:#fff; border-color:#25D366; }
.share-copy:hover{ background: var(--ink); color:#fff; border-color:var(--ink); }
.share-copied{
  font-size: 0.82rem; font-weight:700; color: var(--mint);
  opacity:0; transform: translateX(-4px);
  transition: opacity .2s ease, transform .2s ease;
}
.share-copied.show{ opacity:1; transform: translateX(0); }

.detail-body{ padding: 6px 16px 0; }
.detail-block{ margin-top: 18px; }
.detail-block h2{ font-size: 1.02rem; margin-bottom: 8px; }
.detail-block p{ color: var(--muted); line-height:1.6; font-size:0.94rem; }
.howto-list{ margin:0; padding-left: 20px; color: var(--muted); line-height:1.7; font-size:0.94rem; }
.howto-list li{ margin-bottom: 2px; }

/* ===== 404 page ===== */
.notfound{
  max-width: 420px;
  margin: 0 auto;
  padding: 60px 24px 40px;
  text-align: center;
}
.notfound-mark{ animation: wiggle 1.4s ease-in-out infinite; margin: 0 auto 18px; }
.notfound h1{ font-size: 1.5rem; margin-bottom: 8px; }
.notfound p{ color: var(--muted); margin-bottom: 22px; }

/* ===== Simple content pages ===== */
.content-page{ padding: 22px 16px 40px; max-width: 720px; margin: 0 auto; }
.content-page h1{ font-size: 1.5rem; margin-bottom: 14px; }
.content-page h2{ font-size: 1.08rem; margin: 22px 0 8px; }
.content-page p, .content-page li{ color: var(--muted); line-height:1.7; font-size: 0.95rem; }
.content-page ul{ padding-left: 20px; }
.content-page a{ color: var(--sky); font-weight:600; }

/* ===== Desktop layout ===== */
@media (min-width: 960px){
  .topbar{ padding: 0 24px; }
  .topbar-logo img{ height: 34px; }
  main, .content-page{ max-width: 1180px; margin: 0 auto; }
  .content-page{ max-width: 720px; }

  .hero{ padding: 34px 24px 6px; }
  .hero h1{ font-size: 2rem; }
  .hero p{ font-size: 1.02rem; max-width: 56ch; }

  .pillrow{ padding: 18px 24px 4px; }
  .searchrow{ margin: 14px 24px 0; max-width: 360px; }
  .sortrow{ padding: 4px 24px 0; }
  .section{ padding: 30px 24px 0; }
  .grid{ grid-template-columns: repeat(5, 1fr); gap:16px; }

  .footer-inner{ display:flex; align-items:center; justify-content:space-between; }
  .footer-links{ margin-bottom:0; }
  .site-footer{ padding-bottom: 32px; }

  .detail-head{ max-width: 820px; margin: 0 auto; padding: 26px 24px 0; }
  .detail-icon{ width: 120px; height:120px; }
  .detail-title h1{ font-size: 1.8rem; }
  .play-cta{ max-width: 820px; margin: 0 auto; padding: 18px 24px; }
  .share-row{ max-width: 820px; margin: 0 auto; padding: 0 24px 4px; }
  .btn-block{ width: auto; padding-left: 40px; padding-right: 40px; }
  .detail-body{ max-width: 820px; margin: 0 auto; padding: 6px 24px 0; }
}

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