/*
 * Shared component & primitive styles (the design system).
 *
 * Graduated from the UI prototypes (apps/frontend/prototypes/*) into the real
 * app. Light-DOM components reference these classes instead of inlining a
 * <style> block. Raw values live in tokens.css; this file composes them.
 *
 * Grown by the "rule of three": promote a recurring pattern here rather than
 * re-inlining it. See documentation/LOOK_AND_FEEL.md and UI_SHELL.md.
 *
 * Depends on tokens.css (loaded first).
 */

/* animatable angle for the Play button's shimmer ring */
@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

/* ============================================================
   Immersive backdrop (owned by the app shell)
   ============================================================ */
.app-backdrop {
  position: fixed; inset: -5%;
  background: url('/img/home.jpg') center/cover no-repeat;
  filter: blur(5px) saturate(1.08);
  transform: scale(1.06);
  z-index: -2;
}
.app-scrim {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(40, 22, 8, 0.30), rgba(40, 22, 8, 0.62)),
    linear-gradient(180deg, rgba(40, 22, 8, 0.35), rgba(30, 16, 4, 0.55));
}

/* ============================================================
   App shell layout (persistent frame + swappable main outlet)
   ============================================================ */
.app-shell {
  height: 100vh; display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "nav" "session" "main";
  gap: var(--spacing-md); padding: var(--spacing-md);
}
/* Cream text on the dark shell — but only when chrome is shown, so the bare
   (light-themed, not-yet-redesigned) routes keep their own colors. */
.app-shell:not(.is-bare) { color: var(--on-surface); }
.app-main { grid-area: main; overflow: auto; display: flex; flex-direction: column; }
.app-main > router-outlet { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; }
/* routed shell screens fill the main zone so their inner vertical centering
   resolves (a flex item's height is definite, unlike a min-height: 100% chain) */
home-page, play-page, learning-page, casual-search-page, play-custom-games-page, lobby-room { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; }

/* the shell hides its chrome for immersive, full-window routes (game, welcome) */
.app-shell.is-bare { grid-template-rows: 1fr; grid-template-areas: "main"; padding: 0; gap: 0; }
.app-shell.is-bare .app-topnav,
.app-shell.is-bare .app-bottomnav,
.app-shell.is-bare .app-topbar-mobile,
.app-shell.is-bare .app-session,
.app-shell.is-bare .app-backdrop,
.app-shell.is-bare .app-scrim { display: none; }

/* ---- Session bar: the active play session, surfaced shell-wide -------- */
/* Centered pill so the action hugs the text; tinted green for a lobby, amber for
   a search. Graduated from prototypes/shell.html. */
.app-session {
  grid-area: session; justify-self: center; width: fit-content; max-width: 100%;
  display: flex; align-items: center; gap: var(--spacing-md);
  padding: 0.5rem 0.6rem 0.5rem var(--spacing-lg);
  background: var(--surface-elevated); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--surface-border); border-left: 5px solid var(--success-color);
  border-radius: 999px; box-shadow: var(--shadow-md); font-weight: 600; color: var(--on-surface);
}
.app-session[hidden] { display: none; }
.app-session.is-search { border-left-color: var(--warning-color); }
.app-session-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--success-color); box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.18); }
.app-session.is-search .app-session-dot { background: var(--warning-color); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18); }
.app-session-meta { color: var(--on-surface-muted); font-weight: 500; }
.app-session-spacer { width: var(--spacing-sm); }
.app-session-action {
  padding: 0.4rem 1rem; font-weight: 700; color: var(--border-dark);
  background: var(--current-player-bg); border: 1px solid var(--current-player-border);
  border-radius: var(--radius-md); cursor: pointer;
}
.app-session-action[hidden] { display: none; }
.app-session-action:hover { background: var(--accent-color); color: var(--text-inverse); }
@media (prefers-reduced-motion: no-preference) {
  .app-session { animation: sessionPop 0.3s ease, sessionGlowGreen 2.2s ease-in-out infinite; }
  .app-session.is-search { animation: sessionPop 0.3s ease, sessionGlowAmber 2.2s ease-in-out infinite; }
  .app-session.is-search .app-session-dot { animation: sessionDotPulse 1.2s ease-in-out infinite; }
  @keyframes sessionPop { from { opacity: 0; transform: translateY(-8px) scale(0.96); } to { opacity: 1; transform: none; } }
  @keyframes sessionGlowGreen { 0%, 100% { box-shadow: var(--shadow-md); } 50% { box-shadow: var(--shadow-md), 0 0 16px 1px rgba(5, 150, 105, 0.5); } }
  @keyframes sessionGlowAmber { 0%, 100% { box-shadow: var(--shadow-md); } 50% { box-shadow: var(--shadow-md), 0 0 16px 1px rgba(245, 158, 11, 0.55); } }
  @keyframes sessionDotPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
}

/* ---- Forced-takeover interstitial ("Match starting…") ---------------- */
.app-takeover {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 40%, rgba(20, 11, 3, 0.86), rgba(20, 11, 3, 0.96));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.app-takeover[hidden] { display: none; }
.app-takeover-card { display: grid; justify-items: center; gap: var(--spacing-md); text-align: center; color: var(--on-surface); }
.app-takeover-card h2 { font-family: var(--font-family-display); font-size: var(--font-size-2xl); }
.app-takeover-card p { color: var(--on-surface-muted); }
.app-takeover-spinner { width: 48px; height: 48px; border-radius: 50%; border: 4px solid var(--surface-border); border-top-color: var(--accent-color); }
@media (prefers-reduced-motion: no-preference) {
  .app-takeover-spinner { animation: takeoverSpin 0.9s linear infinite; }
  @keyframes takeoverSpin { to { transform: rotate(360deg); } }
}

/* ============================================================
   Top nav (desktop)
   ============================================================ */
.app-topnav {
  grid-area: nav; display: flex; align-items: center; gap: var(--spacing-lg);
  padding: var(--spacing-sm) var(--spacing-lg);
  background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.brand { display: flex; align-items: center; cursor: pointer; text-decoration: none; }
.brand-logo { height: 40px; width: auto; display: block; }
.nav-primary { display: flex; align-items: center; gap: var(--spacing-sm); }
.nav-spacer { flex: 1; }
.nav-item {
  display: inline-flex; align-items: center; gap: 0.45em;
  padding: 0.6rem 1.1rem; font-size: var(--font-size-base); font-weight: 600;
  color: var(--on-surface); background: transparent; border: none; border-radius: var(--radius-md);
  cursor: pointer; transition: background var(--transition-fast); text-decoration: none;
}
.nav-item .nav-ic { font-size: 1.05em; line-height: 1; }
.nav-item:hover { background: var(--surface-hover); }
.nav-item.is-active { background: var(--current-player-bg); color: var(--border-dark); }
.profile-chip {
  display: inline-flex; align-items: center; gap: 0.55em; padding: 0.2rem 0.5rem 0.2rem 0.45rem;
  background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: 999px;
  cursor: pointer; font: inherit; font-weight: 600; color: var(--on-surface); max-width: 220px;
}
/* The 40px level medallion sits flush at the chip's trailing edge. */
.profile-chip level-badge[data-chip-level] { margin-left: 0.1em; margin-right: -0.15rem; }
.profile-chip:hover { background: var(--surface-hover); }
.profile-chip .profile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1rem;
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color)); flex: 0 0 auto;
}
.avatar-sm {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-size: 0.85rem; font-weight: 700; background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
}

/* ============================================================
   Hero Play CTA (shimmer ring + periodic sheen)
   ============================================================ */
.btn-play {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.85rem 2.2rem; font-size: var(--font-size-xl); font-weight: 800; letter-spacing: 0.01em;
  color: var(--text-inverse);
  background: linear-gradient(180deg, var(--accent-color), var(--primary-color) 55%, var(--primary-hover));
  border: none; border-radius: 999px; box-shadow: var(--shadow-lg); cursor: pointer; text-decoration: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-play > span { position: relative; z-index: 2; }
.btn-play::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 3px;
  background: conic-gradient(from var(--a), rgba(255,211,107,0.10), rgba(255,246,214,0.85), rgba(255,211,107,0.10), rgba(255,246,214,0.85), rgba(255,211,107,0.10));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; z-index: 1;
  animation: spinA 3.4s linear infinite;
}
.btn-play::after {
  content: ''; position: absolute; top: 0; left: -60%; width: 45%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-18deg); pointer-events: none; z-index: 1; animation: glint 3.6s ease-in-out infinite;
}
.btn-play:hover { transform: translateY(-2px); box-shadow: var(--shadow-xl); }
@keyframes spinA { to { --a: 360deg; } }
@keyframes glint { 0%, 55% { left: -60%; } 82% { left: 130%; } 100% { left: 130%; } }

/* active/settled: you're already in the Play section */
.btn-play.is-active { cursor: default; filter: saturate(0.85) brightness(0.9); box-shadow: inset 0 2px 7px rgba(0,0,0,0.45), var(--shadow-md); }
.btn-play.is-active::before { animation: none; background: rgba(255, 245, 230, 0.22); }
.btn-play.is-active::after { display: none; }
.btn-play.is-active:hover { transform: none; box-shadow: inset 0 2px 7px rgba(0,0,0,0.45), var(--shadow-md); }

@media (prefers-reduced-motion: reduce) {
  .btn-play::before, .btn-play::after { animation: none !important; background: none !important; }
  .btn-play { box-shadow: 0 0 0 3px var(--accent-color), var(--shadow-md) !important; }
}

/* ============================================================
   Generic buttons
   ============================================================ */
.btn { padding: 0.7rem 1.8rem; border-radius: 999px; cursor: pointer; font: 700 var(--font-size-base)/1 var(--font-family); border: none; }
.btn-primary { background: linear-gradient(180deg, var(--accent-color), var(--primary-color) 55%, var(--primary-hover)); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); }

/* ============================================================
   Play screen — title + the three mode cards
   ============================================================ */
.screen-centered {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--spacing-lg); min-height: 100%;
}
.screen-title { font-family: var(--font-family-display); font-size: var(--font-size-3xl); text-shadow: 0 2px 12px rgba(0,0,0,0.45); margin-bottom: 0.2rem; }
.screen-subtitle { color: rgba(254,252,243,0.9); margin-bottom: var(--spacing-2xl); text-shadow: 0 1px 8px rgba(0,0,0,0.4); }
/* Play home has no subtitle, so the title needs its own gap to the mode grid. */
play-page .screen-title { margin-bottom: calc(var(--spacing-xl) * 2); }
/* Sit a bit above dead-center (~1/3 down) instead of vertically centered. */
play-page .screen-centered { justify-content: flex-start; padding-top: 14vh; }

.mode-grid { display: flex; flex-wrap: nowrap; justify-content: center; gap: var(--spacing-xl); width: 100%; }
.mode-card {
  position: relative; flex: 0 0 280px; min-height: 330px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 0.4rem;
  background: var(--surface-elevated); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--surface-border); border-radius: var(--radius-xl);
  padding: var(--spacing-xl); box-shadow: var(--shadow-lg);
  cursor: pointer; color: var(--on-surface); text-decoration: none;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}
.mode-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-xl); border-color: var(--primary-color); }
.mode-card .icon { font-size: 4.5rem; line-height: 1; }
.mode-card h3 { margin: 1rem 0 0.4rem; font-size: var(--font-size-2xl); }
.mode-card p { color: var(--on-surface-muted); font-size: var(--font-size-base); line-height: 1.5; }
.mode-card.featured { border-color: var(--primary-color); box-shadow: 0 0 0 2px var(--primary-color), var(--shadow-lg); }
.mode-card.is-disabled { opacity: 0.55; cursor: not-allowed; }
.mode-card.is-disabled:hover { transform: none; box-shadow: var(--shadow-lg); border-color: var(--surface-border); }
.mode-card .mode-tag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  padding: 0.25rem 0.9rem; border-radius: 999px; font-size: var(--font-size-xs); font-weight: 800;
  letter-spacing: 0.03em; text-transform: uppercase;
  background: linear-gradient(180deg, var(--accent-color), var(--primary-color)); color: #fff; box-shadow: var(--shadow-md);
}

/* ============================================================
   Conversion strip — the guest "create an account" hook on Play
   ============================================================ */
.home-strips { display: flex; flex-direction: column; gap: var(--spacing-md); width: 100%; max-width: 640px; margin: var(--spacing-xl) auto 0; }
.home-strip {
  display: flex; align-items: center; gap: var(--spacing-md); text-align: left; text-decoration: none;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--surface-border); border-radius: var(--radius-lg); color: var(--on-surface);
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.home-strip:hover { background: var(--surface-hover); transform: translateY(-2px); }
button.home-strip { font: inherit; width: 100%; cursor: pointer; }
.home-strip .s-ic { font-size: 1.6rem; flex: none; }
.home-strip .s-txt { flex: 1; font-size: var(--font-size-sm); color: var(--on-surface-muted); }
.home-strip .s-txt b { color: var(--on-surface); font-weight: 700; }
.home-strip .s-arrow { color: var(--accent-color); font-weight: 800; font-size: var(--font-size-lg); }

/* ============================================================
   Learn — how to play
   ============================================================ */
.learn-main { overflow: auto; padding: var(--spacing-lg); display: flex; flex-direction: column; align-items: center; }
.learn-inner { width: 100%; max-width: 1040px; display: flex; flex-direction: column; gap: var(--spacing-lg); }
.learn-head { text-align: center; }
.learn-head h1 { font-family: var(--font-family-display); font-size: var(--font-size-3xl); text-shadow: 0 2px 12px rgba(0,0,0,0.45); }
.learn-head .subtitle { color: rgba(254,252,243,0.9); text-shadow: 0 1px 8px rgba(0,0,0,0.4); margin-top: 0.2rem; }
.learn-body { display: grid; grid-template-columns: 220px 1fr; gap: var(--spacing-lg); align-items: start; }
.learn-topics { display: flex; flex-direction: column; gap: 0.4rem; position: sticky; top: 0; }
.learn-topic { text-align: left; padding: 0.7rem 1rem; border-radius: var(--radius-md); border: 1px solid transparent; background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--on-surface); font: inherit; font-weight: 600; cursor: pointer; transition: background var(--transition-fast); }
.learn-topic:hover { background: var(--surface-hover); }
.learn-topic.is-active { background: var(--current-player-bg); color: var(--border-dark); border-color: var(--primary-color); }
.learn-content { background: var(--panel); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--surface-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); padding: var(--spacing-xl); min-height: 380px; }
.learn-content section { display: none; }
.learn-content section.is-active { display: block; animation: learnfade 0.3s ease; }
@keyframes learnfade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.learn-content h2 { font-family: var(--font-family-display); font-size: var(--font-size-2xl); margin-bottom: var(--spacing-md); color: var(--accent-color); }
.learn-content p { line-height: 1.6; margin-bottom: var(--spacing-md); }
.learn-content ul { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.learn-content li { display: flex; gap: 0.6em; line-height: 1.5; }
.learn-content li::before { content: '♦'; color: var(--primary-color); flex: none; }
.learn-content b { color: var(--accent-color); }
.learn-tables { display: flex; gap: var(--spacing-lg); flex-wrap: wrap; }
.learn-table { flex: 1 1 0; min-width: 240px; }
.learn-table h3 { font-size: var(--font-size-base); margin-bottom: 0.5rem; }
.learn-table.trump h3 { color: var(--accent-color); }
.learn-table table { width: 100%; border-collapse: collapse; }
.learn-table th, .learn-table td { padding: 0.4rem 0.6rem; text-align: left; }
.learn-table thead th { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--on-surface-muted); border-bottom: 1px solid var(--surface-border); }
.learn-table tbody tr { border-bottom: 1px solid var(--surface-hover); }
.learn-table td.pts { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.learn-note { color: var(--on-surface-muted); font-size: var(--font-size-sm); margin-top: var(--spacing-md); }
.learn-cta { align-self: center; display: inline-flex; align-items: center; gap: 0.5em; padding: 0.8rem 1.6rem; border-radius: 999px; font-weight: 700; text-decoration: none; color: var(--on-surface); background: var(--surface-elevated); border: 1px solid var(--surface-border); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: transform var(--transition-fast), border-color var(--transition-fast); }
.learn-cta:hover { transform: translateY(-2px); border-color: var(--primary-color); }
.learn-cta .arrow { color: var(--accent-color); font-weight: 800; }

/* ============================================================
   Immersive scene backdrop for full-window dark pages (matchmaking, …)
   (distinct from the shell's .app-backdrop, which is hidden in is-bare)
   ============================================================ */
.scene-backdrop {
  position: fixed; inset: -5%;
  background: url('/img/home.jpg') center/cover no-repeat;
  filter: blur(5px) saturate(1.08); transform: scale(1.06); z-index: -2;
}
.scene-scrim {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(40, 22, 8, 0.30), rgba(40, 22, 8, 0.62)),
    linear-gradient(180deg, rgba(40, 22, 8, 0.35), rgba(30, 16, 4, 0.55));
}

/* ============================================================
   Matchmaking — Quick Play search card (searching → found)
   ============================================================ */
.mm-stage { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--spacing-lg); padding: var(--spacing-xl); }
.qp-badge {
  position: fixed; top: var(--spacing-xl); left: 50%; transform: translateX(-50%); z-index: 5;
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.45rem 1.1rem; border-radius: 999px; font-weight: 700; font-size: var(--font-size-sm);
  color: var(--on-surface);
  background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--surface-border);
}
.mm-card {
  display: flex; flex-direction: column; align-items: center; gap: var(--spacing-md);
  padding: var(--spacing-2xl) var(--spacing-2xl) var(--spacing-xl);
  color: var(--on-surface);
  background: var(--surface); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--surface-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
  text-align: center; max-width: 520px; width: 100%; animation: learnfade 0.35s ease;
}
.mm-card h1 { font-family: var(--font-family-display); font-size: var(--font-size-2xl); }
.mm-card .sub { color: var(--on-surface-muted); }
.mm-card .sub.mm-error { color: #f87171; }
.mm-card .elapsed { color: var(--on-surface-muted); font-variant-numeric: tabular-nums; }
.mm-actions { display: flex; gap: var(--spacing-md); margin-top: var(--spacing-sm); }
.pulse-ring {
  position: relative; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; font-size: 2rem;
  background: var(--surface-elevated); border: 1px solid var(--surface-border);
}
.pulse-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%; padding: 3px;
  background: conic-gradient(from var(--a), rgba(255,211,107,0) 0deg, rgba(255,211,107,0) 250deg, rgba(255,246,214,1) 344deg, rgba(255,211,107,0) 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; animation: spinA 1.6s linear infinite;
}
.status-orb { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 2.4rem; color: #fff; }
.status-orb.ok { background: var(--success-color); box-shadow: 0 0 0 6px rgba(5,150,105,0.25); animation: pop 0.45s ease; }
.status-orb.err { background: var(--error-color); box-shadow: 0 0 0 6px rgba(220,38,38,0.25); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============================================================
   Table room — the in-room lobby (banner row + status zone).
   Renders full-window (the game route is shell-less) so it carries its own
   .scene-backdrop and cream text.
   ============================================================ */
/* Fills the shell's main zone (the shell paints the backdrop); width-capped + centered. */
.lobby-room { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; gap: var(--spacing-lg); padding: var(--spacing-lg) var(--spacing-xl); color: var(--on-surface); max-width: 1200px; margin: 0 auto; }
.lobby-topbar { display: flex; align-items: center; gap: var(--spacing-md); }
.lobby-topbar .leave { display: inline-flex; align-items: center; gap: 0.4em; padding: 0.5rem 1rem; border-radius: var(--radius-md); background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--surface-border); color: var(--on-surface); font-weight: 600; text-decoration: none; }
.lobby-topbar .leave:hover { background: var(--surface-hover); }
.lobby-topbar .room-title { font-family: var(--font-family-display); font-weight: 800; font-size: var(--font-size-xl); }
.lobby-topbar .spacer { flex: 1; }
.room-code { display: inline-flex; align-items: center; gap: 0.6em; padding: 0.4rem 0.5rem 0.4rem 1rem; border-radius: 999px; background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--surface-border); font-weight: 600; }
.room-code .code { letter-spacing: 0.08em; color: var(--accent-color); }
.room-code button { padding: 0.35rem 0.85rem; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 700; background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); }
.room-code button:hover { background: var(--surface-hover); }
.conn { display: inline-flex; align-items: center; gap: 0.45em; font-size: var(--font-size-sm); font-weight: 600; padding: 0.35rem 0.8rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--surface-border); }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--on-surface-muted); }
.conn.connected .dot { background: var(--success-color); }
.conn.connecting .dot { background: var(--warning-color); animation: turnpulse 1.2s ease-in-out infinite; }
.conn.disconnected .dot { background: var(--error-color); }
@keyframes turnpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.lobby-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--spacing-xl); }

/* banner row (grouped teams) */
.banner-row { display: flex; align-items: stretch; justify-content: center; gap: var(--spacing-md); width: 100%; max-width: 1000px; background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--surface-border); border-radius: var(--radius-xl); padding: var(--spacing-lg) var(--spacing-xl); box-shadow: var(--shadow-lg); }
.team { flex: 1; display: flex; flex-direction: column; gap: 0.6rem; }
.team-label { text-align: center; font-size: var(--font-size-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.team-a .team-label { color: var(--team-1-color); }
.team-b .team-label { color: var(--team-2-color); }
.team .banners { display: flex; align-items: stretch; gap: var(--spacing-lg); justify-content: space-evenly; }
.vs { flex: 0 0 auto; align-self: center; padding: 0 var(--spacing-sm); font-family: var(--font-family-display); font-weight: 800; font-size: var(--font-size-2xl); color: var(--on-surface-muted); opacity: 0.8; }
.banner { flex: 1 1 0; max-width: 210px; min-height: 188px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.55rem; text-align: center; padding: var(--spacing-md); background: var(--surface-elevated); border: 1px solid var(--surface-border); border-top: 3px solid var(--seat-color, var(--surface-border)); border-radius: var(--radius-lg); }
.banner[data-team="a"] { --seat-color: var(--team-1-color); }
.banner[data-team="b"] { --seat-color: var(--team-2-color); }
.banner .avatar { width: 56px; height: 56px; font-size: 1.5rem; box-shadow: 0 0 0 3px var(--seat-color, transparent); position: relative; }
/* Level badge incrusted at the bottom of the lobby avatar. */
.banner .avatar level-badge.avatar-level { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5)); }
.banner .bname { font-weight: 700; line-height: 1.15; }
.banner .filled { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; }
.banner { position: relative; }
.banner-remove-ai { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0; line-height: 1; border-radius: 999px; border: 1px solid var(--surface-border); background: var(--surface); color: var(--on-surface-muted); cursor: pointer; opacity: 0.65; transition: opacity 0.15s, color 0.15s, background 0.15s; }
.banner-remove-ai:hover { opacity: 1; color: #fca5a5; background: var(--surface-hover); }
.type-tag { font-size: var(--font-size-xs); font-weight: 700; padding: 0.18rem 0.65rem; border-radius: 999px; display: inline-flex; align-items: center; gap: 0.3em; }
.type-tag.you { background: var(--current-player-bg); color: var(--border-dark); }
.type-tag.ai { background: rgba(123, 90, 240, 0.22); color: #c4b5fd; }
.type-tag.human { background: var(--surface-hover); color: var(--on-surface-muted); }
.ready-status { font-size: var(--font-size-sm); font-weight: 700; display: inline-flex; align-items: center; gap: 0.35em; }
.ready-status.ready { color: #34d399; }
.ready-status.notready { color: var(--on-surface-muted); }
.banner.empty { border-top-color: var(--surface-border); border-style: dashed; }
.banner .empty-content { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; width: 100%; }
.banner .avatar.ghost { background: transparent; color: var(--on-surface-muted); border: 2px dashed var(--surface-border); box-shadow: none; }
.seat-actions { display: flex; flex-direction: column; gap: 0.4rem; width: 100%; }
.seat-actions-label { font-size: 0.8rem; font-weight: 700; color: var(--on-surface-muted); }
.seat-actions button { padding: 0.45rem; border-radius: var(--radius-md); cursor: pointer; font: inherit; font-weight: 700; border: 1px solid var(--surface-border); background: var(--surface-hover); color: var(--on-surface); }
.seat-actions button:hover { filter: brightness(1.1); }
/* The single "+ Add AI" action on an empty seat. */
.btn-add-ai { padding: 0.5rem 0.9rem; }
/* A seated bot's level, shown as a clickable button that opens the level modal.
   Inherits the "Ready up" look (.btn .btn-ready); only sized down to fit the seat. */
.ai-level-btn { padding: 0.4rem 1.1rem; font-size: var(--font-size-sm); }
.ai-level-btn:hover { border-color: var(--accent-color); }
/* "Set AI level" modal (reuses .modal-overlay / .modal). */
.ai-level-modal { width: min(420px, 100%); gap: var(--spacing-lg); }
.ai-level-head { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-md); }
.ai-level-options { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.ai-level-option { display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; text-align: left; padding: 0.7rem 0.9rem; border-radius: var(--radius-md); background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); font: inherit; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.ai-level-option:hover { background: var(--surface-hover); }
.ai-level-option.is-on { border-color: var(--accent-color); background: var(--surface-hover); }
.ai-level-name { font-weight: 700; }
.ai-level-desc { font-size: var(--font-size-sm); color: var(--on-surface-muted); }

/* status zone (shared waiting / CTA pattern) */
.status-zone { display: flex; flex-direction: column; align-items: center; gap: var(--spacing-md); width: 100%; max-width: 560px; padding: var(--spacing-lg); background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px dashed var(--surface-border); border-radius: var(--radius-lg); text-align: center; }
.status-zone .status-line { font-size: var(--font-size-lg); font-weight: 600; }
.status-zone .status-line .accent { color: var(--accent-color); }
.status-actions { display: flex; gap: var(--spacing-md); flex-wrap: wrap; justify-content: center; }
.btn-ready { background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); }
.btn-ready.is-ready { background: rgba(5,150,105,0.22); border-color: var(--success-color); color: #34d399; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 820px) {
  .lobby-room { padding: var(--spacing-md); }
  .lobby-topbar { flex-wrap: wrap; }
  .banner-row { flex-wrap: wrap; gap: var(--spacing-sm); padding: var(--spacing-md); }
  .vs { display: none; }
  .banner { max-width: none; min-width: 120px; }
}

/* ============================================================
   Custom Games — public room browser (panel + scrollable list + create modal)
   ============================================================ */
.cg-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--spacing-lg); min-height: 100%; }
.cg-panel { width: 100%; max-width: 760px; max-height: 100%; display: flex; flex-direction: column; gap: var(--spacing-lg); padding: var(--spacing-xl); background: var(--panel); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--surface-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); }
.cg-header { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--spacing-md); flex-wrap: wrap; }
.cg-header h1 { font-family: var(--font-family-display); font-size: var(--font-size-2xl); }
.cg-header .subtitle { color: var(--on-surface-muted); margin-top: 0.15rem; font-size: var(--font-size-sm); }
.cg-header-actions { display: flex; align-items: center; gap: var(--spacing-sm); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.25rem; background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: var(--radius-md); cursor: pointer; color: var(--on-surface); }
.icon-btn:hover { background: var(--surface-hover); }
.cg-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--spacing-sm); }
.cg-scroll.is-centered { justify-content: center; }
.cg-list { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.cg-row { display: flex; align-items: center; gap: var(--spacing-md); padding: var(--spacing-md) var(--spacing-lg); background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); transition: border-color var(--transition-fast), transform var(--transition-fast); }
.cg-row:not(.is-unavailable):hover { border-color: var(--primary-color); transform: translateY(-1px); }
.cg-main { flex: 1; min-width: 0; }
.cg-name { font-weight: 700; font-size: var(--font-size-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-players { display: inline-flex; align-items: center; gap: 0.4em; font-weight: 700; font-variant-numeric: tabular-nums; }
.cg-players .seats { display: inline-flex; gap: 3px; }
.cg-players .seat { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-hover); }
.cg-players .seat.taken { background: var(--accent-color); }
.cg-badge { font-size: var(--font-size-xs); font-weight: 700; padding: 0.2rem 0.65rem; border-radius: 999px; background: var(--surface-hover); color: var(--on-surface-muted); }
.cg-row.is-unavailable { opacity: 0.6; }
.join-btn { padding: 0.55rem 1.4rem; }
.cg-empty { display: flex; flex-direction: column; align-items: center; gap: var(--spacing-md); text-align: center; padding: var(--spacing-2xl) var(--spacing-lg); }
.cg-empty .big { font-size: 2.6rem; }
.cg-empty h3 { font-size: var(--font-size-xl); }
.cg-empty p { color: var(--on-surface-muted); max-width: 360px; }
.cg-msg { text-align: center; color: var(--on-surface-muted); padding: var(--spacing-xl); }

/* create modal */
.modal-overlay { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: var(--spacing-lg); background: rgba(15, 8, 2, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-overlay.is-open { display: flex; }
.modal { width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--spacing-lg); padding: var(--spacing-2xl); background: var(--panel); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid var(--surface-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); animation: pop 0.25s ease; }
.modal h2 { font-family: var(--font-family-display); font-size: var(--font-size-2xl); }
.modal .field { display: flex; flex-direction: column; gap: 0.4rem; }
.modal label { font-size: var(--font-size-sm); color: var(--on-surface-muted); font-weight: 600; }
.modal input { width: 100%; padding: 0.8rem 1rem; border-radius: var(--radius-md); background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); font: inherit; font-size: var(--font-size-base); }
.modal input:focus { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.modal .note { font-size: var(--font-size-sm); color: var(--on-surface-muted); }
.modal .note.error { color: #f87171; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--spacing-sm); }

/* auth modal (sign in / create account) — vertical stepper rail + step body */
.am-modal { width: min(640px, 100%); flex-direction: row; gap: 0; padding: 0; overflow: hidden; }
.am-rail { flex: 0 0 196px; display: flex; flex-direction: column; padding: var(--spacing-2xl) var(--spacing-xl); background: var(--surface-elevated); border-right: 1px solid var(--surface-border); }
.am-step { display: flex; align-items: flex-start; gap: 0.75rem; position: relative; padding-bottom: 1.9rem; }
.am-step:last-child { padding-bottom: 0; }
.am-step:not(:last-child)::after { content: ''; position: absolute; left: 15px; top: 34px; bottom: 0; width: 2px; background: var(--surface-border); }
.am-step.is-done:not(:last-child)::after { background: var(--accent-color); }
.am-node { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: var(--font-size-sm); background: var(--surface-hover); color: var(--on-surface-muted); border: 2px solid transparent; z-index: 1; }
.am-step.is-active .am-node { background: var(--accent-color); color: #fff; }
.am-step.is-done .am-node { background: transparent; border-color: var(--accent-color); color: var(--accent-color); }
.am-step-label { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.am-step-label .t { font-weight: 600; font-size: var(--font-size-sm); color: var(--on-surface); }
.am-step-label .s { font-size: var(--font-size-xs); color: var(--on-surface-muted); }
.am-step.is-upcoming .am-step-label .t { color: var(--on-surface-muted); }
.am-body { flex: 1; display: flex; flex-direction: column; gap: var(--spacing-lg); padding: var(--spacing-2xl); min-width: 0; color: var(--on-surface); }
.am-body h2 { font-family: var(--font-family-display); font-size: var(--font-size-2xl); }
.am-muted { color: var(--on-surface-muted); font-size: var(--font-size-sm); line-height: 1.5; }

/* feedback modal — category chips + message box */
.fb-modal { width: min(520px, 100%); }
.fb-cats { display: flex; gap: var(--spacing-sm); flex-wrap: wrap; }
.fb-cat { flex: 1; min-width: 96px; padding: 0.7rem 0.9rem; border-radius: var(--radius-md); background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); font: inherit; font-weight: 600; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.fb-cat:hover { background: var(--surface-hover); }
.fb-cat.is-on { border-color: var(--accent-color); background: var(--surface-hover); }
.fb-textarea { width: 100%; min-height: 132px; resize: vertical; padding: 0.8rem 1rem; border-radius: var(--radius-md); background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); font: inherit; font-size: var(--font-size-base); line-height: 1.5; }
.fb-textarea:focus { outline: 2px solid var(--accent-color); outline-offset: 1px; }

@media (max-width: 560px) {
  .am-modal { flex-direction: column; }
  .am-rail { flex-basis: auto; flex-direction: row; justify-content: space-between; gap: var(--spacing-sm); padding: var(--spacing-lg); border-right: none; border-bottom: 1px solid var(--surface-border); }
  .am-step { flex-direction: column; align-items: center; text-align: center; gap: 0.4rem; padding-bottom: 0; flex: 1; }
  .am-step:not(:last-child)::after { display: none; }
  .am-step-label .s { display: none; }
}

@media (max-width: 820px) {
  .cg-header { flex-direction: column; }
  .cg-header-actions { width: 100%; }
  .cg-header-actions .btn-primary { flex: 1; }
  .cg-row { flex-wrap: wrap; }
}

/* ============================================================
   Mobile: top bar + bottom nav (shared)
   ============================================================ */
.app-topbar-mobile { display: none; }
.app-bottomnav { display: none; }

@media (max-width: 820px) {
  .app-shell { grid-template-rows: auto 1fr auto auto; grid-template-areas: "nav" "main" "session" "bottomnav"; gap: var(--spacing-sm); padding: var(--spacing-sm); }
  .app-topnav { display: none; }
  .app-topbar-mobile {
    grid-area: nav; display: flex; align-items: center; padding: 0.5rem var(--spacing-md);
    background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    border: 1px solid var(--surface-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  }
  .app-topbar-mobile .nav-spacer { flex: 1; }
  .icon-btn { width: 42px; height: 42px; display: grid; place-items: center; font-size: 1.25rem; background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: var(--radius-md); cursor: pointer; color: var(--on-surface); }
  .app-bottomnav {
    grid-area: bottomnav; display: flex; justify-content: space-around; align-items: stretch; padding: 0.4rem;
    background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0.4rem; border: none; background: none; cursor: pointer; font-size: var(--font-size-xs); font-weight: 600; color: var(--on-surface-muted); border-radius: var(--radius-md); text-decoration: none; }
  .tab .tab-ic { font-size: 1.4rem; }
  .tab.is-active { color: var(--accent-color); }
  .tab.play .tab-ic { width: 52px; height: 52px; margin-top: -22px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(180deg, var(--primary-color), var(--primary-hover)); color: #fff; box-shadow: var(--shadow-lg); border: 3px solid var(--bg-primary); }
  .tab.play { color: var(--accent-color); }

  /* session bar → compact pill above the bottom nav */
  .app-session { font-size: var(--font-size-sm); padding: 0.4rem 0.5rem 0.4rem var(--spacing-md); }

  /* responsive content tweaks */
  .screen-title, .learn-head h1 { font-size: var(--font-size-2xl); }
  .screen-centered { justify-content: flex-start; padding-top: var(--spacing-lg); }
  /* On phones, top-anchor like the other screens (overrides the 14vh desktop offset). */
  play-page .screen-centered { padding-top: var(--spacing-lg); }
  .mode-grid { flex-wrap: wrap; }
  .mode-card { flex: 1 1 160px; min-height: 0; padding: var(--spacing-lg); }
  .mode-card .icon { font-size: 2.6rem; }
  .learn-body { grid-template-columns: 1fr; }
  .learn-topics { position: static; flex-direction: row; overflow-x: auto; gap: 0.5rem; padding-bottom: 0.3rem; }
  .learn-topic { flex: 0 0 auto; white-space: nowrap; }
}

/* "Players currently playing" pill on /play */
.activity-pill {
  display: inline-flex; align-items: center; gap: 0.5rem; align-self: center;
  margin-bottom: var(--spacing-md); padding: 0.35rem 0.85rem;
  font-size: var(--font-size-sm); color: var(--on-surface);
  background: var(--surface-elevated); border: 1px solid var(--surface-border);
  border-radius: 999px;
}
.activity-pill[hidden] { display: none; }
.activity-dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--success-color, #3fbf6b); box-shadow: 0 0 0 0 rgba(63, 191, 107, 0.6);
  animation: activity-pulse 2s infinite;
}
@keyframes activity-pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 191, 107, 0.5); }
  70% { box-shadow: 0 0 0 0.4rem rgba(63, 191, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 191, 107, 0); }
}

/* Leaderboard (ranked ladder) */
.lb-status { color: var(--on-surface-muted); margin-top: var(--spacing-lg); }
.lb-error { color: var(--danger-color, #e25555); }
.lb-table {
  width: 100%; max-width: 640px; margin: var(--spacing-lg) auto 0;
  border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--surface-border); border-radius: var(--radius-lg); overflow: hidden;
}
.lb-table th, .lb-table td { padding: var(--spacing-sm) var(--spacing-md); text-align: left; }
.lb-table thead th {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--on-surface-muted); background: var(--surface-elevated);
}
.lb-table tbody tr { border-top: 1px solid var(--surface-border); }
.lb-rank { width: 3rem; text-align: center; font-variant-numeric: tabular-nums; }
.lb-num { text-align: right; font-variant-numeric: tabular-nums; }
.lb-self { background: var(--surface-hover); font-weight: 700; }
.lb-pinned { border-top: 2px solid var(--primary-color); }

/* ============================================================
   Post-game recap HUD (overlay on the game table)
   ============================================================ */
game-recap-hud[hidden] { display: none; }
.recap-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: var(--spacing-lg);
  background: radial-gradient(120% 90% at 50% 0%, rgba(0,0,0,0.55), rgba(0,0,0,0.78));
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  overflow: hidden;
}
.recap-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  display: flex; flex-direction: column; gap: var(--spacing-lg);
  background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--surface-border); border-radius: var(--radius-lg);
  padding: var(--spacing-lg); box-shadow: var(--shadow-xl);
  /* The game route is shell-less, so the cream-on-dark text color isn't inherited
     from the shell — set it here (otherwise it falls back to the brown body text). */
  color: var(--on-surface);
}
.recap-winners { text-align: center; }
.recap-trophy { font-size: 2.6rem; line-height: 1; }
.final-winner { font-family: var(--font-family-display); font-size: var(--font-size-2xl); font-weight: 800; margin: 0.2rem 0; }
.recap-winner-names { font-weight: 700; color: var(--on-surface-muted); }
.recap-winner-names.team-1 { color: var(--team-1-color); }
.recap-winner-names.team-2 { color: var(--team-2-color); }
.recap-final-score { margin-top: var(--spacing-sm); font-size: var(--font-size-3xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.recap-final-score .team-1 { color: var(--team-1-color); }
.recap-final-score .team-2 { color: var(--team-2-color); }
.recap-final-score .recap-dash { color: var(--on-surface-muted); margin: 0 0.4rem; }

/* scoreboard (graduated from prototypes/lobby.html) */
table.scoreboard { width: 100%; border-collapse: collapse; }
table.scoreboard th, table.scoreboard td { padding: 0.55rem 0.7rem; text-align: left; }
table.scoreboard thead th { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--on-surface-muted); border-bottom: 1px solid var(--surface-border); }
table.scoreboard tbody tr { border-bottom: 1px solid var(--surface-hover); }
table.scoreboard td.pts { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
table.scoreboard th.col-a, table.scoreboard td.col-a { color: var(--team-1-color); }
table.scoreboard th.col-b, table.scoreboard td.col-b { color: var(--team-2-color); }
table.scoreboard tfoot td { padding-top: 0.7rem; font-size: var(--font-size-lg); font-weight: 800; border-top: 2px solid var(--surface-border); }
.outcome { font-size: var(--font-size-xs); font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.outcome.made { background: rgba(5,150,105,0.2); color: #34d399; }
.outcome.set { background: rgba(220,38,38,0.2); color: #f87171; }
.outcome.capot { background: rgba(245,158,11,0.22); color: var(--accent-color); }

.recap-footer { display: flex; flex-direction: column; gap: var(--spacing-sm); align-items: center; }
.recap-actions { display: flex; justify-content: center; gap: var(--spacing-md); }
.recap-countdown { margin: 0; color: var(--on-surface-muted); font-size: var(--font-size-sm); font-variant-numeric: tabular-nums; }
.recap-countdown .recap-secs, .recap-countdown .recap-ready { font-weight: 800; color: var(--on-surface); }

/* confetti — a physics burst fired from the trophy: launched up in an arc, then
   gravity pulls it back down. Position/spin are driven per-frame in JS. */
.recap-confetti { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.confetti-piece { position: absolute; top: 0; left: 0; will-change: transform; box-shadow: 0 1px 2px rgba(0,0,0,0.25); }
@media (prefers-reduced-motion: reduce) {
  .confetti-piece { display: none; }
}

@media (max-width: 560px) {
  .scoreboard .hide-sm { display: none; }
}

/* ---- Profile page (account + preferences) ----------------------------- */
.pf { display: grid; grid-template-columns: 248px 1fr; gap: var(--spacing-md); width: min(960px, 100%); margin: 0 auto; padding: var(--spacing-lg) 0; align-items: start; }
.pf-rail { display: flex; flex-direction: column; gap: var(--spacing-xs); padding: var(--spacing-md); background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.pf-id { display: flex; align-items: center; gap: var(--spacing-sm); padding: var(--spacing-sm); margin-bottom: var(--spacing-sm); border-bottom: 1px solid var(--surface-border); }
.pf-avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: var(--font-size-lg); color: var(--text-inverse); background: linear-gradient(140deg, var(--accent-color), var(--primary-hover)); }
.pf-who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pf-who b { font-size: var(--font-size-base); }
.pf-who span { font-size: var(--font-size-xs); color: var(--on-surface-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-link { display: flex; align-items: center; gap: 0.7em; min-height: 48px; padding: 0 var(--spacing-sm); color: var(--on-surface); font-weight: 600; border-radius: var(--radius-md); text-decoration: none; cursor: pointer; transition: background var(--transition-fast); }
.pf-link:hover { background: var(--surface-hover); }
.pf-link.is-active { background: var(--current-player-bg); color: var(--border-dark); }
.pf-ic { width: 1.4em; text-align: center; }
.pf-content { min-width: 0; }
.pf-panel { padding: var(--spacing-lg); background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.pf-h1 { font-family: var(--font-family-display); font-size: var(--font-size-xl); }
.pf-h1-row { display: flex; align-items: baseline; gap: var(--spacing-md); flex-wrap: wrap; }
.pf-save { font-size: var(--font-size-sm); font-weight: 600; opacity: 0; transition: opacity var(--transition-fast); }
.pf-save--saving { opacity: 1; color: var(--on-surface-muted); }
.pf-save--saved { opacity: 1; color: var(--success-color); }
.pf-save--error { opacity: 1; color: #f87171; }
.pf-sub { color: var(--on-surface-muted); font-size: var(--font-size-sm); margin: 2px 0 var(--spacing-md); }
.pf-group { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--on-surface-muted); font-weight: 700; margin: var(--spacing-md) 0 var(--spacing-xs); }
.pf-danger-label { color: var(--error-color); }
.pf-row { display: flex; align-items: center; gap: var(--spacing-md); padding: var(--spacing-md) 0; border-top: 1px solid var(--surface-border); }
.pf-row:first-of-type { border-top: none; }
.pf-label { flex: 1; min-width: 0; }
.pf-label b { display: block; font-weight: 600; }
.pf-label span { display: block; font-size: var(--font-size-sm); color: var(--on-surface-muted); margin-top: 2px; }
.pf-field { flex: 1; min-width: 0; }
.pf-input { width: 100%; padding: 0.7rem 0.9rem; border-radius: var(--radius-md); background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); font: inherit; font-size: var(--font-size-base); }
.pf-input:focus { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.pf-hint { font-size: var(--font-size-xs); color: var(--on-surface-muted); margin-top: 4px; }
.pf-error { font-size: var(--font-size-xs); color: #f87171; margin-top: 4px; }
.pf-badge-ok { font-size: var(--font-size-xs); font-weight: 700; color: var(--success-color); border: 1px solid var(--success-color); padding: 2px 8px; border-radius: 999px; }
.btn-danger { background: transparent; border: 1px solid var(--error-color); color: var(--error-color); }
.btn-danger:hover { background: rgba(220, 38, 38, 0.14); }
.pf-seg { display: inline-flex; background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: var(--radius-md); padding: 3px; gap: 3px; flex: none; }
.pf-seg-btn { min-height: 36px; padding: 0 0.9rem; border: none; background: transparent; cursor: pointer; color: var(--on-surface-muted); font: 600 var(--font-size-sm)/1 var(--font-family); border-radius: calc(var(--radius-md) - 3px); }
.pf-seg-btn.is-on { background: var(--current-player-bg); color: var(--border-dark); }
.pf-switch { position: relative; width: 52px; height: 30px; flex: none; cursor: pointer; }
.pf-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.pf-track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-elevated); border: 1px solid var(--surface-border); transition: background var(--transition-fast); }
.pf-knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--on-surface-muted); transition: transform var(--transition-fast), background var(--transition-fast); }
.pf-switch input:checked ~ .pf-track { background: rgba(5, 150, 105, 0.55); }
.pf-switch input:checked ~ .pf-knob { transform: translateX(22px); background: #fff; }

@media (max-width: 860px) {
  .pf { grid-template-columns: 1fr; }
  .pf-rail { flex-direction: row; overflow-x: auto; }
  .pf-id { display: none; }
  .pf-link { white-space: nowrap; }
}

/* ---- Profile › Progress --------------------------------------------- */
.pg-hero { display: flex; align-items: center; gap: var(--spacing-lg); }
.pg-hero level-badge { --sz: 116px; }
.pg-hero-info { flex: 1; min-width: 0; }
.pg-level { font-family: var(--font-family-display); font-size: var(--font-size-2xl); font-weight: 800; display: flex; align-items: baseline; gap: 0.5em; }
.pg-tier { font-size: var(--font-size-sm); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-color); }
.pg-bar { height: 14px; border-radius: 999px; background: rgba(0,0,0,0.35); border: 1px solid var(--surface-border); overflow: hidden; margin: var(--spacing-sm) 0 4px; }
.pg-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-color), var(--primary-color)); }
.pg-xp-row { display: flex; justify-content: space-between; gap: var(--spacing-md); font-size: var(--font-size-sm); color: var(--on-surface-muted); font-variant-numeric: tabular-nums; }
.pg-nexttier { margin-top: 6px; font-size: var(--font-size-xs); color: var(--on-surface-muted); }
.pg-nexttier b { color: var(--on-surface); }
.pg-ladder { display: flex; justify-content: space-between; gap: var(--spacing-sm); }
.ladder-item { display: grid; place-items: center; gap: 6px; flex: 1; opacity: 0.4; }
.ladder-item.done, .ladder-item.current { opacity: 1; }
.ladder-item level-badge { --sz: 40px; }
.ladder-cap { font-size: 0.64rem; color: var(--on-surface-muted); text-align: center; line-height: 1.3; }
.ladder-cap b { display: block; color: var(--on-surface); font-size: var(--font-size-xs); }
@media (max-width: 620px) { .pg-hero { flex-direction: column; text-align: center; } .pg-ladder { flex-wrap: wrap; } .ladder-item { flex: 0 0 22%; } }

/* ---- End-of-game rewards: single XP line + Beans (PROGRESSION.md §6) --- */
/* No box — raw content on the card, with generous space above/below. */
.recap-rewards { display: flex; flex-direction: column; gap: var(--spacing-md); margin: var(--spacing-xl) 0; }
.recap-rewards:empty { display: none; }

/* single progress line: level badge · bar (hover → breakdown) · next level (greyed) */
.xp-line { display: flex; align-items: center; gap: var(--spacing-md); }
.xp-line level-badge { --sz: 40px; flex: none; }
.xp-bar-wrap { position: relative; flex: 1; cursor: help; }
.xp-next-num { font-family: var(--font-family-display); font-weight: 800; font-size: var(--font-size-xl); color: var(--on-surface-muted); opacity: 0.65; font-variant-numeric: tabular-nums; flex: none; }
.xp-bar { display: flex; height: 16px; border-radius: 999px; background: rgba(0,0,0,0.35); border: 1px solid var(--surface-border); overflow: hidden; }
.xp-bar-wrap:hover .xp-bar, .xp-bar-wrap:focus-visible .xp-bar { border-color: var(--accent-color); }
.xp-fill-existing { height: 100%; background: var(--primary-color); }
.xp-fill-earned { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-color), #ffe08a); box-shadow: 0 0 10px rgba(251,191,36,0.5); transition: width 1100ms cubic-bezier(0.25,0.8,0.3,1); }

/* breakdown popovers — moved out to <body> by JS and fixed-positioned to the
   RIGHT of the card, so they never extend the card's scroll area / get clipped
   by its backdrop-filter containing block. */
.xp-tip, .coins-tip { position: fixed; z-index: 2500; width: 250px; padding: 0.6rem 0.75rem; background: var(--bg-dark); color: var(--on-surface); border: 1px solid var(--surface-border); border-radius: var(--radius-md); box-shadow: var(--shadow-xl); opacity: 0; transform: translateX(-6px); pointer-events: none; transition: opacity var(--transition-fast), transform var(--transition-fast); }
.xp-tip.show, .coins-tip.show { opacity: 1; transform: translateX(0); }
.xp-tip table, .coins-tip table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.xp-tip td, .coins-tip td { padding: 0.18rem 0; color: var(--on-surface-muted); }
.xp-tip td.v, .coins-tip td.v { text-align: right; color: var(--on-surface); font-weight: 700; font-variant-numeric: tabular-nums; }
.xp-tip tr.total td, .coins-tip tr.total td { padding-top: 0.4rem; border-top: 1px solid var(--surface-border); color: var(--on-surface); font-weight: 800; }
.xp-tip tr.total td.v, .coins-tip tr.total td.v { color: var(--accent-color); }
.xp-tip-detail { color: var(--on-surface-muted); font-weight: 400; }
.tip-note { margin-top: 0.45rem; padding-top: 0.45rem; border-top: 1px solid var(--surface-border); font-size: var(--font-size-xs); color: var(--on-surface-muted); line-height: 1.45; text-align: left; }
.tip-note b { color: var(--on-surface); font-weight: 800; }

/* Beans line — the economy reward, styled like the XP gain with its own tip. */
.coins-line { text-align: center; padding-top: 2px; }
.coins-wrap { position: relative; display: inline-block; }
.coins-gained { display: inline-flex; align-items: center; gap: 0.35em; font: 800 var(--font-size-base)/1 var(--font-family); color: var(--accent-color); background: none; border: none; cursor: help; font-variant-numeric: tabular-nums; padding: 0; }
.coins-gained .info { width: 1.05em; height: 1.05em; border-radius: 50%; border: 1.5px solid currentColor; font-size: 0.62em; font-weight: 800; display: inline-grid; place-items: center; opacity: 0.85; }

.recap-levelup { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; align-content: center; gap: 12px; border-radius: var(--radius-lg); background: radial-gradient(120% 90% at 50% 32%, rgba(20,11,3,0.85), rgba(20,11,3,0.95)); opacity: 0; pointer-events: none; transition: opacity 320ms ease; }
.recap-levelup.show { opacity: 1; }
.recap-levelup .kicker { font: 800 var(--font-size-base)/1 var(--font-family); letter-spacing: 0.26em; text-transform: uppercase; color: var(--accent-color); }
.recap-levelup .flow { color: var(--on-surface-muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.recap-levelup .flow b { color: var(--on-surface); }
.lu-stack { position: relative; width: 132px; height: 132px; }
.lu-stack > div { position: absolute; inset: 0; margin: auto; width: 132px; height: 132px; display: grid; place-items: center; }
.lu-stack .lu-old { transition: opacity 400ms ease, transform 400ms ease; }
.lu-stack .lu-new { opacity: 0; transform: scale(0.3); }
.recap-levelup.go .lu-old { opacity: 0; transform: scale(0.86); }
.recap-levelup.go .lu-new { animation: badge-pop 720ms cubic-bezier(0.2,0.8,0.2,1) both; }
@keyframes badge-pop { 0% { transform: scale(0.3); opacity: 0; } 55% { transform: scale(1.14); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

.recap-details { border-top: 1px solid var(--surface-border); padding-top: var(--spacing-sm); }
.recap-details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: center; gap: 0.5em; padding: 0.5rem; color: var(--on-surface-muted); font-weight: 600; font-size: var(--font-size-sm); }
.recap-details > summary::-webkit-details-marker { display: none; }
.recap-details[open] > summary .chev { transform: rotate(180deg); }
.recap-details > summary .chev { transition: transform var(--transition-fast); }
@media (prefers-reduced-motion: reduce) { .xp-fill-earned { transition: none; } .recap-levelup.go .lu-new { animation: none; } .recap-levelup .lu-new { opacity: 1; transform: none; } }

/* ---- End-of-game ranked panel (ELO delta) ---------------------------- */
.recap-rank { text-align: center; padding: var(--spacing-md); border-radius: var(--radius-lg); background: var(--surface-elevated); border: 1px solid var(--surface-border); }
.recap-rank:empty { display: none; }
.recap-rank .block-title { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--on-surface-muted); font-weight: 700; }
.rank-flow { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.rank-from { font-size: var(--font-size-xl); font-weight: 700; color: var(--on-surface-muted); }
.rank-arrow { color: var(--on-surface-muted); }
.rank-to { font-size: var(--font-size-3xl); font-weight: 800; }
.rank-delta { margin-top: 2px; font-weight: 800; font-size: var(--font-size-lg); font-variant-numeric: tabular-nums; }
.recap-rank.up .rank-delta { color: #34d399; }
.recap-rank.down .rank-delta { color: #f87171; }

/* ---- Lobby: game-length (max score) picker --------------------------- */
.max-score { display: flex; align-items: center; justify-content: center; gap: 0.6em; margin-bottom: var(--spacing-sm); flex-wrap: wrap; }
.max-score .ms-label { font-size: var(--font-size-sm); color: var(--on-surface-muted); font-weight: 600; }
.ms-seg { display: inline-flex; background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: var(--radius-md); padding: 3px; gap: 3px; }
.ms-btn { min-height: 34px; padding: 0 0.9rem; border: none; background: transparent; cursor: pointer; color: var(--on-surface-muted); font: 700 var(--font-size-sm)/1 var(--font-family); border-radius: calc(var(--radius-md) - 3px); font-variant-numeric: tabular-nums; }
.ms-btn.is-on { background: var(--current-player-bg); color: var(--border-dark); }
.ms-btn.readonly { cursor: default; }

/* Lobby "Game settings" drawer (right-sliding) + its topbar trigger. */
.lobby-settings-btn { display: inline-flex; align-items: center; gap: 0.4em; padding: 0.5rem 0.9rem; border-radius: var(--radius-md); background: var(--surface); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--surface-border); color: var(--on-surface); font-weight: 600; cursor: pointer; }
.lobby-settings-btn:hover { background: var(--surface-hover); }
.lobby-settings { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.lobby-settings .ls-scrim { position: absolute; inset: 0; background: rgba(15, 8, 2, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity var(--transition-fast); }
.lobby-settings .ls-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(360px, 86vw); display: flex; flex-direction: column; gap: var(--spacing-lg); padding: var(--spacing-xl); background: var(--panel); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-left: 1px solid var(--surface-border); box-shadow: var(--shadow-xl); transform: translateX(100%); transition: transform var(--transition-normal); }
.lobby-settings.is-open { pointer-events: auto; }
.lobby-settings.is-open .ls-scrim { opacity: 1; }
.lobby-settings.is-open .ls-panel { transform: translateX(0); }
.ls-head { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-md); }
.ls-head h2 { font-family: var(--font-family-display); font-weight: 800; font-size: var(--font-size-xl); }
.ls-close { width: 36px; height: 36px; flex: 0 0 auto; border-radius: var(--radius-md); border: 1px solid var(--surface-border); background: var(--surface); color: var(--on-surface); cursor: pointer; font-size: var(--font-size-base); }
.ls-close:hover { background: var(--surface-hover); }
.ls-body { display: flex; flex-direction: column; gap: var(--spacing-lg); }
/* In the drawer the picker stacks (label above the segmented control), left-aligned. */
.ls-body .max-score { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 0.5em; margin-bottom: 0; }
.ls-empty { color: var(--on-surface-muted); font-size: var(--font-size-sm); }

/* ===================== Economy: wallet indicator + Shop ===================== */
/* Currency indicator in the shell nav (Beans earned ☕ / Gems bought 💎). */
.wallet { display: inline-flex; align-items: center; gap: 0.4rem; text-decoration: none; }
.wallet[hidden] { display: none; }
.coin { display: inline-flex; align-items: center; gap: 0.4em; padding: 0.4rem 0.7rem; background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: 999px; color: var(--on-surface); font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--font-size-sm); transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast); }
.coin:hover { background: var(--surface-hover); }
.coin-ic { font-size: 1.05em; line-height: 1; transition: transform var(--transition-fast); }
.coin-beans .coin-amt { color: var(--accent-color); }
.coin-gems { border-color: rgba(125, 211, 252, 0.34); }
.coin-gems .coin-amt { color: #bfe9ff; }
.wallet-lg .coin { font-size: var(--font-size-base); padding: 0.5rem 0.9rem; }

/* Active state: while the Shop is open (the beans are its shortcut), the badge
   inverts into a solid gold fill with dark ink — like a primary button — plus a
   soft glow. The gold amount flips to dark so it stays legible on the fill. */
.wallet.is-active .coin-beans { background: var(--accent-color); border-color: var(--accent-color); color: #2a1a06; box-shadow: 0 2px 14px rgba(251, 191, 36, 0.40); }
.wallet.is-active .coin-beans .coin-amt { color: #2a1a06; }
.wallet.is-active .coin-beans:hover { background: var(--accent-color); filter: brightness(1.04); }

/* Cosmetic tier palette — distinct from the Bronze→Diamond level tiers. */
.t-free { --tier-col: rgba(255, 245, 230, 0.22); --tier-ink: var(--on-surface-muted); }
.t-common { --tier-col: #5a8fd0; --tier-ink: #eaf2ff; }
.t-premium { --tier-col: #f5c542; --tier-ink: #3a2708; }
.t-prestige { --tier-col: #9b6cf0; --tier-ink: #f3ebff; }
.t-reward { --tier-col: #2ea98a; --tier-ink: #052a22; }
.tier-chip { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.14rem 0.5rem; border-radius: 999px; background: var(--tier-col); color: var(--tier-ink); }

/* Shop page — full-width screen + a left grid and big right preview, matching the
   Customize layout (customize/components/CustomizePage CUSTOMIZE_STYLES). */
shop-page { display: block; height: 100%; min-height: 0; }
.shop-screen { display: flex; flex-direction: column; gap: var(--spacing-md); width: 100%; height: 100%; min-height: 0; }
/* Title + inline subtitle, baseline-aligned, wallet pushed right — reusing the
   Customize header treatment (.cz-head / .cz-sub). */
.shop-head { display: flex; align-items: baseline; gap: var(--spacing-md); flex-wrap: wrap; }
.shop-title { font-family: var(--font-family-display); font-size: var(--font-size-2xl); }
.shop-sub { color: var(--on-surface-muted, rgba(255,255,255,0.6)); font-size: var(--font-size-sm); }
.shop-head .wallet { margin-left: auto; }
.shop-note { color: var(--on-surface-muted); }

/* Category menu — identical styling to Customize's .cz-cats / .cz-cat (a compact
   pill group). `align-self`/`flex-wrap` are the only shop-specific additions: the
   menu is a direct child of the column-flex screen, so it must opt out of stretch
   (cz-cats gets that from its .cz-tabbar parent). */
.shop-tabs { align-self: flex-start; display: inline-flex; gap: 0.3rem; padding: 0.35rem; background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); flex-wrap: wrap; }
.shop-tab { min-height: 46px; padding: 0 1.1rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.5em; border: none; background: transparent; color: var(--on-surface); font-weight: 700; border-radius: var(--radius-md); cursor: pointer; }
.shop-tab.is-active { background: linear-gradient(180deg, var(--accent-color), var(--primary-color)); color: #fff; }

.shop-studio { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 480px; gap: var(--spacing-md); }
.shop-catalog { min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); padding: var(--spacing-md); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--spacing-md); align-content: start; }

.shop-tile { position: relative; display: flex; flex-direction: column; gap: 0.5rem; padding: 0; background: transparent; border: none; cursor: pointer; color: var(--on-surface); text-align: center; }
.shop-tile .st-thumb { position: relative; height: 200px; display: grid; place-items: center; border: 2px solid var(--tier-col); border-radius: var(--radius-lg); background: var(--surface-elevated); overflow: hidden; transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.shop-tile:hover .st-thumb { transform: translateY(-3px); box-shadow: 0 0 0 1px var(--tier-col), 0 10px 24px -8px var(--tier-col); }
.shop-tile.is-selected .st-thumb { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.shop-tile.is-owned .st-thumb { opacity: 0.85; }
.shop-tile .tier-chip { position: absolute; top: 8px; left: 8px; z-index: 2; }
.shop-tile .st-price { position: absolute; left: 8px; bottom: 8px; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 0.25em; }
.shop-tile .st-name { font-weight: 700; font-size: var(--font-size-sm); }
/* Prestige keeps the same solid `--tier-col` (violet) border as every other tier,
   so it's always visible. (The previous animated `::after` shimmer border was
   clipped by the thumb's `overflow: hidden`, so it rendered no border at all.) */

.pb { font-size: var(--font-size-xs); font-weight: 800; padding: 0.2rem 0.55rem; border-radius: 999px; background: rgba(12, 7, 3, 0.62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); color: var(--on-surface); font-variant-numeric: tabular-nums; }
.pb.beans { color: var(--accent-color); }
.pb.gems { color: #bfe9ff; }
.pb.owned { color: #6ee7b7; background: rgba(5, 80, 55, 0.7); }
.pb.short { opacity: 0.5; }

/* Art (card backs / felts / busts) + the governance badge come from the shared
   `cos-*` styles (customize/ui/catalogRender), injected by the page. */

.shop-inspector { min-height: 0; display: flex; flex-direction: column; gap: var(--spacing-md); background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); padding: var(--spacing-lg); overflow: auto; }
.insp-badges { display: flex; align-items: center; gap: 0.4em; flex-wrap: wrap; }
.insp-vignette { flex: 1; min-height: 480px; display: grid; place-items: center; background: rgba(0, 0, 0, 0.28); border-radius: var(--radius-lg); border: 2px solid var(--tier-col); overflow: hidden; }
.insp-name { font-size: var(--font-size-lg); font-weight: 800; }
.insp-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.buy-tagline, .buy-owned { color: var(--on-surface-muted); font-size: var(--font-size-sm); }
.buy-owned a { color: var(--accent-color); }
.buy-opts { display: flex; flex-direction: column; gap: 0.5rem; }
.buy-btn { display: flex; flex-direction: column; align-items: center; gap: 0.08rem; padding: 0.65rem 1rem; border: none; border-radius: var(--radius-md); cursor: pointer; font-weight: 800; font-size: var(--font-size-base); }
.buy-btn small { font-weight: 600; font-size: var(--font-size-xs); opacity: 0.85; }
.buy-btn.beans { background: linear-gradient(180deg, var(--accent-color), var(--primary-color)); color: #2b180a; }
.buy-btn.gems { background: linear-gradient(180deg, #7fd4ff, #3aa6e0); color: #06283a; }
.buy-btn.disabled { filter: grayscale(0.7) brightness(0.7); cursor: not-allowed; }

.shop-seefull { min-height: 42px; border-radius: var(--radius-md); border: 1px dashed var(--surface-border); background: transparent; color: var(--on-surface); font-weight: 700; cursor: pointer; }
.shop-seefull:hover { background: var(--surface-hover); }

@media (max-width: 860px) {
  /* Stack on narrow screens; keep the preview on top (like Customize). */
  .shop-studio { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .shop-inspector { order: -1; }
  .insp-vignette { min-height: 280px; }
}

/* Shop confirm dialog (no silent spend) + success toast. */
.shop-confirm { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--spacing-lg); }
.shop-confirm-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.shop-confirm-card { position: relative; z-index: 1; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: var(--spacing-sm); text-align: center; background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg); padding: var(--spacing-lg); box-shadow: var(--shadow-xl); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.shop-confirm .cf-title { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--on-surface-muted); font-weight: 700; }
.shop-confirm .cf-item { font-size: var(--font-size-lg); font-weight: 800; }
.shop-confirm .cf-price b { font-variant-numeric: tabular-nums; }
.shop-confirm .cf-price b.beans { color: var(--accent-color); }
.shop-confirm .cf-price b.gems { color: #bfe9ff; }
.shop-confirm .cf-after { font-size: var(--font-size-xs); color: var(--on-surface-muted); font-variant-numeric: tabular-nums; }
.shop-confirm .cf-actions { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.shop-confirm .buy-btn { flex: 1; padding: 0.65rem 1rem; border: none; border-radius: var(--radius-md); cursor: pointer; font-weight: 800; font-size: var(--font-size-base); }
.shop-confirm .buy-btn.beans { background: linear-gradient(180deg, var(--accent-color), var(--primary-color)); color: #2b180a; }
.shop-confirm .buy-btn.gems { background: linear-gradient(180deg, #7fd4ff, #3aa6e0); color: #06283a; }
.shop-confirm .buy-btn.ghost { background: var(--surface-elevated); border: 1px solid var(--surface-border); color: var(--on-surface); }
.shop-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(10px); z-index: 70; padding: 0.6rem 1.1rem; background: var(--surface-elevated); border: 1px solid var(--surface-border); border-radius: 999px; font-weight: 700; color: var(--on-surface); box-shadow: var(--shadow-lg); opacity: 0; transition: opacity var(--transition-fast), transform var(--transition-fast); pointer-events: none; }
.shop-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* End-of-game Beans line (recap): the .coins-* styles live in the rewards block
   above; the line is [hidden] until the async award loads. */

/* ============================================================
   Admin backoffice (/admin, /admin/players, /admin/players/{id})
   Data-dense operator views: override the centred screen layout for a
   left-aligned, top-aligned content column on the espresso surface system.
   ============================================================ */
/* Fill the shell's main zone so the inner min-height chain resolves (matches the
   home-page/play-page rule the other shell screens use). */
admin-page, admin-players-page, admin-player-profile-page, admin-feedback-page {
  flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0;
}
.admin-page {
  justify-content: flex-start;
  align-items: stretch;
  text-align: left;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  gap: var(--spacing-sm);
  color: var(--on-surface);
  padding-top: var(--spacing-xl);
  padding-bottom: var(--spacing-2xl);
}
.admin-page .screen-title { margin: 0; font-size: var(--font-size-2xl); }

.admin-breadcrumb { margin: 0; font-size: var(--font-size-sm); }
.admin-breadcrumb a { color: var(--on-surface-muted); text-decoration: none; transition: color var(--transition-fast); }
.admin-breadcrumb a:hover { color: var(--on-surface); }

.admin-subtitle { color: var(--on-surface-muted); font-size: var(--font-size-sm); margin: 0; }
.admin-status { color: var(--on-surface-muted); padding: var(--spacing-lg) 0; }
.admin-refresh { color: var(--on-surface-muted); font-size: var(--font-size-xs); margin-top: var(--spacing-sm); }

/* KPI tiles on the overview */
.admin-cards { display: flex; flex-wrap: wrap; gap: var(--spacing-md); margin: var(--spacing-sm) 0 var(--spacing-md); }
.admin-card {
  flex: 1 1 150px; min-width: 150px;
  display: flex; flex-direction: column; gap: 0.15rem;
  background: var(--surface-elevated); border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg); padding: var(--spacing-md) var(--spacing-lg);
  box-shadow: var(--shadow-md);
}
.admin-card-value { font-family: var(--font-family-display); font-size: var(--font-size-2xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.admin-card-label { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--on-surface-muted); }

/* Tables (mirror the leaderboard's ladder styling) */
.admin-table {
  width: 100%; margin: var(--spacing-sm) 0 0;
  border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--surface-border); border-radius: var(--radius-lg); overflow: hidden;
}
.admin-table th, .admin-table td { padding: var(--spacing-sm) var(--spacing-md); text-align: left; }
.admin-table thead th {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--on-surface-muted); background: var(--surface-elevated);
}
.admin-table tbody tr { border-top: 1px solid var(--surface-border); }
.admin-row { cursor: pointer; transition: background var(--transition-fast); }
.admin-row:hover { background: var(--surface-hover); }
.admin-table td time, .admin-cell-muted { color: var(--on-surface-muted); font-size: var(--font-size-sm); }

/* Search bar */
.admin-search { display: flex; gap: var(--spacing-sm); align-items: center; margin: var(--spacing-sm) 0; }
.admin-search-input {
  flex: 1 1 auto; min-width: 0;
  padding: 0.55rem 1rem; border-radius: 999px;
  background: var(--surface-elevated); border: 1px solid var(--surface-border);
  color: var(--on-surface); font: inherit;
}
.admin-search-input::placeholder { color: var(--on-surface-muted); }
.admin-search-input:focus { outline: none; border-color: var(--primary-color); }

/* Status / type pills */
.admin-badge {
  display: inline-block; padding: 0.12rem 0.6rem; border-radius: 999px;
  font-size: var(--font-size-xs); font-weight: 700; line-height: 1.6;
  background: var(--surface-elevated); border: 1px solid var(--surface-border);
  color: var(--on-surface-muted);
}
.admin-badge--ok { color: var(--success-color); }
.admin-badge--bot { color: var(--accent-color); }
.admin-badge--danger { color: var(--error-color); }

/* Profile detail — a label/value grid in a panel */
.admin-detail {
  display: grid; grid-template-columns: auto 1fr; align-items: baseline;
  gap: var(--spacing-xs) var(--spacing-xl);
  margin: var(--spacing-sm) 0; padding: var(--spacing-lg);
  background: var(--surface-elevated); border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
}
.admin-detail-label { color: var(--on-surface-muted); font-size: var(--font-size-sm); }
.admin-detail-value { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }

/* Actions placeholder — dashed panel signals "coming soon" */
.admin-actions {
  margin-top: var(--spacing-lg); padding: var(--spacing-lg);
  background: var(--surface); border: 1px dashed var(--surface-border);
  border-radius: var(--radius-lg);
}
.admin-section-title { font-size: var(--font-size-lg); margin: 0 0 var(--spacing-sm); }

/* Inline write form (e.g. Set XP) */
.admin-form-row { display: flex; gap: var(--spacing-sm); align-items: center; }
.admin-xp-input { flex: 0 0 12rem; }
.admin-form-msg { margin: var(--spacing-sm) 0 0; font-size: var(--font-size-sm); }
.admin-form-msg--ok { color: var(--success-color); }
.admin-form-msg--error { color: var(--error-color); }

/* Feedback list: the message column wraps and carries a muted route line */
.admin-feedback-table td { vertical-align: top; }
.admin-feedback-message { white-space: pre-wrap; word-break: break-word; max-width: 42rem; }
.admin-feedback-route { display: block; margin-top: var(--spacing-xs); font-size: var(--font-size-xs); }
