/* ------------------------------------------------------------------ design system
   Ink panels over a storm-lit arena. One sans family; every number is tabular.
   Type scale 10 / 11 / 13 / 15 px; spacing on a 4 px step; one radius per size class. */
:root {
  --ink: #0b1420;                          /* page, gaps between envs, solid bars */
  --panel: rgba(11, 20, 32, .74);          /* cards floating over the scene */
  --raise: rgba(255, 255, 255, .11);       /* active button, empty track */
  --line: rgba(255, 255, 255, .14);
  --text: #eef3f8;
  --dim: #a3b3c6;
  --faint: #6f8095;
  --star: #f5c84b;                         /* the learner */
  --win: #5fd38d; --loss: #ff8177; --draw: #e6b450;
  --kind-idle: #8a98a9; --kind-self: #f5c84b; --kind-past: #b693ff;
  --kind-pursuer: #ff9d5c; --kind-scripted: #4fd1c5;
  --t-xs: 10px; --t-sm: 11px; --t-md: 13px; --t-lg: 15px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 20px;
  --r-sm: 3px; --r-md: 6px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); overflow: hidden;
  font: var(--t-md)/1.3 var(--sans); font-variant-numeric: tabular-nums; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------------ status strip (top) */
#strip { position: fixed; left: 0; right: 0; top: 0; display: flex; flex-wrap: wrap; align-items: center;
  gap: 0 var(--s4); padding: 7px var(--s3); background: var(--ink);
  font-size: var(--t-md); color: var(--dim); white-space: nowrap; }
#strip .run { display: flex; align-items: center; gap: var(--s2); color: var(--text); font-weight: 600; }
#dot { width: 7px; height: 7px; border-radius: 50%; background: var(--loss); flex: none; }
#dot.live { background: var(--win); } #dot.wait { background: var(--draw); }
#strip b { color: var(--text); font-weight: 600; }
#strip [hidden] { display: none; }

/* ------------------------------------------------------------------ env card
   One line: learner (left) against opponent (right), chips in the colours of their models.
   Under it one bar split between the two colours: the learner's share is its outlook. */
#huds { position: fixed; inset: 0; pointer-events: none; }
.card { position: absolute; box-sizing: border-box; padding: 7px 9px 8px; background: var(--panel);
  border-radius: var(--r-md); pointer-events: auto; cursor: pointer; }
.card.focus { cursor: default; padding: var(--s3); }
/* focus mode: closed it is a slim strip (matchup, bar, one line), open it adds the numbers.
   Only its head takes the pointer (tap = open / close), so drags below reach the scene. */
.card.focus { pointer-events: none; }
.card.focus .match, .card.focus .outlook, .card.focus .meta { pointer-events: auto; cursor: pointer; }
.card.focus:not(.open) { padding: 8px 10px; }

.match { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); line-height: 16px; }
.side { display: flex; align-items: center; gap: 5px; min-width: 0; }
.chip { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.star { color: var(--star); font-size: var(--t-sm); }
.side .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .elo { color: var(--dim); }
.side.opp .chip { order: 9; }
.vs { color: var(--faint); font-size: var(--t-xs); }
.card.narrow .me .name, .card.narrow .vs { display: none; }
.card.open .match { font-size: var(--t-lg); line-height: 20px; }
.card.open .chip { width: 10px; height: 10px; }

.outlook { margin-top: 6px; }
.track { position: relative; height: 5px; border-radius: 3px; overflow: hidden; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; box-sizing: border-box;
  border-right: 2px solid #fff; transition: width .35s linear; }
.fill.drawish { background-image: repeating-linear-gradient(135deg, rgba(11, 20, 32, .55) 0 2px, transparent 2px 5px); }
.tick { position: absolute; top: 0; bottom: 0; width: 1px; margin-left: -.5px; background: rgba(255, 255, 255, .7); }
.outlook.off .track { background: var(--raise) !important; }
.outlook.off .fill, .outlook.off .tick, .tick.lose { display: none; }
.card.open .tick.lose:not(.none) { display: block; }
.axis { display: none; position: relative; height: 13px; margin-top: 2px; font-size: var(--t-xs); color: var(--dim); line-height: 13px; }
.axis span { position: absolute; top: 0; white-space: nowrap; }
.axis .hi { right: 0; }
.card.open .track { height: 7px; border-radius: 4px; }
.card.open .axis { display: block; }
[hidden] { display: none !important; }

.meta { display: flex; justify-content: space-between; gap: var(--s2); margin-top: 5px;
  font-size: var(--t-xs); line-height: 12px; color: var(--dim); white-space: nowrap; }
.meta .what { overflow: hidden; text-overflow: ellipsis; }
.result.win { color: var(--win); } .result.loss { color: var(--loss); } .result.draw { color: var(--draw); }
.card.narrow .meta { display: none; }
.card.focus .meta { font-size: var(--t-sm); }
.card.open .meta { margin-top: 2px; }
.meta .more { display: none; flex: none; margin: -4px -4px -4px 0; padding: 4px; border: 0; background: none;
  color: var(--dim); font: 600 var(--t-xs)/12px var(--sans); letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.meta .more::after { content: ''; display: inline-block; width: 5px; height: 5px; margin: 0 1px 2px 5px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.card.open .more::after { transform: rotate(-135deg); margin-bottom: -1px; }
.meta .more:focus-visible { outline: 2px solid var(--star); outline-offset: -2px; border-radius: var(--r-sm); }
.card.focus .more { display: block; }
.card.focus .meta .what { flex: 1; }

/* the open card: the same strip, plus the numbers behind it */
.detail { display: none; }
.card.open .detail { display: block; margin-top: var(--s3); padding-top: var(--s3);
  border-top: 1px solid var(--line); font-size: var(--t-sm); }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 3px var(--s3); color: var(--dim); }
.stats b { color: var(--text); font-weight: 600; }
.stats small { font-size: var(--t-xs); color: var(--dim); margin-left: 6px; }
.players { display: grid; grid-template-columns: auto 56px minmax(0, 1fr) auto; align-items: center;
  gap: 4px var(--s2); margin-top: var(--s3); }
.players .who { display: flex; align-items: center; gap: 5px; color: var(--text); font-weight: 600; }
.players .hp { display: flex; align-items: center; gap: 5px; }
.players .hp i { flex: 1; height: 3px; border-radius: 2px; background: var(--raise); overflow: hidden; }
.players .hp i u { display: block; height: 100%; width: 0; background: var(--win); }
.players .hp span { min-width: 2.2em; }
.players .item { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .state { color: var(--dim); text-align: right; white-space: nowrap; }
.note { margin-top: var(--s3); font-size: var(--t-xs); color: var(--faint); white-space: normal; line-height: 1.4; }

/* ------------------------------------------------------------------ bottom bar */
#bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 2px; padding: 6px var(--s2);
  justify-content: center; background: var(--ink); }
#bar button { position: relative; flex: 0 1 36px; min-width: 26px; height: 32px; padding: 0; border: 0;
  border-radius: var(--r-md); background: none; color: var(--faint); font: 600 var(--t-md)/1 var(--sans);
  font-variant-numeric: tabular-nums; cursor: pointer; }
#bar button.word { flex: none; padding: 0 var(--s3); }
#bar button.gap { margin-right: var(--s3); }
#bar button.on { background: var(--raise); color: var(--text); }
#bar button:focus-visible { outline: 2px solid var(--star); outline-offset: -2px; }
#bar button .kind { position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: transparent; }

#msg { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: var(--t-lg); pointer-events: none; text-align: center; padding: 16px; }
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
@media (max-width: 560px) {            /* a phone: the open card keeps to the numbers */
  .card.open { padding: 10px; }
  .card.open .detail { margin-top: var(--s2); padding-top: var(--s2); }
  .card.open .players { margin-top: var(--s2); gap: 3px 6px; grid-template-columns: auto 44px minmax(0, 1fr) auto; }
  .card.open .note { display: none; }
}

/* ------------------------------------------------------------------ quality toggle, notices */
#bar button.quality { margin-left: var(--s3); min-width: 52px; color: var(--dim); }
#bar button.quality::before { content: 'Quality '; color: var(--faint); font-weight: 400; }
@media (max-width: 560px) {
  #bar { gap: 1px; padding-left: var(--s1); padding-right: var(--s1); }
  #bar button.word { padding: 0 var(--s2); }
  #bar button.gap { margin-right: var(--s1); }
  #bar button.quality { margin-left: var(--s1); min-width: 0; }
  #bar button.quality::before { content: ''; }
}
#bar button.about { flex: none; width: 28px; margin-left: var(--s1); color: var(--dim); font-style: italic; font-family: Georgia, 'Times New Roman', serif; }
/* ------------------------------------------------------------------ about box */
.about { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(5, 9, 15, .6); -webkit-user-select: text; user-select: text; }
.about .box { box-sizing: border-box; width: 100%; max-width: 420px; max-height: 100%; overflow: auto; padding: var(--s4);
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md); font-size: var(--t-md); line-height: 1.45; }
.about h2 { margin: 0 0 var(--s2); font-size: var(--t-lg); }
.about p { margin: 0 0 var(--s3); color: var(--dim); }
.about dl { margin: 0 0 var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.about dt { font-size: var(--t-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.about dd { margin: 2px 0 var(--s3); color: var(--text); }
.about a { color: var(--star); }
.about button { height: 32px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md); background: var(--raise); color: var(--text);
  font: 600 var(--t-md)/1 var(--sans); cursor: pointer; }
#toast { position: fixed; left: 50%; bottom: 58px; transform: translateX(-50%); padding: var(--s2) var(--s3);
  background: var(--panel); border-radius: var(--r-md); color: var(--text); font-size: var(--t-sm);
  pointer-events: none; max-width: 90vw; text-align: center; }

/* ------------------------------------------------------------------ end-of-game banner
   An ink plaque with gold rules, the verdict in the winner's colour. Sized in em: hud.js sets
   the font size from the env's cell, so it scales from a grid cell to the focus view. */
.verdict { position: absolute; transform: translate(-50%, -50%); pointer-events: none; text-align: center;
  white-space: nowrap; padding: .34em 1.1em .3em; background: linear-gradient(180deg, rgba(11, 20, 32, .9), rgba(11, 20, 32, .78));
  border-top: .07em solid var(--star); border-bottom: .07em solid var(--star);
  box-shadow: 0 .12em .7em rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(245, 200, 75, .18);
  clip-path: polygon(.55em 0, calc(100% - .55em) 0, 100% 50%, calc(100% - .55em) 100%, .55em 100%, 0 50%); }
.verdict .title { font-weight: 800; font-size: 1em; line-height: 1.05; letter-spacing: .14em; margin-right: -.14em;
  color: var(--team); text-shadow: 0 .05em 0 var(--team-deep), 0 .1em .3em rgba(0, 0, 0, .7); }
/* the verdict in the viewer's block letters (blockfont.js): 7 dots tall, the shadow half a dot deep */
.verdict .title.block { letter-spacing: 0; margin-right: 0; text-shadow: none; }
.verdict .title.block svg { display: block; height: .8em; width: auto; margin: .12em auto .08em; overflow: visible;
  filter: drop-shadow(0 .1em .15em rgba(0, 0, 0, .7)); }
.verdict .title.block .face { fill: var(--team); } .verdict .title.block .deep { fill: var(--team-deep); }
.verdict .who { margin-top: .5em; font-size: max(var(--t-xs), .3em); font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--dim); }
.verdict.in { animation: verdict-in .42s cubic-bezier(.2, 1.4, .4, 1) both; }
.verdict.out { opacity: 0; transition: opacity .45s linear; }
@keyframes verdict-in { from { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@media (prefers-reduced-motion: reduce) { .verdict.in { animation: none; } .verdict.out { transition: none; } }
