/* =========================================================
   Come Impara una Macchina — arcade machine-learning game
   Orbitron (arcade display) + Syne (headings) + DM Sans (body)
========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700;800;900&family=Syne:wght@600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ---------- tokens ---------- */
:root {
  --bg: #0D0B1A;
  --bg-2: #110F22;
  --panel: #15132A;
  --panel-2: #1A1834;
  --border: #2A2545;
  --ink: #E6EBFF;
  --ink-2: #CDD7F3;
  --muted: #8B8AA3;

  --accent: #4ECDC4;
  --coral: #FF6B6B;
  --teal: #4ECDC4;
  --yellow: #FFE66D;
  --magenta: #FF4081;
  --purple: #A78BFA;
  --orange: #F97316;
  --user: #60A5FA;

  --brand-yellow: #FFE66D;
  --brand-yellow-glow: rgba(255,230,109,.45);

  /* --- map board --- */
  --map-bg: #100E21;
  --map-grid: rgba(78,205,196,.06);
  --map-glow: rgba(167,139,250,.10);

  --font-heading: 'Syne', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-arcade: 'Orbitron', var(--font-heading), system-ui, sans-serif;
}

/* ---------- light mode ---------- */
:root[data-theme="light"] {
  --bg: #F5F3FF;
  --bg-2: #EDE9FE;
  --panel: #FFFFFF;
  --panel-2: #F9F8FF;
  --border: #D4D0E8;
  --ink: #1E1B34;
  --ink-2: #3B3660;
  --muted: #6B6790;
  --brand-yellow: #B8860B;
  --brand-yellow-glow: rgba(184,134,11,.25);
  --teal: #0D8A80;
  --coral: #D03030;
  --yellow: #A07800;
  --purple: #7C5FC4;
  --orange: #C45A10;

  --map-bg: #FFFFFF;
  --map-grid: rgba(124,95,196,.07);
  --map-glow: rgba(124,95,196,.06);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  overflow-x: hidden;
  /* header + main fill the viewport exactly, whatever the header height */
  display: flex;
  flex-direction: column;
}

/* =========================================================
   HEADER — CSS grid 1fr / auto / 1fr
========================================================= */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #0F0D20 0%, var(--bg) 100%);
}
:root[data-theme="light"] header {
  background: linear-gradient(180deg, #EDE9FE 0%, var(--bg) 100%);
}
header h1 {
  grid-column: 2;
  justify-self: center;
  margin: 0;
  font-family: var(--font-arcade);
  font-size: clamp(22px, 3.4vw, 40px);
  font-weight: 900;
  letter-spacing: .04em;
  color: var(--brand-yellow);
  text-shadow: 0 0 8px var(--brand-yellow-glow), 0 0 28px var(--brand-yellow-glow);
  text-align: center;
  animation: titleGlow 2.4s ease-in-out infinite alternate;
}
@keyframes titleGlow {
  from { text-shadow: 0 0 8px var(--brand-yellow-glow), 0 0 20px var(--brand-yellow-glow); }
  to   { text-shadow: 0 0 12px var(--brand-yellow-glow), 0 0 36px var(--brand-yellow-glow); }
}
.header-right {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.header-emoji {
  grid-column: 1;
  justify-self: start;
  display: inline-flex;
  gap: 12px;
  font-size: 22px;
  line-height: 1;
}
.header-emoji span { display: inline-block; animation: emojiBob 2.2s ease-in-out infinite; }
.header-emoji span:nth-child(2) { animation-delay: .35s; }
.header-emoji span:nth-child(3) { animation-delay: .7s; }
@keyframes emojiBob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-7px) rotate(6deg); }
}
@media (max-width: 700px) {
  .header-emoji { display: none; }
}
.header-right button {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink-2);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
}
.header-right button:hover {
  border-color: var(--teal);
  color: var(--ink);
}
/* link back to the arcade home page */
.header-right .home-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 4px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink-2);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  text-decoration: none;
  transition: all .2s;
}
.header-right .home-link:hover { border-color: var(--teal); color: var(--teal); }
.header-right .home-link:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.header-right button[aria-pressed="true"] {
  background: var(--panel);
  border-color: var(--teal);
  color: var(--teal);
}

/* =========================================================
   3-COLUMN LAYOUT — app-like, no body scroll
========================================================= */
main.layout-3col {
  display: grid;
  grid-template-columns: 280px minmax(400px, 1fr) 280px;
  gap: 16px;
  padding: 16px 20px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* sidebar panels */
.left-pane, .right-pane {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ---------- tagline (left pane, arcade hook) ---------- */
.tagline {
  font-family: var(--font-arcade);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--teal);
  text-shadow: 0 0 14px rgba(78,205,196,.35);
  line-height: 1.4;
  margin-bottom: 14px;
}

/* ---------- howto (compact icon chips) ---------- */
.howto-arcade {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.howto-step {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.howto-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* ---------- collapsible theory (details/summary) ---------- */
.theory-details {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.theory-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.theory-details summary::-webkit-details-marker { display: none; }
.theory-details[open] summary { color: var(--ink); margin-bottom: 8px; }
.theory-details p {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 0 0 8px;
}
.theory-details p:last-child { margin-bottom: 0; }

/* =========================================================
   CENTER PANE — controls + canvas + feedback
========================================================= */
.center-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.stage {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.controls-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.controls-bar select {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}
.controls-bar select option {
  background: var(--panel);
  color: var(--ink);
}
.controls-bar button {
  background: var(--panel-2);
  color: var(--ink-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.controls-bar button:hover {
  border-color: var(--coral);
  color: var(--coral);
  background: rgba(255,107,107,.08);
}

/* HUD chips */
#hud {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 4px 12px;
  font-variant-numeric: tabular-nums;
  transition: border-color .2s, box-shadow .2s;
}
.hud-chip b {
  color: var(--ink);
  font-family: var(--font-arcade);
  font-weight: 700;
}
.hud-chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hud-chip.success { border-color: var(--teal); box-shadow: 0 0 10px rgba(78,205,196,.25); }
.hud-chip.success b { color: var(--teal); }
.hud-chip.warn { border-color: var(--coral); }
.hud-chip.warn b { color: var(--coral); }

/* timer */
#timer {
  font-family: var(--font-arcade);
  font-weight: 700;
  font-size: 15px;
  color: var(--yellow);
  min-width: 50px;
  text-align: center;
}
#timer:empty { display: none; }
#timer.warn {
  color: var(--coral);
  animation: pulse .6s ease infinite alternate;
}
@keyframes pulse { from { opacity: 1; } to { opacity: .5; } }

/* =========================================================
   MAP BOARD — the play area: a night-time road map
========================================================= */
.board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    radial-gradient(60% 50% at 50% 0%, var(--map-glow), transparent 70%),
    repeating-linear-gradient(0deg,  var(--map-grid) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, var(--map-grid) 0 1px, transparent 1px 24px),
    var(--bg-2);
  box-shadow: 0 4px 20px rgba(0,0,0,.4), inset 0 0 40px rgba(0,0,0,.3);
}
:root[data-theme="light"] .board-wrap {
  box-shadow: 0 4px 20px rgba(30,27,52,.08), inset 0 0 40px rgba(124,95,196,.06);
}
#canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: var(--map-bg);
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--border), 0 10px 30px rgba(0,0,0,.35);
  cursor: crosshair;
}
:root[data-theme="light"] #canvas {
  box-shadow: 0 0 0 1px var(--border), 0 10px 30px rgba(30,27,52,.10);
}

/* =========================================================
   LEGEND — click a chip to show / hide that route
========================================================= */
.legend-bar {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: .45;
  transition: opacity .2s, border-color .2s;
}
.legend-chip.on { opacity: 1; border-color: currentColor; }
.legend-line {
  width: 22px;
  height: 0;
  border-top: 3px solid currentColor;
  border-radius: 2px;
}
.legend-dash-long, .legend-dash-short { border-top-style: dashed; }

/* =========================================================
   FEEDBACK TOAST — frosted glass, bottom of the map
   (kept low so the route stays visible behind it)
========================================================= */
.feedback-toast {
  display: none;
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  min-width: 280px;
  background: rgba(13,11,26,.62);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 32px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
  z-index: 10;
}
:root[data-theme="light"] .feedback-toast {
  background: rgba(255,255,255,.85);
  border-color: #D4D0E8;
}
.feedback-toast.show { display: block; animation: toastPop .38s cubic-bezier(.34,1.56,.64,1); }
@keyframes toastPop {
  from { opacity: 0; transform: translate(-50%, 14px) scale(.8); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.feedback-toast .score {
  font-family: var(--font-arcade);
  font-weight: 900;
  font-size: 30px;
  letter-spacing: .03em;
  color: var(--teal);
  text-shadow: 0 0 18px rgba(78,205,196,.5);
  vertical-align: middle;
  margin-left: 6px;
}
:root[data-theme="light"] .feedback-toast .score { text-shadow: none; }
.feedback-toast .challenge {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}
.feedback-toast button {
  margin-top: 12px;
  background: rgba(78,205,196,.12);
  border: 1px solid var(--teal);
  color: var(--teal);
  border-radius: 8px;
  padding: 6px 18px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.feedback-toast button:hover { background: rgba(78,205,196,.22); }
.feedback-toast .close-toast {
  position: absolute;
  top: 6px; right: 8px;
  margin: 0;
  padding: 2px 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
}
.feedback-toast .close-toast:hover { background: none; color: var(--ink); }

/* =========================================================
   SIDEBAR — section headers
========================================================= */
.sidebar h3 {
  margin: 14px 0 6px;
  font-family: var(--font-arcade);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: help;
}
.sidebar h3:first-child { margin-top: 0; }

/* =========================================================
   SIDEBAR — algo buttons (TOGGLE with color dot)
========================================================= */
.sidebar .algo-btn {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: all .2s;
}
.sidebar .algo-btn:hover {
  border-color: var(--accent);
  background: rgba(78,205,196,.06);
}
.sidebar .algo-btn .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sidebar .algo-btn.active {
  border-color: var(--accent);
  background: rgba(78,205,196,.1);
  box-shadow: 0 0 12px rgba(78,205,196,.12);
}
.sidebar .algo-btn.disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}
.algo-label {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.algo-label small {
  font-size: 11.5px;
  color: var(--muted);
}

/* algo info box (dynamic description on click) */
.algo-info {
  display: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin: 10px 0 12px;
  font-size: 13px;
  color: var(--ink-2);
  animation: fadeIn .3s ease;
}
.algo-info.show { display: block; }
.algo-info h4 {
  margin: 0 0 4px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.algo-info .meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* =========================================================
   FOOTER — discrete, inside left pane
========================================================= */
.footnote {
  text-align: center;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  opacity: .7;
}

/* =========================================================
   ANIMATIONS
========================================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   FOCUS
========================================================= */
button:focus-visible, select:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 1100px) {
  main.layout-3col {
    grid-template-columns: 240px minmax(360px, 1fr) 240px;
    gap: 12px;
    padding: 12px 14px;
  }
}

@media (max-width: 900px) {
  body { display: block; height: auto; }
  main.layout-3col {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
    padding: 12px;
  }
  .center-pane, .stage { overflow: visible; min-width: 0; }
  .left-pane, .right-pane {
    overflow-y: visible;
    max-height: none;
  }
  .center-pane { order: -1; }
  /* the canvas sizes itself from the board: give it an explicit height */
  .board-wrap { flex: none; height: min(64vw, 56vh); min-height: 220px; }
  .feedback-toast { bottom: 10px; min-width: 0; width: calc(100% - 24px); padding: 12px 16px; }
  .feedback-toast .score { font-size: 22px; }
  header h1 { font-size: 22px; }
}

@media (max-width: 600px) {
  header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 8px;
    padding: 12px;
  }
  header h1 { grid-column: 1; font-size: 18px; }
  .header-right { grid-column: 1; justify-self: center; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .sidebar .algo-btn { padding: 12px; font-size: 15px; }
  #hud { justify-content: center; margin-left: 0; }
}

/* =========================================================
   EXTRA — controls shared by the learning / search demos
========================================================= */
.board-wrap #canvas { cursor: pointer; }

/* one group of controls per mode; JS toggles [hidden] */
.mode-group[hidden] { display: none !important; }
.mode-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* tool chips: pick what a click on the board does */
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.controls-bar .tool-btn[aria-pressed="true"] {
  border-color: var(--yellow);
  color: var(--ink);
  background: rgba(255,230,109,.12);
  box-shadow: 0 0 10px rgba(255,230,109,.25);
}
.controls-bar button.primary {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(78,205,196,.10);
}
.controls-bar button.primary:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(78,205,196,.2);
}
.controls-bar button:disabled { opacity: .4; cursor: not-allowed; }

/* range slider with value pill */
.range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
}
.range input[type="range"] { width: 90px; accent-color: var(--teal); }
.range b {
  font-family: var(--font-arcade);
  font-size: 12px;
  color: var(--ink);
  min-width: 26px;
  text-align: center;
}
.chk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.chk input { accent-color: var(--teal); }

/* caption under the board: what is happening right now */
.caption {
  flex-shrink: 0;
  margin-top: 10px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--ink-2);
  min-height: 42px;
  line-height: 1.45;
}
.caption b { color: var(--ink); }

/* how-to box that changes with the mode */
.mode-help {
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--ink-2);
}
.mode-help h4 {
  margin: 0 0 6px;
  font-family: var(--font-arcade);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--teal);
}
.mode-help ol { margin: 0; padding-left: 18px; }
.mode-help li { margin-bottom: 3px; }

/* sidebar mode buttons with a big emoji */
.sidebar .algo-btn .emoji { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }

/* comparison table inside a <details> */
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
}
.cmp-table th, .cmp-table td {
  text-align: left;
  vertical-align: top;
  padding: 5px 4px;
  border-bottom: 1px dashed var(--border);
}
.cmp-table th {
  font-family: var(--font-arcade);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--ink);
  font-weight: 700;
}
.table-scroll { overflow-x: auto; }

@media (max-width: 600px) {
  .mode-group { justify-content: center; }
  .range input[type="range"] { width: 110px; }
}

/* fruit palette: emoji buttons, the name shows only on the selected one
   (kept for screen readers on the others) */
.fruit-palette { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.controls-bar .tool-btn.fruit { font-size: 17px; padding: 4px 10px; }
.tool-btn.fruit .tool-name { font-size: 14px; }
.tool-btn.fruit[aria-pressed="false"] .tool-name {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
/* a fruit the machine has never been taught */
.tool-btn.fruit.unknown { border-style: dashed; }

/* reinforcement: end-of-mission card */
.feedback-toast .stars { font-size: 26px; letter-spacing: 4px; margin-top: 4px; }
.feedback-toast .stars .off { opacity: .22; filter: grayscale(1); }
.feedback-toast .rules { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* =========================================================
   MOBILE — compact controls, touch targets, pane order
========================================================= */
@media (max-width: 900px) {
  /* the mode picker comes right after the board,
     the instructions go last */
  .right-pane { order: 1; }
  .left-pane  { order: 2; }
}

@media (max-width: 600px) {
  main.layout-3col { padding: 10px; gap: 10px; }
  header { padding-block: 10px; gap: 6px; }
  /* a taller, almost square board: easier to tap points on a phone */
  .board-wrap { height: min(85vw, 60vh); }
  .controls-bar { gap: 8px; }
  .caption { font-size: 13px; }
}

@media (pointer: coarse) {
  .header-right button { min-width: 42px; min-height: 40px; font-size: 14px; }
  .header-right .home-link { min-height: 40px; font-size: 14px; }
  .controls-bar button { min-height: 40px; }
  .theory-details summary { padding-block: 8px; }
  .sidebar .algo-btn { min-height: 52px; }
  .chk { min-height: 40px; }
  .chk input { width: 20px; height: 20px; }
  .range input[type="range"] { height: 32px; }
  .feedback-toast button { min-height: 42px; }
  .feedback-toast .close-toast { padding: 8px 12px; top: 0; right: 0; }
}

/* touch screens keep :hover "stuck" after a tap */
@media (hover: none) {
  .controls-bar button:hover { border-color: var(--border); color: var(--ink-2); background: var(--panel-2); }
  .controls-bar button.primary:hover { border-color: var(--teal); color: var(--teal); background: rgba(78,205,196,.10); }
  .controls-bar .tool-btn[aria-pressed="true"]:hover { border-color: var(--yellow); color: var(--ink); background: rgba(255,230,109,.12); }
}

/* =========================================================
   SITE FOOTER — copyright line under the app
========================================================= */
.site-footer {
  flex-shrink: 0;
  padding: 7px 20px 9px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.site-footer a {
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.site-footer a:hover { color: var(--teal); }
