/* Combat IQ commentator screen + admin dashboard. Dark broadcast look: the
   original layout (two fighter columns, big headline numbers), with Inter,
   tabular figures, softer panels and a clear live state. */
:root {
  --bg: #121315;
  --bar: #17181b;
  --panel: #1d1f22;
  --row: #22252a;
  --row-alt: #1f2125;
  --head: #26292e;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #f4f5f7;
  --muted: rgba(244, 245, 247, 0.58);
  --faint: rgba(244, 245, 247, 0.36);
  --red: #e5484d;
  --blue: #3b82f6;
  --live: #ef4444;
  --accent: #8fff00;
  --radius: 12px;
  --label-w: 30%;
  --topbar-h: 61px;
  --gutter: 28px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.35; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.spacer { flex: 1; }

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: nowrap; align-items: center; gap: 10px 14px;
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
  background: rgba(23, 24, 27, 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; flex: none; color: inherit; text-decoration: none; white-space: nowrap; }
.brand img { height: 18px; display: block; }
.brand .title {
  padding-left: 14px; border-left: 1px solid var(--line-strong);
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}

.live-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: 999px; white-space: nowrap; flex: none;
  border: 1px solid var(--line-strong); background: transparent; color: var(--faint);
  font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.live-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.live-btn .live-round { font-weight: 600; opacity: 0.85; letter-spacing: 0.04em; }
.live-btn.available { color: #fff; border-color: var(--live); }
.live-btn.available .dot { background: var(--live); opacity: 1; }
.live-btn.available:hover { background: rgba(239, 68, 68, 0.14); }
.live-btn.on { color: #fff; background: var(--live); border-color: var(--live); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18); }
.live-btn.on .dot { background: #fff; opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
.live-btn:disabled { cursor: default; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }

.menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.03); font-size: 13px; font-weight: 600;
}
.user-btn:hover { background: rgba(255, 255, 255, 0.07); }
.avatar {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #111; font-size: 12px; font-weight: 800;
}
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px; border-radius: 10px;
  background: #23262b; border: 1px solid var(--line-strong); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column;
}
.menu-pop a, .menu-pop button {
  text-align: left; padding: 8px 10px; border-radius: 6px; border: 0; background: none; color: var(--text);
  text-decoration: none; font-size: 13px;
}
.menu-pop a:hover, .menu-pop button:hover { background: rgba(255, 255, 255, 0.07); }
.menu-who { padding: 6px 10px 8px; font-size: 12px; color: var(--faint); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-who:empty { display: none; }

/* ── controls ── */
select {
  height: 38px; min-width: 120px; max-width: 420px; padding: 0 34px 0 12px; border-radius: 9px;
  border: 1px solid var(--line-strong); background-color: var(--panel); appearance: none; font-size: 14px; font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.25); }
select:disabled { opacity: 0.5; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.seg button {
  height: 30px; padding: 0 16px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.seg.small button { padding: 0 10px; font-size: 12px; }

.notice {
  max-width: 1500px; margin: 10px auto 0; padding: 10px 16px; border-radius: 10px;
  background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.35); color: #fecaca; font-size: 14px;
  width: calc(100% - 2 * var(--gutter));
}
.notice.soft { background: rgba(255, 255, 255, 0.04); border-color: var(--line-strong); color: var(--muted); }
/* ── screen header: a top bar (brand, view, profile) over a subheader (event,
   fight, round, live). Both line up with the stat tables' edges. ── */
.site-header {
  position: sticky; top: 0; z-index: 20;
  --edge-l: max(var(--gutter), calc((100% - 1500px) / 2 + var(--gutter)), env(safe-area-inset-left));
  --edge-r: max(var(--gutter), calc((100% - 1500px) / 2 + var(--gutter)), env(safe-area-inset-right));
}
.site-header .topbar {
  position: static; gap: 12px; padding: 10px var(--edge-r) 10px var(--edge-l);
  background: rgba(13, 14, 16, 0.96); border-bottom: 1px solid var(--line);
}
.site-header .seg button { height: 28px; }
.subbar {
  display: flex; align-items: center; gap: 10px 12px; padding: 10px var(--edge-r) 10px var(--edge-l);
  background: rgba(30, 32, 36, 0.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-strong); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}
.event-block { flex: 1 0 auto; display: flex; flex-direction: column; gap: 2px; margin-right: 8px; }   /* never shrinks: the title stays whole */
.event-name { font-size: 16px; font-weight: 700; letter-spacing: -0.005em; white-space: nowrap; }
.status { min-height: 14px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.subbar .pickers { display: contents; }
.subbar select { height: 36px; }
#org, #event { flex: 0 1 200px; width: 200px; min-width: 120px; }
#fight { flex: 0 1 340px; width: 340px; min-width: 180px; }
#round { flex: none; width: 140px; min-width: 0; }
#third { flex: none; width: 124px; min-width: 0; }

/* ── board ── */
.board { max-width: 1500px; margin: 0 auto; padding: 20px var(--gutter) max(40px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.board.main .panel { width: 100%; }   /* as wide as the detailed layout, edges in line with the header */
.detailed-top { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; overflow: clip;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px rgba(0, 0, 0, 0.25);
}
.row { display: grid; grid-template-columns: var(--label-w) 1fr 1fr; align-items: stretch; }
.row > .label, .row > .cell { display: flex; align-items: center; padding: 0 22px; min-height: 40px; }
.row > .cell { justify-content: center; gap: 6px; border-left: 1px solid var(--line); }
.row + .row { border-top: 1px solid var(--line); }

.row.head { background: var(--head); position: sticky; top: var(--topbar-h); z-index: 5; box-shadow: 0 1px 0 var(--line); }
.row.head > .cell { flex-direction: column; justify-content: center; gap: 2px; min-height: 64px; position: relative; }
.row.head > .cell::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; }
.row.head > .cell.red::before { background: var(--red); }
.row.head > .cell.blue::before { background: var(--blue); }
.row.head .corner { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.row.head .name { font-size: 18px; font-weight: 700; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.row.head .name.unknown { color: var(--faint); font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }

.row.l1 { background: var(--row); }
.row.l1 > .label { font-size: 19px; font-weight: 700; }
.row.l1 > .label, .row.l1 > .cell { min-height: 54px; }
.row.l1 .v { font-size: 24px; font-weight: 800; }
.row.l2 { background: var(--row-alt); }
.row.l2 > .label { padding-left: 42px; font-size: 15px; color: rgba(244, 245, 247, 0.82); }
.row.l2 .v { font-size: 16px; font-weight: 700; }
.row.sep { border-top-color: var(--line-strong) !important; }
.row.size-xl .v { font-size: 30px; }
.row.size-xl > .label, .row.size-xl > .cell { min-height: 60px; }
.row.size-lg .v { font-size: 24px; }

.v { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.of { color: var(--muted); font-variant-numeric: tabular-nums; }
.acc {
  margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.06);
  color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.row.k-la > .cell { flex-wrap: wrap; row-gap: 0; }
.row.l1 .of { font-size: 16px; }
.row.l1 .acc { font-size: 13px; }

.row.section { background: var(--head); }
.section-label {
  grid-column: 1 / -1; padding: 9px 22px 7px; font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--faint);
}

.compass {
  display: grid; grid-template-columns: auto auto auto; grid-template-areas: '. n .' 'w c e' '. s .';
  align-items: center; justify-items: center; column-gap: 8px; row-gap: 2px; padding: 8px 0; font-weight: 700;
}
.compass .n { grid-area: n; } .compass .s { grid-area: s; } .compass .w { grid-area: w; } .compass .e { grid-area: e; }
.compass img { grid-area: c; width: 26px; height: 26px; opacity: 0.85; }
.label-compass { font-weight: 500; font-size: 14px; color: var(--muted); }
.row.k-movement > .label { justify-content: center; padding-left: 22px; }


/* ── dialogs, toast, forms ── */
.dialog {
  border: 1px solid var(--line-strong); border-radius: 14px; background: #1d2024; color: var(--text);
  padding: 22px; width: min(420px, 92vw); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog h2 { margin: 0 0 14px; font-size: 17px; }
.dialog label, .form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=number], .input {
  height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-strong); background: #15171a; font-size: 14px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid rgba(143, 255, 0, 0.55); outline-offset: 1px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-error { min-height: 18px; margin: 0 0 6px; color: #f87171; font-size: 13px; }
.btn {
  height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04); font-size: 13px; font-weight: 600;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #fca5a5; border-color: rgba(239, 68, 68, 0.45); }
.btn.ghost { background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 10px; background: #2a2d33; border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 600; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(239, 68, 68, 0.6); color: #fecaca; }

/* ── login ── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(143, 255, 0, 0.06), transparent 60%), var(--bg); }
.login-card {
  width: min(380px, 100%); padding: 32px 28px 26px; border-radius: 16px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.login-card img { height: 20px; display: block; margin-bottom: 20px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card .btn { width: 100%; height: 40px; margin-top: 4px; }

/* ── responsive: tablets (portrait / landscape) and phones ── */
@media (max-width: 960px) {
  .detailed-top { grid-template-columns: 1fr; }
  :root { --label-w: 34%; --gutter: 18px; }
}
/* touch screens: bigger targets */
@media (pointer: coarse) {
  select, .subbar select { height: 44px; }
  .seg button { height: 36px; }
  .site-header .seg button { height: 34px; }
  .live-btn, .user-btn { height: 40px; }
}
/* subheader on two lines: the event (and Updated), then the pickers and live
   (sooner for admins, who also get the org / event pickers) */
@media (max-width: 900px) {
  .subbar { flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 10px; }
  .event-block { flex: 1 1 100%; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; }
  .subbar .pickers { display: flex; flex: 1 1 100%; align-items: center; gap: 8px; min-width: 0; }
  #org, #event, #fight { flex: 1 1 0; width: 0; min-width: 0; max-width: none; }
}
@media (max-width: 1280px) {
  .subbar.many { flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 10px; }
  .subbar.many .event-block { flex: 1 1 100%; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; }
  .subbar.many .pickers { display: flex; flex: 1 1 100%; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
}
@media (max-width: 600px) {
  .subbar.many .pickers { flex-wrap: wrap; }
  .subbar.many #org, .subbar.many #event { flex: 1 1 40%; width: auto; }
  .subbar.many #fight { flex: 1 1 100%; width: auto; }
}
@media (max-width: 720px) {
  :root { --gutter: 12px; --label-w: 36%; }
  .site-header .topbar { padding-top: 8px; padding-bottom: 8px; }
  #user-name { display: none; }
  .user-btn { padding: 0 4px; }
  .subbar select { font-size: 16px; }   /* 16px: no zoom on iOS */
  #round { width: 132px; }
  #third { width: 116px; }
  .board { gap: 12px; padding-top: 10px; }
  .panel { border-radius: 10px; }
  .row > .label, .row > .cell { padding: 0 8px; }
  .row.l1 > .label { font-size: 15px; }
  .row.l1 .v { font-size: 20px; }
  .row.l2 > .label { padding-left: 16px; font-size: 13px; }
  .row.l2 .v { font-size: 15px; }
  .row.size-xl .v, .row.size-lg .v { font-size: 24px; }
  .row.l1 > .label, .row.l1 > .cell { min-height: 48px; }
  .row.size-xl > .label, .row.size-xl > .cell { min-height: 52px; }
  .row.head > .cell { min-height: 54px; padding: 6px 6px; }
  .row.head .name { font-size: 15px; }
  .row.l1 .of, .of { font-size: 13px; }
  .acc { font-size: 11px; padding: 0 5px; margin-left: 2px; }
  .section-label { padding: 8px 8px 6px; }
  .compass { column-gap: 4px; font-size: 13px; }
  .compass img { width: 18px; height: 18px; }
  .label-compass { font-size: 10px; }
  .site-header .seg button { padding: 0 12px; }
  .live-btn { padding: 0 12px; }
}
@media (max-width: 560px) {
  .brand .title { display: none; }
}
@media (max-width: 480px) {
  :root { --label-w: 34%; }
  .live-btn .live-round { display: none; }
  .live-btn:disabled .live-label { display: none; }   /* nothing live: just the dot (its title says so) */
  .live-btn:disabled { padding: 0 12px; }
  .subbar select { padding-left: 10px; padding-right: 28px; background-position: right 10px center; }
  #round { width: 124px; }
  .live-btn { padding: 0 10px; gap: 6px; }
  .status { display: none; }   /* phones: the title gets the whole line */
  .event-name { font-size: 15px; }
  /* landed / attempted on one line, accuracy under it */
  .row.k-la .acc { flex-basis: 100%; text-align: center; background: none; padding: 0; margin: 0; font-size: 11px; line-height: 1.1; }
  .row.k-la > .cell { padding-top: 4px; padding-bottom: 4px; }
  .row.l2 > .label { padding-left: 12px; }
}
a.btn { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }
@media (max-width: 400px) {
  .site-header .seg button { padding: 0 9px; font-size: 12px; }
  .brand img { height: 14px; }
}
@media (max-width: 380px) {
  .event-name { font-size: 14px; }
  .live-btn { padding: 0 8px; gap: 5px; font-size: 12px; }
}
@media (max-width: 340px) {
  .site-header .seg button { padding: 0 7px; font-size: 11px; }
  .brand img { height: 12px; }
}
