/* An instrument, read under a countdown -- not a page to browse.
   Heroes are identified by portrait, because that is how players know them;
   names are the fallback, not the primary. */

:root {
  --ground: #171320;
  --panel: #221c30;
  --panel-lift: #2c2540;
  --line: #372e4d;
  --ink: #ede9f5;
  --muted: #9a93ae;

  --mine: #4fd1c5;
  --theirs: #f2a25c;
  /* Reserved for the one slot the opponent's post-ban cannot touch. */
  --protected: #c9a227;

  --slot: 74px;
  --radius: 3px;
}

* { box-sizing: border-box; }

/* `display: grid` on a section outranks the [hidden] attribute, so sections
   meant to be hidden would otherwise stay on screen. */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 "Barlow", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h2 {
  margin: 0;
  font-family: "Barlow Semi Condensed", "Barlow", sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

button, select, input {
  font: inherit;
  color: inherit;
  border-radius: var(--radius);
}

button {
  background: var(--panel-lift);
  border: 1px solid var(--line);
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
button:hover { background: var(--line); }

select, input[type="search"] {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
}

:where(button, select, input, [tabindex]):focus-visible {
  outline: 2px solid var(--mine);
  outline-offset: 2px;
}

/* ---------- setup ---------- */

.setup {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 0.7rem 1rem;
}

.setup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: flex-end;
  max-width: 1180px;
  margin: 0 auto;
}

.setup label {
  display: grid;
  gap: 0.2rem;
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

.setup-actions { margin-left: auto; display: flex; gap: 0.5rem; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.1rem 1rem 3rem;
  display: grid;
  gap: 1.1rem;
}

/* ---------- board ---------- */

.board {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.4rem;
  align-items: start;
}

.board-main { display: grid; gap: 0.7rem; min-width: 0; }

.row-label {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  width: 4.2rem;
  flex: none;
  padding-top: 0.2rem;
}

.prebans, .side { display: flex; align-items: flex-start; gap: 0.6rem; }

.slots, .preban-slots { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.slot {
  width: var(--slot);
  display: grid;
  gap: 0.25rem;
  justify-items: center;
}

.slot-face {
  width: var(--slot);
  height: var(--slot);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  background-size: cover;
  background-position: center;
  position: relative;
}

.side-mine .slot-face.filled { border-color: var(--mine); }
.side-theirs .slot-face.filled { border-color: var(--theirs); }

/* The third pick of each side cannot be post-banned: a rule worth seeing. */
.slot.protected .slot-face { border-color: var(--protected); border-width: 2px; }
.slot.protected .slot-order::after {
  content: " safe";
  color: var(--protected);
}

.slot.active .slot-face {
  border-style: dashed;
  border-color: var(--ink);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 50% { border-color: var(--muted); } }
@media (prefers-reduced-motion: reduce) { .slot.active .slot-face { animation: none; } }

.slot-order {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.slot-name {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.74rem;
  line-height: 1.15;
  text-align: center;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.slot-face.banned { filter: grayscale(1) brightness(0.45); }
.slot-face.banned::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom right, transparent 47%, #e05a5a 47%,
              #e05a5a 53%, transparent 53%);
}

.preban-slots .slot-face { width: 52px; height: 52px; }
.preban-slots .slot { width: 52px; }

/* ---------- the reading ---------- */

.reading {
  width: 210px;
  padding: 0.9rem 1rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: right;
}

.reading-value {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: 3.6rem;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  color: var(--mine);
}

.reading-caption {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.gauge {
  margin-top: 0.7rem;
  height: 4px;
  background: var(--ground);
  border-radius: 2px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 50%;
  background: var(--mine);
  transition: width 0.25s ease;
}

@media (prefers-reduced-motion: reduce) { .gauge-fill { transition: none; } }

/* ---------- advice ---------- */

.advice { display: grid; gap: 0.6rem; }

.advice-head { display: flex; gap: 0.9rem; align-items: baseline; flex-wrap: wrap; }
.advice-note { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* While a new board is being searched, the old answer stays readable but is
   visibly not the current one. */
.advice.pending .suggestions { opacity: 0.45; transition: opacity 0.12s 0.15s; }
@media (prefers-reduced-motion: reduce) { .advice.pending .suggestions { transition: none; } }

.suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.sug {
  flex: none;
  width: 92px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem;
  display: grid;
  gap: 0.25rem;
  justify-items: center;
  cursor: pointer;
  text-align: center;
}

.sug:hover, .sug:focus-visible { border-color: var(--mine); }
.sug:first-child { border-color: var(--mine); background: var(--panel-lift); }

.sug img { width: 62px; height: 62px; border-radius: var(--radius); display: block; }

.sug-value {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.sug-gain {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sug-name {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.72rem;
  line-height: 1.1;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* With look-ahead each card also carries the partner of a double pick and
   the opponent's expected answer, as small portraits: players read faces
   faster than names. */
.suggestions.answered .sug { width: 104px; align-content: start; }

.sug-line {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
}
.sug-line > span { margin-right: 0.15rem; }
.sug .sug-line img { width: 26px; height: 26px; }
.sug-line.with img { outline: 1px solid var(--mine); outline-offset: -1px; }
.sug-line.vs img { outline: 1px solid var(--theirs); outline-offset: -1px; }

/* ---------- post-ban ---------- */

.postban { display: grid; gap: 0.6rem; }
.postban-note { margin: 0; color: var(--muted); font-size: 0.92rem; max-width: 62ch; }

.matrix-wrap { overflow-x: auto; }

.matrix {
  border-collapse: collapse;
  font-family: "Barlow Semi Condensed", sans-serif;
  font-variant-numeric: tabular-nums;
}

.matrix th, .matrix td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  text-align: right;
  white-space: nowrap;
}

.matrix th { color: var(--muted); font-weight: 500; text-align: left; }
.matrix thead th { text-align: right; }
.matrix tr.best th, .matrix tr.best td { background: var(--panel-lift); }
.matrix tr.best th:first-child { color: var(--ink); }
.matrix .pick { color: var(--mine); }
/* Rows whose ban target the model has never learned: the numbers are real
   arithmetic on a board it cannot read, so they are shown but pushed back. */
.matrix tr.blind th, .matrix tr.blind td { color: var(--muted); opacity: 0.55; }

/* ---------- picker ---------- */

.picker { display: grid; gap: 0.6rem; }

.picker-head { display: flex; gap: 0.8rem; align-items: baseline; flex-wrap: wrap; }
.picker-head input { flex: 1; min-width: 180px; max-width: 320px; }

.picker-count {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 0.4rem;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.hero {
  padding: 0;
  border: 1px solid transparent;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
}

.hero img { width: 100%; height: 100%; display: block; border-radius: var(--radius); }
.hero:hover, .hero:focus-visible { border-color: var(--ink); }
.hero[disabled] { opacity: 0.22; cursor: not-allowed; }

/* The model has never split on these: pickable, but it cannot judge them. */
.hero.unmodelled img { filter: saturate(0.25) brightness(0.8); }
.hero.unmodelled::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 2px var(--ground);
}

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 760px) {
  /* The five-slot row is the thing to read, so it must never wrap: put the
     side label above it instead of beside it, and size the slots to fit. */
  :root { --slot: 58px; }
  .board { grid-template-columns: 1fr; }
  /* On a phone the reading comes first -- it is the one number to glance at. */
  .reading { order: -1; width: 100%; text-align: left; }
  .prebans, .side { flex-direction: column; gap: 0.3rem; }
  .row-label { width: auto; padding-top: 0; }
  .slots { flex-wrap: nowrap; gap: 0.35rem; }
  .setup-actions { margin-left: 0; }
}
