/* =========================================================
   SOS Orario Scuola — arcade school-timetable 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);

  --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;
}

/* ---------- 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 + footer fill the viewport exactly */
  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: 250px minmax(400px, 1fr) 250px;
  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;
}

/* ---------- card (legacy, still used by JS-injected content) ---------- */
.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.card:last-child { margin-bottom: 0; }
.card p { margin: 0 0 8px; font-size: 14px; color: var(--ink-2); }
.card p:last-child { margin-bottom: 0; }

/* ---------- 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; }

/* ---------- pill hint ---------- */
.pill {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

/* =========================================================
   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 {
  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.warn { border-color: var(--coral); box-shadow: 0 0 10px rgba(255,107,107,.25); }
.hud-chip.warn b { color: var(--coral); animation: chipPulse .5s ease infinite alternate; }
.hud-chip.success { border-color: var(--teal); box-shadow: 0 0 10px rgba(78,205,196,.25); }
.hud-chip.success b { color: var(--teal); }
@keyframes chipPulse { from { opacity: 1; } to { opacity: .55; } }

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

/* =========================================================
   CORKBOARD — the "diario di classe" play area
   (a deliberate fixed-material look: wood + cork read the
   same in light or dark UI theme, like a real corkboard would)
========================================================= */
.board-wrap {
  display: flex;
  justify-content: center;
  position: relative;
  flex: 1;
  min-height: 0;
}
.corkboard {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  /* rows as tall as their lessons: with a fixed board height, plain auto rows
     stop growing and a 3rd lesson spills over the hour below */
  grid-auto-rows: max-content;
  gap: 18px 16px;
  padding: 18px;
  background: linear-gradient(180deg, #4a3220, #2e1f12);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4), inset 0 0 40px rgba(0,0,0,.3);
  overflow-y: auto;
  align-content: start;
}

.ora-zone {
  background: radial-gradient(circle at 20% 20%, #8a6338, #6f4e2a 70%);
  border-radius: 10px;
  padding: 26px 10px 14px;
  position: relative;
  min-height: 120px;
  box-shadow: inset 0 0 30px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: box-shadow .2s;
}
.ora-zone.drop-target {
  box-shadow: inset 0 0 30px rgba(0,0,0,.2), 0 0 0 2px var(--teal), 0 0 16px rgba(78,205,196,.5);
}
.ora-tape {
  position: absolute;
  top: -9px; left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(255,230,109,.88);
  color: #3a2b00;
  font-family: var(--font-arcade);
  font-weight: 800;
  font-size: 10px;
  letter-spacing: .05em;
  padding: 3px 10px;
  border-radius: 2px;
  box-shadow: 0 3px 6px rgba(0,0,0,.35);
  white-space: nowrap;
}

.lesson-note {
  background: #f4ecd8;
  color: #3a3222;
  border-radius: 3px;
  padding: 8px 30px 10px 10px;
  width: 150px;
  box-shadow: 0 5px 10px rgba(0,0,0,.4);
  position: relative;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform .12s ease;
}
.lesson-note:hover { filter: brightness(1.04); }
.lesson-note .pin {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #eafff9, var(--teal) 60%);
  box-shadow: 0 2px 3px rgba(0,0,0,.5);
}
.lesson-note.selected {
  box-shadow: 0 0 0 3px var(--yellow), 0 0 18px rgba(255,230,109,.6);
  transform: translateY(-3px) rotate(0deg) !important;
  z-index: 2;
}
.lesson-note.conflict {
  background: linear-gradient(165deg, #f4ecd8 55%, rgba(255,23,68,.18));
  box-shadow: 0 0 0 4px var(--coral), 0 10px 24px rgba(255,23,68,.7);
  z-index: 3;
  animation: notePulse .85s ease infinite;
}
.lesson-note.conflict .pin { background: radial-gradient(circle at 35% 30%, #ffdede, var(--coral) 60%); }
@keyframes notePulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--coral), 0 8px 20px rgba(255,23,68,.5); }
  50%      { box-shadow: 0 0 0 7px var(--coral), 0 12px 32px rgba(255,23,68,.9); }
}
.lesson-note.hint { box-shadow: 0 0 0 3px var(--yellow), 0 0 22px rgba(255,230,109,.7); }
.lesson-note.pop-in { animation: notePopIn .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes notePopIn {
  from { transform: scale(.55) rotate(0deg); opacity: .4; }
  to   { transform: scale(1) rotate(var(--tilt, 0deg)); opacity: 1; }
}
.lesson-note .subject {
  font-family: var(--font-arcade);
  font-weight: 800;
  font-size: 11.5px;
  line-height: 1.25;
  letter-spacing: .01em;
  white-space: normal;
  text-wrap: pretty;
}
.subject-emoji {
  display: inline-block;
  margin-right: 4px;
  font-size: 13px;
  animation: emojiWiggle 2.4s ease-in-out infinite;
}
@keyframes emojiWiggle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-3px) rotate(10deg); }
}
.lesson-note .teacher {
  font-size: 11px;
  color: #5a4f3a;
  margin-top: 4px;
}
.lesson-note .classtag {
  position: absolute; top: 5px; right: 5px;
  font-family: var(--font-arcade);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0,0,0,.12);
  color: #3a3222;
}
.lesson-note.conflict .warnbadge {
  position: absolute; top: -12px; right: -10px; bottom: auto;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--coral); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900;
  box-shadow: 0 2px 6px rgba(0,0,0,.5), 0 0 0 2px #f4ecd8;
  animation: warnPop .85s ease infinite;
}
@keyframes warnPop {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.22); }
}

.pool-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 6px 4px;
}

/* =========================================================
   FEEDBACK TOAST — frosted glass overlay on canvas
========================================================= */
.feedback-toast {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(13,11,26,.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 32px;
  text-align: center;
  z-index: 10;
  min-width: 260px;
  animation: fadeIn .3s ease;
}
:root[data-theme="light"] .feedback-toast {
  background: rgba(255,255,255,.82);
  border-color: #D4D0E8;
}
:root[data-theme="light"] .feedback-toast .score {
  color: #0D8A80;
}
:root[data-theme="light"] .feedback-toast .detail {
  color: #3B3660;
}
:root[data-theme="light"] .feedback-toast .comparisons {
  color: #3B3660;
}
.feedback-toast.show { display: block; animation: toastPop .38s cubic-bezier(.34,1.56,.64,1); }
@keyframes toastPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  to   { opacity: 1; transform: translate(-50%, -50%) 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);
}
.feedback-toast .detail {
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 8px;
}
.feedback-toast .comparisons {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.6;
}
.optimal-badge {
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 8px;
  font-family: var(--font-arcade);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  display: inline-block;
}
.optimal-badge.optimal-yes {
  color: var(--teal);
  background: rgba(78,205,196,.14);
  border: 1px solid var(--teal);
  text-shadow: 0 0 10px rgba(78,205,196,.4);
}
.optimal-badge.optimal-no {
  color: var(--coral);
  background: rgba(255,107,107,.12);
  border: 1px solid var(--coral);
}
.feedback-toast button {
  margin-top: 14px;
  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);
}

/* =========================================================
   PROGRESS BAR on canvas
========================================================= */
.progress-bar {
  position: absolute;
  bottom: 12px; left: 12px; right: 12px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: var(--teal);
  border-radius: 2px;
  transition: width .15s linear;
}

/* =========================================================
   POOL — lezioni non ancora appuntate ("in mano")
========================================================= */
.pool-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  margin-bottom: 10px;
  min-height: 58px;
  flex-shrink: 0;
  min-width: 0;
}
.pool-bar .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-right: 4px;
  padding-top: 8px;
  flex-shrink: 0;
}
/* lessons in hand sit on a single row that scrolls sideways,
   so the board keeps the same size however many are left */
#pool {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 6px 12px; /* room for the pins and the tilt */
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
#pool .lesson-note { flex-shrink: 0; }
#pool .lesson-note { background: var(--panel-2); color: var(--ink); border: 1.5px dashed var(--muted); box-shadow: none; }
#pool .lesson-note .teacher { color: var(--ink-2); }
#pool .lesson-note .pin { background: radial-gradient(circle at 35% 30%, #fff, var(--muted) 60%); }
#pool .lesson-note .classtag { background: rgba(255,255,255,.08); color: var(--ink-2); }
/* the pool's own box-shadow:none above (id selector) would otherwise beat
   .lesson-note.hint/.selected (two classes) and hide their glow entirely */
#pool .lesson-note.hint { box-shadow: 0 0 0 3px var(--yellow), 0 0 22px rgba(255,230,109,.7); }
#pool .lesson-note.selected { box-shadow: 0 0 0 3px var(--yellow), 0 0 18px rgba(255,230,109,.6); }

/* =========================================================
   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: 8px;
  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;
}
.sidebar .algo-btn.running {
  border-color: var(--yellow);
  box-shadow: 0 0 14px rgba(255,230,109,.3);
  animation: runningPulse 1s ease infinite;
}
@keyframes runningPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255,230,109,.2); }
  50% { box-shadow: 0 0 18px rgba(255,230,109,.45); }
}

/* algo-sub link text (e.g. WP→DSATUR relation) */
.algo-sub {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 10px 18px;
  line-height: 1.4;
}

/* 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-top: 10px;
  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;
}

/* fixed info box at bottom of sidebar */
.info-fixed {
  margin-top: 16px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.info-fixed strong {
  color: var(--ink);
  font-family: var(--font-heading);
  font-weight: 700;
}

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

/* =========================================================
   CONFETTI (canvas-based, just z-index)
========================================================= */
.confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  border-radius: 12px;
}

/* =========================================================
   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) {
  main.layout-3col {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    padding: 12px;
  }
  .left-pane, .right-pane {
    overflow-y: visible;
    max-height: none;
  }
  .center-pane { order: -1; }
  .board-wrap { min-height: 55vh; }
  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; }
  .pool-bar { justify-content: center; }
  .sidebar .algo-btn { padding: 12px; font-size: 15px; }
  #hud { justify-content: center; }
}

/* =========================================================
   MOBILE — compact controls, touch targets, pane order
========================================================= */
@media (max-width: 900px) {
  body { display: block; height: auto; }
  main.layout-3col { grid-template-columns: minmax(0, 1fr); }
  .center-pane { overflow: visible; min-width: 0; }
  /* the algorithms to challenge come right after the board,
     the instructions (read once) 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; }
  /* buttons share a row instead of one full-width row each,
     so the board shows up without scrolling */
  .controls-bar { flex-direction: row; justify-content: center; align-items: center; gap: 8px; }
  .controls-bar > label { flex: 1 1 100%; min-width: 0; }
  .controls-bar select { flex: 1; min-width: 0; }
  .controls-bar > button { flex: 1 1 0; }
  #hud { flex: 1 1 100%; margin-left: 0; }
  .corkboard { gap: 14px; padding: 16px 10px 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .ora-zone { padding-inline: 8px; }
  .lesson-note { width: 100%; max-width: 150px; }
  .feedback-toast { min-width: 0; width: calc(100% - 24px); padding: 18px 16px; }
  .feedback-toast .score { font-size: 24px; }
}

@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, .controls-bar select { min-height: 42px; }
  /* below 16px iOS zooms the page when the select gets focus */
  .controls-bar select { font-size: 16px; }
  .theory-details summary { padding-block: 8px; }
  .sidebar .algo-btn { min-height: 48px; }
  .feedback-toast button { min-height: 42px; }
}

/* 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); }
}

/* =========================================================
   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); }
