/* Widget only. The page around it — nav, copy, calls to action — belongs to the host page. */

/* Vendored, never a CDN: a webfont request hands the visitor's IP to whoever serves it, on the
   page arguing for the opposite. Licences sit beside the files. */
/* Latin subsets with no unicode-range: a glyph they lack (the arrows) falls through to the next
   family in the stack. */
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('fonts/bricolage-grotesque-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #0a0d0c;
  --bg2: #0f1413;
  --panel: #101614;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .12);
  --ink: #e9efe9;
  --dim: #979a99;
  --dimmer: #46524c;
  --you: #b6ff3a;
  --server: #ff8a42;
  --cyan: #54d8ff;
  --tile: #161d1a;
  --tile-hi: #1e2723;
  --valuable: #1d2c22;
  --water: #0c1c24;
  --radius: 4px;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --disp: 'Bricolage Grotesque', system-ui, sans-serif;
  /* seq, ts, actor, event, subject, outcome. In ch, so the header and the rows only line up
     while they share a font size — that is why both sit inside .logwrap and neither sets one. */
  --cols: 3ch 12ch 6ch 8ch 14ch auto;
  /* --dimmer reads 2.43:1 on the log, under AA, and seq and ts carry the "nothing was dropped"
     claim. ponytail: its own token, since --dimmer's other uses are dots and the dead LED. */
  --log-dim: #909391;
}

/* No reset, no body rule and no page container: this file styles the widget and nothing
   around it, so every rule below is reachable only through the widget's own markup. */

/* Which means the face is set here and never inherited from the host page: the log's columns
   are sized in ch and line up in a monospace and nothing else. */
.widget,
.leaderboard,
.note {
  font-family: var(--mono);
  line-height: 1.5;
}

.widget {
  display: grid;
  /* The console takes the larger share, and the widget more width than the page's prose
     column: one log line is ~81ch. */
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  border: 1px solid var(--line2);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .9);
}

.pane { padding: 22px }
.pane.left { border-right: 1px solid var(--line) }
.pane.right { background: linear-gradient(180deg, rgba(84, 216, 255, .03), transparent 30%), var(--panel) }
.paneTop { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px }
.paneLabel { font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--dim) }

/* Relative so the start control can sit over the board it starts. */
.board { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; aspect-ratio: 8/6 }

#start, .result {
  position: absolute;
  /* The tiles are position: relative and come later in the DOM, so without this they paint
     over the control and only the grid gaps show through it. */
  z-index: 1;
  inset: 0;
  margin: auto;
  width: max-content;
  height: max-content;
}

.result { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 18px; background: rgba(10, 13, 12, .92); border: 1px solid var(--line2); border-radius: var(--radius) }
.result .verdict { font-family: var(--disp); font-weight: 800; font-size: 22px; letter-spacing: -.01em; color: var(--ink) }

#start, .result button {
  padding: 11px 18px;
  /* Named because a button does not inherit font-family from .widget at all: left alone it
     renders in the UA's Arial on both pages. */
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .04em;
  color: var(--bg);
  background: var(--you);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

#start:hover, .result button:hover { background: #c6ff52 }

.tile {
  position: relative;
  border-radius: var(--radius);
  background: var(--tile);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .12s, background .2s, border-color .2s;
  animation: pop .5s cubic-bezier(.2, .8, .2, 1) both;
}

/* Only a tile that could still be taken, and only its background: an owned or water tile
   carries information hover must not repaint, and the border belongs to legality. */
.board:not(.inert) .tile:not(.you):not(.server):not(.water):hover { background: var(--tile-hi); transform: translateY(-1px) }
.tile.valuable { background: var(--valuable) }
.tile.water { background: var(--water); cursor: not-allowed; border-color: rgba(84, 216, 255, .10) }
.tile.legal { border-color: rgba(182, 255, 58, .45); box-shadow: inset 0 0 0 1px rgba(182, 255, 58, .12) }
.tile.you { background: linear-gradient(145deg, #9be028, #c6ff52); border-color: #d8ff7a; box-shadow: 0 0 14px -4px var(--you) }
.tile.server { background: linear-gradient(145deg, #e9722c, #ff9a52); border-color: #ffb07a; box-shadow: 0 0 14px -4px var(--server) }
/* The second channel. Your tiles and the opponent's sit 1.89:1 apart in luminance, so hue
   is doing all the work until the dot's shape tells them apart. */
.tile .dot { position: absolute; inset: 0; margin: auto; width: 5px; height: 5px; border-radius: 99px; background: var(--dimmer) }
.tile.you .dot, .tile.server .dot { width: 7px; height: 7px; background: rgba(0, 0, 0, .55) }
.tile.server .dot { border-radius: 2px }
.tile.water .dot { width: 9px; height: 2px; border-radius: 1px; background: var(--cyan); opacity: .45 }
/* Points get a channel of their own, a ring that survives either owner's colour. */
.tile.valuable .dot { outline: 1.5px solid var(--dim); outline-offset: 2px }
.tile.valuable.you .dot, .tile.valuable.server .dot { outline-color: rgba(0, 0, 0, .55) }

/* The socket is gone or the game is decided: the board stops pretending it is interactive. */
.board.inert .tile { cursor: default; opacity: .55 }

.stats { display: flex; gap: 22px; margin-top: 18px; align-items: flex-end }
.stat { display: flex; flex-direction: column; gap: 2px }
.stat .n { font-family: var(--disp); font-weight: 800; font-size: 38px; line-height: 1; letter-spacing: -.02em }
.stat.you .n { color: var(--you) }
.stat.server .n { color: var(--server) }
.stat .l { font-size: 12.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim) }
.turnpill { margin-left: auto; font-size: 14px; color: var(--dim); border: 1px solid var(--line2); padding: 6px 12px; border-radius: 99px }
.turnpill b { color: var(--ink) }
.turnpill.thinking { border-color: var(--server); animation: blink 1.2s infinite }

.conn { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--dim); margin-bottom: 4px }
.led { width: 7px; height: 7px; border-radius: 99px; background: var(--you); box-shadow: 0 0 8px var(--you); animation: blink 2s infinite }
.led.off { background: var(--dimmer); box-shadow: none; animation: none }
.endpoint { font-size: 13.5px; color: var(--cyan); opacity: .8; word-break: break-all; margin-bottom: 16px }

.metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px }
.metric { border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 10px; background: rgba(0, 0, 0, .25) }
.metric .mn { font-family: var(--disp); font-weight: 700; font-size: 23px; letter-spacing: -.02em }
.metric .mn small { font-size: 13px }
.metric .ml { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-top: 2px }
.metric.lag .mn { color: var(--cyan) }

/* One grid column, so the header is exactly as wide as the rows. A plain 1fr rather than
   max-content, which would size this to the widest row instead of letting it wrap. */
.logwrap { border: 1px solid var(--line); border-radius: var(--radius); background: #070a09; height: 252px; overflow-y: auto; font-size: 14px; display: grid; grid-template-columns: 1fr; align-content: start }
.logwrap::-webkit-scrollbar { width: 6px; height: 6px }
.logwrap::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 9px }
.loghead { position: sticky; top: 0; z-index: 1; color: var(--log-dim); background: #070a09; padding: 8px 11px 5px; border-bottom: 1px solid var(--line) }
.log { padding: 8px 11px; display: flex; flex-direction: column; gap: 3px }

.loghead .row, .ln { display: grid; grid-template-columns: var(--cols); gap: 7px; white-space: nowrap }
.ln { animation: slidein .3s ease both }
.ln .sq, .ln .ts { color: var(--log-dim) }
/* Sized for tile= and state=; a match id is longer and rare, so it ellipsises rather
   than pushing the outcome — the column a reader came for — off the panel. */
.ln .su { overflow: hidden; text-overflow: ellipsis }
.ln .ev { color: var(--dim) }
/* The actor column carries the side's colour, so the outcome never has to encode who acted. */
.ln.client .ac { color: var(--you) }
.ln.ai .ac { color: var(--server) }
.ln.server .ac { color: var(--cyan) }
/* The only cell allowed to wrap, and the reason nothing in this panel scrolls sideways: a
   gloss with no room left folds onto a second row rather than widening the line. */
.ln .ou { white-space: normal }
.ln .ou.rejected, .ln .ou.closed, .ln .ou.unshackled { color: var(--server) }
.ln .ou.accepted { color: var(--cyan); opacity: .85 }

/* Outside the widget's two-pane grid on purpose: a strip here moves neither the board's
   column nor the log's fixed height. */
.leaderboard { margin-top: 22px }
.leaderboard .paneLabel { margin-bottom: 10px }
.leaders { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px }
/* Scoped to its container, not bare: .lead is also the apex's hero paragraph, and a bare rule
   here turns that paragraph into a three-column grid. */
.leaders .lead { display: grid; grid-template-columns: 2ch 1fr auto; gap: 9px; font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 5px }
.leaders .lead .rk { color: var(--log-dim) }
/* Ellipsis rather than a wider column: a longer word on the list must not widen the page. */
.leaders .lead .hd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.leaders .lead .pt { color: var(--you) }
.leaders .empty { color: var(--dim); font-size: 14px }

.note { margin-top: 24px; font-size: 14px; line-height: 1.7; color: var(--dim); max-width: 62ch }
/* Both margins, not only the bottom: the host page owns the reset and may not zero them. */
.note p { margin: 0 0 8px }
.note b { color: var(--ink); font-weight: 400 }

@keyframes pop { from { opacity: 0; transform: scale(.6) } to { opacity: 1; transform: scale(1) } }
@keyframes slidein { from { opacity: 0; transform: translateX(-6px) } to { opacity: 1; transform: none } }
@keyframes blink { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* The LED blinks forever and the board pops in 48 tiles at once, on a page a visitor
   did not open to watch an animation. */
@media (prefers-reduced-motion: reduce) {
  .tile, .ln, .led, .turnpill { animation: none }
  .tile { transition: none }
}

/* Stacks well before it has to: side by side, the console's columns stop fitting just under
   1120px, measured (1100 overflows the log by 7px, 1120 and up are clean). The threshold moves
   with .logwrap's font-size, so re-measure here before changing it. */
@media (max-width: 1140px) {
  .widget { grid-template-columns: minmax(0, 1fr) }
  .pane.left { border-right: 0; border-bottom: 1px solid var(--line) }
}

/* Phone width: seq and ts give way, and the outcome takes a row of its own under the rest, so
   the column a reader came for is never the one squeezed to a sliver. */
@media (max-width: 560px) {
  .logwrap { --cols: 6ch 8ch minmax(0, 1fr) }
  .loghead .row > :nth-child(-n+2), .ln > :nth-child(-n+2) { display: none }
  .loghead .row > :last-child, .ln .ou { grid-column: 1 / -1 }
  .ln { padding-bottom: 4px; border-bottom: 1px solid var(--line) }
}
