:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --dark: #111827;
  --yes: #14915f;
  --yes-soft: #ecfdf3;
  --yes-line: #abefc6;
  --no: #d64545;
  --no-soft: #fff1f1;
  --no-line: #fecaca;
  --warn: #a15c00;
  --warn-soft: #fff8e8;
  --warn-line: #f5d68a;
  --info: #3559c7;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 10px 30px rgba(16, 24, 40, 0.08);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --content: 1240px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(53, 89, 199, 0.22);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: 0.48; }
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.topbar-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
}
.brand-button {
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}
.brand-text strong { display: block; font-size: 17px; letter-spacing: -0.02em; }
.brand-text span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.07em; }
.face-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  background: #f2f4f7;
  border: 1px solid var(--line);
  vertical-align: middle;
}
.face-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face-fallback { display: none; width: 100%; height: 100%; place-items: center; font-size: 24px; }
.search-wrap { position: relative; min-width: 0; }
.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-52%);
  color: var(--muted);
  font-size: 20px;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 11px 16px 11px 40px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.search-wrap input:focus { border-color: #98a2b3; background: white; box-shadow: var(--shadow-sm); }
.top-actions { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.top-action {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 8px 9px;
  cursor: pointer;
  font-weight: 700;
  color: #344054;
}
.top-action:hover, .top-action.active { background: #f2f4f7; color: var(--ink); }
.auth-area { display: flex; gap: 7px; align-items: center; margin-left: 2px; }

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 14px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:not(:disabled):active { transform: translateY(1px); }
.btn-dark { background: var(--dark); color: white; border-color: var(--dark); }
.btn-dark:hover:not(:disabled) { background: #232c3c; }
.btn-light { background: white; border-color: var(--line); color: var(--ink); }
.btn-light:hover:not(:disabled), .btn-ghost:hover:not(:disabled) { border-color: var(--line-strong); background: #f9fafb; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-small { min-height: 34px; padding: 7px 10px; border-radius: 9px; font-size: 13px; }
.button-cost { display: inline-flex; gap: 4px; align-items: center; opacity: 0.82; font-size: 12px; }
.text-btn { border: 0; background: none; padding: 0; color: var(--info); font-weight: 750; cursor: pointer; }
.text-btn.danger { color: var(--no); }

.coin-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  vertical-align: -4px;
  flex: 0 0 auto;
}
.coin-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.coin-fallback { display: none; font-size: 16px; line-height: 1; }
.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.balance-pill:hover { background: #f2f4f7; }
.profile-chip {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 9px;
  display: grid;
  text-align: left;
}
.profile-chip:hover { background: #f7f8fa; }
.profile-pnl { font-size: 11px; color: var(--muted); font-weight: 650; }
.user-name { font-weight: 800; }
.username-glow { text-shadow: 0 0 8px rgba(127, 86, 217, 0.55), 0 0 16px rgba(53, 89, 199, 0.25); }
.mini-badge {
  display: inline-flex;
  margin-left: 7px;
  border: 1px solid #d6bbfb;
  background: #f4ebff;
  color: #6941c6;
  font-size: 9px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.05em;
  padding: 4px 5px;
  border-radius: 999px;
  vertical-align: 1px;
}

.ticker {
  max-width: var(--content);
  margin: 13px auto 0;
  padding: 9px 20px;
  color: #475467;
  font-size: 13px;
}
.ticker.is-sponsored { color: #503a08; }
.ticker-expiry { color: var(--muted); margin-left: 9px; font-size: 11px; }

.main-shell { max-width: var(--content); margin: 0 auto; padding: 14px 20px 70px; }
.eyebrow { font-size: 11px; line-height: 1.2; font-weight: 900; letter-spacing: 0.09em; color: #667085; margin-bottom: 8px; }
.hero-card, .page-header-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.hero-card {
  min-height: 280px;
  padding: 38px 42px;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  align-items: center;
  gap: 34px;
  overflow: hidden;
  position: relative;
}
.hero-card::after {
  content: "";
  position: absolute;
  width: 270px;
  height: 270px;
  right: -90px;
  top: -110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 41, 55, 0.05), rgba(31,41,55,0));
}
.hero-copy { position: relative; z-index: 1; }
.hero-copy h1, .page-header-card h1 {
  margin: 0;
  letter-spacing: -0.045em;
  line-height: 1.04;
}
.hero-copy h1 { font-size: clamp(35px, 5vw, 58px); max-width: 780px; }
.hero-copy p { max-width: 690px; color: var(--muted); font-size: 17px; margin: 16px 0 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-face-wrap { display: grid; place-items: center; position: relative; z-index: 1; }
.face-icon.hero-face { width: 170px; height: 170px; border: 6px solid white; box-shadow: 0 14px 44px rgba(16,24,40,0.14); }
.hero-quote {
  margin-top: -10px;
  background: var(--dark);
  color: white;
  border-radius: 999px;
  padding: 9px 13px;
  font-weight: 750;
  font-size: 12px;
  transform: rotate(-2deg);
  box-shadow: var(--shadow-md);
}

.market-section { margin-top: 30px; }
.section-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-header h2 { margin: 0; font-size: 28px; letter-spacing: -0.03em; }
.market-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.market-tab {
  border: 0;
  background: transparent;
  padding: 11px 12px 10px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.market-tab span { background: #eef0f3; border-radius: 999px; padding: 2px 6px; font-size: 10px; margin-left: 5px; }
.market-tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.market-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.market-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.market-card:hover { border-color: #d7dce3; }
.market-debated { border-color: var(--warn-line); background: linear-gradient(180deg, #fffdf9, white 28%); }
.market-settled { background: #f9fafb; color: #475467; }
.market-card-top { display: flex; gap: 12px; align-items: flex-start; }
.market-emoji { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; background: #f2f4f7; border-radius: 12px; font-size: 22px; }
.market-question-wrap { min-width: 0; flex: 1; }
.market-question-wrap h3 { margin: 1px 0 7px; font-size: 17px; line-height: 1.32; color: var(--ink); letter-spacing: -0.015em; }
.market-meta-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.market-description { margin: 8px 0 0; color: #475467; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.status-chip { font-size: 10px; font-weight: 900; letter-spacing: 0.03em; padding: 4px 6px; border-radius: 999px; background: #eef0f3; color: #475467; }
.status-active { background: var(--yes-soft); color: #067647; }
.status-debated { background: var(--warn-soft); color: var(--warn); }
.status-resolved, .status-void { background: #eaecf0; color: #475467; }
.debated-banner, .settlement-banner { margin-top: 13px; border-radius: 10px; padding: 10px 11px; font-size: 12px; }
.debated-banner { background: var(--warn-soft); border: 1px solid var(--warn-line); color: #7a4d00; }
.settlement-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); background: #f2f4f7; }
.settlement-banner strong { color: var(--ink); }
.settlement-banner.voided { background: #f7f7f8; }

.outcome-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 10px; }
.outcome-price { border-radius: 12px; padding: 12px; border: 1px solid var(--line); background: #fbfcfd; }
.outcome-price > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.outcome-price span { font-size: 12px; font-weight: 900; }
.outcome-price strong { font-size: 22px; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.outcome-price small { display: block; margin-top: 5px; color: var(--muted); }
.yes-price { background: var(--yes-soft); border-color: var(--yes-line); }
.yes-price strong, .yes-price span { color: #067647; }
.no-price { background: var(--no-soft); border-color: var(--no-line); }
.no-price strong, .no-price span { color: #b42318; }
.trade-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.buy-btn { min-height: 42px; }
.buy-yes { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.buy-yes:hover:not(:disabled) { background: #dcfae6; }
.buy-no { background: #fff1f1; color: #b42318; border-color: #fecaca; }
.buy-no:hover:not(:disabled) { background: #ffe4e4; }
.market-footer-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 13px; color: var(--muted); font-size: 11px; }
.market-footer-row strong { color: #344054; font-weight: 750; white-space: nowrap; }
.position-box { margin-top: 13px; border-top: 1px solid var(--line); padding-top: 12px; }
.position-title { font-size: 11px; font-weight: 900; color: #475467; margin-bottom: 6px; }
.position-stats { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.position-stats b { color: #344054; }
.admin-controls { margin-top: 13px; padding-top: 12px; border-top: 1px dashed #d0d5dd; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.admin-controls > span { font-size: 9px; font-weight: 900; letter-spacing: 0.08em; color: #98a2b3; margin-right: 3px; }
.admin-btn { border: 1px solid var(--line); background: white; border-radius: 8px; padding: 6px 8px; font-size: 10px; font-weight: 800; cursor: pointer; }
.admin-btn:hover { background: #f9fafb; }
.admin-resolve { border-color: #a6f4c5; color: #067647; }
.admin-danger { border-color: #fecdca; color: #b42318; }

.empty-state { background: white; border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 50px 22px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin: 12px 0 4px; }
.empty-state p { margin: 0; }
.empty-state.compact { border: 0; padding: 34px; }
.face-icon.empty-face { width: 70px; height: 70px; }

.page-header-card { padding: 28px 32px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.page-header-card h1 { font-size: clamp(30px, 4vw, 44px); }
.page-header-card p { color: var(--muted); margin: 10px 0 0; max-width: 760px; }
.face-icon.header-face { width: 105px; height: 105px; border: 4px solid white; box-shadow: var(--shadow-md); }
.sponsor-note { margin-top: 12px; font-size: 12px; color: #7a5a11; font-weight: 700; }

.leaderboard-card { margin-top: 16px; background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.leaderboard-table-wrap { overflow-x: auto; }
.leaderboard-table { width: 100%; border-collapse: collapse; min-width: 660px; }
.leaderboard-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 13px 16px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.leaderboard-table td { padding: 16px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.leaderboard-table tr:last-child td { border-bottom: 0; }
.rank-badge { font-size: 18px; font-weight: 900; }
.rank-1 td { background: linear-gradient(90deg, rgba(255, 248, 220, 0.78), rgba(255,255,255,0)); }
.rank-2 td { background: linear-gradient(90deg, rgba(241, 244, 247, 0.9), rgba(255,255,255,0)); }
.rank-3 td { background: linear-gradient(90deg, rgba(255, 239, 225, 0.75), rgba(255,255,255,0)); }
.pnl-cell { font-weight: 850; }
.pnl-cell.positive { color: #067647; }
.pnl-cell.negative { color: #b42318; }

.shop-balance-line { margin: 18px 0 10px; text-align: right; color: var(--muted); }
.shop-balance-line strong { color: var(--ink); }
.notice-card { margin-top: 16px; border: 1px solid var(--line); background: white; border-radius: 12px; padding: 12px 14px; color: var(--muted); }
.shop-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.shop-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-height: 220px; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.shop-icon { width: 44px; height: 44px; border-radius: 12px; background: #f2f4f7; display: grid; place-items: center; font-size: 24px; }
.shop-icon.large { width: 62px; height: 62px; font-size: 32px; }
.shop-card h3 { margin: 14px 0 6px; font-size: 18px; }
.shop-card p { margin: 0; color: var(--muted); }
.shop-card-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; padding-top: 18px; }
.shop-price { display: flex; align-items: center; gap: 6px; }
.shop-state { display: inline-flex; width: fit-content; margin-top: 12px; border-radius: 999px; padding: 5px 8px; font-size: 10px; font-weight: 900; }
.shop-state.owned { background: #f4ebff; color: #6941c6; }
.shop-state.active { background: var(--yes-soft); color: #067647; }
.shop-state.insufficient { background: #f2f4f7; color: #667085; }

.footer { border-top: 1px solid var(--line); background: white; }
.footer-inner { max-width: var(--content); margin: 0 auto; padding: 22px 20px 90px; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.footer strong { color: #344054; }

.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(16,24,40,0.52); display: grid; place-items: center; padding: 18px; }
.modal-card { width: min(560px, 100%); max-height: min(88vh, 900px); overflow: auto; background: white; border-radius: 18px; box-shadow: 0 24px 70px rgba(16,24,40,0.28); border: 1px solid rgba(255,255,255,0.5); }
.modal-card.modal-wide { width: min(940px, 100%); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; background: rgba(255,255,255,0.98); }
.modal-heading-wrap { display: flex; align-items: center; gap: 12px; }
.modal-header h2 { margin: 0; font-size: 22px; letter-spacing: -0.025em; }
.face-icon.modal-face { width: 48px; height: 48px; }
.modal-close { border: 0; background: #f2f4f7; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 22px; line-height: 1; }
.modal-content { padding: 20px 22px; }
.modal-footer { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); }
.field-label { display: block; font-size: 12px; font-weight: 850; color: #344054; margin: 13px 0 6px; }
.field-label:first-child { margin-top: 0; }
.modal-content input, .modal-content textarea, .modal-content select, .chat-form input, .chat-form select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: white;
  border-radius: 10px;
  padding: 10px 11px;
  color: var(--ink);
}
.modal-content textarea { resize: vertical; min-height: 90px; }
.modal-content textarea.compact-textarea { min-height: 68px; }
.field-optional { color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }
.input-help, .modal-note { color: var(--muted); font-size: 11px; margin-top: 6px; }
.modal-note { line-height: 1.55; }
.modal-note code { background: #f2f4f7; border-radius: 5px; padding: 2px 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; align-items: end; }
.create-cost-box { min-height: 64px; border: 1px solid var(--line); background: #f9fafb; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; justify-content: center; }
.create-cost-box span { font-size: 10px; color: var(--muted); }
.coin-input-wrap { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 10px; padding-left: 11px; }
.coin-input-wrap input { border: 0; padding-left: 0; outline: none; }
.coin-input-wrap:focus-within { outline: 3px solid rgba(53, 89, 199, 0.15); border-color: #98a2b3; }
.trade-side-banner { border-radius: 12px; padding: 13px; text-align: center; font-weight: 950; letter-spacing: 0.1em; margin-bottom: 16px; }
.trade-side-banner.yes { background: var(--yes-soft); color: #067647; border: 1px solid var(--yes-line); }
.trade-side-banner.no { background: var(--no-soft); color: #b42318; border: 1px solid var(--no-line); }
.quote-panel { margin-top: 16px; border: 1px solid var(--line); background: #fafbfc; border-radius: 12px; overflow: hidden; }
.quote-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 9px 11px; border-bottom: 1px solid var(--line); font-size: 12px; }
.quote-row:last-child { border-bottom: 0; }
.quote-row span { color: var(--muted); }
.quote-row.profit strong { color: #067647; }
.quote-error { color: #b42318; padding: 12px; font-size: 12px; }
.confirm-copy { color: #475467; font-size: 14px; margin: 0; }
.purchase-summary { display: grid; gap: 9px; justify-items: start; }
.purchase-summary p { color: var(--muted); margin: 0; }
.purchase-price { margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.how-grid section { border: 1px solid var(--line); background: #fbfcfd; border-radius: 12px; padding: 14px; }
.how-grid h3 { margin: 0 0 6px; font-size: 14px; }
.how-grid p { margin: 0; color: var(--muted); font-size: 12px; }
.disclaimer-box { margin-top: 14px; border: 1px solid #f2cc8f; background: #fff8e8; color: #6f4a00; border-radius: 12px; padding: 13px; }
.profile-identity { margin-bottom: 12px; font-size: 16px; }
.profile-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-stat-grid > div { background: #f9fafb; border: 1px solid var(--line); border-radius: 11px; padding: 12px; }
.profile-stat-grid span { display: block; font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.profile-stat-grid strong { font-size: 16px; }
.bankruptcy-box { margin-top: 14px; padding: 13px; border: 1px solid #fecdca; background: #fff8f7; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.bankruptcy-box strong, .bankruptcy-box span { display: block; }
.bankruptcy-box strong { color: #912018; font-size: 12px; margin-bottom: 3px; }
.bankruptcy-box span { color: #7a271a; font-size: 11px; line-height: 1.4; }
.btn-bankruptcy { flex: 0 0 auto; background: #fff; color: #b42318; border: 1px solid #fda29b; white-space: nowrap; }
.btn-bankruptcy:hover { background: #fef3f2; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-root { position: fixed; right: 18px; top: 76px; z-index: 140; display: grid; gap: 8px; pointer-events: none; width: min(360px, calc(100vw - 36px)); }
.toast { background: #101828; color: white; border-radius: 11px; padding: 11px 13px; box-shadow: var(--shadow-md); transform: translateY(-7px); opacity: 0; transition: 0.2s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #075f45; }
.toast.warning { background: #7a4d00; }
.toast.error { background: #8f1d1d; }

.chat-widget { position: fixed; right: 18px; bottom: 18px; z-index: 60; width: 360px; max-width: calc(100vw - 24px); background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md); overflow: hidden; }
.chat-widget.minimized { width: 260px; }
.chat-header { width: 100%; border: 0; background: white; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.chat-brand { display: flex; align-items: center; gap: 9px; text-align: left; }
.face-icon.chat-face { width: 34px; height: 34px; }
.chat-brand strong, .chat-brand small { display: block; }
.chat-brand small { color: var(--muted); font-size: 9px; }
.chat-body { border-top: 1px solid var(--line); }
.chat-admin-row { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; font-size: 10px; }
.chat-messages { height: 300px; overflow-y: auto; padding: 8px 10px; background: #fafbfc; }
.chat-message { padding: 8px 0; border-bottom: 1px solid #eef0f3; }
.chat-message:last-child { border-bottom: 0; }
.chat-message-meta { display: flex; align-items: center; gap: 6px; font-size: 10px; }
.chat-message-meta time { color: var(--muted); margin-left: auto; }
.chat-delete { border: 0; background: transparent; color: var(--no); cursor: pointer; font-size: 16px; padding: 0 2px; }
.chat-message-text { margin-top: 3px; color: #344054; font-size: 12px; overflow-wrap: anywhere; }
.chat-sticker { font-size: 18px; margin-right: 5px; vertical-align: -2px; }
.chat-empty { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 5px; text-align: center; color: var(--muted); font-size: 11px; }
.chat-empty strong { color: var(--ink); font-size: 13px; }
.face-icon.chat-empty-face { width: 58px; height: 58px; margin-bottom: 4px; }
.chat-form { display: grid; grid-template-columns: 78px 1fr auto; gap: 6px; padding: 9px; border-top: 1px solid var(--line); }
.chat-form select, .chat-form input { padding: 8px; font-size: 11px; }
.chat-login-prompt { padding: 12px; color: var(--muted); font-size: 12px; text-align: center; }

.confetti-piece { position: fixed; z-index: 180; top: -20px; pointer-events: none; font-size: 11px; color: #344054; animation-name: confetti-fall; animation-timing-function: cubic-bezier(.18,.67,.35,1); animation-fill-mode: forwards; }
.confetti-piece:nth-of-type(3n) { color: #067647; }
.confetti-piece:nth-of-type(3n+1) { color: #6941c6; }
.confetti-piece:nth-of-type(3n+2) { color: #b54708; }
@keyframes confetti-fall { to { transform: translate(var(--drift), 105vh) rotate(720deg); opacity: 0.35; } }


.bet-face-rain { position: fixed; inset: 0; z-index: 220; pointer-events: none; overflow: hidden; contain: strict; }
.bet-face-rain-piece { position: absolute; left: 0; top: -100px; width: var(--size); height: auto; opacity: 0; transform: translate3d(var(--x), -110px, 0) rotate(0deg); animation-name: bet-face-fall; animation-timing-function: linear; animation-fill-mode: forwards; will-change: transform, opacity; backface-visibility: hidden; }
@keyframes bet-face-fall {
  0% { opacity: 0; transform: translate3d(var(--x), -110px, 0) rotate(0deg); }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(calc(var(--x) + var(--drift)), 112vh, 0) rotate(var(--spin)); }
}

@media (max-width: 1100px) {
  .topbar-inner { grid-template-columns: auto 1fr; }
  .top-actions { grid-column: 1 / -1; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
  .auth-area { margin-left: auto; }
}

@media (max-width: 820px) {
  .main-shell { padding-inline: 14px; }
  .ticker { padding-inline: 14px; }
  .topbar-inner { padding-inline: 14px; gap: 10px; }
  .brand-text span { display: none; }
  .search-wrap { min-width: 0; }
  .hero-card { grid-template-columns: 1fr; padding: 28px 24px; text-align: left; }
  .hero-face-wrap { grid-row: 1; justify-self: start; display: flex; align-items: center; gap: 12px; }
  .face-icon.hero-face { width: 84px; height: 84px; border-width: 3px; }
  .hero-quote { margin-top: 0; }
  .market-grid, .shop-grid { grid-template-columns: 1fr; }
  .page-header-card { padding: 24px; }
  .face-icon.header-face { width: 76px; height: 76px; }
}

@media (max-width: 580px) {
  .topbar-inner { grid-template-columns: 1fr; }
  .brand-button { justify-self: start; }
  .search-wrap { width: 100%; }
  .top-actions { grid-column: auto; width: 100%; }
  .top-action { padding: 8px; font-size: 12px; }
  .auth-area { margin-left: 0; }
  .balance-pill { margin-left: auto; }
  .profile-chip { display: none; }
  .hero-card { min-height: 0; padding: 22px 18px; }
  .hero-copy h1 { font-size: 34px; }
  .hero-copy p { font-size: 14px; }
  .hero-actions .btn { width: 100%; }
  .hero-face-wrap { display: grid; grid-template-columns: auto 1fr; width: 100%; }
  .section-header { align-items: flex-start; }
  .desktop-create { display: none; }
  .market-card { padding: 15px; }
  .market-footer-row { flex-direction: column; gap: 4px; }
  .settlement-banner { align-items: flex-start; flex-direction: column; }
  .page-header-card { align-items: flex-start; padding: 20px; }
  .face-icon.header-face { width: 58px; height: 58px; }
  .shop-balance-line { text-align: left; }
  .modal-backdrop { padding: 8px; align-items: end; }
  .modal-card { border-radius: 18px 18px 10px 10px; max-height: 92vh; }
  .modal-header, .modal-content { padding-left: 16px; padding-right: 16px; }
  .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer .btn { flex: 1; }
  .form-row, .profile-stat-grid, .how-grid { grid-template-columns: 1fr; }
  .bankruptcy-box { align-items: stretch; flex-direction: column; }
  .btn-bankruptcy { width: 100%; }
  .chat-widget { right: 8px; bottom: 8px; width: calc(100vw - 16px); max-width: none; }
  .chat-widget.minimized { width: 220px; }
  .chat-messages { height: 260px; }
  .chat-form { grid-template-columns: 66px 1fr auto; }
  .footer-inner { padding-bottom: 82px; }
}
