/* Palette ripresa dal sito "Palestra di logica". */
:root {
  --navy: #062c52; --blue: #0b5d88; --sky: #dff1f5; --paper: #f7f4ec; --ink: #132a3a; --muted: #5a7180;
  --coral: #ef765f; --yellow: #f4c95d; --green: #3a9564; --red: #c9533d; --line: #d8e1e4; --white: #fff;
  --sq-light: #eee9da; --sq-dark: #17617b;
  --radius: 18px; --serif: Georgia, 'Times New Roman', serif; --sans: 'Segoe UI', Arial, Helvetica, sans-serif;
  --topbar: 68px; --fs: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: var(--fs)/1.6 var(--sans); }
body.lim { --fs: 19px; }
a { color: inherit; }
h1, h2, h3 { margin: 0; color: var(--navy); font-family: var(--serif); line-height: 1.12; }
h1 { font-size: clamp(2.3rem, 5vw, 3.8rem); letter-spacing: -.03em; }
h1 em { font-weight: 400; color: var(--coral); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
h3 { font-size: 1.25rem; }
code { font: .92em/1 Consolas, monospace; background: #e7eef0; padding: .15em .4em; border-radius: 5px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- Barra superiore e navigazione ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar); display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(14px, 3vw, 32px); background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--navy); text-decoration: none; line-height: 1.1; }
.brand small { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; color: #597183; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 14px; flex: none; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.lim-toggle[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.menu-toggle { display: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 42px; height: 42px; font-size: 20px; cursor: pointer; }

.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }
.stage-nav { position: sticky; top: var(--topbar); align-self: start; height: calc(100vh - var(--topbar)); overflow-y: auto;
  padding: 20px 14px 30px; background: #fff; border-right: 1px solid var(--line); }
.stage-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: .93rem; color: #34505f; }
.stage-nav a em { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--paper);
  font: 700 .8rem var(--sans); font-style: normal; color: var(--navy); }
.stage-nav a:hover { background: #f1f5f6; }
.stage-nav a.active { background: var(--navy); color: #fff; }
.stage-nav a.active em { background: var(--yellow); }
.stage-nav a.done em { background: var(--green); color: #fff; font-size: 0; }
.stage-nav a.done em::before { content: '✓'; font-size: .85rem; }
.nav-group { margin: 18px 10px 4px; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 800; color: var(--blue); }
.progress { margin: 0 6px 14px; padding: 12px; background: var(--paper); border-radius: 12px; font-size: .8rem; font-weight: 700; }
.progress span { display: flex; justify-content: space-between; }
.progress div { height: 8px; background: #e2e0d5; border-radius: 9px; margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--green); transition: width .4s; }

main { min-width: 0; padding: clamp(20px, 4vw, 56px) clamp(16px, 4vw, 60px) 40px; }
main > section { max-width: 1180px; margin: 0 auto; }

/* ---------- Elementi comuni ---------- */
.kicker { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .15em; font-size: .75rem; font-weight: 800; color: var(--blue); }
.lead { max-width: 760px; font-size: 1.12rem; color: #435d6e; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 10px;
  font-weight: 800; font-size: .92rem; text-decoration: none; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.button.small { min-height: 38px; padding: 0 14px; font-size: .85rem; }
.button.primary { background: var(--navy); color: #fff; }
.button.primary:hover { background: var(--blue); }
.button.ghost { background: #fff; border-color: #aabac3; color: var(--navy); }
.button.ghost:hover { border-color: var(--navy); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.actions, .row-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.actions { margin-top: 28px; }

.page-head { padding-bottom: 26px; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.page-head .button { margin-top: 12px; }
.section-title { margin: 48px 0 14px; }
.section-intro { max-width: 820px; color: var(--muted); margin: 0 0 20px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 20px 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 3vw, 30px); }
.card h2 { font-size: 1.5rem; margin-bottom: 12px; }
.card p { color: #3e5968; }
.card.highlight { background: var(--navy); border-color: var(--navy); color: #d6e3e9; }
.card.highlight h2 { color: #fff; }
.card.highlight p, .card.highlight li { color: #d6e3e9; }
.card.highlight b { color: #fff; }
.memo { padding: 10px 14px; border-left: 4px solid var(--yellow); background: #fff7d9; color: var(--ink) !important; border-radius: 0 8px 8px 0; }
.card.highlight .memo b { color: var(--ink); }
.small-cards { margin-top: 30px; }
.small-cards h3 { margin-bottom: 8px; }

.checklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.checklist li { position: relative; padding-left: 26px; }
.checklist li::before { content: '●'; position: absolute; left: 4px; top: 0; color: var(--coral); font-size: .8rem; }

.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.glossary dt { font-weight: 800; color: var(--navy); }
.glossary dd { margin: 0; color: #3e5968; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.facts div { background: #fff; padding: 22px; }
.facts b { display: block; font: 700 2.6rem var(--serif); color: var(--coral); line-height: 1; }
.facts span { color: var(--muted); font-size: .92rem; }

.rule-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 10px 0 20px; }
.rule-cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rule-cards article { background: #fff; padding: 24px 22px; }
.rule-cards article > b { font: 700 1.9rem var(--serif); color: var(--coral); }
.rule-cards h3 { margin: 14px 0 8px; }
.rule-cards p { margin: 0; font-size: .95rem; color: #4d6573; }

.think { margin: 34px 0; padding: 20px 24px; background: #e7f2f4; border-left: 5px solid var(--blue); border-radius: 0 var(--radius) var(--radius) 0; }
.think b { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--blue); }
.think p { margin: 6px 0 0; }
.alert { margin: 34px 0; padding: clamp(22px, 4vw, 40px); background: #fff4d6; border: 1px solid #ead69d; border-radius: var(--radius); }
.alert > strong { color: #9d4d36; text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; }
.alert h2 { margin: 6px 0 10px; }
.alert p { margin: 0; max-width: 860px; font-size: 1.05rem; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 800; letter-spacing: .04em; background: #e7eef0; color: var(--navy); }
.tag.italiana { background: #e4f2e8; color: #1f6b41; }
.tag.inglese { background: #fde8e2; color: #9d3b28; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 50px; align-items: center; padding: 10px 0 40px; }
.hero-board { display: grid; place-items: center; }
.mini-damiera { width: min(360px, 80vw); padding: 12px; background: #fff; box-shadow: 0 28px 70px #0a38502b; transform: rotate(3deg); border-radius: 6px; }
.path-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.faq { display: grid; gap: 10px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 0 20px; }
.faq summary { cursor: pointer; padding: 16px 0; font-weight: 700; color: var(--navy); list-style-position: outside; }
.faq details[open] summary { border-bottom: 1px solid #e8eef0; }
.faq p { margin: 12px 0 16px; color: #3e5968; }
.faq a, .plan a, .card a { color: var(--blue); font-weight: 700; }

/* ---------- Laboratorio ---------- */
.build-cta { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 24px 0; padding: clamp(20px, 3vw, 32px);
  background: #fff4d6; border: 1px solid #ead69d; border-radius: var(--radius); }
.build-cta h2 { margin-bottom: 6px; }
.build-cta p { margin: 0; max-width: 640px; }
.build-steps { list-style: none; counter-reset: st; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.build-steps li { counter-increment: st; position: relative; padding: 20px 20px 18px 66px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.build-steps li::before { content: counter(st); position: absolute; left: 18px; top: 18px; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--navy); color: #fff; font: 700 1rem var(--serif); }
.build-steps h3 { font-size: 1.1rem; }
.build-steps p { margin: 6px 0 0; font-size: .95rem; color: #4d6573; }
.hinge-figure { margin: 22px 0; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.hinge-figure svg { display: block; width: 100%; max-width: 760px; height: auto; margin: 0 auto; }
.path-card { position: relative; display: block; min-height: 170px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 16px; text-decoration: none; transition: transform .15s, box-shadow .15s; }
.path-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px #14394d1c; }
.path-card > b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--paper); color: var(--navy); margin-bottom: 12px; }
.path-card h3 { font-size: 1.08rem; }
.path-card p { margin: 6px 0 22px; font-size: .86rem; color: var(--muted); line-height: 1.45; }
.path-card span { position: absolute; bottom: 14px; font-size: .75rem; font-weight: 800; color: var(--blue); }
.path-card.accent { background: var(--navy); border-color: var(--navy); }
.path-card.accent h3 { color: #fff; }
.path-card.accent p { color: #c8dbe5; }
.path-card.accent span { color: var(--yellow); }
.path-card.accent > b { background: var(--yellow); }
.how-to { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; padding: 30px; background: #fff; border-radius: var(--radius); border: 1px solid var(--line); }
.how-to ol { padding-left: 20px; margin: 10px 0 0; }
.how-to p { margin: 10px 0 0; color: #3e5968; }

/* ---------- Storia ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 118px; top: 10px; bottom: 10px; width: 3px; background: var(--line); }
.timeline li { position: relative; display: grid; grid-template-columns: 100px 1fr; gap: 40px; padding: 12px 0; }
.timeline li::before { content: ''; position: absolute; left: 111px; top: 22px; width: 17px; height: 17px; border-radius: 50%; background: var(--coral); border: 3px solid var(--paper); }
.timeline time { font: 700 1rem var(--serif); color: var(--coral); text-align: right; padding-top: 12px; }
.timeline li > div { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px; }
.timeline p { margin: 4px 0 0; color: #3e5968; }

/* ---------- Damiera ---------- */
.board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); aspect-ratio: 1; width: 100%; user-select: none; }
.board > button { position: relative; display: grid; place-items: center; border: 0; padding: 0; min-width: 0; min-height: 0; cursor: pointer; }
.board.is-static > button { cursor: default; }
.board .light { background: var(--sq-light); }
.board .dark { background: var(--sq-dark); }
.board .num { position: absolute; top: 2px; left: 4px; font: 700 clamp(8px, 1.1vw, 12px)/1 var(--sans); color: #bfe0ea; pointer-events: none; }
.board .marked::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px #f4c95d99; pointer-events: none; }
.board .selected { box-shadow: inset 0 0 0 5px var(--yellow); }
.board .target::before { content: ''; position: absolute; width: 30%; aspect-ratio: 1; border-radius: 50%; background: var(--yellow); z-index: 1; pointer-events: none; }
.board .target { box-shadow: inset 0 0 0 4px var(--yellow); }
.board .on-path::before { content: ''; position: absolute; width: 16%; aspect-ratio: 1; border-radius: 50%; background: #f4c95daa; pointer-events: none; }
.board .last { background: #2d7f8f; }
.board .hint { box-shadow: inset 0 0 0 5px #7be0a4; animation: pulse 1.2s ease-in-out infinite; }
.board .good { box-shadow: inset 0 0 0 5px #6fd49a; }
.board .bad { box-shadow: inset 0 0 0 5px #ff8a70; }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 2px #7be0a4; } }

.piece { position: relative; z-index: 2; display: grid; place-items: center; width: 74%; aspect-ratio: 1; border-radius: 50%; transition: transform .15s; }
.piece.w { background: radial-gradient(circle at 35% 30%, #fff, #f2ead8); border: 3px solid var(--navy); box-shadow: inset 0 0 0 4px #ddd3bf, 0 4px 6px #062c5260; color: var(--navy); }
.piece.b { background: radial-gradient(circle at 35% 30%, #46525a, #1c252b); border: 3px solid #0d1418; box-shadow: inset 0 0 0 4px #ffffff22, 0 4px 6px #062c5260; color: var(--yellow); }
.piece svg { width: 58%; height: 58%; fill: currentColor; }
.piece.king.w { box-shadow: inset 0 0 0 4px #ddd3bf, 0 0 0 3px var(--yellow), 0 5px 8px #062c5260; }
.piece.king.b { box-shadow: inset 0 0 0 4px #ffffff22, 0 0 0 3px var(--yellow), 0 5px 8px #062c5260; }
.selected .piece { transform: scale(1.08); }
.piece.mini { display: inline-grid; width: 18px; height: 18px; border-width: 2px; box-shadow: none; vertical-align: -3px; margin-right: 6px; }

.board-frame { padding: clamp(6px, 1.2vw, 14px); background: #fff; border-radius: 12px; box-shadow: 0 16px 40px #0a385022; }

/* ---------- Esercizi e widget ---------- */
.widget { margin: 0 0 20px; }
.exercise { display: grid; grid-template-columns: minmax(260px, 480px) minmax(260px, 1fr); gap: clamp(18px, 3vw, 36px); align-items: start;
  padding: clamp(14px, 2.5vw, 28px); background: var(--sky); border-radius: var(--radius); }
body.lim .exercise { grid-template-columns: minmax(300px, 600px) minmax(260px, 1fr); }
.exercise-panel { display: grid; gap: 12px; align-content: start; }
.exercise-panel h3 { font-size: 1.45rem; }
.task { margin: 0; font-size: 1.08rem; font-weight: 600; color: var(--ink); }
.feedback { margin: 0; padding: 12px 14px; border-radius: 10px; background: #fff; border-left: 5px solid #b8c9d0; min-height: 48px; }
.feedback:empty { display: none; }
.feedback.ok { border-color: var(--green); background: #e6f5ea; }
.feedback.no { border-color: var(--red); background: #fdebe6; }
.feedback.warn { border-color: var(--yellow); background: #fff7d9; }
.hint-text { margin: 0; padding: 10px 14px; background: #fff; border-radius: 10px; border: 1px dashed #aabac3; }
.switch { display: flex; align-items: center; gap: 8px; font-size: .92rem; font-weight: 600; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--navy); }

.steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.steps button { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px; border-radius: 99px; border: 1px solid #b8c9d0; background: #fff; cursor: pointer; font-size: .88rem; font-weight: 700; }
.steps button span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--paper); font-size: .8rem; }
.steps button.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.steps button.active span { background: var(--yellow); color: var(--navy); }
.steps button.solved span { background: var(--green); color: #fff; }

.choice-row { display: grid; grid-template-columns: repeat(2, minmax(0, 300px)); gap: 20px; margin: 14px 0; }
.choice-board { display: grid; gap: 8px; padding: 0; border: 0; background: none; cursor: pointer; text-align: center; font-weight: 800; color: var(--navy); }
.choice-board:hover .board-frame { box-shadow: 0 0 0 4px var(--yellow), 0 16px 40px #0a385022; }
.big-number { margin: 0; font: 700 2.4rem var(--serif); color: var(--coral); }
.brushes { display: flex; flex-wrap: wrap; gap: 8px; }
.brushes button { display: inline-flex; align-items: center; padding: 8px 12px; border: 1px solid #b8c9d0; border-radius: 10px; background: #fff; cursor: pointer; font-weight: 700; font-size: .9rem; }
.brushes button.active { box-shadow: 0 0 0 3px var(--navy); border-color: var(--navy); }
.eraser { margin-right: 6px; }

.piece-row { display: grid; grid-template-columns: 44px 44px 1fr; gap: 10px; align-items: center; margin: 12px 0; }
.piece-row .piece { width: 42px; }
.piece-row p { margin: 0; }

.priority-list { list-style: none; counter-reset: pr; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.priority-list li { counter-increment: pr; position: relative; padding: 22px 18px 18px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.priority-list li::before { content: counter(pr); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--coral); color: #fff; font: 700 1.1rem var(--serif); margin-bottom: 10px; }
.priority-list b { font: 700 1.2rem var(--serif); color: var(--navy); }
.priority-list p { margin: 6px 0 0; color: #4d6573; font-size: .95rem; }

/* ---------- Confronto ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid #e8eef0; }
thead th { background: var(--navy); color: #fff; font-size: .9rem; }
thead th small { display: block; font-weight: 400; opacity: .75; }
tbody th { color: var(--navy); font-size: .92rem; width: 22%; }
tbody tr:last-child > * { border-bottom: 0; }
.compare thead .it { background: #1f6b41; }
.compare thead .en { background: #9d3b28; }
.compare thead .int { background: #4d6573; }
.compare td:last-child { color: var(--muted); font-size: .92rem; }
.compare tr.key { background: #fff7d9; }

.compare-boards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: clamp(14px, 2.5vw, 26px); background: var(--sky); border-radius: var(--radius); }
.compare-card { margin: 0; display: grid; gap: 10px; align-content: start; }
.compare-note { margin: 0; font-weight: 700; }
.move-chips { margin: 0; font-size: .92rem; }
.move-chips code { margin: 2px; display: inline-block; background: #fff; }

/* ---------- Quiz ---------- */
.quiz { margin: 50px 0 10px; padding: clamp(20px, 3vw, 34px); background: #fff; border: 2px solid var(--navy); border-radius: var(--radius); }
.quiz > h2::before { content: '✎ '; color: var(--coral); }
.quiz-q { padding: 16px 0; border-bottom: 1px solid #e8eef0; }
.quiz-text { margin: 0 0 10px; font-weight: 600; font-size: 1.05rem; }
.quiz-options { display: flex; flex-wrap: wrap; gap: 8px; }
.quiz-options button { padding: 10px 16px; border: 1px solid #b8c9d0; border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; text-align: left; }
.quiz-options button:hover { border-color: var(--navy); }
.quiz-options button.correct { background: #e4f5e8; border-color: var(--green); }
.quiz-options button.wrong { background: #fdebe6; border-color: var(--red); text-decoration: line-through; }
.quiz-why { margin: 10px 0 0; font-size: .95rem; }
.quiz-why:empty { display: none; }
.quiz-why.ok { color: #1f6b41; }
.quiz-why.no { color: #9d3b28; }
.quiz-score { margin: 16px 0 0; font-weight: 800; color: var(--navy); }
.quiz-score:empty { display: none; }

/* ---------- Simulatore ---------- */
.simulator { display: grid; grid-template-columns: minmax(280px, 620px) minmax(280px, 1fr); gap: clamp(18px, 3vw, 36px); align-items: start;
  padding: clamp(14px, 2.5vw, 28px); background: var(--sky); border-radius: var(--radius); }
body.lim .simulator { grid-template-columns: minmax(300px, 760px) minmax(280px, 1fr); }
.sim-left { display: grid; gap: 12px; }
.sim-counts { display: grid; gap: 6px; font-size: .9rem; }
.sim-counts span { padding: 8px 12px; background: #fff; border-radius: 10px; border-left: 5px solid transparent; }
.sim-counts span.on-turn { border-left-color: var(--yellow); font-weight: 700; }
.sim-panel { display: grid; gap: 14px; align-content: start; padding: 22px; background: #fff; border-radius: var(--radius); }
.sim-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.sim-panel, .sim-left, .exercise-panel, .field { min-width: 0; }
.field select { width: 100%; min-width: 0; }
.field { display: grid; gap: 4px; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field select { padding: 9px 10px; border: 1px solid #b8c9d0; border-radius: 8px; background: #fff; font: 700 .95rem var(--sans); color: var(--navy); text-transform: none; letter-spacing: 0; }
.sim-toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.sim-status { font-size: 1.6rem; display: flex; align-items: center; gap: 10px; }
.sim-status::before { content: ''; width: 22px; height: 22px; border-radius: 50%; flex: none; }
.sim-status.w::before { background: #fffaf0; border: 3px solid var(--navy); }
.sim-status.b::before { background: #222c32; border: 3px solid #0d1418; }
.sim-status.over { color: var(--coral); }
.sim-status.over::before { content: '🏁'; width: auto; height: auto; }
.rule-reminder { margin: 0; font-size: .85rem; color: var(--muted); padding: 10px 12px; background: var(--paper); border-radius: 8px; }
.history-box summary { cursor: pointer; font-weight: 800; color: var(--navy); }
.history { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 4px; max-height: 180px; overflow-y: auto; }
.history li { font-size: .88rem; display: flex; align-items: center; padding: 3px 6px; border-radius: 6px; background: var(--paper); }
.history li span { color: var(--muted); margin-right: 4px; }

/* ---------- Pager e footer ---------- */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 50px; padding-top: 24px; border-top: 1px solid var(--line); }
.site-footer { display: flex; gap: 20px; align-items: center; padding: 22px clamp(16px, 4vw, 60px); background: #fff; border-top: 1px solid var(--line); font-size: .9rem; }
.site-footer span { color: var(--muted); flex: 1; }
.site-footer a { font-weight: 800; color: var(--blue); text-decoration: none; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
/* Firma dell'autore: corsivo serif, come una firma a penna. */
.signature { font: italic 400 1.45rem/1.2 var(--serif); color: var(--navy); letter-spacing: .01em; }
.hero .signature { margin: 18px 0 0; padding-left: 46px; position: relative; font-size: 1.6rem; }
.hero .signature::before { content: ''; position: absolute; left: 0; top: 55%; width: 34px; height: 2px; background: var(--coral); }
.site-footer .signature { font-size: 1.25rem; font-weight: 400; }
@media (max-width: 600px) { .site-footer { flex-direction: column; align-items: flex-start; gap: 6px; } }

/* ---------- Responsive ---------- */
@media (max-width: 1420px) {
  .simulator, body.lim .simulator { grid-template-columns: 1fr; }
  .simulator .sim-left { max-width: 600px; width: 100%; margin: 0 auto; }
}
@media (max-width: 1150px) {
  .path-map { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rule-cards, .priority-list, .build-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exercise, .simulator, body.lim .exercise, body.lim .simulator { grid-template-columns: 1fr; }
  .exercise > .board-frame, .simulator .sim-left { max-width: 560px; width: 100%; margin: 0 auto; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: block; }
  .stage-nav { position: fixed; top: var(--topbar); left: 0; z-index: 15; width: 290px; transform: translateX(-105%); transition: transform .2s; box-shadow: 10px 0 40px #062c5230; }
  body.nav-open .stage-nav { transform: none; }
  .hero, .two-col, .how-to { grid-template-columns: 1fr; }
  .hero-board { display: none; }
  .brand small { display: none; }
  .compare-boards { grid-template-columns: 1fr; }
  .compare-card { max-width: 480px; margin: 0 auto; }
}
@media (max-width: 600px) {
  .topbar-actions .button:first-child { display: none; }
  .brand > span:last-child { font-size: .9rem; }
  .path-map, .rule-cards, .rule-cards.three, .priority-list, .facts, .build-steps { grid-template-columns: 1fr; }
  .build-cta { flex-direction: column; align-items: flex-start; }
  .timeline::before { left: 8px; }
  .timeline li { grid-template-columns: 1fr; gap: 6px; padding-left: 30px; }
  .timeline li::before { left: 1px; top: 16px; }
  .timeline time { text-align: left; padding: 0; }
  .choice-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .sim-settings { grid-template-columns: 1fr; }
  .glossary { grid-template-columns: 1fr; gap: 0 0; }
  .glossary dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Stampa (guida docente e pagine di teoria) ---------- */
@media print {
  .topbar, .stage-nav, .pager, .site-footer, [data-print], .widget, .quiz { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  body { background: #fff; }
  .card.highlight { background: #fff; color: var(--ink); border: 2px solid var(--navy); }
  .card.highlight h2, .card.highlight p, .card.highlight li, .card.highlight b { color: var(--ink); }
}

/* Ritorno alla pagina "Palestra di logica" (barra in alto e menu delle tappe). */
.stage-nav a.hub-link { margin: 0 0 12px; padding: 10px; background: #e7f2f4; color: var(--navy); font-weight: 800; line-height: 1.2; }
.stage-nav a.hub-link em { background: var(--navy); color: #fff; }
.stage-nav a.hub-link { flex-wrap: wrap; row-gap: 0; }
.stage-nav a.hub-link small { flex-basis: 100%; padding-left: 36px; margin-top: -4px; font-size: .72rem; font-weight: 600; color: var(--muted); }
.stage-nav a.hub-link:hover { background: #d6eaee; }
@media (max-width: 900px) { .topbar-actions .hub-back { display: none; } }

/* ---------- Simulatore a schermo intero (solo cellulare) ---------- */
.fs-open { display: none; }
@media (max-width: 700px), (pointer: coarse) and (max-height: 520px) {
  .fs-open { display: flex; width: 100%; min-height: 52px; margin: 0 0 12px; font-size: 1rem; }
}
html.fs-lock, html.fs-lock body { overflow: hidden; }
.fs-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; gap: 8px; height: 100vh; height: 100dvh; overflow: hidden;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: var(--sky); }
.fs-bar { display: flex; align-items: center; gap: 8px; }
.fs-title { flex: 1; min-width: 0; }
.fs-title .sim-status { margin: 0; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-title .sim-status::before { width: 16px; height: 16px; }
.fs-icon { flex: none; width: 44px; height: 44px; border: 1px solid #b8c9d0; border-radius: 12px; background: #fff; color: var(--navy); font-size: 1.3rem; cursor: pointer; }
.fs-game { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.fs-game > * { width: 100%; max-width: var(--fs-board, 100%); }
.fs-game > .board-frame { flex: none; padding: 5px; border-radius: 10px; }
.fs-game .sim-counts { display: flex; gap: 6px; font-size: .78rem; }
.fs-game .sim-counts span { flex: 1; min-width: 0; padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-game .sim-captured { min-height: 28px; padding: 2px 8px; font-size: .78rem; white-space: nowrap; overflow: hidden; }
.fs-game .sim-captured .pc { width: 20px; height: 20px; }
.fs-side { display: grid; gap: 8px; }
.fs-side .feedback, .fs-side .feedback:empty { display: block; min-height: 3.3em; margin: 0; padding: 8px 12px; font-size: .9rem; line-height: 1.35; }
.fs-side .row-buttons { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.fs-side .row-buttons .button { min-height: 46px; padding: 0 4px; white-space: normal; line-height: 1.1; font-size: .8rem; }
.fs-sheet { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; padding: inherit; background: #fff; }
.fs-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: var(--navy); }
.fs-sheet-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 14px; padding-top: 12px; }
.fs-sheet-body .sim-settings { grid-template-columns: 1fr; }
@media (orientation: landscape) {
  .fs-overlay { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); column-gap: 12px; }
  .fs-bar { grid-column: 1 / -1; }
  .fs-game { height: 100%; }
  .fs-side { align-content: center; }
}

/* ---------- Scelta della partita (riquadro sopra la scacchiera) ---------- */
.board-frame { position: relative; }
.setup-card { position: absolute; top: 0; left: 0; right: 0; min-height: 100%; z-index: 12; box-shadow: 0 14px 30px #062c5240; display: flex; flex-direction: column; justify-content: safe center; gap: 10px;
  padding: clamp(10px, 3%, 24px); background: #062c52f2; border-radius: 12px; color: #fff; }
.setup-title { margin: 0; font: 700 clamp(1.15rem, 3.4vw, 1.6rem) var(--serif); color: #fff; text-align: center; }
.setup-group { display: grid; gap: 4px; }
.setup-label { font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #9fc4d6; }
.setup-options { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.setup-options button { min-height: 42px; padding: 6px 4px; border: 2px solid #ffffff40; border-radius: 10px; background: #ffffff14; color: #fff;
  font: 800 .88rem/1.15 var(--sans); cursor: pointer; }
.setup-options button:hover { border-color: #ffffffaa; }
.setup-options button.active { background: var(--yellow); border-color: var(--yellow); color: var(--navy); }
.setup-desc { margin: 0; font-size: .82rem; color: #d6e3e9; text-align: center; }
.setup-card .setup-start { width: 100%; min-height: 48px; margin-top: 2px; background: var(--yellow); color: var(--navy); font-size: 1rem; }
.setup-card .setup-start:hover { background: #ffd978; }

@media (max-width: 700px) {
  .setup-card { gap: 6px; padding: 8px 10px; }
  .setup-title { font-size: 1.05rem; }
  .setup-label { font-size: .62rem; }
  .setup-options { gap: 4px; }
  .setup-options button { min-height: 34px; padding: 3px 2px; font-size: .78rem; }
  .setup-desc { font-size: .72rem; }
  .setup-card .setup-start { min-height: 40px; font-size: .92rem; }
}

/* Scelta della partita a schermo intero: il riquadro usa tutta la larghezza sotto la barra in alto.
   C'e' spazio anche con i caratteri del telefono ingranditi; se non basta si scorre, con
   "Inizia la partita" sempre visibile in fondo. */
.fs-overlay .setup-card { position: fixed; top: calc(max(8px, env(safe-area-inset-top)) + 52px);
  left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: auto;
  min-height: 0; max-height: calc(100vh - 70px); max-height: calc(100dvh - 70px); overflow-y: auto;
  justify-content: flex-start; gap: 12px; padding: 16px 12px; }
.fs-overlay .setup-title { font-size: 1.3rem; }
.fs-overlay .setup-label { font-size: .7rem; }
.fs-overlay .setup-options { gap: 6px; }
.fs-overlay .setup-options button { min-height: 46px; font-size: .92rem; }
.fs-overlay .setup-desc { font-size: .82rem; }
.setup-card .setup-start { position: sticky; bottom: 0; box-shadow: 0 -10px 18px #062c52; }
.fs-overlay .setup-card .setup-start { min-height: 52px; font-size: 1.05rem; }

/* Riepilogo delle scelte della partita (al posto dei menu a tendina) */
.sim-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--paper); border-radius: 12px; }
.sim-summary-text { font-weight: 800; color: var(--navy); }
