/* ==========================================================================
   Ojo de tigre — hoja de estilos
   Paleta inspirada en la piedra: bandas de miel y oro sobre marrones
   profundos, con el brillo «chatoyant» (ojo de gato) como acento.
   ========================================================================== */

:root {
  --te-obsidiana: #140d07;
  --te-cafe-900: #1f150c;
  --te-cafe-800: #2a1b0f;
  --te-cafe-700: #3a2512;
  --te-bronce: #8a5a1f;
  --te-ambar: #b7791f;
  --te-oro: #d9a441;
  --te-miel: #f2c25b;
  --te-crema: #f7ead0;
  --te-rojo: #c8553d;      /* ojo de tigre rojo */
  --te-azul: #5b7d8c;      /* ojo de halcón */
  --te-oliva: #8fae4a;

  --chatoyance: linear-gradient(115deg,
      #2a1708 0%, #6b3f14 18%, #c88a1e 34%, #f6d27a 44%, #c88a1e 52%,
      #7b4a1b 66%, #e0a83a 80%, #3b2210 100%);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(0 0 0 / .25), 0 8px 24px -12px rgb(0 0 0 / .45);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Tema oscuro (por defecto) */
  --bg: var(--te-obsidiana);
  --bg-grain: #1a110a;
  --surface: var(--te-cafe-900);
  --surface-2: var(--te-cafe-800);
  --surface-3: var(--te-cafe-700);
  --border: #47301a;
  --border-strong: #6b4824;
  --text: var(--te-crema);
  --text-muted: #c2a57c;
  --text-faint: #8f7656;
  --accent: var(--te-oro);
  --accent-strong: var(--te-miel);
  --accent-ink: #1b1007;
  --good: var(--te-oliva);
  --good-bg: rgb(143 174 74 / .14);
  --bad: #e07258;
  --bad-bg: rgb(200 85 61 / .15);
  --info: #86a9b8;
  --info-bg: rgb(91 125 140 / .18);
  --focus: 0 0 0 3px rgb(242 194 91 / .45);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f8efdd;
    --bg-grain: #f3e6cc;
    --surface: #fffaf0;
    --surface-2: #f6ead2;
    --surface-3: #efdcb7;
    --border: #e1c897;
    --border-strong: #c9a465;
    --text: #2a1a0c;
    --text-muted: #6f5132;
    --text-faint: #957552;
    --accent: #9a6514;
    --accent-strong: #7b4d0c;
    --accent-ink: #fffaf0;
    --good: #557018;
    --good-bg: rgb(85 112 24 / .12);
    --bad: #a63a26;
    --bad-bg: rgb(166 58 38 / .1);
    --info: #3f6474;
    --info-bg: rgb(63 100 116 / .1);
    --shadow: 0 1px 2px rgb(74 44 18 / .08), 0 10px 24px -14px rgb(74 44 18 / .35);
    --focus: 0 0 0 3px rgb(154 101 20 / .35);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f8efdd;
  --bg-grain: #f3e6cc;
  --surface: #fffaf0;
  --surface-2: #f6ead2;
  --surface-3: #efdcb7;
  --border: #e1c897;
  --border-strong: #c9a465;
  --text: #2a1a0c;
  --text-muted: #6f5132;
  --text-faint: #957552;
  --accent: #9a6514;
  --accent-strong: #7b4d0c;
  --accent-ink: #fffaf0;
  --good: #557018;
  --good-bg: rgb(85 112 24 / .12);
  --bad: #a63a26;
  --bad-bg: rgb(166 58 38 / .1);
  --info: #3f6474;
  --info-bg: rgb(63 100 116 / .1);
  --shadow: 0 1px 2px rgb(74 44 18 / .08), 0 10px 24px -14px rgb(74 44 18 / .35);
  --focus: 0 0 0 3px rgb(154 101 20 / .35);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 500px at 85% -10%, rgb(217 164 65 / .10), transparent 60%),
    radial-gradient(900px 400px at -10% 110%, rgb(138 90 31 / .12), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { font-family: var(--font-serif); line-height: 1.2; margin: 0 0 .5em; letter-spacing: .005em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
code, kbd { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 760px; }
main { flex: 1; padding: 28px 0 56px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head .lead { margin: .35rem 0 0; color: var(--text-muted); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.span-all { grid-column: 1 / -1; }

/* ---------- Cabecera ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar::after { /* banda chatoyant */
  content: ""; display: block; height: 3px;
  background: var(--chatoyance); background-size: 200% 100%;
  animation: chatoyance 14s linear infinite;
}
.topbar-inner { display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-serif); font-weight: 700; font-size: 1.12rem; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand svg { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 2px 4px rgb(0 0 0 / .35)); }
.brand span em { font-style: normal; color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a, .nav button.linklike {
  color: var(--text-muted); text-decoration: none; padding: 8px 11px; border-radius: 9px; font-size: .94rem; font-weight: 500; white-space: nowrap;
}
.nav a:hover, .nav button.linklike:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent-strong); background: var(--surface-2); }
.nav .sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.nav form { margin: 0; }
.nav-min { display: flex; align-items: center; margin-left: auto; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.menu-toggle { display: none; margin-left: auto; }

@media (max-width: 960px) {
  .icon-btn.menu-toggle { display: inline-grid; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 10px 16px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a, .nav button.linklike { padding: 11px 12px; text-align: left; }
  .nav .sep { width: auto; height: 1px; margin: 6px 0; }
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.tiger { position: relative; overflow: hidden; }
.card.tiger::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--chatoyance); background-size: 200% 100%; animation: chatoyance 18s linear infinite;
}

/* ---------- Indicadores ---------- */
.stat { padding: 16px 18px; }
.stat .label { color: var(--text-muted); font-size: .84rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-family: var(--font-serif); font-size: 2rem; font-weight: 700; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--text-faint); font-size: .86rem; margin-top: 2px; }
.stat.highlight { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), var(--surface) 70%); border-color: var(--border-strong); }
.stat.highlight .value { color: var(--accent-strong); }

/* ---------- Botones ---------- */
.btn {
  --b-bg: var(--surface-2); --b-fg: var(--text); --b-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--b-bd);
  background: var(--b-bg); color: var(--b-fg); font: inherit; font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform .08s ease, filter .15s ease, background .15s ease;
}
.btn:hover { color: var(--b-fg); filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary {
  --b-fg: #1b1007; --b-bd: #a8701a;
  background: linear-gradient(115deg, #b7791f 0%, #e0a83a 35%, #f6d27a 50%, #e0a83a 65%, #b7791f 100%);
  background-size: 220% 100%; background-position: 0% 0;
  box-shadow: 0 1px 0 rgb(255 255 255 / .25) inset, 0 6px 16px -8px rgb(183 121 31 / .8);
  transition: background-position .6s ease, transform .08s ease;
}
.btn-primary:hover { background-position: 100% 0; filter: none; }
.btn-danger { --b-bg: var(--bad-bg); --b-fg: var(--bad); --b-bd: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--text-muted); }
.btn-ghost:hover { --b-bg: var(--surface-2); --b-fg: var(--text); }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: .86rem; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
button.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font-weight: 600; font-size: .92rem; }
.field .hint { color: var(--text-faint); font-size: .84rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=file], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-grain);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 42px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: .86rem; min-height: 240px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type=file] { padding: 8px; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; margin-right: 12px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 6px 0; }
.check input { margin-top: 3px; flex: none; }
.check small { display: block; }
.form-grid { display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 6px; margin: 0 0 18px; }
legend { padding: 0 8px; font-family: var(--font-serif); font-weight: 700; color: var(--accent-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 260px; overflow: auto; padding: 2px; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); font-size: .9rem; user-select: none;
}
.chip-check span small { color: var(--text-faint); }
.chip-check input:checked + span { background: color-mix(in srgb, var(--accent) 24%, var(--surface-2)); border-color: var(--accent); color: var(--text); }
.chip-check input:focus-visible + span { box-shadow: var(--focus); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .9rem;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-weight: 600;
}
.chip-btn small { color: var(--text-faint); font-weight: 400; }
.chip-btn:hover { border-color: var(--accent); }
.chip-btn:focus-visible { box-shadow: var(--focus); outline: none; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-btn[aria-pressed="true"] small { color: inherit; opacity: .75; }
.chip-btn.ghost { font-weight: 400; background: transparent; }

/* ---------- Mensajes ---------- */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash { padding: 11px 14px; border-radius: 10px; border: 1px solid; font-size: .95rem; display: flex; gap: 10px; align-items: flex-start; }
.flash.success { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.flash.error { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.flash.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.flash::before { font-weight: 700; }
.flash.success::before { content: "✓"; color: var(--good); }
.flash.error::before { content: "!"; color: var(--bad); }
.flash.info::before { content: "i"; color: var(--info); font-style: italic; font-family: var(--font-serif); }

/* ---------- Tablas ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
tr.inactive td { opacity: .55; }

/* ---------- Insignias ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.badge.gold { color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: var(--good-bg); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-bg); }
.badge.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); background: var(--info-bg); }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .78rem; background: var(--surface-3);
  color: var(--text-muted); text-decoration: none; margin: 2px 3px 2px 0;
}
a.tag:hover { color: var(--text); background: var(--border); }

/* ---------- Barras ---------- */
.bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--chatoyance); background-size: 300% 100%; }
.bar.bad > span { background: linear-gradient(90deg, #8a3a22, var(--bad)); }
.bar.good > span { background: linear-gradient(90deg, #4f6a1c, var(--good)); }
.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.split-bar .ok { background: var(--good); }
.split-bar .ko { background: var(--bad); }
.split-bar .bl { background: var(--text-faint); }

.tag-list { list-style: none; margin: 0; padding: 0; }
.tag-list li { display: grid; grid-template-columns: minmax(0, 1fr) 90px 52px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.tag-list li:last-child { border-bottom: 0; }
.tag-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-list .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: .9rem; }

/* Calendario de repasos */
.cal { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; align-items: end; height: 120px; }
.cal .day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.cal .col { width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--te-miel), var(--te-bronce)); min-height: 3px; }
.cal .day.today .col { background: linear-gradient(180deg, #f6d27a, var(--te-rojo)); }
.cal .n { font-size: .72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal .d { font-size: .68rem; color: var(--text-faint); }

/* Sparkline de notas */
.spark { width: 100%; height: 90px; display: block; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: url(#sparkfill); }
.spark .dot { fill: var(--accent-strong); }
.spark .ref { stroke: var(--border-strong); stroke-dasharray: 3 4; }

/* ---------- Preguntas / test ---------- */
.test-bar {
  position: sticky; top: 63px; z-index: 20; margin: -8px 0 20px; padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
}
.test-bar .progress { flex: 1 1 200px; }
.test-bar .count { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: .92rem; }
.test-bar .timer { font-family: var(--mono); color: var(--text-muted); font-size: .92rem; }
.save-state { font-size: .82rem; color: var(--text-faint); min-width: 90px; }
.save-state.err { color: var(--bad); }

.qcard { scroll-margin-top: 140px; }
.qcard + .qcard { margin-top: 16px; }
.qhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.qnum {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px;
  font-weight: 700; font-family: var(--font-serif); color: var(--accent-ink); background: var(--chatoyance); background-size: 260% 100%; background-position: 40% 0;
}
.qtext { font-size: 1.06rem; font-weight: 500; margin: 0 0 14px; }
.options { display: grid; gap: 8px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt label {
  display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--bg-grain); cursor: pointer; transition: border-color .12s, background .12s;
}
.opt label:hover { border-color: var(--border-strong); background: var(--surface-2); }
.opt .letter {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 700; font-size: .9rem;
  border: 1px solid var(--border-strong); color: var(--text-muted); background: var(--surface);
}
.opt input:checked + label { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--surface)); }
.opt input:checked + label .letter { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.opt input:focus-visible + label { box-shadow: var(--focus); }
.opt.correct label, .opt.correct input:checked + label { border-color: var(--good); background: var(--good-bg); }
.opt.correct .letter, .opt.correct input:checked + label .letter { background: var(--good); color: #fff; border-color: var(--good); }
.opt.wrong label, .opt.wrong input:checked + label { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .letter, .opt.wrong input:checked + label .letter { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.locked label { cursor: default; }
.qfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.explain {
  margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--surface-2);
  border-radius: 0 10px 10px 0; font-size: .95rem;
}
.explain strong { color: var(--accent-strong); }
.qcard.res-ok { border-left: 4px solid var(--good); }
.qcard.res-ko { border-left: 4px solid var(--bad); }
.qcard.res-bl { border-left: 4px solid var(--text-faint); }

.qnav { display: flex; flex-wrap: wrap; gap: 5px; }
.qnav a {
  display: inline-grid; place-items: center; width: 32px; height: 30px; border-radius: 7px; font-size: .8rem; font-weight: 600;
  text-decoration: none; border: 1px solid var(--border); color: var(--text-muted); background: var(--surface-2); font-variant-numeric: tabular-nums;
}
.qnav a.done { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); border-color: var(--accent); color: var(--text); }
.qnav a.ok { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.qnav a.ko { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

/* Hoja de respuestas */
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 18px; }
.sheet-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.sheet-row .n { width: 30px; font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: 600; font-size: .9rem; }
.sheet-row label { position: relative; }
.sheet-row input { position: absolute; opacity: 0; }
.sheet-row span {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-strong);
  font-size: .82rem; font-weight: 700; color: var(--text-muted); cursor: pointer; background: var(--bg-grain);
}
.sheet-row input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sheet-row input:focus-visible + span { box-shadow: var(--focus); }

/* Nota */
.score-hero { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.score-ring { --p: 0; width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0); }
.score-ring > div { width: 118px; height: 118px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.score-ring strong { font-family: var(--font-serif); font-size: 2.4rem; line-height: 1; display: block; }
.score-ring small { font-size: .78rem; }
@media (max-width: 560px) { .score-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

/* ---------- Varios ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty svg { width: 64px; height: 64px; opacity: .7; margin-bottom: 8px; }
.pagination { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; color: var(--text-muted); font-size: .9rem; }
.pagination .current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
details.confirm > summary { list-style: none; cursor: pointer; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { margin-bottom: 10px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.danger-zone h2 { color: var(--bad); }
.credential {
  font-family: var(--mono); font-size: 1.3rem; letter-spacing: .04em; padding: 14px 18px; border-radius: 10px;
  background: var(--bg-grain); border: 1px dashed var(--accent); display: flex; justify-content: space-between; align-items: center; gap: 12px; word-break: break-all;
}
.footer { border-top: 1px solid var(--border); padding: 18px 0; color: var(--text-faint); font-size: .84rem; }
.footer .container { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .stone { width: 84px; height: 84px; margin: 0 auto 12px; display: block; filter: drop-shadow(0 8px 18px rgb(0 0 0 / .45)); }
.auth-card h1 { text-align: center; margin-bottom: .2em; }
.auth-card .lead { text-align: center; color: var(--text-muted); margin-bottom: 22px; }

@keyframes chatoyance { from { background-position: 0% 0; } to { background-position: 200% 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .footer, .test-bar, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ==========================================================================
   Comunidad: avatares, perfiles, ranking
   ========================================================================== */
.avatar {
  --av-size: 40px; --user-accent: var(--accent);
  width: var(--av-size); height: var(--av-size); flex: none; border-radius: 50%; overflow: hidden;
  display: inline-grid; place-items: center; vertical-align: middle;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--user-accent) 85%, #fff) 0%, var(--user-accent) 45%, color-mix(in srgb, var(--user-accent) 45%, #140d07) 100%);
  color: #1b1007; font-weight: 700; font-size: calc(var(--av-size) * .38); letter-spacing: .02em;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .25) inset;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.ring { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--user-accent), 0 10px 30px -10px rgb(0 0 0 / .6); }
.user-chip { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.user-chip:hover { color: var(--accent-strong); }
.user-chip .who { min-width: 0; line-height: 1.25; }
.user-chip .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who small { color: var(--text-faint); font-size: .8rem; }
.flame { white-space: nowrap; font-variant-numeric: tabular-nums; }
.flame.dim { filter: grayscale(.8); opacity: .65; }
tr.me td { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* Podio */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 14px; align-items: end; margin-top: 8px; }
.podium .place { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; min-width: 0; }
.podium .place .name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .place .name a { color: var(--text); text-decoration: none; }
.podium .place .score { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 700; color: var(--accent-strong); line-height: 1; }
.podium .place .meta { font-size: .8rem; color: var(--text-faint); }
.podium .step {
  width: 100%; border-radius: 12px 12px 4px 4px; display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 2rem; font-weight: 700; color: #1b1007;
  box-shadow: 0 1px 0 rgb(255 255 255 / .3) inset, var(--shadow);
}
.podium .p1 .step { height: 120px; background: linear-gradient(115deg, #b7791f, #f6d27a 45%, #e0a83a 60%, #b7791f); }
.podium .p2 .step { height: 88px; background: linear-gradient(115deg, #8b8a86, #e4e1d9 45%, #b9b5aa 60%, #8b8a86); }
.podium .p3 .step { height: 64px; background: linear-gradient(115deg, #7b4a1b, #d39a63 45%, #a8692a 60%, #7b4a1b); }
.podium .crown { font-size: 1.4rem; line-height: 1; }
.podium .empty-place { opacity: .35; }
@media (max-width: 520px) {
  .podium { gap: 8px; }
  .podium .place .score { font-size: 1.15rem; }
  .podium .p1 .step { height: 92px; } .podium .p2 .step { height: 68px; } .podium .p3 .step { height: 50px; }
}
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.tabs a { padding: 5px 12px; border-radius: 8px; font-size: .88rem; text-decoration: none; color: var(--text-muted); font-weight: 600; }
.tabs a.active { background: var(--accent); color: var(--accent-ink); }

/* Perfil */
.profile-hero { position: relative; overflow: hidden; padding: 0; }
.profile-hero .banner {
  height: 120px;
  background:
    linear-gradient(115deg, transparent 0%, rgb(255 243 196 / .0) 38%, rgb(255 243 196 / .45) 46%, transparent 54%),
    linear-gradient(115deg, #1f150c 0%, color-mix(in srgb, var(--user-accent) 55%, #1f150c) 30%, var(--user-accent) 50%, color-mix(in srgb, var(--user-accent) 50%, #2a1708) 72%, #140d07 100%);
}
.profile-hero .body { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: end; padding: 0 22px 20px; margin-top: -48px; }
.profile-hero h1 { margin: 0; }
.profile-hero .handle { color: var(--text-faint); }
.profile-hero .goal { margin-top: 4px; color: var(--accent-strong); font-weight: 600; }
.profile-hero .bio { grid-column: 1 / -1; margin: 4px 0 0; color: var(--text-muted); white-space: pre-line; }
@media (max-width: 640px) {
  .profile-hero .body { grid-template-columns: 1fr; justify-items: start; }
}
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge-card { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.badge-card .ico { font-size: 1.5rem; line-height: 1; }
.badge-card strong { display: block; font-size: .9rem; }
.badge-card small { color: var(--text-faint); font-size: .76rem; }
.badge-card.locked { opacity: .45; filter: grayscale(1); }
.badge-card.got { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }

/* Mapa de actividad */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heatmap i { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-3); display: block; }
.heatmap i.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-3)); }
.heatmap i.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-3)); }
.heatmap i.l3 { background: color-mix(in srgb, var(--accent) 80%, var(--surface-3)); }
.heatmap i.l4 { background: var(--accent-strong); }
.heatmap i.today { outline: 1px solid var(--text-muted); outline-offset: 1px; }

/* Selector de color */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--border-strong); cursor: pointer; font-size: .88rem; background: var(--surface-2); }
.swatch span::before { content: ""; width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgb(0 0 0 / .3) inset; }
.swatch input:checked + span { border-color: var(--c); box-shadow: 0 0 0 2px var(--c); }
.swatch input:focus-visible + span { box-shadow: var(--focus); }

.people { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.person { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--text); transition: transform .12s ease, border-color .12s ease; }
.person:hover { transform: translateY(-2px); border-color: var(--border-strong); color: var(--text); }
.person .goal { color: var(--accent-strong); font-size: .86rem; font-weight: 600; }
.person .bio { color: var(--text-muted); font-size: .88rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Marcar / reportar */
.qactions { display: inline-flex; gap: 2px; align-items: center; }
.star .ico { font-size: 1.05rem; line-height: 1; }
.star.on { color: var(--accent-strong); }
.star.on .ico { text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }
.count-pill { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; }
dialog.card { width: min(520px, calc(100vw - 32px)); color: var(--text); padding: 22px; }
dialog::backdrop { background: rgb(10 6 3 / .65); backdrop-filter: blur(2px); }
.report-item { border-left: 3px solid var(--border-strong); padding: 10px 14px; background: var(--surface-2); border-radius: 0 10px 10px 0; }
.report-item.abierto { border-left-color: var(--bad); }
.report-item.resuelto { border-left-color: var(--good); }
.report-item + .report-item { margin-top: 10px; }
.avatar-edit { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0; }
.avatar-edit label { position: relative; cursor: pointer; border-radius: 50%; display: block; }
.avatar-edit .avatar-overlay {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: rgb(20 13 7 / .62); color: var(--te-crema); font-size: 1.4rem; opacity: 0; transition: opacity .15s;
}
.avatar-edit .avatar-overlay small { display: block; font-size: .72rem; font-weight: 600; }
.avatar-edit label:hover .avatar-overlay, .avatar-edit label:focus-within .avatar-overlay { opacity: 1; }

/* ==========================================================================
   Mazmorra (roguelite)
   ========================================================================== */
.dg-hero { text-align: center; }
.dg-title { font-family: var(--mono); color: var(--accent-strong); font-size: clamp(.5rem, 1.6vw, .9rem); line-height: 1.15; margin: 0 auto 12px; overflow-x: auto; text-shadow: 0 0 12px rgb(242 194 91 / .35); display: inline-block; text-align: left; }
.dg-hero .lead { max-width: 640px; margin: 0 auto 14px; color: var(--text-muted); }
.dg-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; color: var(--text-muted); }
.dg-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.dg-list { list-style: none; padding: 0; margin: 0 0 12px; }
.dg-list li { padding: 7px 0; border-bottom: 1px dashed var(--border); }

.r-comun { --r: #b7a58a; } .r-raro { --r: #6fa3c7; } .r-epico { --r: #b77fe0; } .r-legendario { --r: #f2c25b; }
.badge.r-comun, .badge.r-raro, .badge.r-epico, .badge.r-legendario { color: var(--r); border-color: color-mix(in srgb, var(--r) 55%, transparent); background: color-mix(in srgb, var(--r) 12%, transparent); }

.dg-hud { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 12px 16px; position: sticky; top: 63px; z-index: 15; }
.dg-hearts { position: relative; display: flex; flex-wrap: wrap; max-width: 12.5em; gap: 2px; font-size: 1.45rem; line-height: 1; }
.dg-heart { display: inline-block; width: 1.05em; height: 1.1em; line-height: 1.1; text-align: center; overflow: hidden;
  font-family: Arial, "Helvetica Neue", sans-serif; color: #e0573f; text-shadow: 0 0 8px rgb(224 87 63 / .45); }
.dg-heart.lost { color: var(--surface-3); text-shadow: none; -webkit-text-stroke: 1px var(--text-faint); }
.dg-hud-item { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.dg-hud-item b { color: var(--text); }
#hud-efectos { display: flex; flex-wrap: wrap; gap: 6px; }
.dg-floor { margin-left: auto; display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-weight: 700; }
.dg-rooms { display: inline-flex; gap: 4px; font-style: normal; }
.dg-rooms i { font-style: normal; width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--text-faint); font-size: .75rem; }
.dg-rooms i.done { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.dg-rooms i.now { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.dg-main { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; margin-top: 16px; align-items: start; }
.dg-bottom { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; margin-top: 16px; align-items: start; }
.dg-bottom h3 { margin: 0; }
@media (max-width: 900px) { .dg-main, .dg-bottom { grid-template-columns: 1fr; } .dg-hud { top: 63px; } }

.dg-enemy { position: relative; text-align: center; overflow: hidden; }
.dg-enemy.boss { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); box-shadow: 0 0 0 1px rgb(200 85 61 / .25), 0 14px 40px -18px rgb(200 85 61 / .7); }
.dg-enemy-head { display: flex; justify-content: center; align-items: center; gap: 10px; }
.dg-enemy-head h2 { margin: 0; }
.dg-hp-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; }
.dg-hp-row b { font-variant-numeric: tabular-nums; min-width: 44px; }
.dg-hp { flex: 1; height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; border: 1px solid var(--border); }
.dg-hp > span { display: block; height: 100%; background: linear-gradient(90deg, #8a2f1c, #e0573f); transition: width .45s ease; }
.dg-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 8px; }
/* Estados alterados y habilidades anuladas por el sello */
.dg-status { cursor: help; font-variant-numeric: tabular-nums; }
.dg-chips.sellado .badge:not(:first-child) { opacity: .45; text-decoration: line-through; }
.badge.on { animation: dg-pulse 1.2s ease-in-out infinite; }
@keyframes dg-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 25%, transparent); } }
@media (prefers-reduced-motion: reduce) { .badge.on { animation: none; } }
.dg-art {
  font-family: var(--mono); font-size: clamp(.62rem, 1.4vw, .86rem); line-height: 1.2; margin: 12px auto; text-align: left;
  display: inline-block; color: var(--accent-strong); text-shadow: 0 0 10px rgb(242 194 91 / .3); overflow-x: auto; max-width: 100%;
}
.boss .dg-art { color: #ef8a6f; text-shadow: 0 0 12px rgb(224 87 63 / .45); }
.dg-art.idle { color: var(--text-muted); text-shadow: none; }
.dg-art.hit { animation: dg-shake .45s ease; }
/* Sprites (app/mazmorra): imagen fija o tira horizontal de fotogramas */
.dg-sprite { position: relative; display: inline-block; overflow: hidden; line-height: 0; vertical-align: middle; }
.dg-sprite img { display: block; width: 100%; height: 100%; object-fit: contain; }
.dg-sprite.pixel img { image-rendering: pixelated; }
.dg-sprite.anim img { width: calc(var(--frames) * 100%); max-width: none; object-fit: fill; animation: dg-frames var(--dur) steps(var(--frames)) infinite; }
.dg-sprite.dg-foe, .dg-sprite.dg-scene { width: min(220px, 70%); aspect-ratio: 1; margin: 12px auto; display: block; }
.boss .dg-sprite.dg-foe { width: min(280px, 85%); filter: drop-shadow(0 0 14px rgb(224 87 63 / .45)); }
.dg-sprite.dg-foe.hit { animation: dg-shake .45s ease; }
.dg-sprite.ico { width: 1.25em; height: 1.25em; }
/* Miniatura del bestiario: solo el primer fotograma */
.dg-mini { display: inline-block; width: 32px; height: 32px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.dg-mini img { display: block; width: calc(var(--frames, 1) * 100%); max-width: none; height: 100%; object-fit: contain; object-position: left center; }
.dg-mini.pixel img { image-rendering: pixelated; }
.dg-enemy.con-fondo { background-image: linear-gradient(color-mix(in srgb, var(--surface) 55%, transparent), var(--surface) 92%), var(--dg-fondo); background-size: cover; background-position: center; }
@keyframes dg-frames { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .dg-sprite.anim img { animation: none; } }
.dg-phrase { color: var(--text-faint); font-style: italic; margin: 0; }
.dg-float { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); font-weight: 800; font-size: 1.6rem; pointer-events: none; animation: dg-float 1.1s ease forwards; }
.dg-float.dmg { color: var(--accent-strong); }
.dg-float.crit { color: #ffdf7e; font-size: 2.1rem; text-shadow: 0 0 14px rgb(255 214 120 / .8); }
.dg-hearts .dg-float.hurt { left: 100%; top: 0; font-size: 1rem; color: #e0573f; }
.dg.hurt .dg-hud, .dg.hurt .dg-stage { animation: dg-hurt .5s ease; }

.dg-stage .qtext { font-size: 1.08rem; }
.dg-options { margin-top: 6px; }
.dg-opt {
  display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; text-align: left; width: 100%;
  padding: 11px 14px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg-grain); color: var(--text);
  font: inherit; cursor: pointer; transition: border-color .12s, background .12s, transform .08s;
}
.dg-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); }
.dg-opt:active:not(:disabled) { transform: translateY(1px); }
.dg-opt .letter { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 700; font-size: .9rem; border: 1px solid var(--border-strong); color: var(--text-muted); background: var(--surface); }
.dg-opt:disabled { cursor: default; }
.dg-opt.gone { opacity: .3; text-decoration: line-through; }
/* Niebla: la opción se puede elegir, pero no se lee */
.dg-opt.fog span:last-child { filter: blur(5px); user-select: none; color: var(--text-faint); letter-spacing: .1em; }
.dg-opt.fog { background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--bg-grain) 8px 16px); }
.dg-opt.correct { border-color: var(--good); background: var(--good-bg); opacity: 1; }
.dg-opt.correct .letter { background: var(--good); color: #fff; border-color: var(--good); }
.dg-opt.wrong { border-color: var(--bad); background: var(--bad-bg); opacity: 1; }
.dg-opt.wrong .letter { background: var(--bad); color: #fff; border-color: var(--bad); }
.dg-hint { font-size: .8rem; margin: 10px 0 0; }
.dg-timer-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.dg-timer { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dg-timer > span { display: block; height: 100%; background: linear-gradient(90deg, var(--te-ambar), var(--te-miel)); transition: width .2s linear; }
.dg-timer > span.low { background: linear-gradient(90deg, #8a2f1c, #e0573f); }
#timer-txt { font-family: var(--mono); min-width: 34px; text-align: right; }
.dg-result { margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.dg-result.ok { border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.dg-result.ko { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.dg-result p { margin: 0 0 4px; }

.dg-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin-top: 10px; }
.dg-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 16px 12px;
  border-radius: 14px; border: 1px solid color-mix(in srgb, var(--r) 55%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--r) 12%, var(--surface-2)), var(--surface-2));
}
.dg-card .ico { font-size: 2.1rem; line-height: 1.1; }
.dg-card p { font-size: .88rem; color: var(--text-muted); margin: 0 0 6px; flex: 1; }
.dg-card.r-legendario { box-shadow: 0 0 22px -6px rgb(242 194 91 / .6); }

.dg-inv { display: flex; gap: 8px; flex-wrap: wrap; }
.dg-slot {
  width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; font-size: 1.6rem;
  border: 1px solid color-mix(in srgb, var(--r, var(--border)) 60%, var(--border)); background: var(--surface-2); cursor: pointer; color: inherit;
}
.dg-slot:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--r); }
.dg-slot:disabled { opacity: .55; cursor: default; }
.dg-slot.vacio { border-style: dashed; background: transparent; cursor: default; }
.dg-relics { display: flex; flex-wrap: wrap; gap: 6px; }
.dg-relic { display: inline-flex; align-items: center; gap: 2px; padding: 4px 8px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--r) 55%, var(--border)); background: var(--surface-2); font-size: 1.25rem; }
.dg-relic b { font-size: .75rem; color: var(--text-muted); }
.dg-log { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto; font-size: .86rem; color: var(--text-muted); }
.dg-log li { padding: 3px 0; border-bottom: 1px dashed var(--border); }
.dg-log li:first-child { color: var(--text); }
.dg-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--bad); box-shadow: var(--shadow); }

@keyframes dg-shake {
  0%, 100% { transform: translateX(0); filter: none; }
  15% { transform: translateX(-8px); filter: brightness(1.8); }
  30% { transform: translateX(7px); }
  45% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}
@keyframes dg-float { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -48px); } }
@keyframes dg-hurt { 0% { box-shadow: 0 0 0 0 rgb(224 87 63 / 0); } 30% { box-shadow: 0 0 0 3px rgb(224 87 63 / .8), 0 0 40px rgb(224 87 63 / .4); } 100% { box-shadow: var(--shadow); } }

/* Contraseña: requisitos y fortaleza */
.pw-wrap { display: flex; gap: 6px; align-items: center; }
.pw-meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.pw-meter span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.pw-rules { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 4px; font-size: .88rem; color: var(--text-faint); }
.pw-rules li::before { content: "○"; display: inline-block; width: 1.4em; }
.pw-rules li.ok { color: var(--good); }
.pw-rules li.ok::before { content: "✓"; font-weight: 700; }

/* ==========================================================================
   Móvil: barra de pestañas, zonas táctiles, notch, modo concentración
   ========================================================================== */
button, a, input, select, label, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.tabbar { display: none; }

@media (max-width: 960px) {
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-tabbar.focus { padding-bottom: env(safe-area-inset-bottom); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); box-shadow: 0 -8px 24px -16px rgb(0 0 0 / .6);
  }
  .tabbar::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--chatoyance); background-size: 200% 100%; opacity: .7; }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px;
    text-decoration: none; color: var(--text-faint); font-size: .7rem; font-weight: 600; border-radius: 12px;
  }
  .tabbar a .ti { font-size: 1.3rem; line-height: 1; filter: grayscale(.6); opacity: .8; }
  .tabbar a.active { color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .tabbar a.active .ti { filter: none; opacity: 1; }
  .tabbar .avatar { box-shadow: 0 0 0 2px var(--surface); }
  .tabbar a.active .avatar { box-shadow: 0 0 0 2px var(--accent); }
  body.focus .tabbar { display: none; }
  body.has-tabbar .footer { display: none; }
}

@media (max-width: 640px) {
  main { padding: 18px 0 28px; }
  .container { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .topbar-inner { min-height: 54px; }
  .brand { font-size: 1.02rem; }
  .brand svg { width: 30px; height: 30px; }
  h1 { font-size: 1.5rem; }
  .page-head { margin-bottom: 16px; align-items: stretch; }
  .page-head > .btn, .page-head > a.btn { width: 100%; }
  .card { padding: 16px; border-radius: 12px; }
  .card.flush { padding: 0; }
  .grid { gap: 12px; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 1.55rem; }
  .stat .label { font-size: .72rem; }
  /* zonas táctiles de al menos 44 px */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: 6px 12px; }
  .nav a, .nav button.linklike { min-height: 44px; display: flex; align-items: center; }
  input[type=text], input[type=password], input[type=number], input[type=search], select, textarea { font-size: 16px; min-height: 46px; }
  th, td { padding: 10px 10px; }
  .hide-sm { display: none !important; }
  .row.end > .btn, .row.end > form > .btn { flex: 1 1 auto; }
  /* tests */
  .test-bar { top: 57px; padding: 10px 12px; gap: 8px 12px; border-radius: 12px; }
  .test-bar .timer, .test-bar .save-state { font-size: .78rem; min-width: 0; }
  .qtext { font-size: 1.02rem; }
  .opt label { padding: 13px 12px; min-height: 52px; }
  .qnav a { width: 38px; height: 36px; }
  .sheet { grid-template-columns: 1fr; }
  .sheet-row span { width: 40px; height: 40px; }
  .score-ring { width: 130px; height: 130px; }
  .score-ring > div { width: 102px; height: 102px; }
  /* perfil */
  .profile-hero .banner { height: 90px; }
  .profile-hero .body { padding: 0 16px 16px; margin-top: -44px; }
  .heatmap i { width: 11px; height: 11px; }
  /* diálogo como hoja inferior */
  dialog.card { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  /* toasts sobre la barra inferior */
  .dg-toast { bottom: calc(84px + env(safe-area-inset-bottom)); width: calc(100vw - 32px); text-align: center; }
}

@media (hover: none) {
  .kbd-hint, .dg-hint { display: none; }
  .avatar-edit .avatar-overlay { opacity: 1; background: linear-gradient(transparent 55%, rgb(20 13 7 / .75) 55%); align-content: end; padding-bottom: 8px; font-size: 1rem; }
  .person:hover { transform: none; }
}

/* Mazmorra en móvil: HUD compacto, enemigo pequeño, inventario fijo abajo */
@media (max-width: 640px) {
  .dg-hud { top: 57px; padding: 8px 12px; gap: 6px 12px; border-radius: 12px; }
  .dg-hearts { font-size: 1.2rem; }
  .dg-hud-item { font-size: .88rem; }
  .dg-floor { font-size: .9rem; gap: 6px; }
  .dg-rooms i { width: 18px; height: 18px; }
  #btn-abandonar { min-height: 32px; padding: 2px 8px; font-size: .78rem; }
  .dg-main { gap: 10px; margin-top: 10px; }
  .dg-enemy { padding: 12px; }
  .dg-enemy-head h2 { font-size: 1.1rem; }
  .dg-art { font-size: .6rem; margin: 6px auto; }
  .dg-phrase { font-size: .82rem; }
  .dg-opt { padding: 13px 12px; min-height: 52px; }
  .dg-hint { display: none; }
  .dg-bottom { margin-top: 10px; gap: 10px; }
  .dg { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .dg-bottom > .card:first-child {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    padding: 8px max(12px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0; border-bottom: 0; box-shadow: 0 -10px 30px -18px rgb(0 0 0 / .8);
    background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(10px);
  }
  .dg-bottom > .card:first-child .card-head { display: none; }
  .dg-inv { justify-content: space-around; flex-wrap: nowrap; }
  .dg-slot { width: 54px; height: 54px; }
  .dg-cards { grid-template-columns: 1fr; }
  .dg-card { flex-direction: row; flex-wrap: wrap; text-align: left; justify-content: flex-start; align-items: center; }
  .dg-card .ico { font-size: 1.8rem; }
  .dg-card p { flex-basis: 100%; }
  .dg-title { font-size: .5rem; }
}
