/* Cuentas y juego (P0.3–P0.5): logros, estadísticas, "Pide un examen" y aviso
   de cookies. Solo clases propias (medal, ach-*, st-*, band-*, consent-*, ck-*,
   rq-*, pf-*, progress-tabs) y los tokens de styles.css. */

:root {
  --bronze: #c8803f; --bronze-dark: #9a5a22; --bronze-soft: #fbeee2;
  --silver: #b7c1cc; --silver-dark: #8593a2; --silver-soft: #eef2f6;
  --diamond: #5ec8e6; --diamond-dark: #2b8fb0; --diamond-soft: #e3f6fb;
  --legend: #8f5cf0; --legend-dark: #5b2fc0; --legend-soft: #efe7fe;
  --gold-medal: var(--gold-bright); --gold-medal-dark: var(--gold-dark);
  --st-good: var(--green); --st-mid: #c98a00; --st-low: var(--danger);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bronze-soft: #3a2a1c; --silver-soft: #2a3038; --diamond-soft: #16323b; --legend-soft: #2a1d45; --st-mid: #f0b429; }
}
:root[data-theme="dark"] { --bronze-soft: #3a2a1c; --silver-soft: #2a3038; --diamond-soft: #16323b; --legend-soft: #2a1d45; --st-mid: #f0b429; }

.game-page h2 { font-size: var(--t-lg); margin: 0 0 var(--sp-3); display: flex; align-items: center; gap: 8px; }
.game-page .card + .card, .st-stack > .card + .card, .st-stack > * + * { margin-top: var(--sp-4); }

/* ---------- medallas ---------- */
.medal {
  --medal: 56px; --m: var(--bronze); --m-edge: var(--bronze-dark);
  display: inline-grid; place-items: center; flex: none; width: var(--medal); height: var(--medal);
  border-radius: 50%; background: var(--m); color: #fff;
  box-shadow: inset 0 -5px 0 var(--m-edge), 0 0 0 3px color-mix(in srgb, var(--m) 35%, transparent);
}
.medal.tier-silver { --m: var(--silver); --m-edge: var(--silver-dark); color: #26313d; }
.medal.tier-gold { --m: var(--gold-medal); --m-edge: var(--gold-medal-dark); color: #4a3300; }
.medal.tier-diamond { --m: var(--diamond); --m-edge: var(--diamond-dark); color: #06303d; }
.medal.tier-legend { --m: var(--legend); --m-edge: var(--legend-dark); color: #fff;
  background: conic-gradient(from 200deg, #8f5cf0, #e0559b, #f2b134, #8f5cf0); }
.medal.locked.tier-legend { background: var(--m); }
.medal.locked { --m: var(--surface-3); --m-edge: var(--border-strong); color: var(--ink-2); box-shadow: inset 0 -4px 0 var(--m-edge); }
.badge-ic.medal { border-radius: 50%; }

/* ---------- aviso al desbloquear ---------- */
#ach-toast-host { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.ach-toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--surface); color: var(--ink); text-decoration: none;
  border: var(--bw) solid var(--border); border-bottom-width: var(--lip); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); animation: ach-in .5s cubic-bezier(.2, 1.4, .4, 1) both; transition: opacity .4s, transform .4s;
}
.ach-toast .medal { --medal: 40px; }
.ach-toast small { display: block; font: 800 var(--t-xs) var(--font-display); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.ach-toast strong { font-size: var(--t-md); }
.ach-toast.tier-gold { border-color: var(--gold-medal-dark); }
.ach-toast.tier-diamond { border-color: var(--diamond-dark); }
.ach-toast.tier-legend { border-color: var(--legend-dark); }
.ach-toast.out { opacity: 0; transform: translateY(-12px); }
@keyframes ach-in { from { opacity: 0; transform: translateY(-24px) scale(.9); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ach-toast { animation: none; } }

/* ---------- barras de progreso de logros ---------- */
.ach-bar { height: 12px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.ach-bar i { display: block; height: 100%; border-radius: 99px; background: var(--gold-medal); box-shadow: inset 0 -3px 0 rgb(0 0 0 / .12); min-width: 6px; }
.ach-count { font: 700 var(--t-xs) var(--font-mono); color: var(--ink-2); white-space: nowrap; }

.ach-summary-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.ach-summary-head > div { flex: 1; min-width: 0; }
.ach-summary-head strong, .ach-summary-head small { display: block; }
.ach-next { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.ach-next-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.ach-next-body strong { font-size: var(--t-sm); }

/* ---------- página de logros ---------- */
.progress-tabs { display: flex; width: 100%; max-width: 520px; margin: 0 0 var(--sp-5); }
.progress-tabs a { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 10px; min-height: 40px; border-radius: 9px;
  font: 800 var(--t-xs) var(--font-display); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); text-decoration: none; }
.progress-tabs a[aria-current="page"] { background: var(--surface); color: var(--blue); box-shadow: 0 2px 0 var(--border); }
@media (max-width: 420px) { .progress-tabs a .ic { display: none; } }

.ach-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ach-total { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-display); }
.ach-big { font-size: var(--t-3xl); font-weight: 800; line-height: 1; }
.ach-tiers { display: flex; gap: 14px; flex-wrap: wrap; }
.ach-tier { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-display); }
.ach-tier b { font-size: var(--t-lg); margin-left: 4px; }
.ach-nextup { margin-top: var(--sp-4); }
.ach-filter { margin: var(--sp-5) 0 var(--sp-2); }
.ach-group { margin-top: var(--sp-5); }
.ach-group h2 small { font: 700 var(--t-sm) var(--font-mono); }
.ach-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.ach-card {
  position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  background: var(--surface); border: var(--bw) solid var(--border); border-bottom-width: var(--lip); border-radius: var(--r-lg);
}
.ach-card.on.tier-gold { background: color-mix(in srgb, var(--gold-soft) 70%, var(--surface)); border-color: color-mix(in srgb, var(--gold-medal-dark) 50%, var(--border)); }
.ach-card.on.tier-silver { background: var(--silver-soft); }
.ach-card.on.tier-bronze { background: var(--bronze-soft); }
.ach-card.on.tier-diamond { background: var(--diamond-soft); border-color: color-mix(in srgb, var(--diamond-dark) 45%, var(--border)); }
.ach-card.on.tier-legend { background: var(--legend-soft); border-color: color-mix(in srgb, var(--legend-dark) 50%, var(--border)); }
.ach-card.off { border-style: dashed; border-bottom-width: var(--bw); }
.ach-card-body { flex: 1; min-width: 0; display: grid; gap: 4px; padding-right: 44px; }
.ach-card-body strong { font-size: var(--t-md); line-height: 1.2; }
.ach-card-body small { color: var(--ink-2); font-size: var(--t-sm); line-height: 1.3; }
.ach-date { display: inline-flex; align-items: center; gap: 4px; font: 700 var(--t-xs) var(--font-ui); color: var(--green-ink); }
.tier-tag { position: absolute; top: 10px; right: 10px; font: 800 10px var(--font-display); text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 99px; background: var(--bronze-soft); color: var(--bronze-dark); }
.tier-tag.tier-silver { background: var(--silver-soft); color: #4b5866; }
.tier-tag.tier-gold { background: var(--gold-soft); color: var(--gold); }
.tier-tag.tier-diamond { background: var(--diamond-soft); color: var(--diamond-dark); }
.tier-tag.tier-legend { background: var(--legend-soft); color: var(--legend-dark); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tier-tag { color: var(--ink); } }
:root[data-theme="dark"] .tier-tag { color: var(--ink); }

/* ---------- estadísticas ---------- */
.st-kpis { margin-bottom: var(--sp-4); }
.st-exams { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: var(--sp-4); }
.st-exam { flex: none; padding: 8px 14px; border-radius: 99px; border: var(--bw) solid var(--border); background: var(--surface);
  font: 800 var(--t-sm) var(--font-ui); color: var(--ink); text-decoration: none; }
.st-exam.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.st-grid { margin-top: var(--sp-4); }
.st-row { display: grid; gap: 6px; padding: 10px 0; border-bottom: 2px solid var(--border); }
.st-row:last-child { border-bottom: 0; }
.st-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.st-name { font-weight: 800; min-width: 0; }
.st-name small { display: block; font-weight: 600; color: var(--ink-2); font-size: var(--t-xs); }
.st-pct { font: 800 var(--t-lg) var(--font-display); white-space: nowrap; }
.st-pct small { font: 700 var(--t-xs) var(--font-ui); color: var(--ink-2); }
.st-pct.st-good { color: var(--st-good); } .st-pct.st-mid { color: var(--st-mid); } .st-pct.st-low { color: var(--st-low); }
.st-bar { height: 14px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.st-bar i { display: block; height: 100%; border-radius: 99px; min-width: 4px; background: var(--ink-2); }
.st-bar.st-good i, .st-col-bar.st-good i { background: var(--green-bright); }
.st-bar.st-mid i, .st-col-bar.st-mid i { background: var(--gold-bright); }
.st-bar.st-low i, .st-col-bar.st-low i { background: var(--danger-bright); }
.st-col-bar.st-blue i { background: var(--blue-bright); }
.st-go { justify-self: start; }
.st-section { border-bottom: 2px solid var(--border); }
.st-section:last-child { border-bottom: 0; }
.st-section > summary { list-style: none; cursor: pointer; padding-bottom: 6px; }
.st-section > summary::-webkit-details-marker { display: none; }
.st-section > summary .st-row { border-bottom: 0; padding-bottom: 2px; }
.st-more { display: inline-flex; align-items: center; gap: 4px; font: 800 var(--t-xs) var(--font-display); text-transform: uppercase; letter-spacing: .06em; color: var(--blue); }
.st-more .ic { transition: transform .2s; }
.st-section[open] .st-more .ic { transform: rotate(90deg); }
.st-skills { padding: 0 0 10px 12px; border-left: 4px solid var(--surface-3); margin-left: 4px; }
.st-empty .st-name { color: var(--ink-2); }
.st-trend-msg { display: flex; align-items: center; gap: 6px; font-weight: 800; margin: 0 0 10px; }
.st-trend-msg.st-good { color: var(--st-good); } .st-trend-msg.st-low { color: var(--st-low); } .st-trend-msg.st-mid { color: var(--ink-2); }
.st-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; align-items: end; }
.st-col { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.st-col-val { font: 700 10px var(--font-mono); color: var(--ink-2); min-height: 12px; }
.st-col-bar { position: relative; width: 100%; max-width: 34px; height: 110px; border-radius: 8px; background: var(--surface-2); overflow: hidden; display: flex; align-items: flex-end; }
.st-col-bar i { display: block; width: 100%; border-radius: 8px 8px 4px 4px; }
.st-col small { font-size: 10px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.st-daily .st-col-bar { height: 70px; }

.band-row { margin: 6px 0 14px; }
.band-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.band-val { font: 800 var(--t-xl) var(--font-display); color: var(--blue); }
.band-track { position: relative; height: 16px; border-radius: 99px; background: var(--surface-3); margin-top: 6px; }
.band-range { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: color-mix(in srgb, var(--blue-bright) 55%, var(--surface)); }
.band-mid { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--blue); }
.band-scale { display: flex; justify-content: space-between; color: var(--ink-2); }

/* ---------- aviso de cookies ---------- */
.consent-banner {
  position: fixed; z-index: 85; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(720px, calc(100vw - 24px)); display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 16px 18px; background: var(--surface); color: var(--ink);
  border: var(--bw) solid var(--border); border-bottom-width: 6px; border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}
.consent-text { flex: 1 1 320px; min-width: 0; }
.consent-text strong { font-family: var(--font-display); font-size: var(--t-lg); }
.consent-text p { margin: 4px 0 0; font-size: var(--t-sm); color: var(--ink-2); }
.consent-text a { color: var(--blue); font-weight: 700; }
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1 1 240px; }
/* "Rechazar" y "Aceptar": exactamente el mismo estilo y tamaño. */
.consent-eq { background: var(--blue); color: #fff; box-shadow: 0 var(--lip) 0 var(--blue-dark); min-width: 0; }
.consent-actions .link-btn, .ck-foot .link-btn { width: auto; grid-column: 1 / -1; justify-self: center; color: var(--blue); font-weight: 700; padding: 4px 0; }
@media (max-width: 860px) { .consent-banner { bottom: calc(80px + env(safe-area-inset-bottom)); padding: 14px; gap: 10px; } }
body.ux-onboarding .consent-banner { bottom: calc(96px + env(safe-area-inset-bottom)); }
.consent-dialog { width: min(520px, calc(100vw - 24px)); }
.ck-row { display: flex; align-items: center; gap: 14px; justify-content: space-between; padding: 12px 0; border-bottom: 2px solid var(--border); }
.ck-row strong, .ck-row small { display: block; }
.ck-row .switch input:disabled + span { opacity: .6; }
.ck-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 10px; }
.ck-minor { display: flex; gap: 8px; align-items: flex-start; }
.ck-foot { max-width: 1120px; margin: 6px auto 0; }
.ck-foot .link-btn { font-size: inherit; color: inherit; text-decoration: underline; font-weight: 400; }
.ck-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.ck-table th, .ck-table td { text-align: left; padding: 8px; border-bottom: 2px solid var(--border); vertical-align: top; }
.prose h2 { margin-top: var(--sp-5); }

/* ---------- perfil (edad y país) ---------- */
.privacy-settings .settings-title { font-size: var(--t-lg); display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.profile-fields .setting select { max-width: 60%; }
.pf-why { margin: 4px 0 8px; }
.onb-profile { margin-top: var(--sp-5); }
.onb-profile > summary { cursor: pointer; font-weight: 800; display: flex; align-items: center; gap: 8px; }

/* ---------- Pide un examen ---------- */
.rq-fab { right: auto; }
@media (min-width: 861px) {
  .rq-fab { right: 230px; }
  body.in-session .rq-fab { display: none; }
}
@media (max-width: 860px) { .rq-fab { display: none; } }
.fb-tabs { display: flex; width: 100%; margin: 0 0 12px; }
.fb-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: var(--t-sm); }
.fb-tabs button[aria-selected="true"] { background: var(--surface); color: var(--blue); box-shadow: 0 2px 0 var(--border); }
.rq-label { display: block; font-weight: 800; margin: 10px 0 6px; }
.rq-input { width: 100%; box-sizing: border-box; padding: 12px; border: var(--bw) solid var(--border); border-radius: var(--r-sm); font: inherit; background: var(--surface); color: var(--ink); }
.rq-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.rq-chips .fb-cat { padding: 6px 10px; font-size: var(--t-sm); }
.rq-details { width: 100%; box-sizing: border-box; margin-bottom: 10px; }
.rq-line { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin: var(--sp-5) 0 0; color: var(--ink-2); font-weight: 600; }
.rq-line .link-btn { width: auto; font-weight: 800; color: var(--blue); }
.rq-admin-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.rq-admin-head h2 { margin: 0; flex: 1; }
.rq-rank { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; counter-reset: rq; }
.rq-rank li { display: grid; gap: 4px; counter-increment: rq; }
.rq-rank-top { display: flex; justify-content: space-between; gap: 10px; }
.rq-rank-top strong::before { content: counter(rq) ". "; color: var(--ink-2); }
.rq-n { font: 800 var(--t-lg) var(--font-display); color: var(--blue); }
.rq-rank .ach-bar i { background: var(--blue-bright); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rq-chips .fb-cat { background: var(--surface-2); color: var(--ink); } }

/* Edad en el aviso de cookies (age gate neutral, opcional) y perfil dentro de "Configurar cookies". */
.ck-age { display: grid; gap: 4px; margin-top: 10px; font-size: var(--t-sm); }
.ck-age > span { font-weight: 700; }
.ck-age select { max-width: 260px; }
.ck-age small { color: var(--ink-2); }
.ck-profile { margin: 12px 0 0; }
.ck-profile > summary { cursor: pointer; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.ck-profile .profile-fields .setting select { max-width: 55%; }
