/* ============================================================================
 * NorthFive Fun — Main Stylesheet
 * Implements SPEC §4 visual + §4.4 hard constraints.
 *
 * Constraints (do not break):
 *  - .top-nav MUST be first child of .app-frame (§4.4)
 *  - .app-frame MUST NOT have overflow:hidden (§4.4)
 *  - .drawer right:0 + transform:translateX(calc(100% + 30px)) (§4.4)
 *  - top-nav centered via width:var(--max-w); margin:0 auto (§4.4)
 *  - Mobile-first; main max-width 480px centered on PC (§4.1)
 *  - All UI control icons are inline SVG, not emoji (§4.4)
 * ========================================================================== */

/* tokens.css must be loaded before this file */
@import url("./tokens.css");

/* ----- Reset & base ----- */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  padding-top: var(--top-safe);
}

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

button { font: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; padding: 0; }

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

ul, ol { list-style: none; padding: 0; margin: 0; }

input, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--fw-regular);
  line-height: var(--lh-snug);
  margin: 0;
  letter-spacing: 0.01em;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }

p { margin: 0 0 var(--sp-3); }

::selection { background: var(--brand-pink); color: #fff; }

/* =========================================================================
   App frame (mobile-first 480px column, centered on PC)
   ========================================================================= */
.app-frame {
  position: relative;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  background: var(--bg-page);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* SPEC §4.4: do NOT add overflow:hidden here — it would break sticky */
}

main {
  flex: 1 1 auto;
  width: 100%;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-12) + var(--bottom-safe));
}

/* PC / tablet centering (SPEC §4.3) */
@media (min-width: 768px) {
  body { background: linear-gradient(180deg, #FFE5EE 0%, #FFF5F8 100%); }
  .app-frame {
    box-shadow: var(--shadow-3);
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
  }
}

/* =========================================================================
   Top navigation (sticky, 56px)
   SPEC §4.2 #1, §4.4: first child of .app-frame
   ========================================================================= */
.top-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--topnav-h);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  /* SPEC §4.4: PC centering via width+margin, NOT transform (sticky breaks) */
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  left: 0;
  right: 0;
  overflow: hidden; /* 防止内部元素溢出顶栏 56px */
  min-width: 0; /* flex 容器允许子元素收缩 */
}

/* detail/list/play 等动态标题页:窄屏(<540px)隐藏品牌文字 + 限制标题宽度
   防止 "N5 + NorthFive Fun + Ninja Fruit Slash + 🔍 ☰" 在 480px 容器内重叠 */
@media (max-width: 539px) {
  .top-nav__logo-text { display: none; }
  .top-nav__title { max-width: 110px; }
}

/* 540-768 区间:保留品牌文字但进一步压缩 */
@media (min-width: 540px) and (max-width: 767px) {
  .top-nav__logo-text { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-nav__title { max-width: 140px; }
}

.top-nav__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
  min-width: 0;
}

/* .top-nav__logo is a flex container wrapping mark + text.
   Do NOT give it fixed width/height — those belong to the inner mark only. */
.top-nav__logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

/* 32×32 gradient badge showing "N5" */
.top-nav__logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--grad-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 18px;
  box-shadow: var(--shadow-pink);
  flex: 0 0 auto;
}

.top-nav__logo-text {
  font-family: var(--font-heading);
  font-size: var(--fs-md);
  color: var(--brand-purple);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  min-width: 0;
  flex: 0 0 auto;
}

.top-nav__title {
  font-family: var(--font-heading);
  font-size: var(--fs-md);
  color: var(--brand-purple);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  letter-spacing: 0.02em;
  min-width: 0; /* flex item 必须 min-width:0 才能让 max-width 真正生效 */
  flex: 0 1 auto;
}

.top-nav__spacer { flex: 1 1 auto; }

.top-nav__btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-purple);
  border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  flex: 0 0 auto;
}

.top-nav__btn:hover,
.top-nav__btn:focus-visible {
  background: var(--brand-pink-soft);
  color: var(--brand-pink);
}

.top-nav__btn:active { transform: scale(0.94); }

.top-nav__btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =========================================================================
   Drawer (right slide-in)
   SPEC §4.2 #2, §4.4: right:0 from viewport edge, transform:translateX(...)
   ========================================================================= */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--drawer-w);
  max-width: 80vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-surface);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  z-index: var(--z-drawer);
  transform: translateX(calc(100% + var(--drawer-buffer)));
  transition: transform var(--dur-base) var(--ease-out);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: var(--top-safe);
  padding-bottom: var(--bottom-safe);
}

.drawer.is-open { transform: translateX(0); }

.drawer__scrim {
  position: fixed;
  inset: 0;
  background: var(--brand-overlay);
  z-index: calc(var(--z-drawer) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}

.drawer__scrim.is-open { opacity: 1; pointer-events: auto; }

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.drawer__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-heading);
  color: var(--brand-purple);
  font-size: var(--fs-md);
}

.drawer__brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--grad-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 16px;
  box-shadow: var(--shadow-pink);
  flex: 0 0 auto;
}

.drawer__close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  flex: 0 0 auto;
}

.drawer__close:hover,
.drawer__close:focus-visible {
  background: var(--brand-pink-soft);
  color: var(--brand-pink);
}

.drawer__close svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

.drawer__section { padding: var(--sp-4) 0; border-bottom: 1px solid var(--border-soft); }
.drawer__section:last-child { border-bottom: 0; }

.drawer__heading {
  font-family: var(--font-body);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-4) var(--sp-2);
}

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

.drawer__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-primary);
  font-weight: var(--fw-semi);
  font-size: var(--fs-base);
  border-radius: var(--r-md);
  margin: 0 var(--sp-2);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.drawer__item:hover,
.drawer__item:focus-visible {
  background: var(--brand-pink-soft);
  color: var(--brand-pink);
  text-decoration: none;
}

.drawer__item.is-active { color: var(--brand-pink); background: var(--bg-tint); }

.drawer__item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.drawer__cats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  padding: 0 var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
}

.drawer__cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--r-md);
  background: var(--bg-soft);
  color: var(--brand-purple);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  text-align: center;
  min-height: 64px;
  justify-content: center;
}

/* =========================================================================
   Detail-page drawer (alternate BEM: __head / __title / __nav / __link / __foot)
   Re-uses .drawer__cats grid + .drawer__cat from above for the category block
   ========================================================================= */
.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}

.drawer__title {
  font-family: var(--font-heading);
  color: var(--brand-purple);
  font-size: var(--fs-md);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Detail-page brand badge (N5 gradient square).
   Independent class, same visual as .drawer__brand-logo on the home page. */
.drawer__logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--grad-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 16px;
  box-shadow: var(--shadow-pink);
  flex: 0 0 auto;
  letter-spacing: 0;
}

.drawer__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border-soft);
}

.drawer__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-primary);
  font-weight: var(--fw-semi);
  font-size: var(--fs-base);
  border-radius: var(--r-md);
  margin: 0 var(--sp-2);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.drawer__link:hover,
.drawer__link:focus-visible {
  background: var(--brand-pink-soft);
  color: var(--brand-pink);
  text-decoration: none;
}

/* Detail-page drawer link icon (Browse + Info).
   Independent class, same visual as .drawer__item svg on the home page. */
.drawer__link svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.drawer__foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-4) 0;
}

.drawer__cat:hover,
.drawer__cat:focus-visible,
.drawer__cat.is-active {
  background: var(--brand-pink);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.drawer__cat svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =========================================================================
   Search overlay
   SPEC §4.2 #3
   ========================================================================= */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--bg-surface);
  transform: translateY(-100%);
  transition: transform var(--dur-base) var(--ease-out);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-top: var(--top-safe);
  padding-bottom: var(--bottom-safe);
}

.search-overlay.is-open { transform: translateY(0); }

.search-overlay__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  height: var(--topnav-h);
}

.search-overlay__icon {
  width: 22px;
  height: 22px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  flex: 0 0 auto;
  margin-left: var(--sp-2);
}

.search-overlay__input {
  flex: 1 1 auto;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  color: var(--text-primary);
}

.search-overlay__input::placeholder { color: var(--text-muted); font-weight: var(--fw-regular); }

.search-overlay__close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--r-md);
  flex: 0 0 auto;
}

.search-overlay__close:hover,
.search-overlay__close:focus-visible { background: var(--brand-pink-soft); color: var(--brand-pink); }
.search-overlay__close svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

.search-overlay__body { padding: var(--sp-4) var(--sp-3); }

.search-overlay__label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.search-overlay__cats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.search-overlay__cat {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--bg-soft);
  color: var(--text-primary);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  transition: background var(--dur-fast) var(--ease-out);
  min-height: 56px;
}

.search-overlay__cat:hover,
.search-overlay__cat:focus-visible { background: var(--brand-pink-soft); color: var(--brand-pink); text-decoration: none; }

.search-overlay__cat svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.search-overlay__results {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

/* =========================================================================
   Game card (2-col grid)
   SPEC §4.2 #6
   ========================================================================= */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.grid-1 { display: flex; flex-direction: column; gap: var(--sp-3); }

/* More Games grid lives inside .more-games — give it breathing room */
.more-games > [data-render="related"],
.more-games > [data-render="reco-grid"] {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}

.card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  text-decoration: none;
  color: inherit;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  text-decoration: none;
  color: inherit;
}

.card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--brand-purple-soft);
  overflow: hidden;
}

.card__thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__thumb-icon {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  line-height: 1;
}

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

.card__title {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  line-height: var(--lh-snug);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--text-muted);
}

.card__rating { display: inline-flex; align-items: center; gap: 2px; color: var(--brand-yellow); font-weight: var(--fw-bold); }
.card__rating-text { color: var(--text-primary); font-weight: var(--fw-semi); margin-left: 2px; }
.card__plays { font-weight: var(--fw-semi); color: var(--text-muted); }

/* =========================================================================
   Section header
   ========================================================================= */
.section { margin-bottom: var(--sp-7); }
.section:last-child { margin-bottom: 0; }

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 var(--sp-1) var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-soft);
}

.section__title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  color: var(--brand-purple);
  letter-spacing: 0.02em;
}

.section__more {
  font-size: var(--fs-xs);
  color: var(--brand-pink);
  font-weight: var(--fw-bold);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.section__more::after {
  content: "";
  width: 6px; height: 6px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}

.section__empty {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-muted);
}

/* =========================================================================
   Game head (detail page hero card)
   SPEC §4.2 #5
   ========================================================================= */
.game-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--grad-brand);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pink);
  color: #fff;
  margin-bottom: var(--sp-3);
}

.game-head__icon {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.game-head__icon-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-head__icon-emoji { font-size: 40px; line-height: 1; display: none; }

.game-head__body { flex: 1 1 auto; min-width: 0; }

.game-head__title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  line-height: var(--lh-tight);
  margin: 0 0 2px;
  word-break: break-word;
}

.game-head__subtitle {
  font-size: var(--fs-sm);
  opacity: 0.9;
  margin: 0 0 var(--sp-2);
}

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

.game-head__stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 8px;
  border-radius: var(--r-pill);
  width: max-content;
}

.game-head__stat svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* Play CTA */
.play-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  border-radius: var(--r-lg);
  background: var(--grad-brand);
  color: #fff;
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: var(--shadow-pink);
  margin-bottom: var(--sp-5);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.play-cta:hover,
.play-cta:focus-visible {
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(247, 37, 133, 0.35);
}

.play-cta:active { transform: translateY(0); }

.play-cta::before {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  border-left: 14px solid currentColor;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  margin-right: var(--sp-2);
  margin-left: -8px;
}

/* =========================================================================
   Detail page sections
   ========================================================================= */
.detail-block { margin-bottom: var(--sp-5); }

.detail-block__title {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  color: var(--brand-purple);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.01em;
}

.detail-block__text {
  font-size: var(--fs-md);
  line-height: var(--lh-loose);
  color: var(--text-secondary);
}

.howto { padding-left: 0; }
.howto__item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  font-size: var(--fs-md);
  color: var(--text-secondary);
  line-height: var(--lh-snug);
}
.howto__num {
  flex: 0 0 24px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--brand-pink);
  color: #fff;
  font-family: var(--font-heading);
  font-size: var(--fs-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================================
   Detail page typography (game-info / comments / more-games)
   Goal: comfortable reading — generous padding, breathing space, soft rhythm
   ========================================================================= */
.game-info,
.comments,
.more-games {
  margin: 0 0 var(--sp-8);
  padding: var(--sp-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.game-info > h2,
.comments > h2,
.more-games > h2 {
  font-size: var(--fs-xl);
  color: var(--brand-purple);
  letter-spacing: 0.02em;
  margin: 0 0 var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--brand-pink-soft);
  position: relative;
}
.game-info > h2::before,
.comments > h2::before,
.more-games > h2::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 36px;
  height: 2px;
  background: var(--brand-pink);
  border-radius: 2px;
}

.game-info h3 {
  font-size: var(--fs-md);
  color: var(--brand-purple);
  letter-spacing: 0.01em;
  margin: var(--sp-6) 0 var(--sp-3);
  padding-left: var(--sp-3);
  border-left: 3px solid var(--brand-pink);
}

.game-info p {
  font-size: var(--fs-base);
  line-height: var(--lh-loose);
  color: var(--text-secondary);
  margin: 0 0 var(--sp-4);
}

.game-info ol,
.game-info ul {
  padding-left: var(--sp-5);
  margin: 0 0 var(--sp-4);
  color: var(--text-secondary);
}
.game-info ol li,
.game-info ul li {
  font-size: var(--fs-base);
  line-height: var(--lh-loose);
  margin-bottom: var(--sp-2);
  padding-left: var(--sp-1);
}
.game-info ol li::marker {
  color: var(--brand-pink);
  font-weight: var(--fw-bold);
}
.game-info ul li::marker {
  color: var(--brand-purple);
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--brand-purple-soft);
  color: var(--brand-purple);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}

/* =========================================================================
   Rating (with half-star support, SPEC §4.2 #8)
   ========================================================================= */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: var(--brand-yellow);
  line-height: 1;
}
.rating svg { width: 14px; height: 14px; fill: currentColor; stroke: currentColor; stroke-width: 0; }
.rating .is-off { color: var(--neutral-300); }
.rating__num { color: var(--text-primary); font-weight: var(--fw-bold); margin-left: 4px; font-size: var(--fs-sm); }

/* =========================================================================
   Comments
   ========================================================================= */
.comment {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border-soft);
}
.comment:first-child { padding-top: 0; }
.comment:last-child { border-bottom: 0; padding-bottom: 0; }

.comment__avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: var(--r-circle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  text-transform: uppercase;
}

.comment__body { flex: 1 1 auto; min-width: 0; }

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

.comment__name { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-primary); }
.comment__date { font-size: var(--fs-2xs); color: var(--text-muted); }
.comment__badge {
  display: inline-block;
  background: var(--brand-pink);
  color: #fff;
  font-size: 9px;
  font-weight: var(--fw-black);
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
}
.comment__text {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  line-height: var(--lh-loose);
  margin: var(--sp-2) 0 0;
}

/* =========================================================================
   Filters / sort bar (list page)
   ========================================================================= */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.toolbar__row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.toolbar__search {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-pill);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.toolbar__search:focus-within { border-color: var(--brand-pink); }
.toolbar__search svg { width: 18px; height: 18px; stroke: var(--text-muted); fill: none; stroke-width: 2; flex: 0 0 auto; }
.toolbar__search input {
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-sm);
}

.toolbar__select {
  height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.chips {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  margin: 0 calc(-1 * var(--sp-3));
  padding: 0 var(--sp-3);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-decoration: none;
  white-space: nowrap;
}
.chip:hover { border-color: var(--brand-pink); color: var(--brand-pink); text-decoration: none; }
.chip.is-active { background: var(--brand-pink); color: #fff; border-color: var(--brand-pink); }
.chip svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* =========================================================================
   Footer (3 cols)
   SPEC §4.2 #10
   ========================================================================= */
.footer {
  margin-top: auto;
  padding: var(--sp-8) var(--sp-4) calc(var(--sp-6) + var(--bottom-safe));
  background: var(--brand-purple);
  color: #fff;
}

.footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-5);
}

.footer__brand { display: flex; flex-direction: column; gap: var(--sp-2); }

.footer__name {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  letter-spacing: 0.02em;
}

.footer__tagline { font-size: var(--fs-sm); opacity: 0.85; line-height: var(--lh-snug); }

.footer__col h4 {
  font-family: var(--font-body);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-black);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-bottom: var(--sp-2);
}

.footer__col ul { display: flex; flex-direction: column; gap: var(--sp-2); }
.footer__col a { color: #fff; font-size: var(--fs-sm); opacity: 0.9; }
.footer__col a:hover { opacity: 1; text-decoration: underline; }

.footer__bottom {
  margin-top: var(--sp-5);
  padding-top: var(--sp-3);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
  font-size: var(--fs-2xs);
  opacity: 0.7;
}

@media (min-width: 480px) {
  .footer__inner { grid-template-columns: 1.4fr 1fr 1fr; }
}

/* =========================================================================
   Cookie banner (CMP)
   SPEC §6.7
   ========================================================================= */
.consent-banner {
  position: fixed;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: calc(var(--sp-3) + var(--bottom-safe));
  z-index: var(--z-banner);
  max-width: calc(var(--max-w) - var(--sp-6));
  margin: 0 auto;
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  pointer-events: none;
  border: 1px solid var(--border-soft);
}

.consent-banner.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.consent-banner__icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: var(--r-circle);
  background: var(--brand-pink-soft);
  color: var(--brand-pink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.consent-banner__icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.consent-banner__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.consent-banner__title { font-family: var(--font-heading); font-size: var(--fs-md); color: var(--brand-purple); }

.consent-banner__text { font-size: var(--fs-sm); color: var(--text-secondary); line-height: var(--lh-normal); margin: 0; }
.consent-banner__text a { color: var(--brand-pink); text-decoration: underline; }

.consent-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
  min-height: 40px;
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--brand-pink); outline-offset: 2px; }

.btn--primary { background: var(--brand-pink); color: #fff; }
.btn--primary:hover { background: var(--brand-pink-deep); color: #fff; text-decoration: none; }

.btn--ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-default); }
.btn--ghost:hover { background: var(--bg-soft); color: var(--brand-purple); text-decoration: none; }

.btn--link { background: transparent; color: var(--brand-pink); padding: 10px 8px; }
.btn--link:hover { color: var(--brand-pink-deep); text-decoration: underline; }

.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* =========================================================================
   Ad slot (SPEC §5)
   ========================================================================= */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, var(--bg-soft) 0 8px, var(--bg-surface) 8px 16px);
  color: var(--text-muted);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px dashed var(--border-default);
  border-radius: var(--r-md);
  margin: var(--sp-4) 0;
  min-height: 90px;
}

/* =========================================================================
   Play page (game iframe)
   SPEC §4.2 #7
   ========================================================================= */
.play-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

.play-stage__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

/* Floating action buttons over the fullscreen game iframe.
   - .play-fab--back: top-left, calls history.back (falls back to index.html)
   - .play-fab--home: top-right, links to index.html */
.play-fab {
  position: fixed;
  z-index: 50;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.play-fab:hover,
.play-fab:focus-visible {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  text-decoration: none;
  transform: scale(1.05);
}

.play-fab:active { transform: scale(0.95); }

.play-fab--back { left: 12px; }
.play-fab--home { right: 12px; }

.play-fab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Touch devices — slightly larger tap target */
@media (pointer: coarse) {
  .play-fab { width: 48px; height: 48px; }
  .play-fab svg { width: 24px; height: 24px; }
}

.play-loader {
  position: absolute;
  inset: 0;
  background: var(--grad-night);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  z-index: 2;
  transition: opacity var(--dur-base) var(--ease-out);
}

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

.play-loader__logo {
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  background: var(--grad-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 28px;
  color: #fff;
  box-shadow: var(--shadow-pink);
  animation: pulse 1.6s var(--ease-inout) infinite;
}

.play-loader__text {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  opacity: 0.9;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow-pink); }
  50%      { transform: scale(1.06); box-shadow: 0 8px 22px rgba(247, 37, 133, 0.45); }
}

.play-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* When play-meta lives INSIDE .play-stage, it becomes a translucent overlay
   so it doesn't take vertical space outside the game frame. */
.play-stage > .play-meta {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  margin: 0;
  padding: var(--sp-3);
  color: #fff;
  font-size: var(--fs-2xs);
  pointer-events: none; /* let clicks pass through to game; buttons re-enable */
}

.play-stage > .play-meta--top {
  top: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  border-top-left-radius: var(--r-md);
  border-top-right-radius: var(--r-md);
}

.play-stage > .play-meta--bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  border-bottom-left-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
  justify-content: center;
  opacity: 0.85;
}

/* Re-enable pointer events on actual interactive elements inside overlay */
.play-stage > .play-meta a,
.play-stage > .play-meta button {
  pointer-events: auto;
}

.play-stage > .play-meta .play-meta__title {
  font-family: var(--font-heading);
  font-size: var(--fs-md);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.02em;
}

/* In overlay mode, the .btn--ghost button needs contrast */
.play-stage > .play-meta .btn--ghost {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.play-stage > .play-meta .btn--ghost:hover {
  background: rgba(255, 255, 255, 0.3);
}

.play-meta__title { font-family: var(--font-heading); font-size: var(--fs-lg); color: var(--brand-purple); }

/* =========================================================================
   Legal / static pages
   ========================================================================= */
.legal {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-4);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-loose);
}
.legal h1, .legal h2, .legal h3 { color: var(--brand-purple); margin: var(--sp-4) 0 var(--sp-2); }
.legal h1 { font-size: var(--fs-2xl); margin-top: 0; }
.legal h2 { font-size: var(--fs-lg); }
.legal p, .legal li { font-size: var(--fs-sm); color: var(--text-secondary); }
.legal ul, .legal ol { padding-left: var(--sp-5); margin: var(--sp-2) 0; list-style: disc; }
.legal ol { list-style: decimal; }
.legal a { color: var(--brand-pink); text-decoration: underline; }

.legal .updated {
  display: inline-block;
  background: var(--brand-pink-soft);
  color: var(--brand-pink-deep);
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-3);
}

#cookies:target { scroll-margin-top: 80px; }

/* =========================================================================
   404 page
   ========================================================================= */
.notfound {
  text-align: center;
  padding: var(--sp-12) var(--sp-4);
}
.notfound__emoji { font-size: 80px; line-height: 1; margin-bottom: var(--sp-3); }
.notfound__title { font-family: var(--font-heading); font-size: var(--fs-5xl); color: var(--brand-pink); }
.notfound__sub { color: var(--text-secondary); margin: var(--sp-2) 0 var(--sp-5); }

/* =========================================================================
   Contact page
   ========================================================================= */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-4);
  box-shadow: var(--shadow-1);
}
.contact-form label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}
.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  background: var(--bg-page);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  outline: 0;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.contact-form input:focus,
.contact-form textarea:focus { border-color: var(--brand-pink); }
.contact-form textarea { resize: vertical; min-height: 100px; }

.contact-info {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.contact-info svg {
  width: 20px;
  height: 20px;
  stroke: var(--brand-pink);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.contact-info a { color: var(--brand-pink); font-weight: var(--fw-bold); }

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

[hidden] { display: none !important; }
