/* ==========================================================================
   Chasbi component library — blueprint §3.2
   Cozy structure (cream panels, generous radii, calm chrome) with retro
   treatment (tracked uppercase labels, chunky buttons with a hard bottom
   edge, bold outlined marks).
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--size-base);
  font-weight: var(--weight-normal);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
body[data-sheet-open="true"] { overflow: hidden; }
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle at 30% 30%, var(--grain) 0 1px, transparent 1.5px);
  background-size: 6px 6px;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* Safari zooms focused controls whose computed text is below 16px. Keep the
   actual controls at 16px on every route; labels around them can stay smaller. */
input, select, textarea { font-size: 16px; }
button { background: none; border: 0; cursor: pointer; padding: 0; color: inherit; }
a { color: inherit; text-decoration: none; }
/* `manipulation` tells mobile Safari a rapid second tap is another press, not
   a request to zoom. It fixes fast on-screen typing without disabling pinch
   zoom or shrinking anyone's accessibility options. */
button, a, [role="button"], [role="tab"], [role="switch"] {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
svg { display: block; flex: none; }
.avatar__image { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
:focus-visible { outline: 2.5px solid var(--teal); outline-offset: 2px; border-radius: var(--r-sm); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- retro label treatment ---------- */
.label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  font-weight: var(--weight-black);
  font-size: var(--size-xs);
  line-height: 1.1;
}

/* ==========================================================================
   AppShell
   ========================================================================== */
.app-shell {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  min-height: 100dvh;
}
.shell-main {
  flex: 1;
  width: 100%; max-width: var(--shell-max); margin: 0 auto;
  padding: calc(var(--topbar-h) + var(--safe-top) + var(--s-4))
           max(var(--s-4), env(safe-area-inset-right))
           calc(var(--nav-h) + var(--safe-bottom) + var(--s-8));
  padding-left: max(var(--s-4), env(safe-area-inset-left));
}
.app-shell[data-immersive="true"] .shell-main { padding-bottom: var(--s-8); }

@media (min-width: 900px) {
  :root { --shell-max: 680px; }
}

/* ==========================================================================
   TopUtilityBar
   ========================================================================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-topbar);
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--s-4) 0;
  display: flex; align-items: center;
  background: var(--canvas);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  filter: none;
  isolation: isolate;
  border-bottom: 1px solid var(--line);
}
/* iOS can retain an older composited backdrop when a Home Screen app is
   resumed from memory. Give the standalone layer an explicit opaque backing
   and an important no-blur override; the safe-area strip is part of this same
   element, so there is no translucent seam above the controls. */
@media (display-mode: standalone) {
  .topbar {
    background-color: var(--canvas);
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}
.topbar__inner {
  width: 100%; max-width: var(--shell-max); margin: 0 auto;
  display: flex; align-items: center; gap: var(--s-1);
}
.topbar__brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  color: var(--on-canvas);
  font-family: var(--font-display); font-weight: var(--weight-black);
  font-size: var(--size-md); letter-spacing: -.01em;
}
.topbar__spacer { flex: 1; }
.connection-pill {
  display: inline-flex; align-items: center; gap: 4px; margin-left: var(--s-2);
  padding: 4px 8px; border-radius: var(--r-pill);
  background: rgba(230, 171, 60, .16); color: var(--gold);
  font-size: 10px; font-weight: 800;
}

.icon-btn {
  position: relative;
  width: var(--tap-min); height: var(--tap-min); min-width: var(--tap-min);
  display: inline-grid; place-items: center;
  border-radius: var(--r-md); color: var(--on-canvas);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:active { background: var(--press-canvas); transform: scale(.92); }
.icon-btn--onSurface { color: var(--text-2); }
.icon-btn--onSurface:active { background: var(--press); }
.icon-btn__badge {
  position: absolute; top: 5px; right: 5px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--coral); color: #fff;
  font-size: 10px; font-weight: var(--weight-black); line-height: 1;
  display: grid; place-items: center;
  border: 2px solid var(--canvas);
}

/* ==========================================================================
   BottomNavigation — five items, cozy pill for the active one (§7.2)
   ========================================================================== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-nav);
  padding: 0 var(--s-3) var(--safe-bottom);
  display: flex; justify-content: center;
  pointer-events: none;
}
.bottom-nav__inner {
  pointer-events: auto;
  width: 100%; max-width: var(--shell-max);
  height: var(--nav-h);
  margin-bottom: var(--s-2);
  display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding: 0 var(--s-2);
  background: var(--surface); border: 1px solid var(--panel-outline);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow);
}
.nav-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: 52px; border-radius: var(--r-lg);
  color: var(--text-3);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav-item__label {
  font-size: 10.5px; font-weight: var(--weight-bold);
  letter-spacing: .015em;
}
.nav-item[aria-current="page"] {
  background: var(--wash);
  color: var(--teal-contrast);
}
.nav-item[aria-current="page"] .nav-item__label { font-weight: var(--weight-black); }
.nav-item__badge {
  position: absolute; top: 4px; left: calc(50% + 7px);
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--coral); color: #fff;
  font-size: 10px; font-weight: var(--weight-black); line-height: 1;
  display: grid; place-items: center; border: 2px solid var(--surface);
}

.app-shell[data-immersive="true"] .bottom-nav { display: none; }
.exit-game {
  position: fixed; top: calc(var(--safe-top) + var(--s-2)); left: var(--s-3);
  z-index: var(--z-topbar);
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 44px; padding: 0 var(--s-4) 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: var(--size-sm); font-weight: var(--weight-bold);
}

/* ==========================================================================
   Panels & sections
   ========================================================================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--panel-outline);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: var(--s-4);
}
.panel--flush { padding: 0; overflow: hidden; }
.panel--dark { background: var(--surface-alt); color: var(--on-dark); box-shadow: none; }

.card {
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.card--pad { padding: var(--s-3) var(--s-4); }
.card--onDark { background: var(--surface); box-shadow: var(--shadow); }

.section { margin-bottom: var(--s-6); }
.section__head {
  display: flex; align-items: center; gap: var(--s-3);
  margin: 0 var(--s-1) var(--s-3);
}
.section__title {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  font-size: var(--size-xs); font-weight: var(--weight-black);
  margin: 0;
  /* Sections sit on the canvas by default; nested ones inherit the panel's
     palette below. Deriving this from context means a section header can never
     again be dark-on-dark because someone forgot a flag. */
  color: var(--on-canvas-dim);
}
.panel .section__title,
.card .section__title,
.sheet .section__title { color: var(--text-2); }
.section__action {
  margin-left: auto; font-size: var(--size-xs); color: var(--teal-contrast);
  font-weight: var(--weight-black); text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  min-height: 44px; padding-inline: var(--s-2);
  display: inline-flex; align-items: center; gap: 2px;
  color: var(--teal);
}
.panel .section__action,
.card .section__action,
.sheet .section__action { color: var(--teal-contrast); }

.screen-title {
  display: flex; align-items: center; gap: 12px;
  font-size: var(--size-xl); font-weight: var(--weight-black);
  letter-spacing: var(--tracking-tight); line-height: 1.15;
  color: var(--on-canvas); margin: 0 0 var(--s-1);
}
.screen-title::before {
  content: ''; width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%;
  background: var(--teal); box-shadow: 0 0 0 5px color-mix(in srgb, var(--teal) 17%, transparent);
}
/* Route headings receive programmatic focus for screen-reader navigation.
   This applies to native game headings too, not only `.screen-title`. */
[data-route-heading="true"][tabindex="-1"]:focus { outline: none; }
.screen-sub { color: var(--on-canvas-dim); font-size: var(--size-sm); margin: 0 0 var(--s-5); padding-inline-start: 22px; }
.on-surface .screen-title { color: var(--text); }
.on-surface .screen-sub { color: var(--text-2); }

/* ==========================================================================
   Buttons — chunky, tactile, with a hard bottom edge (retro)
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap-min); padding: 0 var(--s-5);
  border-radius: var(--r-pill);
  font-size: var(--size-base); font-weight: var(--weight-bold);
  background: var(--surface-2); color: var(--text);
  box-shadow: 0 2px 0 var(--surface-3);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
              filter var(--dur-fast) var(--ease);
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--surface-3); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn--primary {
  background: var(--teal); color: var(--on-accent);
  box-shadow: 0 3px 0 var(--teal-dark);
}
.btn--primary:active { box-shadow: 0 0 0 var(--teal-dark); }

.btn--game {
  background: var(--game-accent); color: var(--on-accent);
  box-shadow: 0 3px 0 var(--game-accent-deep);
}
.btn--game:active { box-shadow: 0 0 0 var(--game-accent-deep); }

.btn--coral { background: var(--coral); color: #fff; box-shadow: 0 3px 0 var(--coral-deep); }
.btn--coral:active { box-shadow: 0 0 0 var(--coral-deep); }

.btn--ghost { background: transparent; box-shadow: none; color: var(--text-2); }
.btn--ghost:active { background: var(--press); transform: scale(.98); }

.btn--onDark { background: var(--press-canvas); color: var(--on-canvas); box-shadow: none; }
.btn--onDark:active { filter: brightness(1.15); transform: scale(.98); }

.btn--danger { background: transparent; color: var(--coral); box-shadow: none; }
.btn--danger:active { background: color-mix(in srgb, var(--coral) 14%, transparent); }

.btn--block { width: 100%; }
.btn--sm { min-height: 44px; padding: 0 var(--s-4); font-size: var(--size-sm); }
.btn--lg { min-height: 54px; font-size: var(--size-md); border-radius: var(--r-pill); }
.btn--label { text-transform: uppercase; letter-spacing: var(--tracking-label); font-weight: var(--weight-black); }

/* ==========================================================================
   Avatar · Presence · PlayerChip · Badges
   ========================================================================== */
.avatar {
  position: relative; flex: none;
  width: 42px; height: 42px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: var(--caramel); color: #fff;
  font-weight: var(--weight-black); font-size: var(--size-sm);
  letter-spacing: .02em;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .22);
}
.avatar--sm { width: 30px; height: 30px; font-size: 11px; }
.avatar--lg { width: 76px; height: 76px; font-size: var(--size-lg); }
.avatar--stack { margin-left: -10px; box-shadow: 0 0 0 2.5px var(--surface); }

.presence {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: var(--r-pill);
  border: 2.5px solid var(--surface); background: var(--text-3);
}
.presence[data-state="online"]  { background: var(--green); }
.presence[data-state="in_game"] { background: var(--gold); }
.presence[data-state="away"]    { background: var(--caramel); }
.presence[data-state="offline"],
.presence[data-state="invisible"] { background: var(--surface-3); }

.player-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 3px var(--s-3) 3px 3px; border-radius: var(--r-pill);
  background: var(--surface-2); font-size: var(--size-sm);
  font-weight: var(--weight-medium); max-width: 100%;
}
.player-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip--turn { background: var(--wash); box-shadow: inset 0 0 0 1.5px var(--teal); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px var(--s-2); border-radius: var(--r-pill);
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-label); font-size: 10px;
  font-weight: var(--weight-black); line-height: 1.4; white-space: nowrap;
}
.badge--host      { background: var(--gold); color: var(--on-accent); }
.badge--spectator { background: var(--surface-3); color: var(--text-2); }
.badge--live      { background: var(--coral); color: #fff; }
.badge--turn      { background: var(--green); color: #fff; }
.badge--guest     { background: transparent; color: var(--text-3); border: 1.5px solid var(--line-2); }
.badge--new       { background: var(--teal); color: var(--on-accent); }
.badge--quiet     { background: var(--surface-3); color: var(--text-2); }

.status-line {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--size-sm); font-weight: var(--weight-bold);
}
.status-line__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ==========================================================================
   YourTurnsTray (§8)
   ========================================================================== */
.turns-tray {
  display: flex; gap: var(--s-3);
  overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 calc(var(--s-4) * -1); padding: var(--s-1) var(--s-4) var(--s-3);
  scrollbar-width: none;
}
.turns-tray::-webkit-scrollbar { display: none; }
.turn-card {
  scroll-snap-align: start; flex: none;
  width: 236px; padding: var(--s-4);
  border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: var(--s-2);
  text-align: left;
}
.turn-card__top { display: flex; align-items: center; gap: var(--s-2); }
.turn-card__game {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-label); font-size: 10px;
  font-weight: var(--weight-black); color: var(--text-3);
}
.turn-card__lobby { font-weight: var(--weight-black); font-size: var(--size-md); line-height: 1.2; }
.turn-card__meta {
  font-size: var(--size-sm); color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.turn-card__cta { margin-top: auto; padding-top: var(--s-1); }

/* ==========================================================================
   GameTile — the cozy square tile with a retro mark (§7.2)
   ========================================================================== */
.game-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.game-tile {
  position: relative; overflow: hidden; text-align: center;
  border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--panel-outline);
  min-height: 126px;
  padding: var(--s-4) var(--s-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: 0 3px 0 var(--surface-3);
}
.game-tile:active { transform: translateY(3px); box-shadow: 0 0 0 var(--surface-3); }
.game-tile__name {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-label); font-size: 10.5px;
  font-weight: var(--weight-black); color: var(--text);
}

/* Daily cards visibly become keepsakes after a result is locked. The route is
   still useful for sharing/leaderboards, so the action changes to Admire. */
.daily-card { position: relative; overflow: hidden; min-height: 78px; border: 1px solid var(--panel-outline); }
.daily-card__mark { position: relative; flex: none; display: grid; place-items: center; }
.daily-card__done {
  position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px;
  display: grid; place-items: center; border: 3px solid var(--surface);
  border-radius: 50%; background: var(--teal); color: var(--on-accent);
  box-shadow: 0 2px 7px color-mix(in srgb, var(--teal) 30%, transparent);
}
.daily-card[data-complete="true"] {
  border-color: color-mix(in srgb, var(--teal) 42%, var(--line));
  background: linear-gradient(118deg,color-mix(in srgb,var(--teal) 12%,var(--surface)),var(--surface) 64%);
  box-shadow: inset 4px 0 0 var(--teal),var(--shadow);
}
.daily-card[data-complete="true"]::after {
  content: ''; position: absolute; z-index: 0; right: -22px; top: -28px;
  width: 100px; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle,var(--teal) 0 2px,transparent 2.5px); background-size: 15px 15px; opacity: .13;
}
.daily-card > * { position: relative; z-index: 1; }
.daily-card__action { flex: none; }
.daily-card[data-complete="true"] .daily-card__action {
  background: var(--surface-2); color: var(--teal-contrast, var(--teal-dark));
  box-shadow: 0 2px 0 var(--surface-3);
}
/* full-width catalogue row */
.game-row {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; text-align: left;
  padding: var(--s-3); border-radius: var(--r-lg);
  background: var(--surface-2); box-shadow: 0 3px 0 var(--surface-3);
  transition: transform var(--dur-fast) var(--ease);
}
.game-row:active { transform: translateY(3px); box-shadow: 0 0 0 var(--surface-3); }
.game-row__name {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-label); font-size: var(--size-sm);
  font-weight: var(--weight-black);
}
.game-row__desc { font-size: var(--size-sm); color: var(--text-2); }

/* ==========================================================================
   LobbyCard · filters (§7.4)
   ========================================================================== */
.lobby-list { display: flex; flex-direction: column; gap: var(--s-2); }
.lobby-card {
  display: flex; align-items: center; gap: var(--s-3); text-align: left; width: 100%;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  background: var(--surface-2);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  min-height: 60px;
}
.lobby-card:active { transform: scale(.985); }
.lobby-card--turn { background: var(--wash); box-shadow: inset 0 0 0 2px var(--teal); }
.lobby-card__icon {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center;
}
.lobby-card__body { min-width: 0; flex: 1; }
.lobby-card__name {
  font-weight: var(--weight-bold); font-size: var(--size-base);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lobby-card__meta {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--size-sm); color: var(--text-2);
  overflow: hidden; white-space: nowrap;
}
.lobby-card__side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.public-lobby-card { box-shadow: inset 0 0 0 1px var(--line); }
.public-lobby-card__tags { display: flex; gap: var(--s-2); margin-top: 2px; }
.public-lobby-card__tags > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.filter-row {
  display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(var(--s-4) * -1) var(--s-3); padding: 2px var(--s-4);
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; height: 44px; padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2);
  font-size: var(--size-sm); font-weight: var(--weight-bold);
  display: inline-flex; align-items: center; gap: 6px;
}
.filter-chip[aria-pressed="true"] { background: var(--teal); color: var(--on-accent); }
.btn[data-theme-choice][aria-pressed="true"] {
  color: var(--on-accent); background: var(--teal); border-color: var(--teal-dark);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.28), 0 3px 0 var(--teal-dark);
}
.filter-chip__count {
  font-size: 10px; font-weight: var(--weight-black);
  padding: 1px 5px; border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .12);
}

/* ==========================================================================
   TurnBanner · RoundStatus
   ========================================================================== */
.turn-banner {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--wash); box-shadow: inset 0 0 0 2px var(--teal);
  margin-bottom: var(--s-3); color: var(--text);
}
.turn-banner__text { flex: 1; font-weight: var(--weight-bold); font-size: var(--size-sm); }

.round-status { display: flex; align-items: center; gap: var(--s-3); font-size: var(--size-sm); color: var(--text-2); }
.round-status__bar { flex: 1; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.round-status__fill { height: 100%; background: var(--game-accent); border-radius: var(--r-pill); transition: width var(--dur) linear; }

/* ==========================================================================
   Sheets
   ========================================================================== */
.sheet-backdrop {
  position: fixed; top: var(--visual-top, 0px); left: 0; right: 0;
  height: var(--visual-height, 100dvh); z-index: var(--z-sheet);
  background: rgba(10, 6, 4, .58);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade var(--dur) var(--ease);
}
.sheet {
  width: 100%; max-width: var(--shell-max);
  max-height: min(88dvh, calc(var(--visual-height, 100dvh) * .92)); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--panel-outline); border-bottom: 0;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  padding: var(--s-3) var(--s-4) calc(var(--s-6) + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheet-in var(--dur-slow) var(--ease-back);
  transition: transform 180ms var(--ease), opacity 180ms var(--ease);
}
.sheet--dragging { transition: none; user-select: none; }
.sheet--dismiss { opacity: .86; }
.sheet__handle {
  position: relative; min-height: 34px; margin: calc(var(--s-3) * -1) calc(var(--s-2) * -1) var(--s-1);
  display: grid; place-items: start center;
}
.sheet__grip-hit {
  width: 96px; height: 34px; display: grid; place-items: center;
  cursor: grab; touch-action: none;
}
.sheet__grip-hit:active { cursor: grabbing; }
.sheet__grip { display: block; width: 42px; height: 5px; border-radius: var(--r-pill); background: var(--surface-3); }
.sheet__close {
  position: absolute; top: 4px; right: 2px;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2);
}
.sheet__title { font-size: var(--size-lg); font-weight: var(--weight-black); margin: 0 0 var(--s-1); letter-spacing: var(--tracking-tight); }
.sheet__sub { color: var(--text-2); font-size: var(--size-sm); margin: 0 0 var(--s-4); }
.sheet__row {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left;
  min-height: 54px; padding: var(--s-2) var(--s-1);
  border-bottom: 1px solid var(--line);
}
.sheet__row:last-child { border-bottom: 0; }
.sheet__row-icon {
  width: 38px; height: 38px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2);
}
.sheet__row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sheet__row-title { display: block; font-weight: var(--weight-bold); line-height: 1.25; }
.sheet__row-sub { display: block; font-size: var(--size-sm); color: var(--text-3); line-height: 1.35; }

.friend-search { display: flex; flex-direction: column; gap: var(--s-3); }
.friend-search__field { padding-inline: var(--s-4); }
.friend-search__status { min-height: 20px; padding: 0 var(--s-2); color: var(--text-3); font-size: var(--size-xs); line-height: 1.4; }
.friend-search__results {
  list-style: none; margin: 0; padding: 0; max-height: min(42dvh, 360px); overflow-y: auto;
  overscroll-behavior: contain; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface-2); scrollbar-gutter: stable;
}
.friend-search__person {
  min-height: 68px; padding: var(--s-2) var(--s-3); display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.friend-search__person:last-child { border-bottom: 0; }
.friend-search__identity { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.friend-search__identity strong, .friend-search__identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-search__identity strong { color: var(--text); font-size: var(--size-sm); }
.friend-search__identity small { color: var(--text-3); font-size: var(--size-xs); }
.friend-search__action { min-width: 84px; padding-inline: var(--s-3); }
.friend-search__action:disabled { opacity: .72; }
.friend-search__empty {
  min-height: 92px; padding: var(--s-4); display: flex; align-items: center; justify-content: center;
  gap: var(--s-3); color: var(--text-3); text-align: left;
}
.friend-search__empty > svg { flex: none; color: var(--teal-contrast); }
.friend-search__empty > span { display: flex; flex-direction: column; gap: 3px; }
.friend-search__empty strong { color: var(--text-2); font-size: var(--size-sm); }
.friend-search__empty small { max-width: 240px; font-size: var(--size-xs); line-height: 1.4; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes sheet-in { from { transform: translateY(18%) } to { transform: none } }

.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: var(--size-lg);
  font-weight: var(--weight-bold); letter-spacing: .2em;
}

/* ==========================================================================
   Inputs
   ========================================================================== */
.field {
  width: 100%; min-height: var(--tap-min); padding: 0 var(--s-4);
  border-radius: var(--r-pill); border: 0;
  background: var(--surface-2); color: var(--text);
  font-size: 16px;
  border: 1px solid transparent;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.field::placeholder { color: var(--text-3); }
.field:focus { outline: 0; border-color: var(--teal); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 18%, transparent); }
.field__input {
  min-height: 44px; max-width: 100%; padding: 0 38px 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font-size: 16px;
}
textarea.field__input { min-height: 112px; padding: 12px; resize: vertical; }
.field--code {
  text-align: center; letter-spacing: .3em; font-family: var(--font-mono);
  font-size: var(--size-lg); font-weight: var(--weight-bold);
  min-height: 58px; border-radius: var(--r-md);
}

.toggle {
  width: 46px; height: 27px; flex: none; border-radius: var(--r-pill);
  background: var(--surface-3); position: relative;
  transition: background var(--dur) var(--ease);
}
.toggle[data-on="true"] { background: var(--green); }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: left var(--dur) var(--ease);
}
.toggle[data-on="true"]::after { left: 22px; }

/* ==========================================================================
   ChatPanel · MessageBubble
   ========================================================================== */
.chat-panel { display: flex; flex-direction: column; min-height: 0; }
.chat-log { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; gap: var(--s-3); }
.chat-panel--lobby {
  min-height: max(360px,
    calc(100dvh - var(--topbar-h) - var(--nav-h) - var(--safe-top) - var(--safe-bottom) - 238px));
}
.chat-panel--lobby .chat-log { overflow-y: auto; overscroll-behavior: contain; padding: var(--s-1) 0 var(--s-3); }
.chat-panel--lobby .chat-composer {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-bottom)); z-index: 2;
  margin-top: auto; padding: var(--s-2) 0;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.lobby-screen { min-height: calc(100dvh - var(--topbar-h) - var(--nav-h) - var(--safe-top) - var(--safe-bottom) - var(--s-12)); }

/* ==========================================================================
   Universal game entry — Public · Create · Join
   ========================================================================== */
.game-entry { display: flex; flex-direction: column; gap: var(--s-4); }
.game-entry > .tabs { margin: 0; }
.game-entry__hero {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: 132px; padding: var(--s-5);
  display: block;
  border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow);
}
.game-entry__hero::after {
  content: ""; position: absolute; z-index: -1; right: -38px; bottom: -52px;
  width: 170px; aspect-ratio: 1; border-radius: 50%;
  background: color-mix(in srgb, var(--game-accent, var(--teal)) 17%, transparent);
}
.game-entry__back {
  position: absolute; top: var(--s-3); left: var(--s-3); z-index: 1;
  width: var(--tap-min); height: var(--tap-min); display: grid; place-items: center;
  border-radius: var(--r-pill); color: var(--text-2); background: var(--surface-2);
}
.game-entry__intro { min-width: 0; }
.game-entry__title {
  min-height: var(--tap-min); margin-left: 50px;
  display: flex; align-items: center; gap: var(--s-2);
}
.game-entry__mark {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--game-accent, var(--teal)) 16%, var(--surface-2));
}
.game-entry__intro h1 { margin: 0; font-size: clamp(24px, 7vw, 34px); line-height: 1.05; letter-spacing: var(--tracking-tight); }
.game-entry__intro p { margin: var(--s-2) 0 var(--s-3); color: var(--text-2); font-size: var(--size-sm); }
.game-entry__capabilities, .lobby-capabilities {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
}
.game-entry__panel {
  padding: var(--s-4); border-radius: var(--r-xl);
  background: var(--surface); box-shadow: var(--shadow);
}
.playing-as {
  min-height: 48px; padding: var(--s-2) var(--s-3); margin-bottom: var(--s-4);
  display: flex; align-items: center; gap: var(--s-3);
  border-radius: var(--r-md); background: var(--wash);
}
.playing-as span, .game-entry__field-label, .entry-setting-group,
.entry-toggle > span, .public-browser__head > span, .public-table__copy,
.waiting-room__host > .grow, .waiting-room__section-head > span,
.seat > span, .waiting-room__guest-note > span, .host-settings__row > span {
  display: flex; min-width: 0; flex-direction: column;
}
.playing-as small, .entry-toggle small, .public-browser__head small,
.waiting-room__host small, .waiting-room__host span span,
.waiting-room__section-head small, .seat small, .waiting-room__guest-note small,
.host-settings__row small {
  color: var(--text-3); font-size: var(--size-xs); line-height: 1.35;
}
.playing-as__edit { min-height: 44px; padding: 0 var(--s-2); display: grid; place-items: center; color: var(--teal-contrast); font-size: var(--size-sm); font-weight: var(--weight-black); }
.game-entry__field-label { gap: var(--s-2); color: var(--text-2); font-size: var(--size-sm); font-weight: var(--weight-black); }
.game-entry__name-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--tap-min); gap: var(--s-2); }
.game-entry__name { border-radius: var(--r-md); }
.name-suggestions { display: flex; gap: 6px; margin-top: var(--s-2); overflow-x: auto; scrollbar-width: none; }
.name-suggestions::-webkit-scrollbar { display: none; }
.name-suggestion {
  flex: none; min-height: 44px; padding: 0 var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  color: var(--text-2); background: var(--surface-2); font-size: var(--size-xs); font-weight: var(--weight-bold);
}
.segmented {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px;
  padding: 5px; border-radius: var(--r-lg); background: var(--surface-2);
}
.segmented__option {
  min-height: 58px; padding: 7px 5px; border: 1.5px solid transparent; border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-2); font-size: var(--size-sm); font-weight: var(--weight-black);
}
.segmented__option small { color: var(--text-3); font-size: 9px; font-weight: var(--weight-medium); line-height: 1.2; text-align: center; }
.segmented__option[aria-checked="true"] { border-color: var(--teal); background: var(--surface); color: var(--teal-contrast); box-shadow: var(--shadow-sm); }
.segmented__option:disabled { opacity: .42; }
.capacity-stepper {
  min-height: 64px; padding: var(--s-2); display: grid; grid-template-columns: 48px 1fr 48px;
  align-items: center; gap: var(--s-2); border-radius: var(--r-lg); background: var(--surface-2);
}
.capacity-stepper__button {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: var(--r-pill); background: var(--surface); color: var(--teal-contrast); box-shadow: var(--shadow-sm);
}
.capacity-stepper__button:disabled { opacity: .35; }
.capacity-stepper__value { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.capacity-stepper__value strong { font-family: var(--font-display); font-size: 26px; }
.capacity-stepper__value span { color: var(--text-3); font-size: var(--size-xs); }
.game-entry__more, .waiting-settings { margin-top: var(--s-4); border-radius: var(--r-lg); background: var(--surface-2); overflow: clip; }
.game-entry__more > summary, .waiting-settings > summary {
  min-height: 56px; padding: var(--s-3) var(--s-4); list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); cursor: pointer;
}
.game-entry__more > summary::-webkit-details-marker, .waiting-settings > summary::-webkit-details-marker { display: none; }
.game-entry__more > summary > span, .waiting-settings > summary > span { display: flex; min-width: 0; flex-direction: column; }
.game-entry__more > summary small, .waiting-settings > summary small { color: var(--text-3); font-size: var(--size-xs); }
.game-entry__more[open] > summary > svg, .waiting-settings[open] > summary > svg { transform: rotate(180deg); }
.game-entry__settings, .host-settings { padding: 0 var(--s-3) var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.entry-setting-group { gap: var(--s-2); padding: var(--s-2) 0; }
.entry-setting-group__label { font-size: var(--size-xs); font-weight: var(--weight-black); text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--text-3); }
.entry-toggle, .host-settings__row {
  width: 100%; min-height: 56px; padding: var(--s-2) var(--s-3);
  display: flex; align-items: center; gap: var(--s-3); text-align: left;
  border-radius: var(--r-md); background: var(--surface);
}
.entry-toggle:disabled, .host-settings__row:disabled { opacity: .44; }
.game-entry__promise {
  display: flex; align-items: flex-start; justify-content: center; gap: var(--s-2);
  margin-top: var(--s-3); color: var(--text-3); font-size: var(--size-xs); text-align: center;
}
.game-entry__promise svg { margin-top: 1px; color: var(--teal-contrast); }
.public-browser__head { min-height: 46px; display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.public-browser__list { display: flex; flex-direction: column; gap: var(--s-2); }
.public-table {
  padding: var(--s-3); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
  border-radius: var(--r-lg); background: var(--surface-2);
}
.public-table__mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface); }
.public-table__copy { gap: 2px; }
.public-table__copy > span { color: var(--text-3); font-size: var(--size-xs); }
.public-table__badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.join-panel { display: flex; flex-direction: column; align-items: stretch; gap: var(--s-3); text-align: center; }
.join-panel__mark { width: 58px; height: 58px; margin: var(--s-2) auto 0; display: grid; place-items: center; border-radius: var(--r-xl); background: var(--wash); color: var(--teal-contrast); }
.join-panel h2 { margin: 0; }
.join-panel p { max-width: 38ch; margin: -4px auto var(--s-2); color: var(--text-2); font-size: var(--size-sm); }

/* ==========================================================================
   Waiting room — host, seats and rules at a glance
   ========================================================================== */
.waiting-room { display: flex; flex-direction: column; gap: var(--s-3); }
.waiting-room__hero {
  position: relative; overflow: hidden; padding: var(--s-5); border-radius: var(--r-xl);
  background: linear-gradient(145deg, color-mix(in srgb, var(--teal) 17%, var(--surface)), var(--surface));
  box-shadow: var(--shadow);
}
.waiting-room__hero::after {
  content: ""; position: absolute; right: -45px; top: -62px; width: 154px; aspect-ratio: 1;
  border-radius: 50%; border: 24px solid color-mix(in srgb, var(--gold) 13%, transparent); pointer-events: none;
}
.waiting-room__eyebrow { display: flex; align-items: center; gap: 6px; color: var(--teal-contrast); font-size: var(--size-xs); font-weight: var(--weight-black); text-transform: uppercase; letter-spacing: var(--tracking-label); }
.waiting-room__hero h2 { margin: var(--s-2) 0 3px; font-size: clamp(25px, 7vw, 34px); line-height: 1.05; }
.waiting-room__hero p { max-width: 43ch; margin: 0; color: var(--text-2); font-size: var(--size-sm); }
.waiting-room__pulse { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-4); }
.lobby-pulse { min-height: 30px; padding: 0 var(--s-3); display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-pill); background: var(--surface); color: var(--text-2); font-size: var(--size-xs); font-weight: var(--weight-bold); box-shadow: var(--shadow-sm); }
.presence-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }
.waiting-room__host {
  min-height: 78px; padding: var(--s-3) var(--s-4); display: flex; align-items: center; gap: var(--s-3);
  border: 1.5px solid color-mix(in srgb, var(--gold) 60%, var(--line)); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--gold) 9%, var(--surface)); box-shadow: var(--shadow-sm);
}
.waiting-room__host .avatar { width: 48px; height: 48px; }
.waiting-room__host strong { font-size: var(--size-md); }
.waiting-room__host .badge--host {
  flex: none; min-height: 30px; padding: 0 10px;
  flex-direction: row; align-items: center; gap: 5px;
  letter-spacing: .055em;
}
.waiting-room__seats { padding: var(--s-4); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow); }
.waiting-room__section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.waiting-room__queue { padding: var(--s-4); border: 1px solid color-mix(in srgb, var(--teal) 34%, var(--line)); border-radius: var(--r-xl); background: var(--wash); }
.waiting-room__queue-row { min-height: 58px; padding: var(--s-2); display: flex; align-items: center; gap: var(--s-2); border-radius: var(--r-md); background: var(--surface); }
.waiting-room__queue-row > span { min-width: 0; display: flex; flex-direction: column; }
.waiting-room__queue-row small { color: var(--text-3); font-size: var(--size-xs); }
.seat-count { min-width: 48px; min-height: 30px; padding: 0 var(--s-3) 1px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-pill); background: var(--wash); color: var(--teal-contrast); font-size: var(--size-sm); font-weight: var(--weight-black); line-height: 1; }
.seat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.seat {
  min-width: 0; min-height: 64px; padding: var(--s-2); display: flex; align-items: center; gap: var(--s-2);
  text-align: left; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
}
.seat--host { border-color: color-mix(in srgb, var(--gold) 74%, var(--line)); background: color-mix(in srgb, var(--gold) 10%, var(--surface-2)); }
.seat--me { box-shadow: inset 0 0 0 1.5px var(--teal); }
.seat--empty { border-style: dashed; color: var(--text-3); }
.seat__plus { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface); color: var(--teal-contrast); line-height: 0; }
.seat__plus svg, .seat-count svg { display: block; margin: 0; transform: translateY(-1px); }
.seat__remove { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--coral); background: var(--surface); }
.waiting-room__actions { display: flex; flex-direction: column; gap: var(--s-2); }
.waiting-room__secondary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.bot-difficulty { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: var(--s-2) var(--s-3); color: var(--text-3); font-size: var(--size-xs); }
.bot-difficulty > span { margin-right: auto; font-weight: var(--weight-black); }
.waiting-settings { margin-top: var(--s-1); background: var(--surface); box-shadow: var(--shadow-sm); }
.waiting-settings > summary { min-height: 64px; }
.waiting-settings .host-settings { border-top: 1px solid var(--line); padding-top: var(--s-3); }
.host-settings { padding: 0; }
.host-settings__privacy, .host-settings__choice { flex-direction: column; align-items: stretch; }
.host-settings__privacy .wrap-gap, .host-settings__choice .wrap-gap { margin-top: var(--s-2); }
.host-settings__toggle { cursor: pointer; }
.mini-stepper { display: grid; grid-template-columns: 44px 30px 44px; align-items: center; text-align: center; border-radius: var(--r-pill); background: var(--surface-2); }
.mini-stepper button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--teal-contrast); }
.mini-stepper button:disabled { opacity: .3; }
.waiting-room__guest-note { min-height: 66px; padding: var(--s-3) var(--s-4); display: flex; align-items: center; gap: var(--s-3); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.waiting-room__footer { min-height: 46px; padding: 0 var(--s-2) 0 var(--s-3); display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); color: var(--text-3); font-size: var(--size-xs); }
.waiting-room__footer > span { display: inline-flex; align-items: center; gap: 6px; }

/* Age gate stores only an age band, never a birthday. */
.age-check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.age-check-card { min-height: 154px; padding: var(--s-4); display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); text-align: left; border: 1.5px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.age-check-card > svg { color: var(--teal-contrast); }
.age-check-card small { color: var(--text-3); line-height: 1.4; }

@media (max-width: 460px) {
  .game-entry__hero { min-height: 126px; padding: var(--s-4); }
  .game-entry__title { margin-left: 48px; }
  .game-entry__mark { width: 42px; height: 42px; }
  .game-entry__capabilities .badge:nth-child(n+5) { display: none; }
  .segmented__option small { display: none; }
  .public-table { grid-template-columns: auto minmax(0, 1fr); }
  .public-table > .btn { grid-column: 1 / -1; }
  .seat { min-height: 60px; }
  .seat .avatar { width: 27px; height: 27px; }
  .waiting-room__footer { align-items: flex-start; }
}

@media (max-width: 350px) {
  .seat-grid, .age-check-grid { grid-template-columns: 1fr; }
  .waiting-room__secondary { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Collapsible immersive game menu
   ========================================================================== */
.game-dock {
  position: fixed; top: var(--game-dock-top, 78%);
  right: max(-7px, calc(env(safe-area-inset-right, 0px) - 7px)); bottom: auto;
  z-index: 2147482000; width: 50px; height: 50px;
  overflow: visible; transform: translateY(-50%); font-family: var(--font-ui);
  transition: top var(--dur-fast) var(--ease), left var(--dur-fast) var(--ease), right var(--dur-fast) var(--ease);
}
.game-dock[data-side="left"] { right: auto; left: max(-7px, calc(env(safe-area-inset-left, 0px) - 7px)); }
.game-dock[data-dragging="true"] { transition: none; }
.game-dock__launcher {
  position: relative; z-index: 2; width: 50px; height: 50px; display: grid; place-items: center;
  border-radius: 18px 0 0 18px; color: var(--on-accent); background: var(--teal);
  box-shadow: 0 4px 0 var(--teal-deep), 0 11px 26px rgba(0,0,0,.3);
  border: 1px solid color-mix(in srgb, var(--teal) 72%, white);
  cursor: grab; touch-action: none;
}
.game-dock[data-side="left"] .game-dock__launcher { border-radius: 0 18px 18px 0; }
.game-dock[data-dragging="true"] .game-dock__launcher { cursor: grabbing; filter: brightness(1.08); transform: scale(1.04); }
.game-dock__launcher:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--teal-deep), 0 8px 20px rgba(0,0,0,.3); }
.game-dock__menu {
  position: absolute; inset: 0; overflow: visible;
  visibility: hidden; pointer-events: none;
  transition: visibility 0s linear var(--dur);
}
.game-dock[data-open="true"] .game-dock__menu { visibility: visible; pointer-events: auto; transition-delay: 0s; }
.game-dock__item {
  position: absolute; top: 1px; left: 1px; width: 48px; height: 48px; padding: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 50%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 9px; line-height: 1; font-weight: var(--weight-black); white-space: normal;
  text-align: center; overflow: hidden;
  opacity: 0; transform: translate(0, 0) scale(.54);
  transition: transform var(--dur) var(--ease-back), opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  transition-delay: 0ms;
}
.game-dock__item svg { flex: none; }
.game-dock__item span { display: block; max-width: 39px; overflow-wrap: normal; }
.game-dock__item[data-kind="leave"], .game-dock__item[data-kind="host"], .game-dock__item[data-kind="danger"] { color: var(--coral-contrast); }
.game-dock[data-open="true"] .game-dock__item {
  opacity: 1; transform: translate(var(--game-dock-x), var(--game-dock-y)) scale(1);
  transition-delay: var(--game-dock-delay, 0ms);
}
.game-dock[data-open="true"] .game-dock__item:active {
  background: var(--surface-2);
  transform: translate(var(--game-dock-x), var(--game-dock-y)) scale(.92);
}
body.dw-playing .dw[data-keyboard="true"] .game-dock { opacity: 0; pointer-events: none; }

/* A focused iOS control below 16px zooms the entire viewport. Component-level
   font rules appear later in this file, so this final, deliberately specific
   guard keeps Social, lobby chat and every sheet composer at the safe size
   without disabling pinch zoom. */
html body :is(input, select, textarea, [contenteditable="true"]) {
  font-size: 16px !important;
  touch-action: manipulation;
  scroll-margin-block: 18vh;
}
html body .field--code { font-size: var(--size-lg) !important; }
@media (hover: none) and (pointer: coarse) {
  html body :is(input, select, textarea, [contenteditable="true"]):not(.field--code) { font-size: 17px !important; }
}
body[data-native-keyboard="true"] .bottom-nav { display: none; }
body[data-native-keyboard="true"] .shell-main { padding-bottom: var(--s-5); }
@media (prefers-reduced-motion: reduce) {
  .game-dock, .game-dock__menu { transition: none; }
}
.msg { display: flex; gap: var(--s-2); align-items: flex-start; }
.msg--mine { flex-direction: row-reverse; }
.msg__col { min-width: 0; max-width: min(82%, 520px); display: flex; flex-direction: column; gap: 3px; }
.msg--mine .msg__col { align-items: flex-end; }
.msg__who {
  font-size: var(--size-xs); font-weight: var(--weight-black);
  color: var(--caramel-deep); letter-spacing: .01em;
}
.msg__bubble {
  max-width: 100%; padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md); background: var(--surface-2);
  font-size: var(--size-sm); overflow-wrap: anywhere;
}
.msg--mine .msg__bubble { background: var(--wash); }
.msg__bubble--deleted { color: var(--text-3); font-style: italic; background: transparent; border: 1px dashed var(--line); }
.msg__mention { color: var(--teal-contrast); font-weight: var(--weight-black); }
.msg__reply-preview {
  width: 100%; min-width: 0; display: flex; flex-direction: column;
  padding: 5px 9px; border-left: 3px solid var(--teal); border-radius: 7px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--text-3); font-size: 10px; line-height: 1.25;
}
.msg__reply-preview > :first-child { color: var(--teal-contrast); font-weight: var(--weight-black); }
.msg__meta { min-height: 18px; display: flex; align-items: center; gap: 3px; color: var(--text-3); }
.msg__time { font-size: 9px; }
.msg__more {
  width: 26px; height: 22px; display: grid; place-items: center;
  border-radius: var(--r-pill); color: var(--text-3); touch-action: manipulation;
}
.msg__more[aria-expanded="true"], .msg__more:active { background: var(--surface-2); color: var(--text); }
.msg__actions {
  max-width: 100%; display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
  padding: 4px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.msg__actions[hidden] { display: none; }
.msg__action {
  min-height: 30px; padding: 0 8px; display: inline-flex; align-items: center; gap: 4px;
  border-radius: var(--r-pill); color: var(--text-2); font-size: 10px; font-weight: var(--weight-bold);
  touch-action: manipulation;
}
.msg__action--icon { width: 30px; padding: 0; justify-content: center; }
.msg__action:active, .msg__action[aria-pressed="true"] { background: var(--surface-2); }
.msg__action--danger { color: var(--danger); }
.msg__reactions { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.msg__reaction {
  min-width: 34px; height: 25px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface);
  color: var(--text-3); font-size: 10px; font-weight: var(--weight-black); touch-action: manipulation;
}
.msg__reaction[aria-pressed="true"] { border-color: var(--teal); background: var(--wash); color: var(--teal-contrast); }
.msg__reaction:disabled { opacity: 1; }

.event-stream {
  border-left: 2.5px solid var(--surface-3); padding-left: var(--s-3);
  color: var(--text-3); font-size: var(--size-sm);
  display: flex; flex-direction: column; gap: 3px;
}
.chat-locked {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-md);
  background: var(--surface-2); font-size: var(--size-sm); color: var(--text-2);
}
.chat-composer { display: flex; flex-direction: column; gap: 5px; }
.chat-compose { display: flex; align-items: center; gap: var(--s-2); }
.chat-reply-compose {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  padding: 7px 10px; border-radius: var(--r-md); background: var(--surface-2); color: var(--text-2);
}
.chat-reply-compose[hidden] { display: none; }
.chat-reply-compose .grow { min-width: 0; display: flex; flex-direction: column; }
.msg__reply-close { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: var(--r-pill); }
.dm-head {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-4); padding: var(--s-2);
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
}
.dm-thread .chat-panel {
  min-height: clamp(260px,
    calc(var(--visual-height, 100dvh) - var(--topbar-h) - var(--nav-h) - var(--safe-top) - var(--safe-bottom) - 170px),
    640px);
}
.dm-thread .chat-log { overflow-y: auto; overscroll-behavior: contain; }
.dm-thread .chat-composer { margin-top: auto; }
body[data-native-keyboard="true"] .dm-thread {
  height: calc(var(--visual-height, 100dvh) - var(--topbar-h) - var(--safe-top) - var(--s-3));
  min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
body[data-native-keyboard="true"] .dm-thread .dm-head { flex: none; margin-bottom: var(--s-2); }
body[data-native-keyboard="true"] .dm-thread .chat-panel { flex: 1; min-height: 0; overflow: hidden; }
body[data-native-keyboard="true"] .dm-thread > .tiny { display: none; }
body[data-native-keyboard="true"] .dm-thread .chat-composer {
  flex: none; padding-top: var(--s-2); background: var(--canvas);
}

/* ==========================================================================
   VoiceDock · PushToTalk (§14)
   ========================================================================== */
.voice-dock {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-lg);
  background: var(--surface-2);
}
.call-room {
  display: flex; flex-direction: column; gap: var(--s-3);
  min-width: 0; padding: var(--s-3); border: 1px solid var(--line);
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm);
}
.call-room__head, .call-room__top, .call-room__locked {
  display: flex; align-items: center; gap: var(--s-3); min-width: 0;
}
.call-room__mark {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border-radius: 14px; color: var(--teal-contrast); background: var(--wash);
}
.call-room__message { color: var(--teal-contrast); }
.call-room__privacy {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--text-3); font-size: 10px; text-align: center;
}
.call-room__audio { display: none; }
.call-dialog { width: min(100%, 430px); }
.voice-dock__peers { display: flex; }
.ptt {
  width: 68px; height: 68px; border-radius: var(--r-pill); flex: none;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text-2);
  box-shadow: 0 0 0 5px var(--surface-3), 0 3px 0 var(--surface-3);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  touch-action: none;
}
.ptt[data-state="talking"] {
  background: var(--teal); color: var(--on-accent);
  box-shadow: 0 0 0 8px var(--wash), 0 3px 0 var(--teal-dark);
  transform: scale(1.04);
}
.ptt[data-state="denied"] { opacity: .55; }
.speaking-ring { border-radius: var(--r-pill); box-shadow: 0 0 0 3px var(--green); }

/* ==========================================================================
   Leaderboard · Achievements · Stats
   ========================================================================== */
.tabs {
  display: flex; gap: 3px; padding: 4px;
  background: var(--surface-2); border-radius: var(--r-pill);
  margin-bottom: var(--s-4); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; min-width: max-content; min-height: 44px; padding: 0 var(--s-3);
  border-radius: var(--r-pill); font-size: var(--size-sm);
  font-weight: var(--weight-bold); color: var(--text-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.lb-row { min-height: 56px; display: flex; align-items: center; gap: var(--s-3); padding: 10px 12px; }
.lb-row + .lb-row { border-top: 1px solid var(--line); }
.lb-row--me { background: var(--wash); border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--teal) 16%, transparent); }
.lb-row__name { font-weight: var(--weight-bold); font-size: var(--size-sm); }
.lb-row__score { flex: none; margin-left: auto; padding-inline: 4px 2px; display: flex; flex-direction: column; align-items: flex-end; text-align: right; line-height: 1.2; }
.lb-row__score-main { font-weight: var(--weight-black); font-size: var(--size-sm); white-space: nowrap; }
.lb-row__score-detail { margin-top: 2px; color: var(--text-3); font-size: 10px; font-weight: var(--weight-bold); white-space: nowrap; }
.rank-badge {
  width: 26px; flex: none; text-align: center;
  font-family: var(--font-display); font-weight: var(--weight-black);
  font-size: var(--size-sm); color: var(--text-3);
}
.rank-badge[data-rank="1"] { color: var(--gold-contrast); }
.rank-badge[data-rank="2"] { color: var(--text-2); }
.rank-badge[data-rank="3"] { color: var(--caramel-deep); }

.achievement { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.achievement--locked { opacity: .5; }
.achievement__icon {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--gold); color: var(--on-accent);
}
.achievement--locked .achievement__icon { background: var(--surface-3); color: var(--text-3); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.stat { padding: var(--s-3) var(--s-2); border-radius: var(--r-md); text-align: center; background: var(--surface-2); }
.stat__value { font-family: var(--font-display); font-size: var(--size-lg); font-weight: var(--weight-black); line-height: 1.1; }
.stat__label {
  font-size: 10px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: var(--tracking-label); font-weight: var(--weight-black); margin-top: 2px;
}

/* Daily completion cards use one stat/action system across every puzzle. */
.daily-result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.daily-result-stat {
  min-height: 82px; padding: 10px var(--s-2); display: flex; flex-direction: column;
  align-items: center; justify-content: center; border-radius: var(--r-md);
  background: var(--surface-2); text-align: center;
}
.daily-result-stat strong { font-family: var(--font-display); font-size: 24px; font-weight: var(--weight-black); line-height: 1; }
.daily-result-stat span { margin-top: 7px; color: var(--text-3); font-size: 9px; font-weight: var(--weight-black); letter-spacing: var(--tracking-label); text-transform: uppercase; }
.daily-result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.daily-result-actions .btn { width: 100%; min-height: 54px; padding-inline: 10px; font-size: var(--size-sm); white-space: nowrap; }
@media (max-width: 350px) {
  .daily-result-actions { gap: 6px; }
  .daily-result-actions .btn { padding-inline: 7px; font-size: 12px; gap: 6px; }
}

/* ==========================================================================
   Profile
   ========================================================================== */
.profile-header { border-radius: var(--r-xl); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); margin-bottom: var(--s-4); }
.profile-header__banner { height: 84px; background: linear-gradient(118deg, var(--teal), var(--caramel) 70%, var(--coral)); }
.profile-header__banner[data-banner="lagoon"], .profile-banner-choice[data-banner="lagoon"] { background: linear-gradient(120deg, #126d76, var(--teal) 54%, #f0c45c); }
.profile-header__banner[data-banner="berry"], .profile-banner-choice[data-banner="berry"] { background: linear-gradient(120deg, #71466b, var(--plum) 48%, var(--coral)); }
.profile-header__banner[data-banner="meadow"], .profile-banner-choice[data-banner="meadow"] { background: linear-gradient(120deg, #2d7450, var(--green) 55%, var(--gold)); }
.profile-header__banner[data-banner="sunset"], .profile-banner-choice[data-banner="sunset"] { background: linear-gradient(118deg, var(--teal), var(--caramel) 70%, var(--coral)); }
.profile-header__body { padding: 0 var(--s-4) var(--s-4); margin-top: -30px; }
.profile-header__name { font-size: var(--size-lg); font-weight: var(--weight-black); margin: var(--s-2) 0 0; }
.profile-header__handle { color: var(--text-3); font-size: var(--size-sm); font-weight: var(--weight-medium); }

/* Persistent cross-game friend/family groups. */
.crew-card__avatars { width: 64px; flex: none; display: flex; align-items: center; padding-left: 2px; }
.crew-card__avatars .avatar { box-shadow: 0 0 0 2px var(--surface-2); }
.crew-card__avatars .avatar + .avatar { margin-left: -12px; }

/* ==========================================================================
   Pattern Pop · reusable mini-game/challenge proof (§22, Phase 11)
   ========================================================================== */

.pattern-pop { width: 100%; max-width: 560px; margin: 0 auto; }
.pp-hero {
  position: relative; overflow: hidden; isolation: isolate; text-align: center;
  padding: clamp(28px, 8vw, 46px) 24px 30px; border: 1px solid color-mix(in srgb, var(--teal) 45%, var(--line));
  border-radius: var(--r-xl); background:
    radial-gradient(circle at 18% 4%, color-mix(in srgb, var(--gold) 32%, transparent), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--teal) 18%, var(--surface-2)), var(--surface-2) 58%, color-mix(in srgb, var(--coral) 12%, var(--surface-2)));
  box-shadow: var(--shadow-lg);
}
.pp-hero__glow { position: absolute; z-index: -1; width: 180px; height: 180px; right: -62px; top: -68px;
  border: 28px solid color-mix(in srgb, var(--paper) 28%, transparent); border-radius: 50%; opacity: .72; }
.pp-hero__mark { display: grid; place-items: center; margin-bottom: 10px; filter: drop-shadow(0 7px 0 color-mix(in srgb, var(--ink-deep) 14%, transparent)); }
.pp-kicker { color: var(--teal-contrast); font: 800 var(--size-xs)/1 var(--font-display); letter-spacing: .11em; text-transform: uppercase; }
.pp-title { margin: 8px 0 10px; color: var(--text); font: 900 clamp(2.1rem, 11vw, 3.4rem)/.95 var(--font-display); letter-spacing: -.05em; }
.pp-lede { max-width: 370px; margin: 0 auto 22px; color: var(--text-2); font-size: var(--size-md); line-height: 1.45; }
.pp-best { display: flex; justify-content: center; align-items: center; gap: 7px; margin-top: 15px; color: var(--text-2); font-size: var(--size-sm); font-weight: 750; }
.pp-challenge { display: flex; align-items: center; gap: var(--s-3); }
.pp-challenge .grow { display: flex; min-width: 0; flex-direction: column; }
.pp-how { display: grid; gap: 13px; }
.pp-how > div { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: var(--size-sm); font-weight: 680; }
.pp-how__num { display: grid; width: 28px; height: 28px; flex: none; place-items: center; border-radius: 9px;
  color: var(--ink-deep); background: var(--gold); font: 900 var(--size-sm)/1 var(--font-display); }

.pp-playing { overflow: hidden !important; overscroll-behavior: none; }
.pp-playing .topbar, .pp-playing .bottom-nav { display: none !important; }
.pattern-pop[data-state="playing"] { position: fixed; z-index: 1200; inset: 0; max-width: none; min-height: 100dvh; display: flex; flex-direction: column;
  overflow: hidden; padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  background: var(--canvas); }
.pp-runbar { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: var(--s-2);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--shadow-sm); }
.pp-runbar__metric { display: flex; align-items: baseline; justify-content: flex-end; gap: 7px; }
.pp-runbar__time, .pp-runbar__score { color: var(--text); font: 900 var(--size-md)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.pp-progress { height: 7px; margin: 10px 8px 0; overflow: hidden; border-radius: 99px; background: var(--surface-3); }
.pp-progress__fill { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .2s ease; }
.pp-versus { display: flex; width: fit-content; align-items: center; gap: 8px; margin: 10px auto 0; padding: 5px 11px 5px 6px;
  border-radius: 99px; color: var(--text-2); background: var(--surface-2); font-size: var(--size-xs); font-weight: 750; }
.pp-stage { flex: 1; display: flex; min-height: 0; flex-direction: column; align-items: center; justify-content: center; padding: 12px 0 10px; }
.pp-round-label { color: var(--teal-contrast); font: 850 var(--size-xs)/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase; }
.pp-prompt { margin: 7px 0 14px; color: var(--text); font: 900 var(--size-lg)/1.1 var(--font-display); }
.pp-grid { --pp-size: 3; --pp-accent: var(--teal); display: grid; width: min(100%, 350px, calc(100dvh - 300px));
  aspect-ratio: 1; grid-template-columns: repeat(var(--pp-size), 1fr); gap: clamp(6px, 2vw, 10px); }
.pp-grid[data-tone="gold"] { --pp-accent: var(--gold-contrast); }
.pp-grid[data-tone="coral"] { --pp-accent: var(--coral-contrast); }
.pp-grid[data-tone="mint"] { --pp-accent: var(--green-contrast); }
.pp-grid[data-tone="plum"] { --pp-accent: var(--plum); }
.pp-tile { display: grid; min-width: 0; min-height: 0; place-items: center; touch-action: manipulation; border: 1px solid color-mix(in srgb, var(--pp-accent) 36%, var(--line));
  border-radius: clamp(11px, 3vw, 18px); color: var(--pp-accent); background: var(--surface-2); box-shadow: 0 4px 0 color-mix(in srgb, var(--pp-accent) 25%, var(--line));
  transition: transform .11s ease, background .11s ease, box-shadow .11s ease; -webkit-tap-highlight-color: transparent; }
.pp-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--pp-accent) 25%, var(--line)); }
.pp-tile--right { color: var(--ink-deep); background: var(--gold); transform: scale(.9); }
.pp-tile--wrong { animation: pp-shake .22s ease; color: var(--coral-contrast); background: color-mix(in srgb, var(--coral) 16%, var(--surface-2)); }
@keyframes pp-shake { 25% { transform: translateX(-4px); } 55% { transform: translateX(4px); } 80% { transform: translateX(-2px); } }

.pp-result { position: relative; overflow: hidden; text-align: center; padding: 34px 22px 26px; border: 1px solid var(--line);
  border-radius: var(--r-xl); background: linear-gradient(165deg, color-mix(in srgb, var(--gold) 20%, var(--surface-2)), var(--surface-2) 42%); box-shadow: var(--shadow-lg); }
.pp-result__mark { display: grid; width: 72px; height: 72px; margin: 0 auto 15px; place-items: center; border-radius: 24px;
  color: var(--ink-deep); background: var(--gold); box-shadow: 0 7px 0 color-mix(in srgb, var(--gold-deep) 45%, var(--line)); }
.pp-result__title { margin: 8px 0 16px; color: var(--text); font: 900 var(--size-xl)/1 var(--font-display); }
.pp-result__score { color: var(--teal-contrast); font: 950 clamp(3rem, 16vw, 5rem)/.85 var(--font-display); letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.pp-result__label { margin-top: 8px; color: var(--text-3); font: 850 var(--size-xs)/1 var(--font-display); letter-spacing: .14em; text-transform: uppercase; }
.pp-compare { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 22px; padding: 14px;
  border-radius: var(--r-lg); background: var(--surface-3); }
.pp-compare > div { display: grid; justify-items: center; gap: 4px; color: var(--text-2); font-size: var(--size-xs); }
.pp-compare > div b { color: var(--text); font-size: var(--size-md); font-variant-numeric: tabular-nums; }
.pp-compare__vs { color: var(--text-3); font: 900 var(--size-xs)/1 var(--font-display); }

@media (max-height: 640px) {
  .pp-runbar { padding-block: 5px; }
  .pp-stage { padding: 7px 0 5px; }
  .pp-prompt { margin: 4px 0 8px; font-size: var(--size-md); }
  .pp-grid { width: min(100%, 286px, calc(100dvh - 278px)); gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .pp-progress__fill, .pp-tile { transition: none; }
  .pp-tile--wrong { animation: none; outline: 3px solid var(--coral); }
}
.crew-hero__mark {
  width: 62px; height: 62px; display: grid; place-items: center;
  border-radius: 20px; background: var(--surface-2); color: var(--teal-contrast);
  box-shadow: 0 0 0 5px var(--surface), var(--shadow-sm);
}
.crew-hero .profile-header__body { margin-top: -34px; }

.mood-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px var(--s-3); border-radius: var(--r-pill); background: var(--surface-2); font-size: var(--size-sm); font-weight: var(--weight-medium); }
.post-reactions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.post-reaction {
  min-width: 36px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface-2);
  color: var(--text-3); font-size: 10px; font-weight: var(--weight-black);
}
.post-reaction[aria-pressed="true"] { color: var(--teal-contrast); border-color: var(--teal); background: var(--wash); }
.profile-edit-preview { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-lg); background: var(--surface-2); }
.profile-colours { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s-2); }
.profile-colour { width: 100%; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.42); }
.profile-colour[aria-pressed="true"] { outline: 3px solid var(--text); outline-offset: 2px; }
.profile-banners { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); }
.profile-banner-choice { min-height: 56px; padding: var(--s-2); border-radius: var(--r-md); color: #fff; display: flex; align-items: flex-end; box-shadow: inset 0 0 0 2px transparent; }
.profile-banner-choice span { padding: 2px 7px; border-radius: var(--r-pill); background: rgba(0,0,0,.28); font-size: 10px; font-weight: 800; }
.profile-banner-choice[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--ink-deep); }
.post-card { padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-2); display: flex; flex-direction: column; gap: var(--s-2); }
.post-card__meta { font-size: var(--size-xs); color: var(--text-3); }

.xp-bar { height: 10px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.xp-bar__fill { height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--teal), var(--gold)); }

/* ==========================================================================
   Notifications
   ========================================================================== */
.notif { display: flex; gap: var(--s-3); align-items: flex-start; text-align: left; width: 100%; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.notif--unread { background: var(--wash); box-shadow: inset 0 0 0 1.5px var(--teal); }
.notif__icon { width: 38px; height: 38px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface); color: var(--teal-contrast); }
.notif--unread .notif__icon { background: var(--teal); color: var(--on-accent); }
.notif__title { font-weight: var(--weight-bold); font-size: var(--size-sm); line-height: 1.3; }
.notif__time { font-size: var(--size-xs); color: var(--text-3); margin-top: 2px; }

/* ==========================================================================
   States
   ========================================================================== */
.state { text-align: center; padding: var(--s-10) var(--s-5); display: flex; flex-direction: column; align-items: center; gap: var(--s-3); }
.state__icon { width: 56px; height: 56px; border-radius: var(--r-lg); display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.state__title { font-weight: var(--weight-black); font-size: var(--size-md); }
.state__text { color: var(--text-2); font-size: var(--size-sm); max-width: 34ch; }
.state__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; margin-top: var(--s-2); }
.state--onDark .state__icon { background: var(--press-canvas); color: var(--on-canvas-dim); }
.state--onDark .state__title { color: var(--on-canvas); }
.state--onDark .state__text { color: var(--on-canvas-dim); }
.state--error .state__icon { background: color-mix(in srgb, var(--coral) 18%, var(--surface-2)); color: var(--coral); }

.notice {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-md);
  background: var(--surface-2); font-size: var(--size-sm); color: var(--text-2);
}
.notice--warn { background: color-mix(in srgb, var(--gold) 22%, var(--surface-2)); color: var(--text); }
.notice__icon { color: var(--caramel-deep); }

.spinner { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--text-2); animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.10) 37%, rgba(255,255,255,.05) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: 0 0 } }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-host {
  position: fixed; left: 0; right: 0; z-index: var(--z-toast);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--s-4));
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  pointer-events: none;
}
.toast {
  max-width: calc(var(--shell-max) - var(--s-8));
  padding: var(--s-3) var(--s-5); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text);
  font-size: var(--size-sm); font-weight: var(--weight-bold);
  box-shadow: var(--shadow-lg);
  animation: sheet-in var(--dur) var(--ease-back);
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.row { display: flex; align-items: center; gap: var(--s-2); }
.row--between { justify-content: space-between; }
.row--top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: var(--s-2); }
.col-3 { display: flex; flex-direction: column; gap: var(--s-3); }
.wrap-gap { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.muted { color: var(--text-2); }
.muted-3 { color: var(--text-3); }
.tiny { font-size: var(--size-xs); line-height: 1.4; }
.small { font-size: var(--size-sm); }
.bold { font-weight: var(--weight-bold); }
.black { font-weight: var(--weight-black); }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); }
.hidden { display: none !important; }

/* Production welcome: deliberately calm and useful on a 320px phone. */
body[data-onboarding="true"] .app-shell { min-height: 100dvh; }
body[data-onboarding="true"] .topbar,
body[data-onboarding="true"] .bottom-nav { display: none !important; }
body[data-onboarding="true"] .shell-main {
  max-width: 560px;
  padding-top: max(32px, env(safe-area-inset-top));
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}
.welcome-screen { min-height: calc(100dvh - 64px); display: flex; flex-direction: column; justify-content: center; gap: var(--s-6); }
.welcome-screen__brand { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--on-canvas); font: 800 25px/1 var(--font-display); letter-spacing: -.04em; }
.welcome-screen__copy { text-align: center; color: var(--on-canvas); }
.welcome-screen__copy h1 { margin: 12px 0 5px; font: 800 clamp(38px, 13vw, 58px)/.95 var(--font-display); letter-spacing: -.055em; }
.welcome-screen__copy p { max-width: 410px; margin: 0 auto; color: var(--on-canvas-dim); line-height: 1.5; }
.welcome-screen__benefits { display: grid; gap: 8px; }
.welcome-benefit { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border: 1px solid var(--press-canvas); border-radius: var(--r-md); background: var(--press-canvas); color: var(--on-canvas); }
.welcome-benefit__icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 14px; display: grid; place-items: center; background: var(--teal); color: var(--on-accent); }
.welcome-benefit strong, .welcome-benefit small { display: block; }
.welcome-benefit small { margin-top: 2px; color: var(--on-canvas-dim); line-height: 1.35; }
.welcome-screen__actions { display: grid; gap: 9px; }

/* Shared Home Screen walkthrough: one Chasbi icon for every game. */
.install-walkthrough { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(82%, 1fr); gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-inline: contain; padding: 4px 2px 12px; scrollbar-width: none; }
.install-walkthrough::-webkit-scrollbar { display: none; }
.install-step { scroll-snap-align: center; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.install-step img { display: block; width: 100%; height: 245px; object-fit: contain; border-radius: var(--r-md); background: #111; }
.install-step figcaption { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; color: var(--text); }
.install-step figcaption > b { display: grid; place-items: center; width: 25px; height: 25px; flex: 0 0 25px; border-radius: 50%; background: var(--teal); color: var(--on-accent); }
.install-step figcaption strong, .install-step figcaption small { display: block; }
.install-step figcaption small { margin-top: 2px; color: var(--text-2); line-height: 1.3; }
