/* Sistema de diseño común a todas las pantallas */
:root {
  --navy: #0b2f6b; --navy-2: #123f8c; --ink: #101828; --text: #344054; --muted: #667085; --line: #e3e8f0;
  --bg: #f3f5f9; --surface: #fff; --tint: #eef3fc; --accent: #ffd23f; --ok: #0e7a55; --ok-bg: #e7f6ef; --bad: #b42318; --bad-bg: #fdecea;
  --r: 18px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06); --shadow-lg: 0 12px 28px rgba(16, 24, 40, .12);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 84px; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 3.6vw, 32px); } h2 { font-size: 20px; } h3 { font-size: 17px; }
p { margin: 0; } a { color: var(--navy-2); }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid #2f7df6; outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* Cabecera y navegación */
.top { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .in { max-width: 1160px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 18px; letter-spacing: -.02em; margin-right: auto; }
.brand svg { width: 34px; height: 34px; } .brand span { color: var(--navy-2); font-weight: 600; }
.nav { display: none; gap: 4px; }
.nav a, .tabs a { text-decoration: none; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.nav a { padding: 9px 14px; border-radius: 999px; }
.nav a:hover { background: var(--tint); color: var(--navy); }
.nav a[aria-current], .tabs a[aria-current] { color: var(--navy); }
.nav a[aria-current] { background: var(--tint); }
.nav svg, .tabs svg { width: 20px; height: 20px; flex: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs a { flex-direction: column; gap: 2px; font-size: 12px; padding: 6px 2px; min-height: 52px; justify-content: center; border-radius: 12px; }
.tabs a[aria-current] { background: var(--tint); }
@media (min-width: 860px) { body { padding-bottom: 40px; } .nav { display: flex; } .tabs { display: none; } }

.wrap { max-width: 1160px; margin: 0 auto; padding: 22px 16px; }
.narrow { max-width: 820px; }
.stack { display: grid; gap: 16px; }
.head { display: flex; align-items: end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.head p, .sub { color: var(--muted); margin-top: 6px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; padding: 8px 0; margin-bottom: 6px; }

/* Piezas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
a.card, button.card { display: block; width: 100%; text-align: left; text-decoration: none; color: inherit; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
a.card:hover, button.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #c9d4e8; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 11px 18px; border-radius: 12px; border: 1.5px solid transparent; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--navy); color: #fff; } .btn.primary:hover { background: var(--navy-2); }
.btn.accent { background: var(--accent); color: var(--navy); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--navy); } .btn.ghost:hover { background: var(--tint); }
.btn:disabled { background: #c5cddb; color: #fff; cursor: not-allowed; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--tint); color: var(--navy); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.muted { background: #eef1f6; color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: #e6ebf3; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--navy-2), #2f7df6); }
.meta { font-size: 14px; color: var(--muted); }
.seg { display: inline-flex; padding: 4px; background: #e6ebf3; border-radius: 12px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 9px 14px; min-height: 40px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--navy); box-shadow: var(--shadow); }
.field { padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); min-height: 46px; }

/* Inicio */
.hero { background: linear-gradient(135deg, #0b2f6b 0%, #164a9e 60%, #2166c9 100%); color: #dbe7fb; border-radius: 24px; padding: 28px; display: grid; gap: 20px; align-items: center; box-shadow: var(--shadow-lg); }
.hero h1 { color: #fff; } .hero p { max-width: 52ch; }
@media (min-width: 760px) { .hero { grid-template-columns: 1fr auto; padding: 36px; } }
.ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255, 255, 255, .18) 0); }
.ring div { width: 104px; height: 104px; border-radius: 50%; background: #0f3a82; display: grid; place-items: center; text-align: center; color: #fff; line-height: 1.1; }
.ring b { font-size: 30px; display: block; } .ring span { font-size: 12px; opacity: .8; }
.tile { display: grid; gap: 12px; }
.tile .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--tint); color: var(--navy); display: grid; place-items: center; }
.tile .ico svg { width: 24px; height: 24px; }
.tile .num { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }

/* Señales */
.thumbs { display: flex; gap: 8px; align-items: center; height: 54px; overflow: hidden; }
.thumbs img { height: 50px; width: 50px; object-fit: contain; }
.sign { display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; padding: 14px 12px; }
.sign img { height: 84px; width: 100%; object-fit: contain; }
.sign .code { font-size: 12px; font-weight: 800; color: var(--navy-2); letter-spacing: .04em; }
.sign .es { font-weight: 600; color: var(--ink); line-height: 1.3; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
dialog { border: 0; border-radius: 22px; padding: 0; max-height: calc(100dvh - 24px); overflow: auto; width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); color: var(--text); }
dialog::backdrop { background: rgba(16, 24, 40, .55); }
dialog .in { padding: 22px; display: grid; gap: 14px; }
.big { height: 150px; object-fit: contain; margin: 0 auto; display: block; }
.note { background: var(--tint); border-radius: 14px; padding: 14px 16px; color: #1f3b6e; }
.note b { color: var(--navy); }
.kv { display: grid; gap: 4px; } .kv span { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.confuse { display: flex; gap: 12px; align-items: center; } .confuse img { height: 54px; width: 54px; object-fit: contain; }

/* Preguntas */
.opts { display: grid; gap: 10px; } .opts.two { grid-template-columns: 1fr 1fr; } .opts.pics { grid-template-columns: 1fr 1fr; }
.opt { text-align: left; padding: 13px 15px; min-height: 50px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.opt:hover:not(:disabled) { border-color: #b8c6de; background: #fafcff; }
.opt[aria-pressed=true] { border-color: var(--navy); background: var(--tint); font-weight: 600; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); font-weight: 600; } .opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { cursor: default; color: var(--ink); }
.opt.pic { display: grid; place-items: center; padding: 12px; } .opt.pic img { height: 96px; object-fit: contain; }
.hint { color: var(--muted); font-size: 14px; margin-top: 10px; }
.unit { margin-left: 8px; color: var(--muted); }
input[type=number].field { font-size: 22px; width: 140px; }
.ok-t { color: var(--ok); } .bad-t { color: var(--bad); }
.law { font-size: 13px; color: var(--muted); }
#stage { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--r); overflow: hidden; background: #bfe3f7; box-shadow: var(--shadow); }
#stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.play { display: grid; gap: 16px; }
.play:not(.has-scene) #stage { display: none; }
.play:not(.has-scene) { max-width: 720px; margin: 0 auto; }
@media (min-width: 900px) { .play.has-scene { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } }

/* Lecciones */
ol.points { padding-left: 22px; margin: 0; } ol.points li { margin-bottom: 14px; color: var(--ink); } ol.points .law { display: block; }
table.terms { width: 100%; border-collapse: collapse; } table.terms td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; } table.terms td:first-child { font-style: italic; width: 45%; color: var(--ink); }
.lesson { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.lesson b { display: block; color: var(--ink); }
figure { margin: 0; }
