/* 100 Turns to Treasure — the in-game screen (src/ui/gamescreen.js).
   Builds on the tokens and components of base.css. */

/* ---------- frame ----------
   Phone: top bar, turn counter, map, then the panel scrolling beneath; the page itself never scrolls.
   Wide: the square map fills the height on the left, counter and panel on the right. */
.game {
  --top-h: 48px;
  --pad: var(--s-3);
  --gap: var(--s-3);
  --side-min: 360px;
  /* full width, but always leaving the panel beneath a workable strip */
  --map: min(100vw, max(50vh, 100vh - 420px));
  --map: min(100vw, max(50dvh, 100dvh - 420px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--top-h) auto auto minmax(0, 1fr);
  grid-template-areas: "top" "hud" "stage" "side";
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.game-top { grid-area: top; min-height: 0; padding: 0 var(--s-1) 0 var(--pad); gap: var(--s-2); }
.game-top h1 { font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-rule { color: var(--text-2); font-size: var(--fs-xs); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-tags { display: none; align-items: center; gap: 6px; }
.game-top .topbar-actions { gap: 0; }

/* short and wide (a phone on its side, a small window zoomed to 200%): map and panel side by side, as on a wide screen */
@media (min-width: 480px) and (max-width: 819px) and (min-aspect-ratio: 5/4) {
  .game {
    --map: min(calc(100vh - var(--top-h)), calc(100vw - 300px));
    --map: min(calc(100dvh - var(--top-h)), calc(100vw - 300px));
    grid-template-columns: var(--map) minmax(0, 1fr);
    grid-template-rows: var(--top-h) auto minmax(0, 1fr);
    grid-template-areas: "top top" "stage hud" "stage side";
  }
}
@media (min-width: 820px) {
  .game {
    --top-h: 56px;
    --pad: var(--s-4);
    --map: min(calc(100vh - var(--top-h) - var(--pad)), calc(100vw - var(--side-min) - var(--pad) * 2 - var(--gap)));
    --map: min(calc(100dvh - var(--top-h) - var(--pad)), calc(100vw - var(--side-min) - var(--pad) * 2 - var(--gap)));
    grid-template-columns: var(--map) minmax(var(--side-min), 640px);
    grid-template-rows: var(--top-h) auto minmax(0, 1fr);
    grid-template-areas: "top top" "stage hud" "stage side";
    justify-content: center;
    column-gap: var(--gap);
    padding: 0 var(--pad) var(--pad);
  }
  .game-top { padding: 0; }
  .game-top h1 { font-size: var(--fs-lg); }
  .game-rule { font-size: var(--fs-sm); }
}
@media (min-width: 960px) {
  .game-tags { display: flex; }
}

/* ---------- turn counter ---------- */
.hud {
  --tick: var(--cyan);
  grid-area: hud;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "turns dives" "ticks ticks";
  align-items: end;
  gap: 6px var(--s-4);
  padding: 2px var(--pad) var(--s-2);
}
.hud[data-level="low"] { --tick: var(--amber); }
.hud[data-level="critical"] { --tick: var(--coral); }
.hud-label { color: var(--text-3); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; }
.hud-turns { grid-area: turns; display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; }
.hud-row { display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; }
.hud-num {
  color: var(--tick);
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 0 22px color-mix(in srgb, var(--tick) 45%, transparent);
  transition: color var(--t-med);
}
.hud-ghost { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.hud-ghost.is-over { color: var(--coral); }
.hud-dives { grid-area: dives; display: flex; align-items: center; gap: var(--s-2); padding-bottom: 5px; }

.pips { display: inline-flex; gap: 6px; }
.pips i {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--amber);
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 181, 69, 0.45);
}
.pips i.is-used { border-color: var(--text-3); background: none; box-shadow: none; opacity: 0.7; }
.pips i.is-ghost { animation: ghost 0.7s ease-in-out infinite alternate; }

/* one tick per turn: lit = left, blinking = what the selected action would spend, dim = spent */
.ticks { grid-area: ticks; display: flex; gap: 1px; height: 10px; }
.ticks i { flex: 1 1 0; min-width: 0; border-radius: 1px; background: var(--tick); transition: background var(--t-med), opacity var(--t-med); }
.ticks i:nth-child(10n):not(:last-child) { margin-right: 2px; }
.ticks i.is-spent { background: var(--surface-3); opacity: 0.75; }
.ticks i.is-ghost { background: var(--text); animation: ghost 0.7s ease-in-out infinite alternate; }
@keyframes ghost {
  from { opacity: 1; }
  to { opacity: 0.3; }
}

/* narrow phones: the label sits above the number, so the cost preview and the dives fit beside it */
@media (max-width: 429px) {
  .hud-turns { flex-direction: column; align-items: flex-start; gap: 2px; }
}
@media (min-width: 480px) and (max-width: 819px) and (min-aspect-ratio: 5/4) {
  .hud-turns { flex-direction: column; align-items: flex-start; gap: 2px; } /* the side-by-side column is as narrow */
}
@media (min-width: 820px) and (max-height: 619px) {
  .hud { padding-inline: 0; }
}
@media (min-width: 820px) and (min-height: 620px) {
  .hud {
    gap: var(--s-2) var(--s-4);
    margin-bottom: var(--gap);
    padding: var(--s-3) var(--s-4) var(--s-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-3);
    background: linear-gradient(180deg, rgba(106, 223, 242, 0.05), transparent 80%), var(--surface-1);
    box-shadow: var(--shadow-1);
  }
  .hud-turns { flex-direction: column; align-items: flex-start; gap: var(--s-1); }
  .hud-num { font-size: 3.25rem; }
  .hud-ghost { font-size: var(--fs-md); }
  .hud-dives { flex-direction: column; align-items: flex-end; gap: 10px; padding-bottom: 10px; }
  .pips i { width: 14px; height: 14px; }
  .ticks { height: 14px; }
}

/* ---------- map ---------- */
.stage {
  grid-area: stage;
  position: relative;
  justify-self: center;
  width: var(--map);
  height: var(--map);
  background: var(--bg-0);
  overflow: hidden;
}
.game-canvas { width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.game-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.stage.is-aiming .game-canvas { cursor: crosshair; }
@media (min-width: 820px) {
  .stage { align-self: start; border-radius: var(--r-3); box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-1); }
}

.map-tip { display: grid; gap: 2px; min-width: 168px; white-space: nowrap; }
/* the magnifier: 11 cells at 14px, as src/ui/gamescreen.js draws it */
.loupe { width: 154px; height: 154px; margin-bottom: 4px; border: 1px solid var(--line-strong); border-radius: var(--r-1); }
.tip-head { color: var(--cyan); font-weight: 600; }
.tip-row { display: flex; justify-content: space-between; gap: var(--s-3); color: var(--text-2); }
.tip-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-sub { color: var(--text-3); }
.tip-rule { height: 1px; margin: 3px 0; background: var(--line-strong); }

.banner {
  position: absolute;
  top: var(--s-4);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: calc(100% - 2 * var(--s-4));
  padding: var(--s-3) var(--s-5);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  background: rgba(3, 9, 17, 0.9);
  box-shadow: var(--shadow-2);
  text-align: center;
  animation: banner-in var(--t-slow) var(--ease);
}
.banner-title { font-size: var(--fs-xl); line-height: 1.2; }
.banner-sub { color: var(--text-2); font-size: var(--fs-sm); }
.banner.is-won { border-color: var(--amber); box-shadow: var(--glow-amber), var(--shadow-2); }
.banner.is-won .banner-title { color: var(--amber); }
@keyframes banner-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
}

/* ---------- side panel ---------- */
.side {
  grid-area: side;
  position: relative; /* contains the visually-hidden text inside it, so the page itself never grows */
  container: side / inline-size;
  min-height: 0;
  --side-end: var(--s-5);
  padding: var(--s-2) var(--pad) var(--side-end);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.side-grid, .side-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-content: start; }
@media (min-width: 820px) {
  .side { --side-end: var(--s-2); margin-right: calc(var(--pad) * -1); padding: 0 var(--pad) var(--side-end) 0; scrollbar-gutter: stable; }
}
/* one column, mystery: the theories and the recovered log are consulted all game, so the briefing sits
   right under the instruments (or under the open instrument and the latest result), ahead of the idle cards */
@container side (width < 520px) {
  .side-grid.is-mystery > .side-col { display: contents; }
  .side-grid.is-mystery .context:has(.context-empty),
  .side-grid.is-mystery .summary:has(> .empty),
  .side-grid.is-mystery .briefing ~ .panel { order: 1; }
}
@container side (min-width: 520px) {
  .side-grid { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); align-items: start; }
  .side-grid > .tools, .side-grid > .coach, .side-grid > .rival { grid-column: 1 / -1; }
}

.side .panel { padding: var(--s-3); }
.side .panel > .panel-title { margin-bottom: var(--s-2); }
.side .panel-head { margin-bottom: var(--s-2); }
.empty { color: var(--text-3); font-size: var(--fs-sm); }

/* ---------- toolbar ---------- */
.tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tool {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 3px;
  min-width: 0;
  padding: 9px 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface-2);
  color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.tool:hover { background: var(--surface-3); border-color: var(--cyan-dim); }
.tool:active { transform: translateY(1px); }
.tool .icon { width: 22px; height: 22px; color: var(--cyan); }
.tool .kbd { position: absolute; top: 4px; left: 4px; min-width: 17px; height: 17px; padding: 0 3px; border-bottom-width: 1px; font-size: 10px; color: var(--text-2); }
.tool-name { display: grid; place-items: center; min-height: 2.3em; font-size: 0.6875rem; font-weight: 650; line-height: 1.15; text-align: center; text-wrap: balance; overflow-wrap: anywhere; }
.tool-cost { color: var(--text-3); font: 500 0.625rem / 1.2 var(--mono); text-align: center; }
.tool[aria-pressed="true"] { background: var(--cyan-wash); border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.tool[aria-pressed="true"] .tool-name { color: var(--cyan-strong); }
.tool--commit .icon { color: var(--amber); }
.tool--commit:hover { border-color: var(--amber); }
.tool--commit[aria-pressed="true"] { background: var(--amber-wash); border-color: var(--amber); box-shadow: var(--glow-amber); }
.tool--commit[aria-pressed="true"] .tool-name { color: var(--amber); }
.tool:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.tool:disabled:hover { background: var(--surface-2); border-color: var(--line-strong); }
/* the coach points at the instrument its step asks for */
.tool.is-coached:not([aria-pressed="true"]) { border-color: var(--success); animation: coached 1.6s ease-out infinite; }
@keyframes coached {
  from { box-shadow: 0 0 0 0 rgba(98, 214, 160, 0.55); }
  to { box-shadow: 0 0 0 9px rgba(98, 214, 160, 0); }
}

/* wide tiles: the names fit on one line */
@container side (min-width: 520px) {
  .tool-name { min-height: 0; font-size: var(--fs-xs); }
}

/* ---------- context panel ---------- */
.context { display: grid; gap: var(--s-3); border-color: var(--line-strong); }
.context-empty { color: var(--text-2); font-size: var(--fs-sm); line-height: 2; }
.context-head { display: flex; align-items: center; gap: var(--s-2); color: var(--cyan); }
.context-title { color: var(--text); font-size: var(--fs-md); }
.context-niche { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.45; }
.context-how { color: var(--text-3); font-size: var(--fs-xs); line-height: 1.45; }
.context-foot {
  display: grid;
  gap: var(--s-3);
  margin: calc(var(--s-2) * -1) calc(var(--s-3) * -1);
  padding: var(--s-2) var(--s-3);
  background: var(--surface-1);
}
/* the quote and Confirm stay in view while a panel taller than the column scrolls beneath them
   (not on short screens, where they would cover the little there is to see) */
@media (min-height: 700px) {
  .context-foot {
    position: sticky;
    bottom: calc(var(--side-end) * -1);
    z-index: 1;
    box-shadow: 0 -12px 12px -6px var(--surface-1); /* fades what scrolls under; invisible on the panel itself */
  }
}
.context-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.context-actions .btn { min-height: var(--control-h); padding-inline: var(--s-3); }
.context-actions [data-act="confirm"] { flex: 1 1 120px; }
.context-actions .btn--commit { flex-basis: 100%; min-height: 48px; padding-inline: var(--s-4) var(--s-3); }
.context .kbd { height: 20px; min-width: 20px; font-size: 10px; }
.btn--primary .kbd, .btn--commit .kbd { border-color: rgba(0, 0, 0, 0.35); background: rgba(0, 0, 0, 0.16); color: inherit; }
.confirm-text { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.35em; }
.confirm-text small { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.confirm-text small:empty { display: none; }
.btn--commit { justify-content: space-between; text-align: left; border-color: transparent; background: var(--amber); color: #2b1700; box-shadow: 0 0 20px rgba(255, 181, 69, 0.25); }
.btn--commit:hover { border-color: transparent; background: #ffc670; }

.quote {
  min-height: 38px;
  padding: 9px var(--s-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: var(--r-1);
  background: rgba(4, 10, 19, 0.55);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.quote.is-bad { border-left-color: var(--coral); color: #ffa093; font-weight: 500; }
.quote.is-flash { animation: flash 0.5s var(--ease); }
@keyframes flash {
  from { background: var(--coral-wash); box-shadow: 0 0 0 2px rgba(255, 122, 107, 0.5); }
}

.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.field-head output { color: var(--cyan-strong); font-size: var(--fs-sm); font-weight: 600; }
.presets { display: grid; grid-template-columns: 1.6fr repeat(4, minmax(0, 1fr)); gap: 6px; }
.presets .btn { padding: 0 var(--s-1); }
.field-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--s-2); }
.field-pair .segmented > label > span { padding: 0 var(--s-1); }

.algos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.algo { position: relative; display: flex; min-width: 0; }
.algo input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.algo span {
  display: flex;
  flex: 1;
  align-items: center;
  min-height: 34px;
  padding: 5px var(--s-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--bg-0);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.2;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.algo:hover span { border-color: var(--cyan-dim); color: var(--text); }
.algo input:checked + span { border-color: var(--cyan); background: var(--cyan-wash); color: var(--cyan-strong); }
.algo input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.algo-blurb { min-height: 3.9em; color: var(--text-2); font-size: var(--fs-xs); line-height: 1.45; }

/* ---------- latest result ---------- */
.summary { display: grid; gap: var(--s-2); }
.summary .panel-head, .summary > .panel-title { margin-bottom: 0; }
.summary-what { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; }
.summary-what .icon { width: 15px; height: 15px; color: var(--cyan); }
.summary-text { color: var(--text); font-size: var(--fs-sm); line-height: 1.5; }
.facts { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); }
.facts dt { color: var(--text-3); font-size: 0.625rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.facts dd { color: var(--text); font-size: var(--fs-sm); font-weight: 600; }
.spots { display: grid; gap: var(--s-1); }
.spot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label show" "value show";
  align-items: center;
  gap: 0 var(--s-2);
  padding: 6px var(--s-2) 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: rgba(4, 10, 19, 0.5);
  text-align: left;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.spot:hover, .spot:focus-visible { border-color: var(--cyan); background: var(--cyan-wash); }
.spot-label { grid-area: label; color: var(--text-3); font-size: 0.625rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.spot-value { grid-area: value; color: var(--text); font-size: var(--fs-sm); font-weight: 600; }
.spot-show { grid-area: show; display: inline-flex; align-items: center; gap: 5px; color: var(--cyan); font-size: var(--fs-xs); font-weight: 600; }
.spot-show .icon { width: 15px; height: 15px; }

/* ---------- briefing ---------- */
.briefing { display: grid; gap: var(--s-2); }
.briefing > .panel-title { margin-bottom: 0; }
.rule-name { color: var(--amber); font-weight: 650; }
.rule-text { color: var(--text); font-size: var(--fs-sm); line-height: 1.45; }
.brief-blurb { color: var(--text-3); font-size: var(--fs-xs); line-height: 1.45; }
.briefing .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.briefing .stat { padding: 6px 10px; }
.briefing .stat-label { font-size: 0.625rem; }
.briefing .stat-value { font-size: var(--fs-sm); }
.theories { display: grid; gap: 6px; }
.theory {
  position: relative;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--r-1);
  background: rgba(4, 10, 19, 0.5);
}
.theory-text { display: grid; gap: 1px; font-size: var(--fs-xs); line-height: 1.4; color: var(--text-2); }
.theory-text strong { min-height: 24px; padding-right: 76px; color: var(--text); font-size: var(--fs-sm); line-height: 24px; }
.theory .btn { position: absolute; top: 5px; right: 5px; min-height: 26px; padding: 0 var(--s-2); font-size: var(--fs-xs); }
.theory .btn[aria-pressed="true"] { box-shadow: none; }
.theory.is-struck { border-left-color: var(--text-3); }
.theory.is-struck .theory-text { text-decoration: line-through; opacity: 0.5; }
.clues { display: grid; gap: var(--s-1); }
.clues ul { display: grid; gap: var(--s-1); }
.clues li { padding-left: 10px; border-left: 2px solid var(--line-strong); color: var(--text-2); font-size: var(--fs-xs); line-height: 1.45; font-style: italic; }

/* ---------- chart card: confidence, toggles, legend ---------- */
.chart { display: grid; gap: var(--s-3); }
.chart > .panel-title { margin-bottom: calc(var(--s-1) * -1); }
.confidence { display: grid; gap: 5px; }
.conf-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); color: var(--text-2); font-size: var(--fs-sm); }
.conf-row > :last-child { color: var(--text); font-weight: 600; white-space: nowrap; }
.conf-row .dim { display: block; font-size: var(--fs-xs); white-space: nowrap; } /* its own line: the row keeps its height whatever it reads */
.meter { height: 6px; margin-bottom: 4px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--cyan-dim), var(--teal)); transition: width var(--t-slow) var(--ease); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggles .btn { flex: 1 1 auto; gap: 6px; padding: 0 var(--s-2); color: var(--text-2); }
.toggles .btn[aria-pressed="true"] { box-shadow: none; }
.toggles .kbd { min-width: 18px; height: 18px; padding: 0 3px; border-bottom-width: 1px; font-size: 10px; color: inherit; background: none; }
.legend { display: grid; gap: 6px; }
.ramp { height: 12px; border: 1px solid var(--line-strong); border-radius: 3px; }
.ramp-ends { display: flex; justify-content: space-between; gap: var(--s-2); color: var(--text-2); font-size: 0.6875rem; }
.legend-keys { display: flex; flex-wrap: wrap; gap: 3px var(--s-3); margin-top: 2px; color: var(--text-2); font-size: 0.6875rem; }
.legend-keys li { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.key-glyph { display: inline-flex; padding: 2px; border-radius: 3px; background: #0d2740; }
.key-glyph svg { width: 16px; height: 12px; }
.legend-note { color: var(--text-3); font-size: 0.6875rem; line-height: 1.45; }

/* ---------- cross-section ---------- */
.profile { display: grid; gap: var(--s-1); }
.profile-svg { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r-1); background: rgba(4, 10, 19, 0.55); touch-action: none; cursor: crosshair; }
.profile-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.profile-svg polyline { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.profile-depth { stroke: var(--cyan); }
.profile-signal { stroke: var(--amber); stroke-dasharray: 4 3; }
.profile-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.profile-cursor { stroke: var(--text); stroke-width: 1; vector-effect: non-scaling-stroke; }
.profile-label { fill: var(--text-2); font: 500 11px var(--mono); }
.profile-label--signal { fill: var(--amber); }
.profile-readout { color: var(--text-2); font-size: 0.6875rem; }

/* ---------- rival, coach ---------- */
.rival {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid rgba(255, 122, 107, 0.4);
  border-radius: var(--r-2);
  background: var(--coral-wash);
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.rival .icon { width: 16px; height: 16px; color: var(--coral); }
.rival strong { color: var(--text); font-weight: 650; }
.rival span:last-child { margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--coral); }

.coach {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid rgba(98, 214, 160, 0.45);
  border-radius: var(--r-3);
  background: var(--success-wash);
}
.coach > .icon { width: 22px; height: 22px; margin-top: 1px; color: var(--success); }
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: 2px; }
.coach .eyebrow { color: var(--success); }
.coach-text { color: var(--text); font-size: var(--fs-sm); line-height: 1.5; }
.link { padding: 2px 0; border: 0; background: none; color: var(--text-2); font-size: var(--fs-xs); text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--text); }

/* ---------- log ---------- */
.log { max-height: 300px; margin-right: calc(var(--s-2) * -1); padding-right: var(--s-2); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.log li {
  display: grid;
  grid-template-columns: 1.875rem 16px minmax(0, 1fr);
  gap: var(--s-2);
  padding: 7px 0;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 1.45;
}
.log li:first-child { border-top: 0; padding-top: 0; color: var(--text); }
.log .icon { width: 16px; height: 16px; margin-top: 1px; color: var(--cyan-dim); }
.log li:first-child .icon { color: var(--cyan); }
.log-turn { margin-top: 1px; color: var(--text-3); font-size: 0.6875rem; font-weight: 600; }

/* ---------- fingers: the small controls get a 40px target ---------- */
@media (pointer: coarse) {
  .presets .btn, .toggles .btn { min-height: 40px; }
  .coach .link { margin-block: -9px; padding-block: 11px; }
  .field .range { height: 40px; margin-block: -8px; }
}

/* ---------- phones ---------- */
@media (max-width: 819px) {
  .tool { padding: 7px 2px 6px; }
  .tool-cost { display: none; }
}
/* short phones: one row of icons, so the open instrument stays in view (names remain for screen readers) */
@media (max-width: 819px) and (max-height: 720px) {
  .tools { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
  .tool { min-height: 44px; padding: 0; align-content: center; }
  .tool .kbd { display: none; }
  .tool-name { position: absolute; width: 1px; height: 1px; min-height: 0; overflow: hidden; clip-path: inset(50%); }
}
