/* Home: big banner, shortcut tiles, poster-style game cards, public chat column. */

/* ---------- layout: games on the left, chat on the right ---------- */
@media (min-width: 1100px) {
  html body #home:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, calc(24vw / var(--site-zoom, 1)), 340px);
    column-gap: 22px;
    align-items: start;
  }
  html body #home > * { grid-column: 1; min-width: 0; }
  html body #home > .lobby-chat {
    grid-column: 2;
    grid-row: 1 / span 8;
    position: sticky;
    top: calc(var(--site-header-height, 96px) + 14px);
    height: calc(calc(100dvh / var(--site-zoom, 1)) - var(--site-header-height, 96px) - 28px);
    margin-top: 18px;
  }
}

/* ---------- banner ---------- */
html body #home .hero.hero-banner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 300px;
  margin: 18px 0 14px;
  padding: 30px clamp(20px, calc(3vw / var(--site-zoom, 1)), 40px);
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background:
    radial-gradient(circle at 82% 28%, #ff9be0 0, transparent 34%),
    radial-gradient(circle at 10% 110%, #5fd3ff66 0, transparent 40%),
    linear-gradient(118deg, #5b34e6 0%, #8f52ff 46%, #d863d6 100%);
  color: #fff;
  box-shadow: 6px 6px 0 var(--ink), 0 18px 40px #6d3df540;
}
.banner-copy { position: relative; z-index: 2; display: grid; justify-items: start; gap: 12px; }
.banner-chip {
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #b6f06b;
  color: #20182e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  transform: rotate(-2deg);
  box-shadow: 3px 3px 0 var(--ink);
}
html body #home .hero-banner h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(30px, calc(4.2vw / var(--site-zoom, 1)), 56px);
  line-height: 1.02;
  letter-spacing: -.03em;
  text-shadow: 0 4px 0 #3a1f8a;
}
html body #home .hero-banner h1 em { color: #ffe066; text-shadow: 0 4px 0 #3a1f8a; transform: none; }
html body #home .hero-banner p { margin: 0; max-width: 460px; color: #f1e8ff; font-size: 15px; font-weight: 600; }
.banner-steps { display: flex; flex-wrap: wrap; gap: 8px; }
html body #home .banner-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px 6px 6px;
  border: 1px solid #ffffff66;
  border-radius: 14px;
  background: #ffffff22;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: none;
  backdrop-filter: blur(4px);
}
html body #home .banner-step:hover { background: #ffffff38; transform: translateY(-2px); }
.banner-step b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: #b6f06b;
  color: #20182e;
  font-size: 14px;
}
html body #home .banner-step.step-done b { background: #fff; color: #1f7a4d; }
html body #home .hero-banner #random { margin: 4px 0 0; background: #f8d633; color: #20182e; }
.banner-art { position: relative; z-index: 1; height: 280px; }
.banner-glow { position: absolute; right: 12%; bottom: 8%; width: 230px; height: 230px; border-radius: 50%; background: radial-gradient(circle, #fff6 0, #fff0 70%); }
.banner-hero {
  position: absolute;
  right: 14%;
  bottom: -14px;
  width: clamp(150px, calc(15vw / var(--site-zoom, 1)), 196px);
  aspect-ratio: 2 / 3;
  filter: drop-shadow(0 14px 18px #2a136680);
}
.banner-hero svg { display: block; width: 100%; height: 100%; }
.banner-hero { width: clamp(170px, calc(17vw / var(--site-zoom, 1)), 220px); }
.float { position: absolute; font-size: 40px; filter: drop-shadow(0 6px 6px #0004); }
.f1 { top: 6%; left: 8%; } .f2 { top: 4%; right: 4%; font-size: 46px; } .f3 { bottom: 16%; left: 2%; font-size: 34px; }
.f4 { top: 42%; right: 0; font-size: 30px; } .f5 { bottom: 4%; left: 34%; font-size: 30px; }

/* ---------- shortcut tiles ---------- */
.home-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 20px; }
html body #home .home-tiles button {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--ui-panel, #fffdf7);
  color: var(--ui-text, #252046);
  text-align: left;
  box-shadow: 3px 3px 0 var(--ink);
}
.home-tiles .tile-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: radial-gradient(circle at 35% 30%, #d9c6ff, #8f52ff);
  font-size: 22px;
}
.home-tiles button:nth-child(2) .tile-icon { background: radial-gradient(circle at 35% 30%, #c6f4ff, #3aa0e8); }
.home-tiles button:nth-child(3) .tile-icon { background: radial-gradient(circle at 35% 30%, #ffd6ef, #e25aa8); }
.home-tiles button:nth-child(4) .tile-icon { background: radial-gradient(circle at 35% 30%, #fff1b3, #f0a820); }
.home-tiles b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-tiles small { font-size: 11px; opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- game cards: clean posters with 3D illustrations ---------- */
html body #home #games .games,
html body #home #favouriteGames {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
  grid-auto-rows: auto !important;
  gap: 16px;
}
html body #home :is(#games, #favouriteGames) .game-card { position: relative; }
html body #home :is(#games, #favouriteGames) .game-card .game {
  --c: var(--cartridge, #c6abff);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 4 / 5;
  padding: 12px 12px 14px;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 30%, #ffffffb3 0, #ffffff00 52%),
    linear-gradient(180deg, color-mix(in srgb, var(--c) 70%, #fff) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 62%, #2a1650) 100%);
  text-align: left;
  box-shadow: inset 0 0 0 2px #ffffff66, inset 0 -40px 40px -30px #2a165055, 0 14px 24px -14px color-mix(in srgb, var(--c) 40%, #1b0f3a);
  transition: transform 260ms cubic-bezier(.34, 1.56, .64, 1), box-shadow 220ms ease;
}
html body #home :is(#games, #favouriteGames) .game-card .game::before { content: none; }
html body #home :is(#games, #favouriteGames) .game-card .game::after {
  content: '';
  position: absolute;
  inset: 2% 8% 30% 8%;
  width: auto;
  height: auto;
  grid-area: auto;
  background: var(--tile-3d) center / contain no-repeat;
  filter: none;
  pointer-events: none;
  transition: transform 320ms cubic-bezier(.34, 1.56, .64, 1);
}
html body #home :is(#games, #favouriteGames) .game-card .game .icon,
html body #home :is(#games, #favouriteGames) .game-card .game p { display: none; }
html body #home :is(#games, #favouriteGames) .game-card .game h3 {
  position: relative;
  z-index: 2;
  align-self: stretch;
  margin: 0;
  color: #fff;
  font-size: clamp(14px, calc(1.35vw / var(--site-zoom, 1)), 17px);
  font-weight: 850;
  line-height: 1.15;
  letter-spacing: -.01em;
  text-transform: none;
  text-wrap: balance;
  text-shadow: 0 1px 2px #1b0f3a99, 0 2px 10px #1b0f3a55;
}
html body #home :is(#games, #favouriteGames) .game-card .game small {
  position: relative;
  z-index: 2;
  display: block;
  align-self: flex-start;
  width: auto;
  margin: 6px 0 0;
  padding: 2px 9px;
  border-radius: 999px;
  background: #ffffff33;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.6;
  backdrop-filter: blur(2px);
}
/* Hover: a "▶ Тоглох" button takes the place of the player-count line at the bottom of the tile. */
html body #home :is(#games, #favouriteGames) .game-card .game .arrow {
  position: absolute;
  z-index: 3;
  top: auto;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 6px 14px #1b0f3a55;
  color: #5b34e6;
  font: 800 14px/1 inherit;
  letter-spacing: .2px;
  opacity: 0;
  transform: translateY(6px) scale(.9);
  transition: opacity 180ms ease, transform 240ms cubic-bezier(.34, 1.56, .64, 1);
}
html body #home :is(#games, #favouriteGames) .game-card .game .arrow::before {
  content: '';
  flex: none;
  width: 10px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
html body #home :is(#games, #favouriteGames) .game-card .game small { transition: opacity 160ms ease; }
@media (hover: hover) {
  html body #home :is(#games, #favouriteGames) .game-card .game:hover {
    transform: translateY(-6px);
    box-shadow: inset 0 0 0 2px #ffffff88, inset 0 -40px 40px -30px #2a165055, 0 22px 30px -16px color-mix(in srgb, var(--c) 45%, #1b0f3a);
    filter: none;
  }
  html body #home :is(#games, #favouriteGames) .game-card:nth-child(even) .game:hover { transform: translateY(-6px); }
  html body #home :is(#games, #favouriteGames) .game-card .game:hover::after { transform: translateY(-8px) scale(1.08) rotate(-3deg); }
  html body #home :is(#games, #favouriteGames) .game-card .game:hover .arrow { opacity: 1; transform: none; }
  html body #home :is(#games, #favouriteGames) .game-card .game:hover small { opacity: 0; }
}
html body #home :is(#games, #favouriteGames) .game-pin {
  top: 10px;
  right: 10px;
  left: auto;
  z-index: 4;
  min-width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 50%;
  background: #ffffff66;
  color: #fff;
  box-shadow: none;
  backdrop-filter: blur(4px);
}
html body #home :is(#games, #favouriteGames) .game-pin[aria-pressed="true"] { background: #ffd34a; color: #2a1650; }

/* ---------- public chat ---------- */
.lobby-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 440px;
  margin: 20px 0;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: linear-gradient(180deg, #2b2046, #1d1631);
  color: #f1ecff;
  box-shadow: 6px 6px 0 var(--ink);
}
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid #ffffff1f; }
.lobby-head h2 { margin: 0; font-size: 16px; color: #fff; }
.lobby-online { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: #ffffff14; font-size: 12px; }
.lobby-online i { width: 8px; height: 8px; border-radius: 50%; background: #5bf08c; box-shadow: 0 0 8px #5bf08c; }
#lobbyList { flex: 1; min-height: 0; margin: 6px 0; padding: 0 2px; overflow-y: auto; list-style: none; overscroll-behavior: contain; scrollbar-width: thin; }
#lobbyList li { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px; margin: 10px 0; }
html body .lobby-face {
  width: 38px;
  height: 38px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid #ffffff40;
  border-radius: 11px;
  background: #c6abff;
  box-shadow: none;
}
html body .lobby-face:hover { border-color: #b6f06b; transform: scale(1.06); }
.lobby-face svg { display: block; width: 100%; height: 100%; }
.lobby-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }
.lobby-meta b { overflow: hidden; color: #fff; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.lobby-level { flex: none; padding: 0 6px; border-radius: 999px; background: #f8d63333; color: #ffe066; font-size: 10px; font-weight: 800; }
.lobby-meta time { margin-left: auto; font-size: 10px; opacity: .55; }
#lobbyList p {
  width: fit-content;
  max-width: 100%;
  margin: 3px 0 0;
  padding: 6px 10px;
  border-radius: 4px 14px 14px 14px;
  background: #ffffff16;
  color: #f1ecff;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#lobbyList .lobby-mine p { background: #8f52ffaa; }
#lobbyList p.lobby-emoji { padding: 0; background: none; font-size: 30px; }
#lobbyEmpty { flex: 1; margin: 12px 0; color: #cfc3ef; font-size: 13px; }
#lobbyEmpty[hidden], #lobbyForm[hidden] { display: none; }
#lobbyForm { display: flex; gap: 6px; }
html body #lobbyInput { flex: 1; min-width: 0; min-height: 44px; padding: 8px 14px; border: 1px solid #ffffff3a; border-radius: 999px; background: #ffffff12; color: #fff; font-size: 16px; }
html body #lobbyInput::placeholder { color: #cfc3ef99; }
html body #lobbyForm button { flex: none; width: 44px; min-height: 44px; padding: 0; border: 2px solid var(--ink); border-radius: 50%; background: #b6f06b; color: #20182e; font-size: 18px; box-shadow: none; }
.lobby-signin { display: block; padding: 11px; border: 2px solid var(--ink); border-radius: 14px; background: #b6f06b; color: #20182e; font-weight: 800; text-align: center; }
.lobby-signin[hidden] { display: none; }
#lobbyError { margin: 4px 0 0; color: #ffb5c6; font-size: 12px; }
#lobbyError:empty { display: none; }

/* ---------- phones and tablets ---------- */
@media (max-width: 760px) {
  html body #home .hero.hero-banner { grid-template-columns: 1fr; min-height: 0; padding: 22px 18px; }
  .banner-copy { padding-right: 34%; }
  .banner-art { position: absolute; right: 0; bottom: 0; width: 42%; height: 100%; }
  .banner-hero { right: 8%; bottom: -10px; width: min(130px, calc(34vw / var(--site-zoom, 1))); }
  .banner-steps { margin-right: -50%; }
  html body #home .hero-banner p { font-size: 13px; }
  .float { font-size: 26px; }
  .f2 { font-size: 30px; } .f3, .f5 { display: none; }
  .home-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  html body #home #games .games, html body #home #favouriteGames { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .lobby-chat { height: 400px; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .banner-hero { animation: hero-bob 3.2s ease-in-out infinite; }
  .hero-swap svg { animation: hero-swap 520ms cubic-bezier(.34, 1.56, .64, 1); }
  .float { animation: float-y 4s ease-in-out infinite; }
  .f2 { animation-delay: -1s; } .f3 { animation-delay: -2s; } .f4 { animation-delay: -1.5s; } .f5 { animation-delay: -3s; }
  @keyframes hero-bob { 50% { transform: translateY(-8px); } }
  @keyframes hero-swap { from { opacity: 0; transform: scale(.7) rotate(-6deg); } }
  @keyframes float-y { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-12px) rotate(8deg); } }
  #lobbyList li.lobby-new { animation: lobby-in 360ms cubic-bezier(.34, 1.56, .64, 1) both; }
  @keyframes lobby-in { from { opacity: 0; transform: translateY(10px) scale(.95); } }
  html body #home .home-tiles button:hover .tile-icon { animation: tile-wiggle 500ms ease; }
  @keyframes tile-wiggle { 30% { transform: rotate(-10deg) scale(1.1); } 60% { transform: rotate(8deg) scale(1.1); } }
}

/* Language switch beside the theme switch. */
#langToggle {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: 50%;
  background: var(--ui-panel);
  color: var(--ui-text);
  box-shadow: none;
  font: 800 13px/1 system-ui, sans-serif;
  letter-spacing: .5px;
}
#langToggle:hover { background: var(--ui-hover); }

/* ---------- desktop: compact home page ----------
   Short banner and shortcuts on top, then every game card (the page scrolls a little if needed); chat stays in view on the right. */
@media (min-width: 1100px) and (min-height: 600px) {
  html body #home:not([hidden]) {
    --home-h: calc(calc(100dvh / var(--site-zoom, 1)) - var(--site-header-height, 76px) - 14px);
    max-width: 1760px;
    width: calc(100% - 48px);
    margin-inline: auto;
    grid-template-rows: auto auto auto 1fr;
    align-items: start;
    row-gap: 10px;
    padding-bottom: 20px;
  }
  html body #home > .hero { grid-row: 1; }
  html body #home > .home-tiles { grid-row: 2; }
  html body #home > #favouriteSection { grid-row: 3; }
  html body #home > #regularGamesSection { grid-row: 4; }
  html body #home > .lobby-chat {
    grid-row: 1 / -1;
    position: sticky;
    top: calc(var(--site-header-height, 76px) + 10px);
    height: var(--home-h);
    margin: 10px 0 0;
  }
  /* Compact banner */
  html body #home .hero.hero-banner { min-height: 0; margin: 10px 0 0; padding: 16px 26px; border-radius: 22px; }
  html body #home .hero-banner h1 { font-size: clamp(26px, calc(2.6vw / var(--site-zoom, 1)), 42px); }
  html body #home .hero-banner p { font-size: 13px; }
  html body #home .banner-copy { gap: 8px; }
  html body #home .banner-step { padding-block: 4px; }
  html body #home .hero-banner #random { margin-top: 0; padding-block: 8px; }
  html body #home .banner-art { height: clamp(140px, calc(19dvh / var(--site-zoom, 1)), 210px); }
  html body #home .banner-hero { width: clamp(96px, calc(9.5dvh / var(--site-zoom, 1)), 140px); bottom: -10px; }
  html body #home .float { font-size: 28px; }
  /* Banner as a short strip: title on top, steps and the random button side by side */
  html body #home .hero.hero-banner { grid-template-columns: minmax(0, 1fr) clamp(180px, 22%, 280px); padding: 14px 24px; }
  html body #home .banner-copy { grid-template-columns: auto auto; justify-content: start; align-items: center; column-gap: 12px; row-gap: 8px; }
  html body #home .banner-copy > :is(.banner-chip, h1, p) { grid-column: 1 / -1; }
  html body #home .banner-chip { display: none; }
  html body #home .hero-banner h1 br { display: none; }
  html body #home .hero-banner h1 em { margin-right: .28em; }
  html body #home .hero-banner h1 { font-size: clamp(24px, calc(2.2vw / var(--site-zoom, 1)), 36px); }
  html body #home .banner-art { height: 120px; }
  html body #home .banner-hero { width: 82px; bottom: -6px; }
  html body #home .float { font-size: 22px; }
  /* Compact shortcuts */
  html body #home .home-tiles { margin: 0; gap: 10px; }
  html body #home .home-tiles button { padding: 7px 10px; grid-template-columns: 36px minmax(0, 1fr); border-radius: 14px; }
  html body #home .home-tiles .tile-icon { width: 36px; height: 36px; }
  /* Games: fill the rest */
  html body #home #regularGamesSection { margin: 0; }
  html body #home #regularGamesSection .section-head { margin: 0 0 6px; }
  html body #home #regularGamesSection .section-head h2 { margin: 0; font-size: 20px; }
  html body #home #regularGamesSection .library-controls { margin-bottom: 8px; }
  html body #home #games { padding: 4px 2px 8px; }
  html body #home #games .games, html body #home #favouriteGames {
    grid-template-columns: repeat(auto-fill, minmax(clamp(140px, calc(9.2vw / var(--site-zoom, 1)), 178px), 1fr)) !important;
    gap: 12px;
  }
  html body #home :is(#games, #favouriteGames) .game-card .game { padding: 11px 11px 12px; border-radius: 20px; }
  html body #home :is(#games, #favouriteGames) .game-card .game h3 { font-size: clamp(14px, calc(1.1vw / var(--site-zoom, 1)), 18px); }
  html body #home :is(#games, #favouriteGames) .game-card .game small { font-size: 11px; }
  html body #home #favouriteSection:not([hidden]) { margin: 6px 0 0; }
  html body #home #favouriteSection .section-head { margin-bottom: 6px; }
  html body #home #favouriteSection .section-head h2 { margin: 0; font-size: 20px; }
  html body #home #favouriteGames { padding: 4px 2px 8px; }
}

/* ---------- website backgrounds (menu: Вэбийн дэвсгэр) and game backgrounds ---------- */
/* The picture sits on a layer pinned to the screen, so it always fits the visible screen
   (phones ignore "fixed" backgrounds, and desktop game scaling would otherwise enlarge it). */
html[data-site-bg="waves"] body:not([data-game-scene]),
body[data-game-scene][data-game-background="waves"],
html[data-site-bg="purple"] body:not([data-game-scene]),
body[data-game-scene][data-game-background="purple"] {
  background: transparent !important;
}
html[data-site-bg="waves"]:has(body:not([data-game-scene])),
html:has(body[data-game-scene][data-game-background="waves"]) { background: #1b1446; }
html[data-site-bg="purple"]:has(body:not([data-game-scene])),
html:has(body[data-game-scene][data-game-background="purple"]) { background: #1d1148; }
html[data-site-bg="waves"]:has(body:not([data-game-scene]))::before,
html:has(body[data-game-scene][data-game-background="waves"])::before,
html[data-site-bg="purple"]:has(body:not([data-game-scene]))::before,
html:has(body[data-game-scene][data-game-background="purple"])::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("bg/waves.avif") center / cover no-repeat;
}
html[data-site-bg="purple"]:has(body:not([data-game-scene]))::before,
html:has(body[data-game-scene][data-game-background="purple"])::before { background-image: url("bg/purple.avif"); }
/* Tall screens (phones): the same pictures turned upright, so the whole design fits. */
@media (orientation: portrait) {
  html[data-site-bg="waves"]:has(body:not([data-game-scene]))::before,
  html:has(body[data-game-scene][data-game-background="waves"])::before { background-image: url("bg/waves-tall.avif"); }
  html[data-site-bg="purple"]:has(body:not([data-game-scene]))::before,
  html:has(body[data-game-scene][data-game-background="purple"])::before { background-image: url("bg/purple-tall.avif"); }
}
/* Words that sit straight on a dark/bold background turn light. */
:is(html[data-site-bg="waves"], html[data-site-bg="purple"]) body:not([data-game-scene]) :is(#home .section-head h2, footer, footer span),
body[data-game-scene]:is([data-game-background="waves"], [data-game-background="purple"]) :is(.score-panel h3, .room-toolbar small, #gameMeta, .score-panel > small) {
  color: #fff;
  text-shadow: 0 2px 8px #0009;
}
html[data-site-bg="waves"] body:not([data-game-scene]) #home .section-head h2 {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  background: #1b1446cc;
  text-shadow: none;
}

/* Menu: background choices with a little preview swatch */
.site-bg-picker { display: grid; gap: 6px; margin-top: 10px; text-align: left; }
.site-bg-picker > b { font-size: 13px; }
.site-bg-picker > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.site-bg-picker button { display: grid; justify-items: center; gap: 4px; margin: 0; padding: 6px 4px; font-size: 11px; line-height: 1.2; }
.site-bg-picker button[aria-pressed="true"] { outline: 3px solid #8f52ff; outline-offset: 1px; }
.site-bg-swatch { display: block; width: 100%; height: 34px; border: 2px solid var(--ink, #252046); border-radius: 8px; }
.site-bg-plain { background: #fff8ed radial-gradient(circle, #825cc722 1px, transparent 1px) 0 0 / 8px 8px; }
.site-bg-waves { background: url("bg/waves.avif") center / cover; }
.site-bg-purple { background: url("bg/purple.avif") center / cover; }

/* ---------- game tiles: a little playful texture (halftone dots, confetti, a soft shine) ---------- */
html body #home :is(#games, #favouriteGames) .game-card .game::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 12%, #ffffff55 0 3px, transparent 3.5px),
    radial-gradient(circle at 84% 22%, #ffffff40 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 8%, #ffe06688 0 2.5px, transparent 3px),
    radial-gradient(circle at 10% 46%, #ffffff33 0 2px, transparent 2.5px),
    linear-gradient(135deg, transparent 0 28%, #ffffff1f 28% 34%, transparent 34% 100%),
    radial-gradient(circle at 40% 18%, #ff9be088 0 2px, transparent 2.5px),
    radial-gradient(circle at 90% 50%, #8fe3ff88 0 2.5px, transparent 3px),
    radial-gradient(circle, #ffffff45 1.1px, transparent 1.6px) 0 0 / 7px 7px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 85%);
  mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 85%);
}

/* ---------- public chat in light mode: cream panel, dark text (dark mode keeps the night look) ---------- */
html:not([data-theme="dark"]) .lobby-chat {
  background: linear-gradient(180deg, #fffdf7, #f6efff);
  color: #2a1f45;
}
html:not([data-theme="dark"]) .lobby-head { border-bottom-color: #2520461a; }
html:not([data-theme="dark"]) .lobby-head h2 { color: #2a1f45; }
html:not([data-theme="dark"]) .lobby-online { background: #8f52ff1a; color: #4a2fa0; }
html:not([data-theme="dark"]) .lobby-online i { background: #1fbf5b; box-shadow: 0 0 6px #1fbf5b88; }
html:not([data-theme="dark"]) body .lobby-face { border-color: #2520462e; }
html:not([data-theme="dark"]) .lobby-meta b { color: #2a1f45; }
html:not([data-theme="dark"]) .lobby-level { background: #f8d63355; color: #8a5a00; }
html:not([data-theme="dark"]) .lobby-meta time { color: #2a1f45; }
html:not([data-theme="dark"]) #lobbyList p { background: #efe7ff; color: #2a1f45; }
html:not([data-theme="dark"]) #lobbyList .lobby-mine p { background: #8f52ff; color: #fff; }
html:not([data-theme="dark"]) #lobbyList p.lobby-emoji { background: none; }
html:not([data-theme="dark"]) #lobbyEmpty { color: #6b5f86; }
html:not([data-theme="dark"]) body #lobbyInput { border-color: #2520462e; background: #fff; color: #2a1f45; }
html:not([data-theme="dark"]) body #lobbyInput::placeholder { color: #6b5f8699; }
html:not([data-theme="dark"]) #lobbyError { color: #c0284f; }
html:not([data-theme="dark"]) #lobbyList { scrollbar-color: #c6abff transparent; }

/* ---------- banner: 2560×1440 shape (16:9) ----------
   Tablets and computers; phones keep a banner sized to its text. */
@media (min-width: 900px) { html body #home .hero.hero-banner { aspect-ratio: 2560 / 1440; min-height: auto !important; align-content: center; } }
@media (min-width: 1100px) {
  html body #home .hero.hero-banner {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    padding: clamp(24px, calc(3.2vw / var(--site-zoom, 1)), 64px);
    border-radius: 28px;
  }
  html body #home .banner-copy { grid-template-columns: 1fr; gap: clamp(10px, 1.2vw, 20px); }
  html body #home .banner-chip { display: inline-flex; }
  html body #home .hero-banner h1 br { display: inline; }
  html body #home .hero-banner h1 em { margin-right: 0; }
  html body #home .hero-banner h1 { font-size: clamp(38px, calc(4.4vw / var(--site-zoom, 1)), 84px); }
  html body #home .hero-banner p { max-width: 560px; font-size: clamp(14px, 1.1vw, 19px); }
  html body #home .banner-steps { gap: 10px; }
  html body #home .banner-step { padding-block: 8px; }
  html body #home .hero-banner #random { padding: 12px 20px; font-size: 16px; }
  html body #home .banner-art { height: clamp(240px, calc(30vw / var(--site-zoom, 1)), 560px); }
  html body #home .banner-hero { width: clamp(150px, calc(15vw / var(--site-zoom, 1)), 300px); bottom: -10px; }
  html body #home .float { font-size: clamp(30px, 2.8vw, 54px); }
}

/* Who's online: the green count opens a list of signed-in players. */
html body button.lobby-online { min-height: 0; margin: 0; border: 0; color: inherit; font: inherit; font-size: 12px; box-shadow: none; cursor: pointer; }
html body button.lobby-online:hover { background: #ffffff26; transform: none; }
html:not([data-theme="dark"]) body button.lobby-online:hover { background: #8f52ff2e; }
button.lobby-online::after { content: '▾'; font-size: 10px; opacity: .7; }
button.lobby-online[aria-expanded="true"]::after { content: '▴'; }
.lobby-people { max-height: 220px; margin: 6px 0 0; padding: 6px; overflow-y: auto; border-radius: 14px; background: #ffffff10; scrollbar-width: thin; }
.lobby-people[hidden] { display: none; }
.lobby-people ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.lobby-people li { display: flex; align-items: center; gap: 8px; min-width: 0; }
html body .lobby-people .lobby-face { flex: none; width: 30px; height: 30px; border-radius: 9px; }
.lobby-people li b { overflow: hidden; color: #fff; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.lobby-people p { margin: 4px 2px 0; font-size: 12px; opacity: .7; }
.lobby-people p:empty { display: none; }
html:not([data-theme="dark"]) .lobby-people { background: #8f52ff12; }
html:not([data-theme="dark"]) .lobby-people li b { color: #2a1f45; }
html.chat-docked .lobby-head h2 { white-space: nowrap; }
html.chat-docked body button.lobby-online { padding-inline: 8px; }
html.chat-docked button.lobby-online::after { display: none; }
