/* Phone first: one column to 900px, three arm columns above it. Dark palette. */
:root {
  --bg: #000;
  --panel: #0b0b0b;
  --fg: #E7E9EA;
  --muted: #71767B;
  --accent: #1D9BF0;
  --border: #2F3336;
  --high: #00BA7C;
  --low: #F91880;
  --warn: #FFD400;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

#app { max-width: 1400px; margin: 0 auto; padding: 12px 16px 90px; }

h1 { font-size: 20px; margin: 6px 0; }
h2 { font-size: 15px; margin: 0 0 8px; display: flex; gap: 6px; align-items: center;
     flex-wrap: wrap; }
h3 { font-size: 14px; margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .06em;
     color: var(--muted); }
p { margin: 6px 0; }
a { color: var(--accent); }

.muted { color: var(--muted); font-weight: 400; }

.chip {
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.chip.settled { color: var(--accent); border-color: var(--accent); }
.chip.decoy-chip { color: var(--low); border-color: var(--low); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.company { display: inline-block; margin-bottom: 4px; }

.status { font-size: 13px; color: var(--muted); }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); margin-right: 6px;
}
.dot.live { background: var(--high); }
.dot.reconnecting, .dot.resyncing, .dot.polling { background: var(--warn); }
.dot.offline { background: var(--low); }

.prefer { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }

button {
  background: transparent; color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.on { border-color: var(--accent); color: var(--accent); }
button[disabled] { opacity: .4; cursor: default; }

#tabs { display: flex; gap: 6px; margin: 10px 0; }

#arms { display: block; }
.arm {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  background: var(--panel); margin-bottom: 12px; display: none;
}
.arm.active { display: block; }

.cards { display: flex; flex-direction: column; gap: 8px; }

.card { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.card.streaming { opacity: .6; }
.card.decoy { border-color: var(--low); }
.card-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.seat { font-weight: 600; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }

.meter { margin-top: 6px; }
.label { font-size: 11px; color: var(--muted); }
.bar { height: 6px; background: #161616; border-radius: 3px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar i.contested { background: var(--accent); }
.bar.split i.high { background: var(--high); }
.bar.split i.low { background: var(--low); }

.rate-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.rate-row button.rate { min-width: 44px; min-height: 44px; font-size: 15px; }

.digest { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 8px; }
.proxy { font-size: 14px; color: var(--fg); border-left: 2px solid var(--accent);
         padding-left: 8px; }

/* ---- live mode: graph, detail sheet, settlement, board ---- */

#graph, #detail, #answer { display: none; }
body.view-live #graph, body.view-live #detail, body.view-live #answer { display: block; }
body.view-live #tabs, body.view-live #arms, body.view-live #side, body.view-live #map {
  display: none;
}
body.view-live main { display: block; }

#graph-svg { width: 100%; aspect-ratio: 1 / 1; max-height: 60vh; display: block; }
.gnode.selected circle.face { stroke: var(--fg); stroke-width: 3; }

#detail, #answer {
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
  padding: 8px 10px; margin: 12px 0;
}
#answer h3 { margin-top: 0; }

@media (max-width: 899px) {
  body.view-map #map-svg { display: none; }     /* 11 px labels in a 900 px canvas are unreadable on a phone */
  body.view-live #detail {
    position: sticky; bottom: 84px; z-index: 2; max-height: 46vh; overflow-y: auto;
    box-shadow: 0 -8px 18px rgba(0, 0, 0, .8);
  }
}

#settle, #board { border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
                  padding: 8px 10px; margin: 12px 0; }
#settle:empty, #board:empty { display: none; }
#settle h3, #board h3 { margin-top: 0; overflow-wrap: anywhere; }

.payouts, .board { list-style: none; margin: 0; padding: 0; }
.payouts li, .board li {
  display: flex; gap: 8px; align-items: baseline; padding: 4px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.payouts li:last-child, .board li:last-child { border-bottom: 0; }
.payouts .delta, .board .delta { margin-left: auto; font-variant-numeric: tabular-nums; }
.payouts li.up .delta { color: var(--high); }
.payouts li.down .delta { color: var(--low); }
.board .rank { color: var(--muted); min-width: 16px; }

#qr { margin-top: 16px; }
#qr:empty { display: none; }
#qr img, #qr canvas { border: 6px solid #000; background: #000; max-width: 100%; }

.return-link { display: flex; gap: 6px; margin-top: 8px; }
.return-link input {
  flex: 1; min-width: 0; background: #161616; color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px; padding: 0 8px;
  min-height: 44px; font-size: 16px;            /* 16px keeps iOS from zooming on focus */
}
.return-link button.share { min-height: 44px; }

#ticker {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 6px 12px;
  list-style: none; background: rgba(0, 0, 0, .94); border-top: 1px solid var(--border);
  max-height: 76px; overflow: hidden; font-size: 12px; color: var(--muted);
}

#map { display: none; }
#map-svg { width: 100%; height: 70vh; min-height: 380px; }
.trials { list-style: none; padding: 0; margin: 0; }
.trials li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.trials li a { font-size: 16px; display: inline-block; min-height: 24px; }
a.button {
  display: inline-block; min-height: 44px; line-height: 44px; padding: 0 18px;
  border-radius: 10px; background: var(--accent); color: #000; font-weight: 600;
  text-decoration: none;
}
.map-legend { margin-top: 12px; }

body.view-map #arms, body.view-map #side, body.view-map #tabs { display: none; }
body.view-map #map { display: block; }
body.view-trial #map { display: none; }

@media (min-width: 900px) {
  #tabs { display: none; }
  #arms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: start; }
  .arm, .arm.active { display: block; }
  main { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
  body.view-map main { grid-template-columns: 1fr; }
  body.view-live main { display: block; }
}
