:root {
  --paper: #f6efe3;
  --paper-2: #ede3d1;
  --card: #fffaf1;
  --ink: #1f1b16;
  --ink-2: #5d5448;
  --ink-3: #8a7f70;
  --orange: #ff7a1a;
  --orange-deep: #e25f00;
  --night: #121829;
  --night-2: #1a2238;
  --night-3: #243050;
  --night-line: #33406a;
  --night-ink: #e9ecf6;
  --night-ink-2: #a3acc8;

  --t-rapida: #2f7bf5;
  --t-segura: #22955a;
  --t-comum: #8c8375;
  --t-arriscada: #df4336;

  --s-current: #ff7a1a;
  --s-open: #6fb2ff;
  --s-done: #2fbf73;
  --s-test: #ffd23d;
  --s-tree: #6fb2ff;
  --s-path: #ff7a1a;

  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --display: "Pixelify Sans", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --maxw: 1200px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* o fundo do html aparece quando o navegador "estica" a página além do topo
   ou do fim: fica escuro, da cor do topbar e do rodapé, em vez de branco */
html { scroll-behavior: smooth; scroll-padding-top: 72px; background: var(--night); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0 0 0.5em; letter-spacing: 0.01em; }
h3 { font-size: 1.35rem; }
p { margin: 0 0 0.9em; }
a { color: inherit; }
code, .math { font-family: var(--mono); font-size: 0.92em; }
b { font-weight: 700; }
.small { font-size: 0.88rem; color: var(--ink-2); }
button, select, input { font: inherit; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px max(16px, calc((100vw - var(--maxw)) / 2));
  background: rgba(18, 24, 41, 0.92);
  backdrop-filter: blur(8px);
  color: var(--night-ink);
  border-bottom: 2px solid #000;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 1.2rem; text-decoration: none; white-space: nowrap; }
.brand-mark {
  width: 22px; height: 20px; display: inline-block; flex: none;
  background:
    linear-gradient(var(--ink), var(--ink)) 6px 9px / 3px 3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 13px 9px / 3px 3px no-repeat,
    var(--orange);
  clip-path: polygon(0 0, 27% 0, 27% 25%, 73% 25%, 73% 0, 100% 0, 100% 100%, 0 100%);
}
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; padding: 6px 12px; border-radius: 3px; font-size: 0.92rem; font-weight: 600;
  color: var(--night-ink-2); white-space: nowrap;
}
.nav a:hover, .nav a.active { color: #fff; background: var(--night-3); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: 2px solid var(--ink); border-radius: 3px;
  font-weight: 700; text-decoration: none; cursor: pointer; line-height: 1.1;
  box-shadow: var(--shadow-sm); transition: transform 0.08s, box-shadow 0.08s;
  background: var(--card); color: var(--ink);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-primary { background: var(--orange); color: #1b0f05; }
.btn-ghost { background: transparent; color: #fff; border-color: #fff; box-shadow: 3px 3px 0 #000; }
.btn-ghost-dark { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---------------- Hero ---------------- */
.hero {
  position: relative;
  min-height: min(88vh, 820px);
  display: flex; align-items: center;
  padding: 72px max(16px, calc((100vw - var(--maxw)) / 2)) 64px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(1200px 500px at 75% 115%, rgba(255, 146, 72, 0.55), transparent 60%),
    linear-gradient(180deg, #0e1426 0%, #1c2346 45%, #4a3a63 78%, #c1686a 100%);
}
.hero::before { /* estrelas em pixel */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.7;
  background-image:
    radial-gradient(2px 2px at 10% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 24% 30%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 38% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 62% 18%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 81% 9%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 26%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 52% 34%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 5% 44%, #fff 50%, transparent 51%);
}
.hero-scene { position: absolute; inset: 0 0 0 28%; cursor: grab; touch-action: pan-y; }
.hero-scene:active { cursor: grabbing; }
.hero-scene canvas { display: block; width: 100% !important; height: 100% !important; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(14, 20, 38, 0.94) 0%, rgba(14, 20, 38, 0.82) 30%, rgba(14, 20, 38, 0.35) 46%, transparent 58%);
}
.hero-content { position: relative; z-index: 2; max-width: 560px; pointer-events: none; }
.hero-content > * { pointer-events: auto; }
.kicker {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--orange-deep); margin-bottom: 10px;
}
.hero .kicker { color: #ffb37d; }
.hero h1 {
  font-size: clamp(3rem, 8vw, 5.6rem); margin-bottom: 0.25em;
  text-shadow: 4px 4px 0 #000;
}
.lead { font-size: 1.12rem; color: #dfe3f2; max-width: 52ch; }
.lead b { color: #fff; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 34px; }
.hero-actions .btn-primary { box-shadow: 3px 3px 0 #000; border-color: #000; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.hero-stats div {
  background: rgba(10, 14, 28, 0.6); border: 2px solid rgba(255, 255, 255, 0.18);
  padding: 8px 14px; border-radius: 3px; min-width: 96px;
}
.hero-stats dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--night-ink-2); }
.hero-stats dd { margin: 0; font-family: var(--display); font-size: 1.5rem; }
.hero-hint {
  position: absolute; right: max(16px, calc((100vw - var(--maxw)) / 2)); bottom: 18px; z-index: 2;
  font-family: var(--mono); font-size: 0.75rem; color: rgba(255, 255, 255, 0.6); margin: 0;
}

/* ---------------- Sections ---------------- */
main { display: block; }
.section { padding: 96px max(16px, calc((100vw - var(--maxw)) / 2)); }
.section + .section:not(.section-dark) { border-top: 2px dashed rgba(31, 27, 22, 0.15); }
.section-head { max-width: 760px; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(2.1rem, 4.5vw, 3.2rem); }
.section-head p:last-child { color: var(--ink-2); font-size: 1.05rem; }
.section-dark { background: var(--night); color: var(--night-ink); }
.section-dark .section-head p:last-child { color: var(--night-ink-2); }
.section-dark .kicker { color: #ffa25e; }

.panel {
  background: var(--card); border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: var(--shadow); padding: 24px; min-width: 0;
}
.panel-dark { background: var(--night-2); border-color: #000; box-shadow: 5px 5px 0 #000; color: var(--night-ink); }
.panel h3 { margin-bottom: 14px; }

.formula {
  font-family: var(--mono); font-size: 0.95rem; background: var(--paper-2);
  border-left: 4px solid var(--orange); padding: 10px 14px; margin: 14px 0; border-radius: 2px;
  overflow-x: auto; white-space: nowrap;
}
.note { font-size: 0.92rem; color: var(--ink-2); margin: 0; }
.table-wrap { overflow-x: auto; }

/* ---------------- Teoria ---------------- */
.concepts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.concept {
  position: relative; background: var(--card); border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: var(--shadow); padding: 28px 28px 22px;
}
.concept-num {
  position: absolute; top: -18px; right: 20px; font-family: var(--display); font-size: 1.1rem;
  background: var(--orange); border: 2px solid var(--ink); padding: 2px 10px; box-shadow: var(--shadow-sm);
}
.concept h3 { font-size: 1.7rem; }
.checks { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.checks li { display: flex; gap: 10px; font-size: 0.9rem; align-items: baseline; }
.checks li::before {
  content: "✓"; flex: none; width: 20px; height: 20px; display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 700; color: #fff; background: var(--t-segura); border-radius: 2px;
  transform: translateY(3px);
}
.checks li.no::before { content: "✗"; background: var(--t-arriscada); }
.checks li.info::before { content: "i"; background: var(--t-rapida); font-family: var(--mono); }

/* ---------------- Modelagem ---------------- */
.model-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.model-grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 28px; }
.graph-panel { margin: 0; padding: 12px; }
.graph-svg { display: block; width: 100%; height: auto; user-select: none; }
.graph-panel figcaption { padding: 8px 10px 4px; }
.hover-info { margin: 8px 0 0; font-size: 0.92rem; color: var(--ink-2); min-height: 3em; }
.formal dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 8px; }
.formal dt { font-family: var(--mono); font-weight: 600; color: var(--orange-deep); }
.formal dd { margin: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.85rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 22px; height: 6px; border-radius: 1px; }
.legend-dark { color: var(--night-ink-2); margin-top: 12px; }
.sw { width: 14px !important; height: 14px !important; border: 2px solid #000; }
.sw-current { background: var(--s-current); }
.sw-open { background: var(--s-open); }
.sw-done { background: var(--s-done); }
.ln-test { background: var(--s-test); }
.ln-tree { background: var(--s-tree); }
.ln-path { background: var(--s-path); height: 8px !important; }

.places { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.place {
  background: var(--card); border: 2px solid var(--ink); border-radius: 4px; padding: 12px 14px;
  box-shadow: var(--shadow-sm); cursor: default; transition: transform 0.1s;
}
.place.hot { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--orange); }
.place-id {
  display: inline-grid; place-items: center; width: 30px; height: 30px; font-family: var(--display);
  background: var(--ink); color: #fff; border-radius: 2px; margin-bottom: 8px; font-size: 1.05rem;
}
.place h4 { font-family: var(--body); font-size: 0.95rem; margin: 0 0 4px; }
.place p { font-size: 0.82rem; color: var(--ink-2); margin: 0; line-height: 1.4; }

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--ink); }
td { padding: 6px 8px; border-bottom: 1px solid rgba(31, 27, 22, 0.1); }
.edges-table tbody { display: table-row-group; }
.edges-table td:first-child { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.edges-table td:nth-child(3) { font-family: var(--mono); font-weight: 700; }
.edges-table tr.hot td { background: #ffe6cf; }
.table-wrap .edges-table { min-width: 380px; }
.tag {
  display: inline-block; font-size: 0.74rem; font-weight: 700; padding: 1px 8px; border-radius: 2px;
  color: #fff; white-space: nowrap; line-height: 1.6;
}
.tag-rápida, .tag-rapida { background: var(--t-rapida); }
.tag-segura { background: var(--t-segura); }
.tag-comum { background: var(--t-comum); }
.tag-arriscada { background: var(--t-arriscada); }

.matrix { font-family: var(--mono); font-size: 0.82rem; width: auto; margin: 0 auto; }
.matrix th, .matrix td { width: 32px; height: 30px; text-align: center; padding: 0; border: 1px solid rgba(31, 27, 22, 0.12); }
.matrix th { border-bottom: 1px solid rgba(31, 27, 22, 0.12); color: var(--ink); font-size: 0.8rem; font-weight: 700; letter-spacing: 0; text-transform: none; }
.matrix td.w { font-weight: 700; color: #1b0f05; }
.matrix td.diag { background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(31, 27, 22, 0.08) 4px 5px); }
.matrix td.hl, .matrix th.hl { outline: 2px solid var(--ink); outline-offset: -2px; }
.matrix td.mirror { outline: 2px dashed var(--orange-deep); outline-offset: -2px; }

/* ---------------- Funções ---------------- */
.functions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.fn { background: var(--card); border: 2px solid var(--ink); border-radius: 4px; box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.fn-wide { grid-column: 1 / -1; }
.fn-sig {
  display: inline-block; background: var(--ink); color: #ffd7b5; padding: 4px 10px; border-radius: 2px;
  font-size: 0.9rem; margin-bottom: 14px; max-width: 100%; overflow-x: auto; white-space: nowrap;
}
.fn h3 { font-size: 1.5rem; }
.fn-props { font-size: 0.88rem; color: var(--ink-2); margin: 12px 0 0; }
.fn-props b { color: var(--ink); }

.arrow-map { display: grid; grid-template-columns: max-content minmax(60px, 1fr) 52px; gap: 0; position: relative; margin-top: 6px; }
.arrow-map svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.arrow-col { display: flex; flex-direction: column; gap: 3px; z-index: 1; }
.arrow-col.right { grid-column: 3; justify-content: space-around; }
.arrow-col .chip {
  font-family: var(--mono); font-size: 0.75rem; padding: 1px 6px; border: 1.5px solid var(--ink); border-radius: 2px;
  background: var(--card); text-align: center; cursor: default; line-height: 1.5;
}
.arrow-col.right .chip { font-weight: 700; font-size: 0.9rem; padding: 3px 6px; }
.arrow-col .chip.hot { background: var(--orange); }
.arrow-map path { fill: none; stroke: rgba(31, 27, 22, 0.22); stroke-width: 1.3; }
.arrow-map path.hot { stroke: var(--orange-deep); stroke-width: 2.5; }

.type-bars, .bars { display: grid; gap: 8px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 28px; gap: 10px; align-items: center; font-size: 0.86rem; }
.bar-row .track { height: 16px; background: var(--paper-2); border-radius: 2px; overflow: hidden; }
.bar-row .fill { height: 100%; border-right: 2px solid var(--ink); }
.bar-row .val { font-family: var(--mono); font-weight: 700; text-align: right; }
.bar-row small { color: var(--ink-3); }

.dist-fn { font-family: var(--mono); text-align: center; margin: 10px 0 12px; min-width: 520px; }
.dist-fn th, .dist-fn td { text-align: center; padding: 6px 4px; }
.dist-fn th:first-child, .dist-fn td:first-child { text-align: left; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
.dist-fn td.origin { background: #ffe6cf; font-weight: 700; }
.inline-select { display: inline-flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: 0.9rem; }
select {
  background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: 3px;
  padding: 6px 10px; cursor: pointer; max-width: 100%;
}

/* ---------------- Laboratório ---------------- */
.lab-controls {
  display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px;
  background: var(--night-2); border: 2px solid #000; box-shadow: 5px 5px 0 #000; border-radius: 4px; padding: 16px;
}
.lab-controls label { display: grid; gap: 4px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--night-ink-2); font-weight: 600; }
.lab-controls select { background: var(--night); color: var(--night-ink); border-color: var(--night-line); min-width: 190px; text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
.swap { background: var(--night-3); color: #fff; border: 2px solid var(--night-line); border-radius: 3px; height: 40px; width: 40px; cursor: pointer; font-size: 1.1rem; }
.swap:hover { background: var(--night-line); }
.lab-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-controls .btn { box-shadow: 3px 3px 0 #000; border-color: #000; }
.btn-icon { width: 44px; padding: 10px 0; background: var(--night-3); color: #fff; }
.lab-controls .speed { margin-left: auto; }
.speed input { accent-color: var(--orange); width: 140px; }
.progress { height: 6px; background: var(--night-2); margin: 16px 0 20px; border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--orange); transition: width 0.2s; }

.lab-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.lab-view { min-width: 0; }
.view-tabs { display: flex; align-items: end; gap: 4px; }
.view-tabs button {
  background: var(--night-2); color: var(--night-ink-2); border: 2px solid #000; border-bottom: 0;
  padding: 8px 16px; font-weight: 700; cursor: pointer; border-radius: 4px 4px 0 0;
}
.view-tabs button[aria-selected="true"] { background: var(--night-3); color: #fff; }
.step-count { margin-left: auto; font-family: var(--mono); font-size: 0.82rem; color: var(--night-ink-2); padding-bottom: 6px; }
.view-body {
  position: relative; aspect-ratio: 16 / 10.5; border: 2px solid #000; box-shadow: 5px 5px 0 #000;
  border-radius: 0 4px 4px 4px; overflow: hidden;
  background:
    radial-gradient(800px 300px at 50% 120%, rgba(255, 146, 72, 0.3), transparent 70%),
    linear-gradient(180deg, #172042, #2c2a52 80%, #5a3f64);
}
.lab-scene { position: absolute; inset: 0; cursor: grab; touch-action: pan-y; }
.lab-scene:active { cursor: grabbing; }
.lab-scene canvas { display: block; width: 100% !important; height: 100% !important; }
.scene-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lab-graph { position: absolute; inset: 0; width: 100%; height: 100%; background: #f6efe3; }
.view-hint {
  position: absolute; left: 10px; bottom: 8px; margin: 0; z-index: 3; pointer-events: none;
  font-family: var(--mono); font-size: 0.7rem; color: rgba(255, 255, 255, 0.7);
  background: rgba(14, 18, 34, 0.6); padding: 2px 6px; border-radius: 2px;
}
@media (hover: none) { .view-hint { display: none; } }
.zoom { position: absolute; right: 10px; top: 10px; display: grid; gap: 6px; z-index: 3; }
.zoom button {
  width: 34px; height: 34px; background: rgba(18, 24, 41, 0.85); color: #fff; border: 2px solid #000;
  border-radius: 3px; cursor: pointer; font-size: 1.05rem; line-height: 1;
}
.zoom button:hover { background: var(--night-3); }

.v-label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  background: rgba(14, 18, 34, 0.86); border: 2px solid #000; border-radius: 3px;
  padding: 2px 8px 2px 3px; color: #fff; font-size: 0.78rem; font-weight: 600;
  transition: background 0.2s, opacity 0.2s;
}
.v-label b {
  display: grid; place-items: center; width: 20px; height: 20px; background: #fff; color: #000;
  font-family: var(--display); border-radius: 2px; font-size: 0.85rem;
}
.v-label .d { font-family: var(--mono); color: var(--night-ink-2); }
.v-label.open { background: #1d3f6e; }
.v-label.open .d { color: #cfe5ff; }
.v-label.done { background: #135c37; }
.v-label.done .d { color: #c9f5da; }
.v-label.current { background: var(--s-current); color: #1b0f05; }
.v-label.current .d { color: #1b0f05; font-weight: 700; }
.v-label.origin b, .v-label.target b { background: var(--orange); }
.v-label:not(.origin):not(.target):not(.current) .nm { display: none; }
.w-label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 3px;
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700;
  background: #fffaf1; color: #111; border: 2px solid #000; border-radius: 2px;
}
.w-label.is-test { background: var(--s-test); }
.w-label.is-path { background: var(--orange); }
.w-label.is-dim { opacity: 0.55; }

.narration {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 14px 16px;
  background: var(--night-2); border: 2px solid #000; border-radius: 4px; min-height: 84px;
}
.narration p { margin: 0; color: var(--night-ink); }
.narration p b { color: #ffc28f; }
.narration-tag {
  flex: none; font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 2px; background: var(--night-3); color: var(--night-ink-2); margin-top: 2px;
}
.narration-tag.select { background: var(--s-current); color: #1b0f05; }
.narration-tag.improve { background: var(--s-open); color: #04162f; }
.narration-tag.keep { background: #4a5680; color: #fff; }
.narration-tag.done { background: var(--orange); color: #1b0f05; }

.lab-side { display: grid; gap: 20px; min-width: 0; }
.state-table { font-family: var(--mono); font-size: 0.86rem; }
.state-table th { color: var(--night-ink-2); border-bottom-color: var(--night-line); }
.state-table td { border-bottom-color: rgba(255, 255, 255, 0.06); padding: 5px 8px; transition: background 0.25s; }
.state-table td:first-child { font-weight: 700; }
.state-table tr.current td { background: rgba(255, 122, 26, 0.28); }
.state-table tr.changed td { background: rgba(111, 178, 255, 0.28); }
.state-table tr.target td:first-child::after { content: " ★"; color: var(--orange); }
.state-table .st { font-family: var(--body); font-size: 0.74rem; padding: 1px 7px; border-radius: 2px; }
.st-open { background: #1d3f6e; color: #cfe5ff; }
.st-done { background: #135c37; color: #c9f5da; }
.st-none { color: #6a7396; }
.st-current { background: var(--s-current); color: #1b0f05; }

.code-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.small-link { font-size: 0.8rem; color: #ffb37d; }
.code {
  position: relative; max-height: 440px; overflow: auto;
  margin: 0; font-family: var(--mono); font-size: 0.74rem; line-height: 1.55;
  background: var(--night); border-radius: 3px; padding: 10px 0; color: #cdd3ea; counter-reset: ln;
}
.code .line { display: block; padding: 0 12px 0 0; white-space: pre; border-left: 3px solid transparent; transition: background 0.15s; }
.code .line::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 30px; text-align: right; margin-right: 12px; color: #4f5a80; }
.code .line.on { background: rgba(255, 122, 26, 0.22); border-left-color: var(--orange); color: #fff; }
.code .c { color: #7d88ad; font-style: italic; }
.code .k { color: #ff9f6b; }

/* ---------------- Testes ---------------- */
.tests { display: grid; gap: 28px; }
.test {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 4px; box-shadow: var(--shadow); padding: 26px;
}
.test-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.test-head h3 { margin: 0; font-size: 1.8rem; }
.test-num { font-family: var(--mono); font-size: 0.78rem; background: var(--ink); color: #fff; padding: 2px 8px; border-radius: 2px; }
.route { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 6px; }
.route .stop {
  font-family: var(--display); font-size: 1.1rem; width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--orange); border: 2px solid var(--ink); border-radius: 3px; box-shadow: 2px 2px 0 var(--ink);
}
.route .leg { display: flex; flex-direction: column; align-items: center; font-size: 0.7rem; line-height: 1.2; min-width: 36px; }
.route .leg b { font-family: var(--mono); font-size: 0.85rem; }
.route .leg i { width: 30px; height: 4px; border-radius: 1px; margin: 3px 0; }
.big-cost { font-family: var(--display); font-size: 2.4rem; line-height: 1; margin: 14px 0 4px; }
.big-cost small { font-family: var(--mono); font-size: 0.95rem; color: var(--ink-2); margin-left: 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.facts span { font-size: 0.78rem; border: 1.5px solid var(--ink); border-radius: 2px; padding: 1px 8px; background: var(--paper); }
.test p.reading { font-size: 0.95rem; }
.test .btn { margin-top: 6px; font-size: 0.9rem; padding: 8px 14px; }
.ranking h4 { font-family: var(--body); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin-bottom: 10px; }
.rank { display: grid; gap: 5px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 30px; gap: 10px; align-items: center; font-size: 0.82rem; }
.rank-row .p { font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .track { height: 14px; background: var(--paper-2); border-radius: 2px; overflow: hidden; }
.rank-row .fill { height: 100%; background: #c9bda9; }
.rank-row .c { font-family: var(--mono); font-weight: 700; text-align: right; }
.rank-row.best .fill { background: var(--orange); }
.rank-row.best .p { font-weight: 700; }
.rank-row.best .p::after { content: " ★"; color: var(--orange-deep); }
.rank-row.chosen .p::before { content: "▶ "; color: var(--orange-deep); }
.rank-more { font-size: 0.8rem; color: var(--ink-3); margin-top: 8px; }
.conclusions { margin-top: 36px; }
.conclusions ol { margin: 0; padding-left: 22px; display: grid; gap: 10px; }

/* ---------------- Jogo ---------------- */
.game-teaser { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.game-teaser h2 { font-size: clamp(2.1rem, 4.5vw, 3.2rem); }
.game-teaser p { color: var(--night-ink-2); }
.game-list { color: var(--night-ink-2); padding-left: 20px; display: grid; gap: 6px; }
.game-list b { color: #fff; }
.small-dark { font-size: 0.85rem; color: var(--night-ink-2); }
.game-card {
  position: relative; display: grid; align-content: space-between; gap: 12px; aspect-ratio: 4 / 3; padding: 20px;
  text-decoration: none; color: #fff; border: 2px solid #000; border-radius: 4px; box-shadow: 6px 6px 0 #000; overflow: hidden;
  background:
    radial-gradient(circle at 70% 70%, #67a052 0 18%, transparent 18.5%),
    radial-gradient(circle at 28% 40%, #67a052 0 15%, transparent 15.5%),
    linear-gradient(20deg, transparent 47%, #9b6a3f 47% 53%, transparent 53%),
    linear-gradient(180deg, #7fb3e6, #3f8fd0);
  transition: transform 0.12s;
}
.game-card:hover { transform: translate(-2px, -2px); }
.gc-hud, .gc-cost { justify-self: start; background: rgba(18, 24, 41, 0.9); border: 2px solid #000; padding: 4px 10px; font-family: var(--display); border-radius: 3px; }
.gc-cost { justify-self: end; font-family: var(--mono); font-size: 0.85rem; }
.gc-route { display: flex; align-items: center; gap: 6px; justify-self: center; }
.gc-route i { font-style: normal; font-family: var(--display); width: 36px; height: 36px; display: grid; place-items: center; background: var(--orange); color: #1b0f05; border: 2px solid #000; }
.gc-route em { font-style: normal; font-family: var(--mono); background: #fffaf1; color: #111; border: 2px solid #000; padding: 0 6px; }
.gc-play { position: absolute; right: 16px; top: 16px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--orange); color: #1b0f05; border: 2px solid #000; font-size: 1.2rem; }

/* ---------------- Apresentação ---------------- */
.roadmap { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.roadmap li { position: relative; background: var(--card); border: 2px solid var(--ink); border-radius: 4px; padding: 20px; box-shadow: var(--shadow-sm); }
.roadmap span {
  display: grid; place-items: center; width: 36px; height: 36px; font-family: var(--display); font-size: 1.2rem;
  background: var(--orange); border: 2px solid var(--ink); border-radius: 3px; margin-bottom: 12px;
}
.roadmap h3 { font-size: 1.25rem; margin-bottom: 6px; }
.roadmap p { font-size: 0.92rem; color: var(--ink-2); margin-bottom: 10px; }
.roadmap a { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; color: var(--orange-deep); }
.team { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 28px; margin-top: 36px; align-items: start; }
.team ul { margin: 0; padding-left: 18px; }
.team-links { display: grid; gap: 12px; }

.footer {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; text-align: center;
  padding: 28px 16px; background: var(--night); color: var(--night-ink-2); font-size: 0.88rem;
}

/* ---------------- Grafo SVG ---------------- */
.g-edge { stroke-width: 5; stroke-linecap: round; transition: stroke 0.25s, stroke-width 0.25s, opacity 0.25s; }
.g-edge-bridge { stroke-dasharray: none; }
.g-gap { stroke: #fffaf1; stroke-width: 13; stroke-linecap: butt; }
.g-weight rect { fill: #fffaf1; stroke: var(--ink); stroke-width: 2; transition: fill 0.25s; }
.g-weight text { font: 700 15px var(--mono); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.g-node { cursor: pointer; }
.g-node rect.body { fill: #fffaf1; stroke: var(--ink); stroke-width: 2.5; transition: fill 0.25s; }
.g-node rect.shade { fill: var(--ink); }
.g-node text.id { font: 700 22px var(--display); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.g-node text.name { font: 600 13px var(--body); fill: var(--ink-2); text-anchor: middle; }
.g-node text.dist { font: 700 13px var(--mono); fill: var(--ink); text-anchor: middle; }
.g-node .dist-bg { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.graph-svg.focus .g-edge:not(.hot) { opacity: 0.15; }
.graph-svg.focus .g-weight:not(.hot) { opacity: 0.2; }
.graph-svg.focus .g-node:not(.hot) { opacity: 0.35; }
.g-node.hot rect.body { fill: #ffe6cf; }
.g-node.sel rect.body { fill: var(--orange); }

/* estados do algoritmo no grafo 2D */
.lab-graph .g-edge { stroke: #cbbfa9; }
.lab-graph .g-edge.is-tree { stroke: var(--s-tree); stroke-width: 7; }
.lab-graph .g-edge.is-test { stroke: var(--s-test); stroke-width: 9; }
.lab-graph .g-edge.is-path { stroke: var(--s-path); stroke-width: 10; }
.lab-graph .g-weight.is-test rect { fill: var(--s-test); }
.lab-graph .g-weight.is-path rect { fill: var(--orange); }
.lab-graph .g-node.open rect.body { fill: #cfe5ff; }
.lab-graph .g-node.done rect.body { fill: #b9ecd0; }
.lab-graph .g-node.current rect.body { fill: var(--s-current); }

/* ---------------- Responsivo ---------------- */
@media (max-width: 1000px) {
  .lab-grid, .model-grid, .model-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .places { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .test { grid-template-columns: minmax(0, 1fr); }
  .roadmap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team { grid-template-columns: minmax(0, 1fr); }
  .game-teaser { grid-template-columns: minmax(0, 1fr); }
  .hero { flex-direction: column; align-items: stretch; min-height: 0; padding-bottom: 0; }
  .hero::after { display: none; }
  .hero-scene { position: relative; inset: auto; order: 2; height: 420px; margin: 8px -16px 0; }
  .hero-hint { bottom: 12px; }
  .lab-controls .speed { margin-left: 0; }
}
@media (max-width: 720px) {
  .topbar { gap: 12px; }
  .brand span:last-child { display: none; }
  .section { padding-top: 68px; padding-bottom: 68px; }
  .concepts, .functions { grid-template-columns: minmax(0, 1fr); }
  .concept { padding: 24px 18px 18px; }
  .fn, .panel, .test { padding: 18px; }
  .roadmap { grid-template-columns: minmax(0, 1fr); }
  .hero { padding-top: 44px; }
  .hero-scene { height: 330px; }
  .hero-stats div { min-width: 0; flex: 1 1 40%; }
  .lab-controls select { min-width: 0; width: 100%; }
  .lab-controls label { flex: 1 1 40%; }
  .view-body { aspect-ratio: 4 / 5; }
  .lab-buttons { flex-wrap: nowrap; width: 100%; gap: 6px; }
  .lab-buttons .btn-icon { width: 40px; flex: none; }
  .lab-buttons .btn-primary { flex: 1; padding: 10px 6px; }
  .rank-row { grid-template-columns: minmax(0, 1fr) 70px 26px; }
}
/* ---------------- Animações ---------------- */
.hero-content > * { animation: subir 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.hero-content > :nth-child(2) { animation-delay: 0.08s; }
.hero-content > :nth-child(3) { animation-delay: 0.16s; }
.hero-content > :nth-child(4) { animation-delay: 0.24s; }
.hero-content > :nth-child(5) { animation-delay: 0.32s; }
.hero-hint { animation: piscar 2.4s ease-in-out 1.2s infinite both; }
@keyframes subir { from { opacity: 0; transform: translateY(22px); } }
@keyframes piscar { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.9; } }

.revelar { opacity: 0; }
.revelar.revelado { animation: subir 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) var(--atraso, 0s) both; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-content > *, .hero-hint, .revelar.revelado { animation: none; }
  .revelar { opacity: 1; }
  * { transition: none !important; }
}

@media print {
  .topbar, .hero-scene, .hero-hint, .lab-controls, .progress, .view-tabs, .zoom, .lab-scene, .scene-labels, .test .btn, .team-links { display: none !important; }
  html, body, .section-dark, .hero { background: #fff !important; color: #000 !important; }
  .revelar { opacity: 1 !important; animation: none !important; }
  .hero { min-height: 0; padding: 24px; }
  .hero h1 { text-shadow: none; color: #000; }
  .lead, .hero .kicker, .hero-stats dt { color: #333 !important; }
  .lab-graph { display: block !important; position: static; }
  .view-body { aspect-ratio: auto; }
  .code { max-height: none; }
  .section { padding: 32px 16px; break-inside: avoid-page; }
  .panel, .concept, .fn, .test { box-shadow: none; break-inside: avoid; }
}
