:root {
  --bg: #0d1a23;
  --panel: rgba(16, 30, 40, 0.94);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8eef2;
  --muted: #9fb1bd;
  --accent: #f2c14e;
  --good: #6fcf7f;
  --bad: #ef6b5b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

.top { position: fixed; inset: 0 0 auto 0; height: 48px; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: linear-gradient(#0d1a23ee, #0d1a2300); z-index: 5; pointer-events: none; }
.brand { font-weight: 700; letter-spacing: .5px; font-size: 18px; }
.beta { font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 0 5px;
  vertical-align: middle; }
.clock, .pop { color: var(--muted); font-size: 13px; white-space: nowrap; text-shadow: 0 0 2px #0d1a23, 0 1px 3px #0d1a23, 0 0 6px #0d1a23; }
.pop { margin-left: auto; }
.gene-help { margin: 4px 0 0; }
.clock { pointer-events: auto; cursor: pointer; text-decoration: underline dotted rgba(159,177,189,.5); text-underline-offset: 3px; }
@media (max-width: 480px) {   /* en el móvil, la población debajo de la hora para que no se corte la estación */
  .top { flex-wrap: wrap; align-content: center; row-gap: 0; column-gap: 10px; height: 54px; }
  .pop { margin-left: 0; font-size: 12px; }
}

main { position: fixed; inset: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map.picking { cursor: crosshair; }

.mapctl { position: fixed; right: 12px; top: 56px; display: flex; flex-direction: column; gap: 8px; z-index: 4; }
.mapctl button { min-width: 96px; height: 40px; border-radius: 10px; border: 1px solid var(--line); padding: 0 10px;
  background: var(--panel); display: flex; align-items: center; gap: 7px; justify-content: flex-start; }
.mapctl button span { width: 20px; text-align: center; font-size: 18px; line-height: 1; }
.mapctl button b { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
#btn-follow.on b { color: #222; }
#btn-follow.on { background: var(--accent); color: #222; }

.hint { position: fixed; left: 50%; top: 60px; transform: translateX(-50%); background: var(--accent); color: #222;
  padding: 8px 14px; border-radius: 999px; font-weight: 600; z-index: 6; max-width: calc(100% - 32px); text-align: center; }

.intro { position: fixed; left: 12px; right: 12px; bottom: 132px; z-index: 6; max-width: 420px; margin: 0 auto;
  background: var(--panel, #13212b); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.intro p { margin: 0 0 6px; }
.intro h2 { margin: 0 0 6px; font-size: 18px; }
.intro canvas { display: block; margin: 0 auto 8px; width: 300px; max-width: 100%; height: auto; }
.intro-dots { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.intro-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.intro-dots i.on { background: var(--accent); }
/* BRUMOKIS · bruma de la bienvenida: el mapa de verdad con niebla por los bordes */
.bruma { position: fixed; inset: 0; z-index: 5; pointer-events: none; animation: bruma 9s ease-in-out infinite alternate;
  background: radial-gradient(ellipse at 50% 42%, rgba(222,231,237,0) 30%, rgba(222,231,237,.5) 62%, rgba(222,231,237,.88) 100%); }
@keyframes bruma { from { opacity: .82; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bruma { animation: none; } }
.brand { cursor: pointer; }
.intro .row { margin-top: 8px; }

/* leyenda de dietas: mismos colores que DIETA en app.js (borde del punto y suelo del dibujo) */
.leyenda { position: fixed; left: 10px; bottom: calc(57px + env(safe-area-inset-bottom)); z-index: 3; display: flex; gap: 10px;
  padding: 4px 9px; font-size: 12px; color: var(--muted); background: rgba(16, 30, 40, 0.8); border: 1px solid var(--line);
  border-radius: 999px; pointer-events: none; }
.leyenda span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.leyenda svg { width: 13px; height: 13px; overflow: visible; }
.leyenda svg * { fill: #c4d0d8; stroke-width: 2.2; stroke-linejoin: round; }
.leyenda .herb { stroke: #2e7d32; }
.leyenda .omni { stroke: #f5a623; }
.leyenda .carn { stroke: #a3161c; }
/* segunda fila: qué hace cada una (mismos dibujos que marcaEstado y pelea en app.js) */
.leyenda.estados { bottom: calc(57px + 28px + env(safe-area-inset-bottom)); }
.leyenda .m-huye { color: #fff; font-weight: 700; font-size: 13px; line-height: 1; width: 13px; text-align: center; }
.leyenda svg .caza { fill: none; stroke: #ff5a4a; stroke-width: 1.8; }
.leyenda svg .pelea { fill: #ffd84d; stroke: rgba(40, 20, 10, .6); stroke-width: 1; }
.leyenda svg .bebe { fill: #6cc7e5; stroke: rgba(20, 20, 30, .55); stroke-width: 1.2; }
.leyenda svg .defiende { fill: #f28cb1; stroke: rgba(20, 20, 30, .55); stroke-width: 1.2; }

.bottom { position: fixed; inset: auto 0 0 0; display: flex; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.bottom button { flex: 1; background: none; border: 0; padding: 12px 4px; font-size: 13px; color: var(--muted); }
.bottom button.on { color: var(--accent); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 6px; margin-left: 2px; }

.panel { position: fixed; right: 12px; top: 56px; bottom: 64px; width: min(400px, calc(100% - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); z-index: 5;
  overflow-y: auto; padding: 16px 16px 24px; backdrop-filter: blur(6px); }
.panel .close { position: sticky; top: 0; float: right; background: var(--panel); border: 0; font-size: 24px; color: var(--muted);
  line-height: 1; min-width: 44px; min-height: 44px; margin: -10px -10px 0 4px; border-radius: 12px; z-index: 2; }
.tag-mine { font-size: 12px; color: #222; background: var(--accent); border-radius: 6px; padding: 0 5px; }
@media (max-width: 640px) {
  .panel { left: 0; right: 0; width: 100%; top: auto; bottom: 49px; max-height: 62vh; border-radius: var(--radius) var(--radius) 0 0; }
  .mapctl { top: 56px; }
}
h2 { margin: 0 0 4px; font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.btn { border: 1px solid var(--line); background: #ffffff10; border-radius: 10px; padding: 9px 14px; }
.btn.primary { background: var(--accent); color: #1c1c1c; border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.sel { outline: 2px solid var(--accent); }
input[type=text], input[type=email], input[type=password] { width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #0008; color: var(--text); font: inherit; }
label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.gene { margin: 10px 0; }
.gene .head { display: flex; justify-content: space-between; font-size: 14px; }
.gene .why { font-size: 12px; color: var(--muted); }
.budget { padding: 8px 0 4px; font-weight: 700; color: var(--accent); }
.budget.over { color: var(--bad); }
.budget-row { display: flex; align-items: center; gap: 8px; }
.budget .star { color: rgba(255,255,255,.25); font-size: 15px; letter-spacing: 1px; }
.budget .star.on { color: var(--accent); }
.budget-label { font-size: 12px; opacity: .85; margin-right: 2px; }
.budget-left { font-size: 12px; font-weight: 600; white-space: nowrap; }
.help-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: inherit; font-weight: 700; cursor: pointer; flex: 0 0 auto; }
.budget-text { margin: 4px 0 6px; line-height: 1.35; }

.bar { height: 8px; border-radius: 99px; background: #ffffff18; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--good); }
.bar.low > i { background: var(--bad); }
.bar.water > i { background: #6cc7e5; }
.bar.water.low > i { background: var(--bad); }
.bar.preg > i { background: #f28cb1; }
.vitals { margin: 6px 0 4px; }
.vitals p { margin: 4px 0; }
.vitals .how { font-weight: 600; }
.vitals .how.bad { color: var(--bad); }
.vrow { display: grid; grid-template-columns: 5.5em 1fr 3em; align-items: center; gap: 8px; margin: 3px 0; }
.vrow .muted { text-align: right; }
/* grado de una parte en la ficha: no es bueno ni malo, va en el color de acento */
.gbar { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.gbar .bar { flex: 1; }
.gbar .bar > i { background: var(--accent); }
.gbar span { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list li .when { color: var(--muted); font-size: 12px; margin-right: 6px; }
.list li.unread { color: #fff; font-weight: 600; }
.link { color: var(--accent); background: none; border: 0; padding: 0; text-decoration: underline; }
canvas.portrait { width: 100%; max-width: 260px; aspect-ratio: 1; display: block; margin: 6px auto; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.tree { display: flex; flex-direction: column; gap: 10px; }
.tree .lvl { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tree .node { border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; font-size: 13px; background: #ffffff0a; }
.tree .node.dead { opacity: .45; }
.tree .node.me { border-color: var(--accent); }
.tree .node .own { color: var(--accent); font-size: 12px; display: block; }
.tree .lab { text-align: center; font-size: 12px; color: var(--muted); text-transform: uppercase; }
/* árbol centrado en una criatura: padres arriba, ella en medio, sus crías por camada */
/* árbol con ramas (docs/superpowers/specs/2026-11-15-arbol-con-ramas-design.md): los nudos se colocan
   aquí y las ramas (svg.branches, por detrás) se miden sobre ellos en app.js (ramas) */
.ftree { position: relative; display: flex; flex-direction: column; gap: 26px; padding: 8px 0 12px; }
.ftree svg.branches { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.ftree svg.branches path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ftree .tnode { position: relative; z-index: 1; background: #142530; min-width: 0; padding: 3px 5px; }
.ftree .tnode b { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree .tnode.dead { opacity: 1; }
.ftree .tnode.dead > * { opacity: .45; }
.tnode.t-me { border-color: var(--accent); }
.f-top { display: grid; grid-template-columns: repeat(var(--n), 1fr); row-gap: 26px; }
.f-row { display: flex; gap: 4px; justify-content: center; align-items: flex-end; }
.f-merow { display: flex; gap: 8px; justify-content: center; align-items: center; }
.f-sis { display: flex; flex-direction: column; gap: 6px; }
.f-sis .tnode { font-size: 11px; }
.f-sis .tnode b { max-width: 52px; }
.f-more { position: relative; z-index: 1; font-size: 12px; color: var(--muted); text-align: center; }
.f-litters { display: flex; flex-direction: column; gap: 20px; padding-left: 24px; }
.f-litter { display: flex; flex-direction: column; }
.f-knot { position: relative; z-index: 1; align-self: flex-start; font-size: 12px; color: var(--muted); background: #142530;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.f-kids { display: flex; flex-wrap: wrap; gap: 16px 6px; margin-top: 18px; }
.f-center { text-align: center; }
.tnode { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px; background: #ffffff0a; color: inherit; font: inherit; font-size: 13px; cursor: pointer; min-width: 72px; }
.tnode canvas { display: block; }
.tnode .own { color: var(--accent); font-size: 12px; }
.tnode.dead, .tchip.dead { opacity: .45; }
.tchip { border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; background: #ffffff0a; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.kin-warn { color: #e8b04a; }

.toast { position: fixed; left: 50%; top: 58px; transform: translateX(-50%); background: #000e; padding: 10px 16px;
  border-radius: 10px; z-index: 9; max-width: calc(100% - 32px); }

/* diseñador por piezas */
.part { margin: 10px 0 14px; }
.part .head { font-weight: 600; margin-bottom: 6px; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.opt { text-align: left; background: rgba(255,255,255,.04); color: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 2px; }
.opt b { font-size: 14px; }
.opt[hidden] { display: none; }
.diet-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 2px 0 4px; }
.diet-chip { padding: 8px 4px; border-radius: 999px; font-weight: 600; }
.diet-chip.sel { background: var(--accent); color: #1b1630; border-color: transparent; }
.diet-chip[disabled] { opacity: .45; }
.diet-help { margin: 0 0 6px; }
.opt small { opacity: .9; font-size: 12px; line-height: 1.3; }
.opt .pts { font-size: 12px; color: var(--accent); }
.opt .pts { letter-spacing: 1px; }
.opt .pts.free { color: #9fd9a8; letter-spacing: 0; }
.opt.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.opt:disabled { opacity: .65; cursor: not-allowed; }
.gene .why { display: flex; justify-content: space-between; }
select { padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: #0008; color: var(--text); font: inherit; }
.gene.grade { margin: 6px 0 0; }
.opt.rare { border-style: dashed; }
.opt.rare .pts { color: #c79bff; }
.opt.rare:disabled { opacity: .78; color: #e8d9ff; background: rgba(139, 92, 246, .08); border-color: rgba(199, 155, 255, .55); }

/* El creador mantiene a la criatura a la vista y divide el formulario en decisiones cortas. */
.designer-head { position: sticky; top: -16px; z-index: 3; margin: -16px -16px 8px; padding: 16px 16px 10px;
  background: linear-gradient(180deg, #10202b 78%, rgba(16,32,43,.96)); border-bottom: 1px solid var(--line); }
.designer-preview { display: grid; grid-template-columns: minmax(118px, 42%) 1fr; gap: 12px; align-items: center; }
.designer-preview canvas.portrait { width: 100%; max-width: 160px; margin: 0; filter: drop-shadow(0 8px 18px #0007); }
.designer-preview canvas.changed { animation: creature-change .32s ease-out; }
@keyframes creature-change { 0% { transform: scale(.95) rotate(-1deg); } 65% { transform: scale(1.035) rotate(1deg); } 100% { transform: none; } }
.designer-meta label { margin-top: 0; }
.designer-meta .surprise { padding: 6px 9px; font-size: 12px; color: #e8d9ff; border-color: rgba(199,155,255,.45); }
.designer-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 12px; }
.designer-tabs .btn, .part-tabs .btn { padding: 7px 8px; font-size: 12px; }
.designer-tabs .sel, .part-tabs .sel { background: var(--accent); border-color: var(--accent); color: #1c1c1c; font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.panel h2[tabindex="-1"]:focus { outline: none; }   /* título enfocado al abrir: sin marco */
.field-err { color: var(--bad); margin: 4px 0 0; }
@media (min-width: 641px) {   /* en escritorio el panel no tapa los botones del mapa */
  body.panel-open .mapctl { right: calc(min(400px, 100% - 24px) + 24px); }
}
.part-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 9px -2px 12px; padding: 2px 2px 7px; scrollbar-width: thin; }
.part-tabs .btn { flex: 0 0 auto; }
.part-tabs { flex-wrap: wrap; overflow-x: visible; }
.design-part { margin-top: 6px; }
.rare-help { padding: 9px 10px; border: 1px dashed rgba(199,155,255,.45); border-radius: 10px; color: #d6baff; background: rgba(139,92,246,.08); }
.designer-actions { position: sticky; bottom: -24px; z-index: 3; margin: 18px -16px -24px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(16,30,40,.82), #10202b 28%); }
.designer-actions .btn { width: 100%; min-height: 44px; }

/* Regreso diario, progreso y avisos ilustrados. */
.recap-callout { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; text-align: left;
  border: 1px solid rgba(242,193,78,.55); border-radius: 12px; background: linear-gradient(135deg, rgba(242,193,78,.16), rgba(111,207,127,.08)); padding: 10px 12px; margin-bottom: 12px; }
.recap-callout { padding: 7px 12px; margin-bottom: 10px; }
.recap-callout small { color: var(--muted); }
.recap-callout strong, .recap-spark { color: var(--accent); }
.progress-callout, .origin-note { display: flex; flex-direction: column; gap: 2px; margin: 9px 0; padding: 8px 10px;
  border-left: 3px solid var(--good); background: rgba(111,207,127,.08); border-radius: 0 9px 9px 0; font-size: 13px; }
.origin-note { border-left-color: #80bfff; background: rgba(128,191,255,.08); color: #c7d7e2; }
.event-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 9px; }
.event-card { display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: center; border: 1px solid var(--line);
  border-radius: 12px; padding: 9px; background: rgba(255,255,255,.035); }
.event-card.hero { grid-template-columns: 108px 1fr; min-height: 124px; margin: 10px 0 12px;
  border-color: rgba(242,193,78,.55); background: radial-gradient(circle at 12% 20%, rgba(242,193,78,.17), transparent 52%), rgba(255,255,255,.04); }
.event-card.unread { box-shadow: inset 3px 0 var(--accent); }
.event-visual { width: 62px; height: 62px; position: relative; display: grid; place-items: center; border-radius: 10px; background: #07121988; overflow: hidden; }
.event-card.hero .event-visual { width: 108px; height: 108px; }
.event-visual canvas { width: 100%; height: 100%; position: relative; z-index: 1; }
.event-icon { font-size: 28px; position: absolute; z-index: 0; }
.event-visual.has-portrait .event-icon { z-index: 2; font-size: 16px; right: 4px; bottom: 3px; padding: 1px 4px; background: #071219cc; border-radius: 99px; }
.event-copy p { margin: 3px 0 5px; }
.event-open { font-size: 12px; }
.digest-group, .older-events { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; }
.digest-group summary, .older-events summary { cursor: pointer; padding: 9px 0; color: var(--muted); }
.digest-group summary { display: flex; justify-content: space-between; }
.owner-rank { list-style-position: inside; padding: 0; margin: 0; }
.owner-rank li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.owner-rank span { color: var(--muted); }

@media (max-width: 380px) {
  .mapctl button { min-width: 88px; padding: 0 7px; }
  .designer-preview { grid-template-columns: 112px 1fr; gap: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .designer-preview canvas.changed { animation: none; }
}
