/* Pirate Chain Stats. Brand tokens from piratechain.com/canvas (Roboto, #BB9645 gold, navy surfaces). */
:root {
  --bg: #14131c;
  --card: #202033;
  --card-hi: #26263d;
  --raised: #2f2f4c;
  --line: #2c2c45;
  --grid: #2a2a42;
  --text: #e4e5ec;
  --text-2: #cacbd2;
  --muted: #9aa1ad;
  --faint: #6f7590;
  --heading: #a0a7c1;
  --gold: #bd974e;
  --gold-2: #d6b46f;
  /* chart categorical order (validated: dark, surface #202033) */
  --c1: #b08b3e; --c2: #4a7fe0; --c3: #2c9c73; --c4: #9168d4; --c5: #c56d43;
  --radius: 6px;
  --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Roboto Mono', ui-monospace, 'SFMono-Regular', monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text-2); font: 15px/1.5 var(--font); }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-2); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* header */
.top { display: flex; align-items: center; gap: 18px; padding: 12px 20px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line); background: rgba(20, 19, 28, .85); position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 500; }
.brand img { height: 30px; }
.top nav { margin-left: auto; display: flex; gap: 22px; font-size: 14px; }
.top nav a { color: var(--muted); }
.top nav a:hover, .top nav a[aria-current] { color: var(--gold); }

main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 48px; }

/* hero */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
h1 { margin: 0; color: var(--text); font-weight: 700; font-size: clamp(28px, 4vw, 40px); letter-spacing: -.01em; }
.lede { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.live { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.live b { color: var(--text); font-weight: 500; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--c3); box-shadow: 0 0 0 0 rgba(44,156,115,.6); animation: pulse 2.4s infinite; }
.live.stale .pulse { background: #e05263; animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(44,156,115,.55); } 70% { box-shadow: 0 0 0 9px rgba(44,156,115,0); } 100% { box-shadow: 0 0 0 0 rgba(44,156,115,0); } }
.error { background: #3a1f28; border: 1px solid #e05263; color: #f3c2ca; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { position: relative; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 56px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; overflow: hidden;
  transition: border-color .15s, transform .15s, background .15s; }
.kpi:hover { border-color: rgba(189,151,78,.55); background: var(--card-hi); }
.kpi:active { transform: scale(.99); }
.k-label { color: var(--muted); font-size: 13px; }
.k-value { color: var(--text); font-size: clamp(24px, 2.6vw, 32px); font-weight: 500; letter-spacing: -.01em; line-height: 1.2; }
.k-sub { color: var(--faint); font-size: 12px; }
.k-sub .up { color: #4fbf8e; } .k-sub .down { color: #e3826a; }
.kpi .spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; outline: none;
  cursor: pointer; transition: border-color .15s, background .15s; min-width: 0; }
.card:hover, .card:focus-visible { border-color: rgba(189,151,78,.55); }
.card h2 { display: flex; align-items: center; margin: 0 0 10px; color: var(--heading); font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.card h2::after { content: ''; margin-left: auto; width: 14px; height: 14px; opacity: .55;
  background: no-repeat center/14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239aa1ad' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9'/%3E%3C/svg%3E"); }
.card:hover h2::after { opacity: 1; }
.card-intro, .feature-intro { margin: -4px 0 12px; color: var(--muted); font-size: 13.5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.wide { margin-top: 16px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row > span:first-child { color: var(--muted); }
.row > span:last-child { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.strong { color: var(--text) !important; font-weight: 500; }
.dim { color: var(--faint) !important; }
.sub { color: var(--faint); font-size: 12px; }
.note { color: var(--faint); font-size: 12px; margin-top: 8px; }

/* pool bar */
.bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; margin: 8px 0 10px; }
.bar div { height: 100%; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.legend .line-key { width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; }

/* Ironwood feature */
.feature { display: grid; grid-template-columns: minmax(260px, 1fr) 1.6fr; gap: 24px; align-items: stretch;
  background: radial-gradient(120% 140% at 100% 0%, rgba(44,156,115,.10), transparent 55%), var(--card); }
.feature h2 { font-size: 19px; }
.big { margin: 4px 0 10px; }
.big span { display: block; color: var(--text); font-size: clamp(34px, 4.4vw, 48px); font-weight: 500; line-height: 1.1; letter-spacing: -.015em; }
.big small { color: var(--muted); font-size: 13px; }
.feature-chart { min-height: 220px; }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { color: var(--heading); font-weight: 500; font-size: 13px; text-align: right; padding: 6px 8px; white-space: nowrap; }
td { text-align: right; padding: 9px 8px; border-top: 1px solid var(--line); white-space: nowrap; color: var(--text-2); }
td:first-child { text-align: left; color: var(--muted); white-space: normal; min-width: 170px; }
tr.key td:not(:first-child) { color: var(--text); font-weight: 500; }

/* heatmap */
.heatmap { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10.5px; color: var(--faint); }
.heatmap .hl { display: flex; align-items: center; }
.heatmap .hh { text-align: left; padding-top: 4px; white-space: nowrap; overflow: visible; }
.heatmap .cell { aspect-ratio: 1 / 1; border-radius: 2px; background: var(--grid); }
.heatmap .cell:hover, .heatmap .cell.on { outline: 1.5px solid var(--text); outline-offset: -1px; }
.heat-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--faint); }
.heat-legend i { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }

/* records */
.countdown { color: var(--gold-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
tr.warn-row td:first-child { color: var(--text-2); }
.records { list-style: none; margin: 0; padding: 0; }
.records li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.records li:first-child { border-top: 0; }
.records .r-label { color: var(--muted); }
.records .r-value { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.records .r-value small { display: block; color: var(--faint); font-size: 12px; }

/* embed */
.embed-preview { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 16px; }
.embed-preview img { max-width: 100%; height: auto; }
.snippet { position: relative; margin: 8px 0 14px; }
.snippet pre { margin: 0; padding: 12px 84px 12px 14px; background: #17172a; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text-2); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.copy { position: absolute; top: 8px; right: 8px; background: var(--raised); border: 1px solid var(--line); border-radius: 4px;
  color: var(--text-2); font-size: 12px; padding: 4px 10px; cursor: pointer; }
.copy:hover { border-color: var(--gold); color: var(--gold); }
.api { list-style: none; padding: 0; margin: 0; }
.api li { padding: 10px 0; border-top: 1px solid var(--line); }
.api li:first-child { border-top: 0; }
.api code { font: 13px var(--mono); color: var(--gold-2); word-break: break-all; }
.api span { display: block; color: var(--muted); font-size: 13px; }

footer { color: var(--faint); font-size: 12.5px; text-align: center; padding: 0 20px calc(32px + env(safe-area-inset-bottom, 0px)); }

/* explanation bubble */
.tip { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 6px;
  border-radius: 50%; border: 1px solid var(--faint); color: var(--faint); cursor: help; vertical-align: 1px; outline: none;
  font: italic 500 10.5px/1 Georgia, serif; }
.tip::before { content: 'i'; }
.tip:hover, .tip:focus, .tip.open { border-color: var(--gold); color: var(--gold); }
.tipbox, .charttip { position: fixed; z-index: 100; max-width: min(300px, calc(100vw - 24px)); padding: 9px 12px; border-radius: var(--radius);
  background: #0f0f18; border: 1px solid rgba(189,151,78,.7); color: var(--text-2); font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0,0,0,.5); pointer-events: none; }
.charttip { border-color: var(--raised); min-width: 150px; }
.charttip .t-head { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.charttip .t-row { display: flex; align-items: center; gap: 8px; }
.charttip .t-row b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.charttip .t-row span { color: var(--muted); }
.charttip .t-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }

/* charts */
.chart-block { margin-top: 18px; }
.chart-block h3 { margin: 0 0 2px; color: var(--text); font-size: 15px; font-weight: 500; }
.chart-block .c-sub { color: var(--faint); font-size: 12.5px; margin-bottom: 6px; }
.chart { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--faint); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: #3a3a58; stroke-width: 1; }
.chart .ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.chart .ref-label { fill: var(--muted); font: 11px var(--font); }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .empty { fill: var(--faint); font: 13px var(--font); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.data-table { margin-top: 6px; }
.data-table summary { color: var(--faint); font-size: 12px; cursor: pointer; }
.data-table summary:hover { color: var(--gold); }
.data-table .table-wrap { max-height: 260px; overflow: auto; margin-top: 6px; }
.data-table table { font-size: 12.5px; }
.data-table td:first-child { min-width: 90px; }
.ranges { display: inline-flex; background: #17172a; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; margin: 4px 0 2px; }
.ranges button { background: none; border: 0; color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.ranges button[aria-pressed=true] { background: var(--raised); color: var(--text); }
.coverage { color: var(--faint); font-size: 12px; margin-left: 10px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; }

/* focus view */
.focus { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 8, 14, .74); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 24px; }
.focus[hidden] { display: none; }
.panel { background: var(--card); border: 1px solid var(--raised); border-radius: 10px; width: min(860px, 100%); max-height: 100%;
  overflow-y: auto; padding: 0 26px 28px; box-shadow: 0 24px 80px rgba(0,0,0,.6); touch-action: pan-y; overscroll-behavior: contain; }
.panel .head { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 2; background: var(--card);
  margin: 0 -26px 6px; padding: 18px 26px 12px; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0; color: var(--text); font-weight: 700; font-size: 22px; }
.titles { min-width: 0; }
.dots { display: flex; gap: 6px; margin-top: 7px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--raised); transition: width .2s, background .2s; }
.dots i.on { width: 18px; border-radius: 3px; background: var(--gold); }
.panel .nav, .panel .close { background: none; border: 1px solid var(--line); color: var(--text-2); border-radius: var(--radius);
  width: 40px; height: 40px; font-size: 22px; line-height: 1; cursor: pointer; flex: none; }
.panel .nav:hover, .panel .close:hover { border-color: var(--gold); color: var(--gold); }
.panel .nav.prev { margin-left: auto; }
.frow { padding: 14px 0; border-top: 1px solid var(--line); }
.frow:first-of-type { border-top: 0; }
.fline { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.flabel { color: var(--muted); font-size: 15.5px; }
.fvalue { color: var(--text); font-size: 21px; font-weight: 500; text-align: right; }
.fvalue .sub { font-weight: 400; display: block; }
.fexplain { color: var(--faint); font-size: 13px; line-height: 1.55; margin-top: 5px; max-width: 62ch; }
.fwins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.fwins div { background: #17172a; border-radius: var(--radius); padding: 8px 6px; text-align: center; }
.fwins b { display: block; color: var(--text); font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.fwins span { color: var(--faint); font-size: 11px; }
.panel .bar { height: 14px; border-radius: 7px; }
.panel .legend { font-size: 13.5px; gap: 6px 18px; }
.panel .heatmap { font-size: 11.5px; }
#focusBody.from-right { animation: fromRight .24s ease-out; }
#focusBody.from-left { animation: fromLeft .24s ease-out; }
@keyframes fromRight { from { transform: translateX(36px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fromLeft { from { transform: translateX(-36px); opacity: 0; } to { transform: none; opacity: 1; } }
body.focus-open { overflow: hidden; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .feature { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .top { padding-left: 16px; padding-right: 16px; gap: 12px; }
  .top nav { gap: 14px; font-size: 13.5px; }
  .top nav .ext, .brand span { display: none; }
  main { padding: 20px 16px 40px; }
  .kpis { gap: 10px; }
  .kpi { padding: 12px 12px 48px; }
  .kpi .spark { height: 38px; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .heatmap { grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 1px; font-size: 9px; }
  .focus { padding: 0; }
  .panel { width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0 18px calc(30px + env(safe-area-inset-bottom, 0px)); }
  .panel .head { margin: 0 -18px 6px; padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 10px; }
  .panel h2 { font-size: 20px; }
  .fvalue { font-size: 18px; }
  .fwins { grid-template-columns: repeat(3, 1fr); }
}
@media (hover: none) and (max-width: 700px) { .panel .nav { display: none; } .panel .close { margin-left: auto; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
