/* ===== Chicago font (matches other ben.gy sites) ===== */
@font-face {
  font-family: 'Chicago';
  src: url('ChicagoFLF.woff2') format('woff2');
  font-weight: normal; font-style: normal; font-display: swap;
}
.chicago-font { font-family: 'Chicago', 'Geneva', system-ui, sans-serif; letter-spacing: .5px; }

/* ===== Theme ===== */
:root {
  --bg: #0c1322;
  --bg-2: #111c32;
  --panel: #14213b;
  --ink: #eaf1ff;
  --ink-dim: #9fb0cf;
  --line: #243456;
  --accent: #34d399;       /* spy green */
  --accent-2: #f5c518;     /* gold */
  --danger: #ff6b6b;
  --node: #18253f;
  --node-line: #2c3e63;
  --shadow: 0 10px 30px rgba(0,0,0,.4);
  --r32: #6ea8fe; --r16: #a78bfa; --qf: #f0883e; --sf: #f5c518; --final: #34d399; --third: #93a4c4;
  font-synthesis: none;
}
[data-theme="light"] {
  --bg: #f4f7ff; --bg-2: #eaf0fb; --panel: #ffffff; --ink: #0f1b30; --ink-dim: #5a6b8c;
  --line: #d8e0f0; --node: #ffffff; --node-line: #d8e0f0; --shadow: 0 10px 30px rgba(20,40,80,.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, var(--bg-2), var(--bg));
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--bg-2), transparent);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.brand-text h1 { font-size: 19px; margin: 0; letter-spacing: -.02em; }
.brand-text .tagline { margin: 3px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-dim); max-width: 560px; }
.brand-text .tagline b { color: var(--ink); font-weight: 600; }

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctrl { display: flex; flex-direction: column; gap: 2px; }
.ctrl-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-dim); }
select, .ctrl-btn {
  font: inherit; color: var(--ink); background: var(--node); border: 1px solid var(--node-line);
  padding: 0 12px; border-radius: 10px; cursor: pointer; transition: .15s; font-size: 14px;
}
/* uniform control height across select / buttons / switch */
select, .ctrl-btn, .switch { height: 42px; box-sizing: border-box; }
.ctrl-btn { display: inline-flex; align-items: center; }
.select-wrap { position: relative; display: inline-flex; }
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  min-width: 200px; width: 100%; padding-right: 34px; line-height: 40px;
}
.select-wrap::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 11px; height: 7px;
  transform: translateY(-50%); pointer-events: none; background: var(--ink-dim);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.ctrl-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.ctrl-btn.icon { padding: 9px 11px; }
.ctrl-btn.primary { background: var(--accent); color: #062014; border-color: transparent; font-weight: 700; }
.ctrl-btn.primary:hover { filter: brightness(1.06); }

/* Disguise switch — ON = disguised, OFF = real fixtures shown */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none;
  background: var(--node); border: 1px solid var(--node-line); border-radius: 10px; padding: 8px 12px 8px 10px; }
.switch:hover { border-color: var(--accent); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--node-line); transition: background .18s; flex: none; }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.switch-text { font-size: 14px; font-weight: 600; min-width: 92px; }

/* ===== Stage / canvas ===== */
.stage { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.stage-tools {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg-2); flex-wrap: wrap;
}
.selcount { font-size: 13px; color: var(--ink-dim); }
.sel-actions, .zoom { display: flex; gap: 6px; }
.zoom { margin-left: auto; }
.mini {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--node);
  border: 1px solid var(--node-line); border-radius: 8px; padding: 5px 11px; cursor: pointer;
}
.mini:hover { border-color: var(--accent); }

.canvas { position: relative; flex: 1; min-height: 0; cursor: grab; overflow: hidden; touch-action: none; }
.canvas.grabbing { cursor: grabbing; }
#bracket { width: 100%; height: 100%; display: block; }
.hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--ink-dim); background: rgba(0,0,0,.25); padding: 4px 12px;
  border-radius: 999px; pointer-events: none; backdrop-filter: blur(4px);
}
[data-theme="light"] .hint { background: rgba(255,255,255,.6); }

/* ===== Bracket nodes ===== */
.node { cursor: pointer; }
.node-bg { fill: var(--node); stroke: var(--node-line); stroke-width: 1.5; transition: stroke .15s, opacity .15s; }
.node-accent { fill: var(--r32); }
.node[data-round="R16"] .node-accent { fill: var(--r16); }
.node[data-round="QF"]  .node-accent { fill: var(--qf); }
.node[data-round="SF"]  .node-accent { fill: var(--sf); }
.node[data-round="FINAL"] .node-accent { fill: var(--final); }
.node[data-round="3RD"] .node-accent { fill: var(--third); }
.node-title { fill: var(--ink); font-size: 13px; font-weight: 600; pointer-events: none; }
.node-sub { fill: var(--ink-dim); font-size: 11px; pointer-events: none; }
.node-check { fill: none; stroke: var(--node-line); stroke-width: 1.5; }
.node-tick { stroke: #062014; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.node.selected .node-check { fill: var(--accent); stroke: var(--accent); }
.node.selected .node-tick { opacity: 1; }
.node:not(.selected) .node-bg { opacity: .5; }
.node:hover .node-bg, .node:focus .node-bg { stroke: var(--accent); }
.node:focus { outline: none; }
.node.focused .node-bg { stroke: var(--accent-2); stroke-width: 2.5; }

.conn { stroke: var(--node-line); stroke-width: 1.5; transition: stroke .15s, opacity .15s; }
svg.has-hover .conn { opacity: .25; }
svg.has-hover .node:not(.lit) .node-bg { opacity: .35; }
.conn.lit { stroke: var(--accent); opacity: 1 !important; stroke-width: 2.5; }
.node.lit .node-bg { stroke: var(--accent); opacity: 1 !important; }

/* ===== Invite panel ===== */
.panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 380px; max-width: 92vw;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; z-index: 30; overflow-y: auto;
}
.panel.open { transform: translateX(0); }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-round { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.panel-close { background: none; border: none; color: var(--ink-dim); font-size: 18px; cursor: pointer; }
.panel-card {
  position: relative; background: var(--node); border: 1px solid var(--node-line);
  border-radius: 14px; padding: 16px; overflow: hidden;
}
.stamp {
  position: absolute; top: 14px; right: -34px; transform: rotate(18deg);
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .15em;
  padding: 3px 40px; opacity: .9;
}
.panel-title { font-size: 18px; margin: 0 0 6px; line-height: 1.25; }
.panel-loc { font-size: 12px; color: var(--ink-dim); margin-bottom: 10px; }
.panel-desc { font: inherit; font-size: 13px; color: var(--ink); white-space: pre-wrap; margin: 0; line-height: 1.5; }
.panel-real {
  font-size: 12px; color: var(--ink-dim); background: var(--bg-2); border: 1px dashed var(--line);
  border-radius: 10px; padding: 10px 12px; line-height: 1.4;
}
.panel-include { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.panel-include input { width: 17px; height: 17px; accent-color: var(--accent); }
.panel-copy { display: flex; gap: 8px; }

/* ===== Toast / decode animation ===== */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px;
  font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 40;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.decoding { animation: flicker .5s steps(2) 1; }
@keyframes flicker { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; display: none; }
.confetti.go { display: block; }

/* ===== Footer ===== */
.footer {
  display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap;
  padding: 8px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-dim);
  background: var(--bg-2);
}
.footer-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.footer-dot { opacity: .5; }
.credit { color: var(--ink-dim); white-space: nowrap; }
.credit a { color: var(--ink-dim); text-decoration: none; transition: color .15s; }
.credit a:hover { color: var(--ink); }

@media (max-width: 720px) {
  .brand-text .tagline { font-size: 11.5px; max-width: 100%; }
  .controls { gap: 7px; }
  select { min-width: 150px; }
  .footer { font-size: 10.5px; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
