:root {
  --bg: #eaf5ff;
  --card: #ffffff;
  --ink: #1f3550;
  --muted: #475a6e;
  --line: #d6e8f7;
  --brand: #1565c0;
  --brand2: #4fb3f0;
  --grad: linear-gradient(120deg, #1565c0, #1e7ad4);
  --brand-soft: #eaf5ff;
  --key: #a8dcff;
  --prog: #1565c0;
  --warn-bg: #fff3dc;
  --warn-line: #f2b04a;
  --lock-bg: #edf3f9;
  --shadow: 0 8px 24px rgba(21, 101, 192, .12);
  --radius: 18px;
}
html { font-size: 100%; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); line-height: 1.55;
  background: radial-gradient(900px 400px at 85% -5%, #a8dcff 0, transparent 60%),
              radial-gradient(700px 400px at -5% 10%, #eaf5ff 0, transparent 55%), var(--bg);
  background-attachment: fixed;
}
main { max-width: 1160px; margin: 0 auto; padding: 12px 16px 40px; }

header {
  background: linear-gradient(135deg, #0b3c8c, #1565c0 55%, #4fb3f0); color: #fff; border-radius: 18px; padding: 14px 22px; margin-bottom: 12px;
  box-shadow: 0 14px 34px rgba(21, 101, 192, .30); position: relative; overflow: hidden;
}
header::after {
  content: ""; position: absolute; right: -60px; top: -70px; width: 240px; height: 240px;
  border-radius: 50%; background: rgba(255, 255, 255, .14);
}
.back {
  position: relative; display: inline-block; color: #fff; opacity: .9; font-size: .85rem;
  font-weight: 600; text-decoration: none; margin-bottom: 4px;
}
.back:hover { opacity: 1; text-decoration: underline; }
header h1 { font-size: clamp(1.2rem, 3vw, 1.6rem); margin: 0 0 2px; letter-spacing: -.02em; position: relative; }
header p { margin: 0; font-size: .92rem; max-width: 70ch; opacity: .92; position: relative; }

.steps { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); }
.step {
  background: var(--card); border-radius: var(--radius); padding: 10px 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line); transition: opacity .25s, transform .25s;
}
.step:not(.locked):hover { transform: translateY(-2px); }
.step.locked { opacity: .5; }
.step h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 6px;
  color: var(--brand); font-weight: 800;
}
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt {
  font: inherit; text-align: left; cursor: pointer; min-height: 38px;
  border: 1.5px solid var(--line); background: #f6fbff; color: var(--ink);
  border-radius: 12px; padding: 7px 12px;
  transition: all .18s;
}
.opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.opt:active { transform: scale(.97); }
.opt:focus-visible { outline: 3px solid var(--brand2); outline-offset: 2px; }
.opt[aria-pressed="true"] {
  background: var(--grad); border-color: transparent; color: #fff; font-weight: 700;
  box-shadow: 0 6px 16px rgba(21, 101, 192, .35);
}
.opt[aria-disabled="true"] { background: var(--lock-bg); color: #5a6d83; border-style: dashed; cursor: not-allowed; }
.opt[aria-disabled="true"]:hover { border-color: var(--warn-line); background: var(--lock-bg); }
.na {
  border: 1.5px dashed var(--line); background: var(--lock-bg); color: var(--muted);
  border-radius: 12px; padding: 10px 12px; font-size: .9rem;
}

#msg {
  margin: 14px 0 0; padding: 0 16px; border-radius: 14px; border: 1px solid transparent;
  max-height: 0; overflow: hidden; opacity: 0; transition: max-height .25s, opacity .25s, padding .25s;
}
#msg.show { max-height: 30rem; opacity: 1; padding: 13px 16px; }
#msg.warn { background: var(--warn-bg); border-color: var(--warn-line); border-left: 6px solid var(--warn-line); }
#msg.lock { background: var(--lock-bg); border-color: var(--line); color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 2px 8px; }
#ruta { font-size: .95rem; color: var(--muted); }
#ruta b {
  color: var(--brand); background: var(--brand-soft); padding: 3px 10px; border-radius: 999px;
  font-weight: 700; font-size: .88rem; white-space: nowrap;
}
.reset {
  font: inherit; font-weight: 600; border: 2px solid var(--brand); background: #fff; color: var(--brand);
  border-radius: 999px; padding: 8px 20px; cursor: pointer; transition: all .15s;
  box-shadow: 0 4px 12px rgba(21, 101, 192, .18);
}
.reset::before { content: "\21BB  "; }
.reset:hover { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(21, 101, 192, .35); }
.reset:active { transform: scale(.97); }

.temas { background: var(--card); border-radius: 20px; padding: 14px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.temas h2 { margin: 0 0 2px; font-size: 1.1rem; letter-spacing: -.01em; }
.formula { color: var(--brand); font-weight: 600; font-size: .92rem; margin: 0 0 10px; }
.tema {
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; margin-bottom: 8px;
  border-radius: 16px; background: linear-gradient(135deg, #ffffff, #eef7ff);
  border: 1px solid var(--line); border-left: 6px solid var(--brand);
}
.tema:nth-child(2) { border-left-color: var(--brand2); }
.tema:nth-child(3) { border-left-color: #0b3c8c; }
.tema .n {
  flex: none; width: 30px; height: 30px; border-radius: 12px; background: var(--grad);
  color: #fff; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(21, 101, 192, .3);
}
.tema p { margin: 0; font-size: 1rem; }
.tema.empty p { color: var(--muted); font-style: italic; }
mark { padding: 1px 6px; border-radius: 6px; background: var(--key); color: inherit; font-weight: 700; }
mark.p { background: var(--prog); color: #fff; }
.swap .tema { animation: swap .5s cubic-bezier(.2, .8, .2, 1) both; }
.swap .tema:nth-child(2) { animation-delay: .07s; }
.swap .tema:nth-child(3) { animation-delay: .14s; }
@keyframes swap { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.note {
  margin-top: 8px; padding: 8px 14px; border-radius: 14px; font-size: .93rem; display: none;
  background: var(--brand-soft); border-left: 6px solid var(--brand);
}
.note.show { display: block; }
.legend { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }

.info { margin-top: 24px; }
.info h2 { font-size: 1.15rem; margin: 0 0 12px; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: var(--card); border-radius: 16px; padding: 16px; font-size: .92rem;
  box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 5px solid var(--brand);
}
.card:nth-child(2) { border-top-color: var(--brand2); }
.card:nth-child(3) { border-top-color: #0b3c8c; }
.card:nth-child(4) { border-top-color: #4fb3f0; }
.card small { color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-size: .7rem; font-weight: 700; }
.card h3 { margin: 2px 0 8px; font-size: 1.02rem; }
.card p { margin: 0 0 6px; }
.card .ej { color: var(--muted); font-size: .88rem; }
.card.empty { color: var(--muted); font-style: italic; border-top-color: var(--line); }

body.hc { --ink: #000; --muted: #1a1a1a; --line: #5a6b80; --brand: #0039a6; --key: #ffe066; --lock-bg: #e4e4e4; background: #fff; }
body.hc .opt[aria-disabled="true"] { color: #444; }

@media (max-width: 820px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) {
  header { padding: 12px 16px; border-radius: 16px; }
  .steps { grid-template-columns: 1fr; }
  .opts { flex-direction: row; flex-wrap: wrap; } .opt { flex: 1 1 140px; }
  .temas { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
