/* Circle Trader — Familiar First kit (same tokens, top bar, pill
   buttons, cards and display-options bar as every other John
   Whitehouse Solutions service), plus game pieces in the Mars
   Unsettled shape: stat bar, tabs, news log, bottom pop-up notices. */

:root{
  --bg:#F0F2F5; --card:#FFFFFF; --ink:#202124; --muted:#5F6368;
  --brand:#1A73E8; --brand-dark:#174EA6; --soft:#E8F0FE; --line:#DADCE0;
  --good:#137333; --bad:#A50E0E;
}
html[data-theme="dark"]{
  --bg:#202124; --card:#303134; --ink:#E8EAED; --muted:#9AA0A6;
  --brand:#8AB4F8; --brand-dark:#AECBFA; --soft:#3C4043; --line:#4D5156;
  --good:#81C995; --bad:#F28B82;
}
html{ font-size:16px; }
html[data-size="large"]{ font-size:19px; }
html[data-size="xl"]{ font-size:22px; }

*{ box-sizing:border-box; }
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size:1rem; line-height:1.55;
}
a{ color:var(--brand-dark); }
.hidden{ display:none !important; }
.sr-only{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }

/* --- top bar --- */
.ff-topbar{
  background:var(--card); border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:10;
}
.ff-topbar-row{
  max-width:960px; margin:0 auto; padding:10px 16px;
  display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
}
.wordmark{ font-weight:700; font-size:1.15rem; }
.wordmark-thin{ font-weight:400; color:var(--muted); }
.displaybar{ display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.displaybar .db-btn{
  background:var(--card); color:var(--ink); border:1px solid var(--line);
  border-radius:999px; min-height:36px; padding:3px 12px; font-size:.85rem; cursor:pointer;
}
.displaybar .db-btn[aria-pressed="true"]{
  background:var(--soft); border-color:var(--brand); color:var(--brand-dark); font-weight:700;
}

/* --- layout --- */
.column{ max-width:960px; margin:0 auto; padding:8px 16px 32px; }
h1{ font-size:1.6rem; margin:20px 0 4px; }
h2{ font-size:1.2rem; margin:0 0 8px; }
h3{ font-size:1.05rem; margin:16px 0 6px; }
.tagline{ color:var(--muted); margin:0 0 8px; }
.card{
  background:var(--card); border:1px solid var(--line); border-radius:8px;
  box-shadow:0 1px 2px rgba(60,64,67,.15);
  padding:20px 24px; margin:16px 0;
}
.note{ color:var(--muted); font-size:.92rem; }
.notice{
  background:var(--soft); border:1px solid var(--line); border-radius:8px;
  padding:10px 14px; margin:0 0 14px;
}
.err{ color:#B3261E; min-height:1.2em; margin:8px 0; }
html[data-theme="dark"] .err{ color:#F28B82; }
.good{ color:var(--good); }
.bad{ color:var(--bad); }

/* --- forms (kit pattern: label above, helper below) --- */
label{ display:block; font-weight:600; margin:14px 0 6px; }
input[type="email"], input[type="password"], input[type="text"], input[type="number"]{
  width:100%; background:var(--card); color:var(--ink);
  border:1px solid var(--line); border-radius:8px; padding:10px 12px; font-size:1rem;
}
input:focus{ outline:none; border-color:var(--brand); }

/* --- buttons (big tap targets) --- */
.btn-primary{
  background:var(--brand); color:#fff; border:1px solid var(--brand);
  border-radius:999px; padding:10px 22px; font-weight:700; font-size:1rem;
  min-height:44px; cursor:pointer;
}
html[data-theme="dark"] .btn-primary{ color:#202124; }
.btn-primary:disabled{ opacity:.55; cursor:default; }
.btn-secondary{
  background:var(--card); color:var(--ink); border:1px solid var(--line);
  border-radius:999px; padding:8px 18px; font-size:.95rem; min-height:44px; cursor:pointer;
}
.btn-secondary:disabled{ opacity:.55; cursor:default; }
.btn-wide{ width:100%; margin-top:14px; }
.row-actions{ display:flex; gap:10px; margin-top:16px; flex-wrap:wrap; align-items:center; }

/* --- stat bar --- */
.stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(105px,1fr)); gap:8px; }
.stat{ background:var(--soft); border-radius:10px; padding:8px 10px; }
.stat small{ display:block; color:var(--muted); }
.stat b{ font-size:1.15rem; }

/* --- tabs --- */
.tabs{ display:flex; flex-wrap:wrap; gap:6px; margin:0 0 4px; }
.tabs button{
  background:var(--card); color:var(--ink); border:1px solid var(--line);
  border-radius:999px; padding:9px 18px; font-size:1rem; min-height:44px; cursor:pointer;
}
.tabs button.on{ background:var(--brand); color:#fff; border-color:var(--brand); }
html[data-theme="dark"] .tabs button.on{ color:#202124; }

/* --- game rows and tables --- */
table{ width:100%; border-collapse:collapse; }
td, th{ padding:8px 4px; border-bottom:1px solid var(--line); text-align:left; font-size:.98rem; vertical-align:top; }
tr:last-child td{ border-bottom:none; }
.big-num{ font-size:1.15rem; font-weight:700; white-space:nowrap; }
.arrow-up{ color:var(--bad); font-weight:700; }
.arrow-down{ color:var(--good); font-weight:700; }
.arrow-flat{ color:var(--muted); font-weight:700; }

/* stock bar: plenty / some / low, in a bar plus plain words */
.stockbar{ background:var(--soft); border-radius:999px; height:12px; min-width:70px; overflow:hidden; }
.stockbar > div{ background:var(--brand); height:100%; border-radius:999px; }
.stock-word{ font-size:.9rem; color:var(--muted); white-space:nowrap; }

/* quantity stepper */
.stepper{ display:flex; gap:6px; align-items:center; }
.stepper button{
  background:var(--card); color:var(--ink); border:1px solid var(--line);
  border-radius:999px; width:44px; height:44px; font-size:1.2rem; cursor:pointer; flex:0 0 auto;
}
.stepper input{ width:76px; text-align:center; }
.trade-btns{ display:flex; gap:6px; flex-wrap:wrap; }
.trade-btns button{ min-height:44px; }

/* world / invite rows */
.world-row{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  width:100%; text-align:left; background:none; border:none; border-bottom:1px solid var(--line);
  padding:14px 4px; cursor:pointer; color:var(--ink); font-size:1rem; flex-wrap:wrap;
}
.world-row:last-child{ border-bottom:none; }
.world-main{ min-width:0; }
.world-name{ font-weight:700; display:block; }
.world-meta{ color:var(--muted); display:block; font-size:.92rem; }
.list-row{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  border-bottom:1px solid var(--line); padding:12px 4px; flex-wrap:wrap;
}
.list-row:last-child{ border-bottom:none; }

/* phrase bar */
.phrase-bar{ display:flex; flex-wrap:wrap; gap:8px; margin:10px 0; }
.phrase-bar button{
  background:var(--soft); color:var(--ink); border:1px solid var(--line);
  border-radius:999px; padding:9px 16px; font-size:.98rem; min-height:44px; cursor:pointer;
}
.log{ font-size:.95rem; }
.log div{ padding:6px 0; border-bottom:1px solid var(--line); }
.log div:last-child{ border-bottom:none; }
.log .day{ color:var(--muted); font-size:.85rem; white-space:nowrap; }

/* bottom pop-up notice (Mars Unsettled shape) */
#toast{
  position:fixed; left:50%; transform:translateX(-50%); bottom:18px; max-width:92%;
  background:var(--ink); color:var(--bg); padding:12px 16px; border-radius:12px;
  display:none; z-index:20; box-shadow:0 4px 18px rgba(0,0,0,.3); font-size:1rem;
}
#toast button{
  background:transparent; color:inherit; border:1px solid currentColor;
  border-radius:999px; margin-left:10px; padding:4px 12px; min-height:32px; cursor:pointer;
}

/* --- system map (code-drawn SVG, no images) --- */
.system-map{ width:100%; max-width:640px; margin:8px auto; }
.system-map svg{ display:block; width:100%; height:auto; }
.map-orbit{ fill:none; stroke:var(--line); stroke-width:.35; }
.map-sun{ fill:#E8710A; stroke:var(--line); stroke-width:.3; }
html[data-theme="dark"] .map-sun{ fill:#F9AB78; }
.map-planet{ fill:var(--brand); stroke:var(--card); stroke-width:.4; }
.map-me{ fill:var(--good); stroke:var(--ink); stroke-width:.7; }
.map-label{ fill:var(--muted); font-size:3.6px; font-family:inherit; }
.map-me-label{ fill:var(--ink); font-weight:700; }
.map-sun-label{ fill:var(--muted); }

/* --- footer --- */
.footer{ margin-top:24px; }

@media (max-width:560px){
  .card{ padding:16px; }
  .stats{ grid-template-columns:repeat(auto-fit,minmax(96px,1fr)); }
  td, th{ font-size:.94rem; }
}
