@font-face {
  font-family: Chakra;
  src: url("/assets/fonts/ChakraPetch-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
:root {
  color-scheme: dark;
  font-family: Arial, sans-serif;
  background: #0b0d11;
  color: #eee;
  --green: #b7ff39;
  --red: #ff4d5e;
  --muted: #a2a9b3;
  --panel: #12151b;
  --line: #262b33;
  --light-sq: #bbc6a7;
  --dark-sq: #596a50;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #0b0d11;
}
a {
  color: var(--green);
  text-decoration: none;
}
h1,
h2 {
  font-family: "Chakra Petch", Chakra, Arial, sans-serif;
  margin: 0;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:focus-visible,
.tile:focus-visible,
a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.muted {
  color: var(--muted);
}
.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 1.5px;
}
.brand {
  font-weight: 900;
}
.on-air {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
}
.on-air i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.on-air[data-live="true"] {
  border-color: var(--red);
  color: #fff;
}
.on-air[data-live="true"] i {
  background: var(--red);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}
.title-block {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.title-block strong {
  font-family: "Chakra Petch", Chakra, Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0.5px;
}
.event-badge {
  padding: 3px 8px;
  border-radius: 4px;
  background: #ffcf3a;
  color: #111;
  font-weight: 900;
  letter-spacing: 2px;
}
.event-progress {
  color: var(--muted);
}
.bracket-link {
  margin-left: auto;
}
.exhibition-note {
  margin: 0;
  padding: 8px 24px;
  background: #2a2410;
  color: #ffe69a;
  font-size: 13px;
  border-bottom: 1px solid #4a3f17;
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas:
    "featured bracket"
    "grid bracket";
  gap: 20px;
  padding: 20px 24px 32px;
  max-width: 1680px;
  margin: 0 auto;
}
.featured {
  grid-area: featured;
  min-width: 0;
}
.bracket-side {
  grid-area: bracket;
  min-width: 0;
}
.grid-section {
  grid-area: grid;
  min-width: 0;
}

/* ---------- featured ---------- */
.featured-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px 20px;
  margin-bottom: 12px;
}
.featured-head > div:first-child,
.featured-head p,
.featured-head h1 {
  flex: 1 1 100%;
}
.featured-head h1 {
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: -0.5px;
}
.rotation {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
  flex: 1 1 100%;
}
.rotation-bar {
  flex: 0 1 160px;
  height: 3px;
  background: var(--line);
  overflow: hidden;
}
.rotation-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 1s linear;
}
:root[data-motion="reduced"] .rotation-bar span {
  transition: none;
}
.rotation button {
  border: 1px solid var(--line);
  background: transparent;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  letter-spacing: 1px;
}
.featured-body {
  display: grid;
  grid-template-columns: minmax(0, min(60vh, 600px)) minmax(220px, 1fr);
  gap: 20px;
  align-items: start;
}
.featured-stage {
  min-width: 0;
}
.featured-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.eval-readout,
.decision {
  display: grid;
  gap: 4px;
}
.eval-readout strong {
  font-size: 26px;
  font-family: "Chakra Petch", Chakra, Arial, sans-serif;
}
.decision strong {
  font-size: 22px;
  color: var(--green);
}
.decision .muted,
.eval-readout .muted {
  font-size: 12px;
}
.moves-heading {
  display: flex;
  justify-content: space-between;
}
.moves {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
}
.move-pair {
  display: grid;
  grid-template-columns: 3.2em 1fr 1fr;
  padding: 3px 0;
  border-bottom: 1px solid #1b1f26;
}
.move-number {
  color: var(--muted);
}
.move-pair .latest {
  color: var(--green);
  font-weight: 700;
}
.empty-moves {
  color: var(--muted);
}
.game-link {
  font-size: 13px;
}

/* ---------- players, clocks, boards ---------- */
.player-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  min-width: 0;
}
.player-bar .pname {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.player-bar .seed {
  font-size: 11px;
  color: var(--muted);
}
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex: none;
  border: 1px solid #555;
}
.swatch.white {
  background: #f1f1f1;
}
.swatch.black {
  background: #111;
}
.clock {
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 4px;
  background: #1c2028;
  font-family: Consolas, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.player-bar.to-move .clock {
  background: var(--green);
  color: #0b0d11;
  font-weight: 700;
}
.board-row {
  display: flex;
  gap: 6px;
}
.eval-rail {
  position: relative;
  width: 14px;
  flex: none;
  border: 1px solid #333;
  overflow: hidden;
}
.eval-rail .eval-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: #f1f1f1;
}
.eval-rail {
  background: #222;
}
.eval-rail[data-available="false"] {
  opacity: 0.35;
}
.eval-rail.mini {
  width: 6px;
}
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  flex: 1;
  min-width: 0;
  border: 1px solid #535e4c;
  container-type: inline-size;
}
.sq {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light-sq);
  color: #080b09;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", serif;
  font-size: 9.5cqi;
  line-height: 1;
  text-shadow: 0 1px 1px #fff5;
  user-select: none;
}
.sq.dark {
  background: var(--dark-sq);
}
.sq.wp {
  color: #fff;
  text-shadow:
    0 1px 1px #000,
    1px 0 #000,
    -1px 0 #000;
}
.sq.last {
  box-shadow: inset 0 0 0 3px var(--green);
}
.board.mini .sq.last {
  box-shadow: inset 0 0 0 2px var(--green);
}

/* ---------- bracket sidebar ---------- */
.bracket-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  align-self: start;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 12px;
}
.bracket-head h2 {
  font-size: 20px;
}
.round-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.round-tabs button {
  border: 1px solid var(--line);
  background: transparent;
  padding: 4px 9px;
  border-radius: 4px;
  font-size: 12px;
}
.round-tabs button.live {
  border-color: var(--red);
}
.round-tabs button[aria-pressed="true"] {
  background: var(--green);
  color: #0b0d11;
  border-color: var(--green);
  font-weight: 700;
}
.round-matches {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: grid;
  gap: 8px;
}
.bm {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1217;
  font-size: 13px;
}
.bm.live {
  border-color: var(--red);
}
.bm.done {
  opacity: 0.85;
}
.bm-meta {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
}
.bm.live .bm-meta {
  color: var(--red);
}
.bm-row {
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}
.bm-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.bm-row .seed {
  min-width: 2.2em;
  font-size: 10px;
  color: var(--muted);
}
.bm-row b {
  margin-left: auto;
}
.bm-row.winner {
  color: var(--green);
  font-weight: 700;
}
.bm-row.out {
  color: var(--muted);
}
.bm-row .placeholder {
  color: var(--muted);
  font-style: italic;
}
.bm-watch {
  position: absolute;
  right: 8px;
  top: 6px;
  border: 1px solid var(--red);
  background: transparent;
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 11px;
}
.champion-line {
  margin: 12px 0 0;
  color: #ffcf3a;
  font-weight: 700;
}

/* ---------- grid ---------- */
.grid-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.grid-head h2 {
  font-size: 20px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.grid[data-count="1"],
.grid[data-count="2"] {
  grid-template-columns: repeat(auto-fill, minmax(260px, 340px));
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 10px;
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.2s;
}
.tile:hover {
  border-color: #4a525e;
}
.tile.featured-tile {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}
.tile-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
  text-transform: uppercase;
}
.tile-round {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-state[data-live="true"] {
  color: var(--red);
  font-weight: 700;
}
.player-bar.mini {
  padding: 5px 0;
  font-size: 12px;
}
.player-bar.mini .clock {
  padding: 1px 6px;
  font-size: 11px;
}
.tile-last {
  margin: 6px 0 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid-empty {
  color: var(--muted);
}
footer {
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "featured"
      "grid"
      "bracket";
  }
  .bracket-side {
    position: static;
    max-height: none;
  }
}
@media (max-width: 760px) {
  .topbar,
  .layout,
  footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .exhibition-note {
    padding: 8px 16px;
  }
  .bracket-link {
    margin-left: 0;
  }
  .featured-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }
  .grid[data-count="1"],
  .grid[data-count="2"] {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}
