/* Field-control look: polycarb-wall grey, alliance red/blue, hub lights in fuel yellow.
   System fonts only: the venue WiFi may not have internet. */
:root {
  --wall: #eceee9; --panel: #ffffff; --panel-2: #f5f6f2; --ink: #161a1f; --ink-2: #2a3038;
  --muted: #5d656e; --line: #e0e3dc; --line-strong: #c3c8bf;
  --red: #cf1430; --red-soft: #fce6e9; --red-line: #f3b9c1;
  --blue: #0a5fbd; --blue-soft: #e3edfa; --blue-line: #b5cdee;
  --fuel: #f4c300; --fuel-soft: #fff5c7; --ok: #157045; --ok-soft: #dbf1e4; --warn: #b4520a; --warn-soft: #fdeedd;
  --shadow: 0 1px 2px rgba(17, 24, 39, .05), 0 2px 8px rgba(17, 24, 39, .06);
  --r-lg: 16px; --r-md: 12px; --r-sm: 9px;
  --tap: 44px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink); background: var(--wall);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { overflow-x: clip; }
body { margin: 0; min-height: 100vh; background: var(--wall); line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom); }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 .75rem; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--blue); }
a:has(> button) { text-decoration: none; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; background: var(--panel-2);
  padding: .05rem .3rem; border-radius: 5px; overflow-wrap: anywhere; }
p { margin: .5rem 0; }

/* ---------- controls */
button, select, input, textarea { font: inherit; color: inherit; }
button {
  min-height: var(--tap); padding: .55rem 1rem; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  font-weight: 650; cursor: pointer; touch-action: manipulation;
  transition: background .12s, border-color .12s, transform .06s, box-shadow .12s;
}
button:hover:not(:disabled) { border-color: var(--ink-2); }
button:active:not(:disabled) { transform: translateY(1px) scale(.99); }
button:disabled { opacity: .38; cursor: not-allowed; }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--ink-2); }
button.red { background: var(--red); border-color: var(--red); color: #fff; }
button.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
button.ghost { background: transparent; border-color: var(--line-strong); font-weight: 550; }
button.danger { color: var(--warn); border-color: #e7b48c; background: var(--panel); }
button.danger:hover:not(:disabled) { background: var(--warn-soft); border-color: var(--warn); }
button.small { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
:focus-visible { outline: 3px solid var(--fuel); outline-offset: 2px; }

input, select, textarea {
  min-height: var(--tap); padding: .5rem .7rem; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: #fff; font-size: 16px; /* 16px: no iOS focus zoom */
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--fuel-soft); }
input[type=number] { width: 5.5rem; }
input[type=checkbox] { min-height: 0; width: 1.25rem; height: 1.25rem; accent-color: var(--ink); vertical-align: middle; }
textarea { width: 100%; min-height: 8rem; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
label { display: inline-flex; align-items: center; gap: .45rem; }
label.field { display: flex; flex-direction: column; align-items: stretch; gap: .3rem; font-size: .8rem;
  font-weight: 600; color: var(--muted); }
label.field input, label.field select { width: 100%; color: var(--ink); font-weight: 500; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .75rem; align-items: end; }

/* ---------- tables */
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 650; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  background: var(--panel-2); border-bottom-color: var(--line-strong); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r-md); }
.scroll table { min-width: max-content; }
.scroll th:first-child, .scroll td:first-child { padding-left: .8rem; }
.kv td { border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.kv td:first-child { color: var(--muted); width: 40%; }

/* ---------- layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); min-width: 0; }
.panel:empty { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel-head h2 { margin: 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tred { color: var(--red); } .tblue { color: var(--blue); }
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 650; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.warnbox { border: 1px solid #efc39d; background: var(--warn-soft); color: #7a3a07; border-radius: var(--r-sm); padding: .65rem .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .5rem; }

/* status bar shared by every page */
.bar { display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: calc(.65rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .65rem max(1rem, env(safe-area-inset-left));
  background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 5; min-height: 52px; }
.bar > span:first-child { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.bar b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .pill { background: rgba(255, 255, 255, .1); color: #e8eaed; border-color: rgba(255, 255, 255, .14); }
.bar .pill.ok { background: rgba(61, 220, 132, .16); color: #7ee2a8; border-color: transparent; }
.bar .pill.bad { background: rgba(255, 153, 82, .18); color: #ffb47e; border-color: transparent; }
.bar .row { flex-wrap: nowrap; gap: .4rem; }
.bar .conn { width: .6rem; height: .6rem; flex: none; border-radius: 50%; background: var(--warn); display: inline-block;
  box-shadow: 0 0 0 3px rgba(180, 82, 10, .25); }
.bar .conn.on { background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, .2); }

/* the signature element: hub lights */
.hubs { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.hub { border-radius: var(--r-lg); padding: 1.1rem .8rem; border: 2px solid var(--line); background: var(--panel);
  text-align: center; box-shadow: var(--shadow); transition: background .2s, box-shadow .2s; }
.hub .name { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.hub .state { font-size: 2rem; font-weight: 850; margin-top: .2rem; letter-spacing: -.02em; }
.hub.red { border-color: var(--red-line); } .hub.blue { border-color: var(--blue-line); }
.hub.red.on { border-color: var(--red); } .hub.blue.on { border-color: var(--blue); }
.hub.on { background: var(--fuel); box-shadow: 0 0 0 4px var(--fuel-soft), 0 0 30px rgba(244, 195, 0, .7); }
.hub.on .name { color: var(--ink); }
.hub.off .state { color: var(--line-strong); }

.clock { font-size: 3.2rem; font-weight: 850; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.phase { font-weight: 650; color: var(--muted); }
.score { font-size: 2.8rem; font-weight: 850; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.teams { font-weight: 650; }

/* login gate */
.gate { max-width: 380px; margin: 12vh auto 0; padding: 1.6rem; width: calc(100% - 2rem); }
.gate h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.gate input { width: 100%; margin-bottom: .7rem; font-size: 1.2rem; }
.gate::before { content: ""; display: block; width: 44px; height: 44px; margin-bottom: 1rem; border-radius: 12px;
  background: url(/static/icon.svg) center / cover, var(--ink); }

/* tabs: one scrollable row of segments, never wraps */
.tabs { display: flex; gap: .25rem; margin: 0 0 1rem; padding: .3rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 38px; border: 0; background: transparent; color: var(--muted);
  font-weight: 600; padding: .4rem .9rem; border-radius: 8px; white-space: nowrap; }
.tabs button:hover:not(.sel) { background: var(--panel-2); color: var(--ink); }
.tabs button.sel { background: var(--ink); color: #fff; }

.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: var(--r-md); z-index: 20;
  max-width: min(92vw, 520px); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-weight: 550;
  overflow-wrap: anywhere; animation: toast-in .18s ease-out; }
.toast.err { background: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 720px) {
  .wrap { padding: .75rem; }
  .panel { padding: .9rem; margin-bottom: .75rem; border-radius: 14px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); gap: .9rem; }
  .clock { font-size: 2.6rem; }
  .score { font-size: 2.4rem; }
  table { font-size: .9rem; }
  th, td { padding: .5rem .45rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
