/* Modern look (reference: dark gaming dashboard).
   Same page layout; softer surfaces: rounded corners, thin borders, no hard offset shadows,
   a pink "primary" button with a glow, and the menu docked on the left on wide screens.
   Loaded last so it sits on top of the older style layers. */

:root {
  --m-bg: #f3f4fa;
  --m-panel: #ffffff;
  --m-panel-2: #f6f7fc;
  --m-border: #e2e4ef;
  --m-text: #1b1d2e;
  --m-muted: #6b7089;
  --m-hover: #eef0f8;
  --m-active: #e7e9f6;
  --m-accent: #ff3d71;
  --m-accent-2: #ff2a55;
  --m-glow: 0 6px 18px #ff3d7159;
  --m-shadow: 0 8px 24px #1b1d2e12;
  --m-radius: 12px;
  --rail-w: 236px;
}
:root:not([data-theme="light"]) {
  --m-bg: #12131e;
  --m-panel: #1b1d2c;
  --m-panel-2: #222538;
  --m-border: #ffffff14;
  --m-text: #e8e9f3;
  --m-muted: #9397b0;
  --m-hover: #272a40;
  --m-active: #2c3048;
  --m-shadow: 0 10px 30px #00000059;
}

/* ---------- page background (plain website background only) ---------- */
html:not([data-site-bg="waves"]):not([data-site-bg="purple"]) body:not([data-game-scene]) {
  background: var(--m-bg) !important;
}
html:not([data-theme="light"]):not([data-site-bg="waves"]):not([data-site-bg="purple"]) body:not([data-game-scene]) {
  background:
    radial-gradient(1000px 600px at 70% -10%, #3a2a7a33, transparent 70%),
    radial-gradient(800px 500px at 10% 110%, #ff3d7114, transparent 70%),
    var(--m-bg) !important;
  background-attachment: fixed !important;
}

/* ---------- header: flat bar with a hairline, like the reference ---------- */
html body > header,
html[data-theme="dark"] body > header {
  background: color-mix(in srgb, var(--m-panel) 88%, transparent);
  border-bottom: 1px solid var(--m-border) !important;
  box-shadow: none;
  backdrop-filter: blur(14px);
}
html body > header #brand { color: var(--m-text) !important; text-shadow: none; }
html body > header #brand span { color: var(--m-accent); }
html body > header .top-note {
  background: var(--m-hover) !important;
  color: var(--m-muted) !important;
  border: 1px solid var(--m-border);
  box-shadow: none;
  font-family: inherit;
  letter-spacing: 1.2px;
}
html body > header :is(#themeToggle, #langToggle, #sidebarOpen),
html[data-theme="dark"] body > header :is(#themeToggle, #langToggle, #sidebarOpen) {
  border: 1px solid var(--m-border);
  border-radius: 10px;
  background: var(--m-panel-2);
  color: var(--m-text);
  box-shadow: none;
  font-size: 17px;
}
html body > header :is(#themeToggle, #langToggle, #sidebarOpen):hover,
html[data-theme="dark"] body > header :is(#themeToggle, #langToggle, #sidebarOpen):hover { background: var(--m-hover); }

/* ---------- buttons ---------- */
html body :is(#headerMenu, .room-toolbar, .play-top, .score-panel, .library-controls, .game-controls-bar, .game-size) button,
html body dialog button:not(.dark):not(.swatch):not(.intro-shot):not(.intro-play):not(.lobby-face),
html body .stage-card:not(.card-game-stage) .actions button:not(.dark),
html body .stage-card:not(.card-game-stage) .player-grid button,
html[data-theme="dark"] body :is(#headerMenu, .room-toolbar, .play-top, .score-panel) button,
html[data-theme="dark"] body dialog button:not(.dark):not(.swatch):not(.intro-shot):not(.intro-play),
html[data-theme="dark"] body .stage-card:not(.card-game-stage) button:not(.dark):not(.truth-card):not(.wyr-option) {
  border: 1px solid var(--m-border);
  border-radius: 10px;
  background: var(--m-panel-2);
  color: var(--m-text);
  box-shadow: none;
  transform: none;
  font-weight: 700;
  transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
}
html body :is(#headerMenu, .room-toolbar, .play-top, .score-panel, .library-controls, .game-controls-bar, .game-size) button:hover,
html body dialog button:not(.dark):not(.swatch):not(.intro-shot):not(.intro-play):not(.lobby-face):hover,
html body .stage-card:not(.card-game-stage) :is(.actions, .player-grid) button:not(.dark):hover {
  background: var(--m-hover);
  border-color: color-mix(in srgb, var(--m-text) 18%, transparent);
  transform: translateY(-1px);
  box-shadow: none;
}
html body :is(#headerMenu, .room-toolbar, .play-top, .score-panel, .library-controls) button:active,
html body dialog button:active,
html body .stage-card .actions button:active { transform: translateY(1px); box-shadow: none; }

/* Primary actions: pink with a soft glow (the reference's "Join now"). */
html body .dark,
html body .stage-card:not(.card-game-stage) .actions button.dark,
html body #home .hero-banner #random,
html body #gameIntro .intro-play,
html body #lobbyForm button,
html body .lobby-signin,
html body #createRoom {
  border: 0 !important;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--m-accent), var(--m-accent-2)) !important;
  color: #fff !important;
  box-shadow: var(--m-glow) !important;
  font-weight: 800;
  text-shadow: none;
}
html body .dark:hover,
html body #home .hero-banner #random:hover,
html body #gameIntro .intro-play:hover,
html body #createRoom:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}
html body .small { border-radius: 10px; }
html body #count {
  border: 0;
  border-radius: 999px;
  background: var(--m-accent);
  color: #fff !important;
}

/* ---------- inputs ---------- */
html body :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), textarea, select),
html[data-theme="dark"] body :is(dialog, #play, #roomMain, .game-background-picker) :is(input, textarea, select) {
  border: 1px solid var(--m-border);
  border-radius: 10px;
  background: var(--m-panel-2);
  color: var(--m-text);
  box-shadow: none;
}
html body :is(input, textarea, select):focus { outline: 2px solid color-mix(in srgb, var(--m-accent) 55%, transparent); outline-offset: 1px; border-color: transparent; }

/* ---------- panels: dialogs, game stage, prompts ---------- */
html body dialog,
html[data-theme="dark"] body dialog,
:root[data-theme="dark"] body:has(#home:not([hidden])) dialog {
  border: 1px solid var(--m-border);
  border-radius: 18px;
  background: var(--m-panel);
  color: var(--m-text);
  box-shadow: 0 24px 60px #0000004d;
}
html body dialog::backdrop { background: #0b0c14a6; backdrop-filter: blur(6px); }
html body dialog p { color: var(--m-muted); }
html body .dialog-head button {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  border-radius: 10px !important;
  font-size: 20px !important;
}
html body .stage-card:not(.card-game-stage),
:root[data-theme="dark"] body :is(#play, #roomMain) .stage-card:not(.card-game-stage) {
  border: 1px solid var(--m-border);
  border-radius: 20px;
  background: var(--m-panel);
  color: var(--m-text);
  box-shadow: var(--m-shadow);
}
html body .stage-card h2 { color: var(--m-text); letter-spacing: -.5px; }
html body .stage-card:not(.card-game-stage) p { color: var(--m-muted); }
html body .stage-card .chip {
  border: 1px solid var(--m-border);
  border-radius: 999px;
  background: var(--m-hover);
  color: var(--m-muted) !important;
  box-shadow: none;
  transform: none;
  font-weight: 700;
}
html body .stage-card .prompt,
:root[data-theme="dark"] body .stage-card .prompt {
  border: 1px solid color-mix(in srgb, var(--m-accent) 30%, var(--m-border));
  border-radius: 16px;
  background:
    radial-gradient(circle at 0 0, color-mix(in srgb, var(--m-accent) 14%, transparent), transparent 60%),
    var(--m-panel-2);
  color: var(--m-text) !important;
  box-shadow: none;
}
html body .stage-card .room-wait { color: var(--m-muted) !important; }
html body .timer { color: var(--m-accent); text-shadow: none; }
html body .score-panel { border-top: 1px solid var(--m-border); }
html body .score-panel h3 { color: var(--m-text); }
html body :is(.score-panel .score, .room-player-list > span),
:root[data-theme="dark"] body :is(.score-panel .score, .room-player-list > span) {
  border: 1px solid var(--m-border);
  border-radius: 10px;
  background: var(--m-panel);
  color: var(--m-text);
  box-shadow: none;
}
html body .score b, html body .room-player-list > span b { color: var(--m-accent); }
html body #toast {
  border: 1px solid var(--m-border);
  border-radius: 12px;
  background: var(--m-panel);
  color: var(--m-text);
  box-shadow: var(--m-shadow);
}

/* Game screens' small cards (Two Truths, Would You Rather…) lose the hard shadow too. */
html body :is(.truth-card, .wyr-option, .wyr-side, .guess-row, .guess-answer) { box-shadow: none; border-width: 1px; border-color: var(--m-border); }
html body .wyr-option[aria-pressed="true"],
html body .guess-win,
html body .wyr-win { box-shadow: 0 0 0 2px var(--m-accent); }

/* ---------- home: banner, shortcut tiles, game cards, chat ---------- */
html body #home .hero.hero-banner {
  border: 1px solid #ffffff1f;
  border-radius: 20px;
  background:
    radial-gradient(circle at 85% 20%, #ff6fae66 0, transparent 40%),
    radial-gradient(circle at 5% 120%, #22d3ee40 0, transparent 45%),
    linear-gradient(120deg, #2a1c6e 0%, #5b2bd1 45%, #b2338f 100%);
  box-shadow: var(--m-shadow);
}
html body #home .banner-step { border-radius: 10px; border-color: #ffffff2e; background: #ffffff14; }
html body #home .banner-step b { border-radius: 8px; background: #ffffff; color: #2a1c6e; }

html body #home .home-tiles button {
  border: 1px solid var(--m-border);
  border-radius: 14px;
  background: var(--m-panel);
  color: var(--m-text);
  box-shadow: none;
  transition: background .15s, transform .15s, border-color .15s;
}
html body #home .home-tiles button:hover { background: var(--m-hover); transform: translateY(-2px); }
html body #home .home-tiles .tile-icon { border-radius: 10px; }
html body #home .home-tiles small { color: var(--m-muted); opacity: 1; }

html body #home .section-head h2 { color: var(--m-text); }
html body #home .section-head h2 span { border: 0; border-radius: 999px; background: var(--m-hover); color: var(--m-muted); }
html body #home .library-controls [aria-pressed="true"],
html[data-theme="dark"] body #home .library-controls [aria-pressed="true"] {
  border-color: transparent;
  background: var(--m-text);
  color: var(--m-panel);
}

html body #home :is(#games, #favouriteGames) .game-card .game { border-radius: 14px; }
html body #home :is(#games, #favouriteGames) .game-card .game .arrow {
  inset: 50% auto auto 50%;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--m-accent), var(--m-accent-2));
  color: #fff;
  box-shadow: var(--m-glow);
  font-size: 0;
  transform: translate(-50%, -50%) scale(.8);
}
html body #home :is(#games, #favouriteGames) .game-card .game .arrow::before { width: 16px; height: 18px; margin-left: 4px; }
@media (hover: hover) {
  html body #home :is(#games, #favouriteGames) .game-card .game:hover .arrow { transform: translate(-50%, -50%); }
  html body #home :is(#games, #favouriteGames) .game-card .game:hover small { opacity: 1; }
  html body #home :is(#games, #favouriteGames) .game-card .game:hover::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: #0b0c1466;
    pointer-events: none;
  }
}
html body #home :is(#games, #favouriteGames) .game-pin { border-radius: 10px; background: #0b0c1440; }

html body .lobby-chat,
html:not([data-theme="dark"]) body .lobby-chat {
  border: 1px solid var(--m-border);
  border-radius: 18px;
  background: var(--m-panel);
  box-shadow: var(--m-shadow);
}
html body .lobby-head h2, html:not([data-theme="dark"]) body .lobby-head h2 { color: var(--m-text); }
html body .lobby-head { border-bottom-color: var(--m-border); }
html body #lobbyInput,
html:not([data-theme="dark"]) body #lobbyInput { border-color: var(--m-border); border-radius: 10px; background: var(--m-panel-2); color: var(--m-text); }
html body #lobbyForm button { border-radius: 10px; }
html body .lobby-signin { padding: 11px; border-radius: 12px; text-align: center; }

/* ---------- side menu ---------- */
html body #siteSidebar {
  border: 1px solid var(--m-border);
  border-left: 0;
  background: var(--m-panel);
  color: var(--m-text);
  box-shadow: 0 24px 60px #00000040;
}
html body #siteSidebar nav { gap: 4px; }
html body #siteSidebar :is(nav, .side-cats, .side-settings) button, html body #siteSidebar .side-signout {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--m-muted);
  box-shadow: none;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transform: none;
}
html body #siteSidebar .side-signout { text-decoration: none; box-sizing: border-box; }
html body #siteSidebar .side-signout[hidden] { display: none; }
html body #siteSidebar :is(nav, .side-cats, .side-settings) button:hover, html body #siteSidebar .side-signout:hover { background: var(--m-hover); color: var(--m-text); transform: none; }
html:has(#home:not([hidden])) body #siteSidebar nav [data-sidebar-go="brand"] { background: var(--m-active); color: var(--m-text); }
.side-ico { flex: none; display: grid; place-items: center; width: 22px; height: 22px; }
.side-ico svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-cats { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--m-border); }
.side-cats h3 { margin: 0 0 6px; padding: 0 12px; color: var(--m-text); font-size: 13px; font-weight: 800; }
.side-cats .side-ico { border-radius: 7px; background: var(--m-hover); color: var(--m-text); font-size: 12px; font-weight: 800; }
.side-settings { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--m-border); }
.side-settings:empty { display: none; }
html body #siteSidebar .site-bg-picker { padding: 0 4px; }
html body #siteSidebar .site-bg-picker button { flex-direction: column; justify-content: center; min-height: 0; padding: 6px 4px; font-size: 11px; }
html body #siteSidebar .site-bg-swatch { border-width: 1px; border-color: var(--m-border); }

/* Wide screens: the menu stays open on the left, under the header (the ☰ button folds it away). */
@media (min-width: 1100px) {
  html.sidebar-docked body { padding-left: var(--rail-w); }
  html.sidebar-docked body > header { margin-left: calc(-1 * var(--rail-w)); width: calc(100% + var(--rail-w)); }
  html.sidebar-docked body #siteSidebar {
    position: fixed;
    inset: var(--site-header-height, 72px) auto 0 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    width: var(--rail-w);
    height: auto;
    max-height: none;
    margin: 0;
    padding: 14px 12px 18px;
    border: 0;
    border-right: 1px solid var(--m-border);
    border-radius: 0;
    background: color-mix(in srgb, var(--m-panel) 92%, transparent);
    box-shadow: none;
    backdrop-filter: blur(14px);
  }
  html.sidebar-docked body #siteSidebar .dialog-head { display: none; }
  html.sidebar-docked body #siteSidebar nav { margin-top: 0; }
  html.sidebar-docked body #siteSidebar .side-settings { margin-top: auto; }
}

/* Header buttons, as in the reference: quiet text buttons plus one pink call to action. */
html body > header #headerMenu button {
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  background: transparent !important;
  color: var(--m-text) !important;
  box-shadow: none !important;
  transform: none !important;
  font-weight: 700;
}
html body > header #headerMenu button:hover { background: var(--m-hover) !important; }
html body > header #headerMenu #roomsOpen {
  padding-inline: 16px;
  background: linear-gradient(180deg, var(--m-accent), var(--m-accent-2)) !important;
  color: #fff !important;
  box-shadow: var(--m-glow) !important;
}
html body > header #headerMenu #roomsOpen:hover { filter: brightness(1.07); }
html body > header .top-note { opacity: 1; }
html body #home .section-head button,
html body #home .library-controls button {
  border: 1px solid var(--m-border) !important;
  border-radius: 10px !important;
  background: var(--m-panel) !important;
  color: var(--m-text) !important;
  box-shadow: none !important;
  transform: none !important;
}
html body #home .library-controls [aria-pressed="true"] { border-color: transparent !important; background: var(--m-text) !important; color: var(--m-panel) !important; }
html body #siteSidebar { scrollbar-width: thin; scrollbar-color: var(--m-border) transparent; }
/* With the menu docked the banner column is narrower: keep the title from overflowing. */
html.sidebar-docked body #home .hero-banner h1 { font-size: clamp(28px, calc(3vw / var(--site-zoom, 1)), 46px); }
html.sidebar-docked body > header .top-note { display: none; }
html body #home .banner-chip { border: 1px solid #ffffff33; border-radius: 999px; background: #ffffff1f; color: #fff; box-shadow: none; transform: none; }
html body .game-size,
html body .game-controls-bar .game-background-picker,
html body .game-controls-bar > label {
  border: 1px solid var(--m-border) !important;
  border-radius: 12px !important;
  background: var(--m-panel) !important;
  color: var(--m-text) !important;
  box-shadow: none !important;
}
html body .game-size button {
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: var(--m-text) !important;
  box-shadow: none !important;
}
html body .game-size button:hover { background: var(--m-hover) !important; }

/* Header profile chip: avatar, name, level and coins (signed in). */
html body > header #headerMenu #accountOpen.has-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--m-border) !important;
  background: var(--m-panel-2) !important;
}
html body > header #headerMenu #accountOpen.has-profile:hover { background: var(--m-hover) !important; }
#accountOpen.has-profile #headerProfileLabel { display: none; }
html body > header #accountOpen.has-profile :is(#headerProfilePhoto, #headerProfileAvatar) { width: 36px; height: 36px; border: 0; border-radius: 10px; }
#headerProfileInfo { display: grid; gap: 2px; text-align: left; line-height: 1.15; }
#headerProfileInfo .hp-name { max-width: 150px; overflow: hidden; color: var(--m-text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
#headerProfileInfo .hp-stats { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; }
#headerProfileInfo .hp-level { padding: 1px 7px; border-radius: 999px; background: #f8c62e2e; color: #a86f00; }
:root:not([data-theme="light"]) #headerProfileInfo .hp-level { color: #ffd84d; }
#headerProfileInfo .hp-coins { color: var(--m-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  #headerProfileAvatar:not([hidden]) + #headerProfileLabel { display: none; }
  #headerProfileInfo .hp-name { max-width: 90px; }
}
@media (max-width: 680px) {
  html body > header #headerMenu #accountOpen.has-profile { gap: 6px; padding: 3px 8px 3px 3px; }
  html body > header #accountOpen.has-profile :is(#headerProfilePhoto, #headerProfileAvatar) { width: 30px; height: 30px; }
  #headerProfileInfo .hp-name { max-width: 70px; font-size: 12px; }
}

/* ---------- Home layout: two banners on top; tiles + games on the left; chat on the right ---------- */
.home-banners { display: grid; gap: 14px; margin: 14px 0; }
.home-banners > .hero.hero-banner { margin: 0 !important; }
html body #home .hero.hero-banner { grid-template-columns: minmax(0, 1fr) !important; }
.avatar-banner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  min-height: 180px;
  padding: 18px 24px;
  border: 1px solid #ffffff1f;
  border-radius: 20px;
  background:
    radial-gradient(circle at 75% 30%, #ffd1f066 0, transparent 45%),
    radial-gradient(circle at 0 100%, #ffb34733 0, transparent 50%),
    linear-gradient(120deg, #a2329e 0%, #d6457e 55%, #ff7a59 100%);
  color: #fff;
  box-shadow: var(--m-shadow);
}
.avatar-banner-copy { position: relative; z-index: 2; display: grid; justify-items: start; gap: 8px; }
.avatar-banner h2 { margin: 0; font-size: clamp(22px, calc(2vw / var(--site-zoom, 1)), 34px); line-height: 1.05; letter-spacing: -.02em; color: #fff; overflow-wrap: anywhere; }
.avatar-banner p { margin: 0; color: #fff3f8; font-size: 14px; font-weight: 600; }
html body #home .avatar-banner .banner-art { position: relative; height: clamp(150px, calc(22dvh / var(--site-zoom, 1)), 260px); min-height: 0; }
html body #home .avatar-banner .banner-hero { position: absolute; left: 50%; bottom: -14px; width: clamp(110px, 60%, 190px); translate: -50% 0; }
html body #home .avatar-banner .banner-chip { margin: 0; }
.home-library { min-width: 0; }

@media (min-width: 1100px) {
  html body #home:not([hidden]) {
    --chat-w: clamp(280px, calc(22vw / var(--site-zoom, 1)), 380px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--chat-w);
    grid-template-rows: auto auto minmax(0, 1fr);
    column-gap: 18px;
    row-gap: 14px;
    width: auto;
    max-width: none;
    height: calc(calc(100dvh / var(--site-zoom, 1)) - var(--site-header-height, 72px));
    margin: 0;
    padding: 14px 22px 0;
    overflow: hidden;
  }
  html body #home > * { min-width: 0; margin: 0; }
  /* red: the two banners, full width */
  html body #home > .home-banners {
    grid-column: 1 / -1;
    grid-row: 1;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    min-height: clamp(180px, calc(24dvh / var(--site-zoom, 1)), 300px);
    margin: 0;
  }
  html body #home .home-banners > * { width: auto; max-width: none; height: auto; min-height: 0; justify-self: stretch; }
  html body #home .hero.hero-banner { padding: 18px 28px; border-radius: 20px; }
  html body #home .hero-banner h1 { font-size: clamp(26px, calc(2.4vw / var(--site-zoom, 1)), 44px); }
  /* blue: shortcut tiles */
  html body #home > .home-tiles { grid-column: 1; grid-row: 2; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; gap: 10px; margin: 0; }
  html body #home .home-tiles button { grid-template-columns: 34px minmax(0, 1fr); column-gap: 8px; padding: 7px 10px; }
  html body #home .home-tiles .tile-icon { width: 34px; height: 34px; font-size: 18px; }
  html body #home .home-tiles b { font-size: 13px; }
  /* pink: games, scrolling on their own */
  html body #home > .home-library {
    grid-column: 1;
    grid-row: 3;
    align-self: stretch;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 4px 24px 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--m-border) transparent;
  }
  html body #home .home-library > #favouriteSection:not([hidden]) { margin: 0 0 14px; }
  html body #home .home-library > #regularGamesSection { margin: 0; }
  /* green: public chat, from the tiles down to the bottom */
  html body #home > .lobby-chat {
    grid-column: 2;
    grid-row: 2 / 4;
    align-self: stretch;
    position: static;
    height: auto;
    min-height: 0;
    margin: 0 0 14px;
  }
  /* The footer would sit below the fitted page. */
  body:has(#home:not([hidden])) > footer { display: none; }
}
@media (max-width: 1099px) {
  .home-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; }
}
@media (max-width: 760px) {
  .avatar-banner { min-height: 150px; padding: 16px 18px; }
  html body #home .avatar-banner .banner-art { min-height: 130px; }
  html body #home .avatar-banner .banner-hero { width: clamp(90px, 70%, 130px); }
  html body #home .avatar-banner .float { display: none; }
  html body #home .hero.hero-banner .banner-copy { padding-right: 0; }
}
/* The two-banner row sizes to its content (an older rule forced the banner to 16:9). */
html body #home .home-banners .hero.hero-banner { aspect-ratio: auto !important; }
@media (max-width: 680px) {
  #headerProfileInfo .hp-name, #headerProfileInfo .hp-level { display: none; }
  #headerProfileInfo .hp-stats { font-size: 12px; }
}
/* Shorter screens: compact banners so games and chat keep most of the height. */
@media (min-width: 1100px) and (max-height: 1000px) {
  html body #home > .home-banners { min-height: 0; }
  html body #home .home-banners .banner-chip,
  html body #home .hero-banner .banner-copy > p { display: none; }
  html body #home .hero.hero-banner { padding: 14px 22px; }
  html body #home .hero-banner h1 { font-size: clamp(22px, calc(2vw / var(--site-zoom, 1)), 32px); }
  html body #home .hero-banner h1 br { display: none; }
  html body #home .hero-banner .banner-copy { gap: 8px; }
  html body #home .banner-step { min-height: 36px; padding-block: 3px; }
  html body #home .hero-banner #random { min-height: 36px; padding-block: 6px; }
  .avatar-banner { min-height: 0; padding: 12px 20px; }
  .avatar-banner h2 { font-size: clamp(20px, calc(1.6vw / var(--site-zoom, 1)), 28px); }
  html body #home .avatar-banner .banner-art { height: clamp(110px, calc(17dvh / var(--site-zoom, 1)), 170px); }
  html body #home .avatar-banner .banner-hero { width: clamp(80px, 45%, 120px); }
}
/* Very short screens: the whole page scrolls; chat stays pinned beside the games. */
@media (min-width: 1100px) and (max-height: 760px) {
  html body #home:not([hidden]) { height: auto; overflow: visible; }
  html body #home > .home-library { overflow: visible; }
  html body #home > .lobby-chat {
    position: sticky;
    top: calc(var(--site-header-height, 72px) + 10px);
    align-self: start;
    height: calc(calc(100dvh / var(--site-zoom, 1)) - var(--site-header-height, 72px) - 24px);
  }
}

/* Home on wide screens: the whole page scrolls (no inner scroll box for games);
   chat stays pinned on the right; the footer sits at the very bottom, full width. */
@media (min-width: 1100px) {
  html body #home:not([hidden]) {
    grid-template-rows: auto auto auto;
    height: auto;
    overflow: visible;
    padding-bottom: 22px;
  }
  html body #home > .home-library { overflow: visible; align-self: start; padding-bottom: 0; }
  html body #home > .lobby-chat {
    grid-row: 2 / 4;
    position: sticky;
    top: calc(var(--site-header-height, 72px) + 12px);
    align-self: start;
    height: calc(calc(100dvh / var(--site-zoom, 1)) - var(--site-header-height, 72px) - 28px);
    margin: 0;
  }
}

/* Footer: right after the home page, only while the home page is showing. */
body:has(#home[hidden]) > #siteFooter { display: none; }
body > #siteFooter { margin: 0 22px 22px; }
@media (max-width: 1099px) { body > #siteFooter { margin: 18px 18px 18px; } }

/* ---------- Public chat pinned on the right (wide screens), like the menu on the left ---------- */
:root { --chat-rail: clamp(290px, calc(21vw / var(--site-zoom, 1)), 360px); }
.lobby-fold, #chatReopen { display: none; }
@media (min-width: 1100px) {
  html.sidebar-docked { --pad-l: var(--rail-w); }
  html.chat-docked { --pad-r: var(--chat-rail); }
  html:is(.sidebar-docked, .chat-docked) body { padding-left: var(--pad-l, 0px); padding-right: var(--pad-r, 0px); }
  html:is(.sidebar-docked, .chat-docked) body > header {
    margin-left: calc(-1 * var(--pad-l, 0px));
    margin-right: calc(-1 * var(--pad-r, 0px));
    width: calc(100% + var(--pad-l, 0px) + var(--pad-r, 0px));
  }
  /* The home page no longer holds the chat: one column. */
  html body #home:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
  html body #home > .home-tiles, html body #home > .home-library { grid-column: 1; }
  html.chat-docked body > #lobbyChat {
    position: fixed;
    top: var(--site-header-height, 72px);
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    width: var(--chat-rail);
    height: auto;
    margin: 0;
    padding: 14px 14px 16px;
    border: 0;
    border-left: 1px solid var(--m-border);
    border-radius: 0;
    background: color-mix(in srgb, var(--m-panel) 92%, transparent);
    box-shadow: none;
    backdrop-filter: blur(14px);
  }
  html.chat-folded body > #lobbyChat { display: none; }
  html.chat-docked .lobby-fold {
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    min-height: 0;
    margin-left: 6px;
    padding: 0;
    border: 1px solid var(--m-border) !important;
    border-radius: 8px !important;
    background: var(--m-panel-2) !important;
    color: var(--m-text) !important;
    box-shadow: none !important;
    transform: none !important;
    font-size: 16px;
    line-height: 1;
  }
  html.chat-docked .lobby-head h2 { flex: 1; }
  html.chat-folded #chatReopen {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 30;
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    padding: 0;
    border: 0 !important;
    border-radius: 16px !important;
    background: linear-gradient(180deg, var(--m-accent), var(--m-accent-2)) !important;
    box-shadow: var(--m-glow) !important;
    font-size: 24px;
    transform: none !important;
  }
}

/* ---------- Public chat on phones and tablets: a 💬 button opens it as a pop-up ---------- */
@media (max-width: 1099px) {
  html.chat-popup body #home:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
  html.chat-popup body > #lobbyChat { display: none; }
  html.chat-popup.chat-open body > #lobbyChat {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 66px);
    z-index: 70;
    display: flex;
    width: auto;
    max-width: 520px;
    height: min(560px, calc(100dvh - 160px));
    margin: 0 0 0 auto;
    box-shadow: 0 24px 60px #00000066;
    animation: chat-pop .18s ease-out;
  }
  @keyframes chat-pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
  html.chat-popup body:has(#home:not([hidden])) #chatReopen,
  html.chat-popup.chat-open #chatReopen {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 71;
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    padding: 0;
    border: 0 !important;
    border-radius: 16px !important;
    background: linear-gradient(180deg, var(--m-accent), var(--m-accent-2)) !important;
    box-shadow: var(--m-glow) !important;
    font-size: 24px;
    transform: none !important;
  }
  html.chat-popup .lobby-fold {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    min-height: 0;
    margin-left: 6px;
    padding: 0;
    border: 1px solid var(--m-border) !important;
    border-radius: 8px !important;
    background: var(--m-panel-2) !important;
    color: var(--m-text) !important;
    box-shadow: none !important;
    transform: none !important;
    font-size: 20px;
    line-height: 1;
  }
  html.chat-popup .lobby-head h2 { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { html.chat-popup.chat-open body > #lobbyChat { animation: none; } }

/* The players button is no longer in the header (the player list still opens when a one-phone game needs names). */
#headerMenu #setupOpen { display: none !important; }
