.family .app { max-width: 670px; margin-inline: auto; }
.family-main { display: grid; gap: 1rem; align-content: start; padding-block-end: 2rem; }
.family-card { display: grid; gap: .75rem; padding: 1rem; }
#child-entry-back { order: -2; }
#invitacion [data-action="ver"].primary, #invitacion [data-action="etapa_aprobar"].primary {
  min-height: 48px;
  padding-inline: 1.25rem;
  font-weight: 500;
}
#invitacion [data-action="etapa_despues"] { min-height: 48px; }
.family h2 { font-size: 1.2rem; }
.family form, .family label { display: grid; gap: .55rem; }
.family form { gap: .85rem; }
.family input { min-width: 0; width: 100%; padding: .75rem; border-radius: .5rem;
  border: 1px solid var(--line); color: inherit; background: var(--base); }
.family .family-check { grid-template-columns: auto 1fr; align-items: start; }
.family-check input { width: 1.3rem; height: 1.3rem; }
.family details p { margin-block: .5rem; }
.family summary { cursor: pointer; padding-block: .5rem; }
.family [popover] form { padding: 0; }
.family-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: 0; }
.family-stats div { padding: .55rem; border-radius: .5rem; background: var(--base); }
.family-stats dt { font-size: .8rem; color: var(--muted); }
.family-stats dd { margin: 0; font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.permission-list { list-style: none; padding: 0; margin-block: .4rem 1rem; }
.permission-list > li { padding-block: .5rem; border-block-end: 1px solid var(--line); }
.empty-medals { grid-column: 1 / -1; padding: .75rem; color: var(--muted); }
#photo-preview img { max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 10px; }
#photo-preview input { max-width: 100%; }
[data-team-note] { margin-top: .5rem; color: var(--muted); }
[hidden] { display: none !important; }

.achievements[data-medal-layout="flexible"] .collection {
  grid-template-rows: auto auto;
  align-content: start;
  gap: 10px;
}
.achievements[data-medal-layout="flexible"] .collection-group { grid-template-rows: auto auto; }
.achievements[data-medal-layout="flexible"] .medal-grid { grid-auto-rows: 1fr; }
.achievements[data-medal-layout="flexible"] .medal { gap: 4px; padding-block: 6px; }
.achievements[data-medal-layout="flexible"] .medal img { width: min(100%, 74px); }
.achievements[data-medal-layout="flexible"] .medal strong { min-height: 22px; }
.achievements[data-medal-layout="flexible"] .medal small { min-height: 27px; font-size: 0.75rem; }

.home .follow-up:empty { display: none; }
.home .hero-info .control { white-space: normal; }
.family select { max-width: 100%; padding: 8px; font: inherit; }
.retained-badges { padding: 12px; }
.family h2, .family strong, .home strong { font-weight: 500; }

[data-cerebro-extras-infantil] label:has([type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 44px;
}
[data-cerebro-extras-infantil] input[type="checkbox"] {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: #c8addd;
}
[data-cerebro-extras-infantil] [role="status"]:empty { display: none; }

.family .family-card { gap: .45rem; }
.family .family-card details details { border-block-start: 1px solid var(--line); }
.family .family-card details details > :not(summary) { margin-inline: .55rem; }
.family .family-card [type=number], .family .family-card [name=hora] { width: min(100%, 10rem); }
.family .family-card form button { justify-self: start; }
.family .family-card form + form { margin-block-start: .9rem; }
.family .family-card summary { font-weight: 500; }
.family :is([data-enviar-carta], [data-carta-familia]) :is(select, textarea) {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: .65rem .75rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--base);
  color: inherit;
  font: inherit;
}
.family :is([data-enviar-carta], [data-carta-familia]) textarea { min-height: 5rem; resize: vertical; }
.family .app:has(.family-main :is([data-enviar-carta], .family-letter)) { min-height: 100svh; }
.family .family-main:has([data-enviar-carta], .family-letter) > h1 {
  width: min(100%, 34rem);
  justify-self: center;
  font-size: clamp(1.45rem, calc(3.5vw * var(--ge-letra, 1)), 2.3rem);
  font-weight: 500;
}
.family .family-card:has([data-enviar-carta], .family-letter) {
  width: min(100%, 34rem);
  justify-self: center;
}
.family-letter { display: grid; justify-items: start; gap: .4rem; padding: .7rem .8rem; overflow-wrap: anywhere; }
.family-letter h2 { margin: 0; font-weight: 500; }
.family-letter p { margin: 0; }
.family [data-oir-carta] { width: max-content; }
.family [data-carta-estado]:empty { display: none; }

@media (min-width: 700px) {
  .app { width: min(100% - 48px, 930px); min-height: 0; }
  .screen { padding: 18px 22px 24px; gap: 14px; }
  .topbar { min-height: 56px; padding-inline: 22px; }
  .home {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    grid-template-rows: repeat(4, auto);
    align-content: start;
    align-items: start;
  }
  .home .intro { grid-column: 1 / -1; }
  .home .hero { grid-row: 2 / span 3; min-height: 0; aspect-ratio: 4 / 3; }
  .home .guide, .home .dock, .home .follow-up { grid-column: 2; }
  .home .hero-info .control { justify-self: start; min-height: 44px; }
  .home .dock { grid-template-columns: minmax(0, 1fr); }
  .home .dock .control { min-height: 44px; }
  .family .app { max-width: 850px; }
}

@media (min-width: 700px) {
  .family-main:has(.family-card) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .family-main > :not(article) { grid-column: 1 / -1; }
  .family-main > button { justify-self: start; }
}

@media (min-width: 1000px) {
  .family .app { max-width: 1060px; }
  .family-main:has(.family-card) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .family-main > aside { grid-column: 1 / -1; }
}

@media (min-width: 1000px) {
  .family .topbar { min-height: 52px; }
  .family .family-main { gap: 10px; padding-block: 12px 12px; }
  .family .family-card { gap: .35rem; padding: .85rem; }
}

@media (min-width: 850px) {
  .app:has(.home) { width: min(calc(100% - 48px), 1030px); }
  .home { grid-template-columns: minmax(0, 530px) minmax(0, 1fr); column-gap: 20px; }
  .home .hero { aspect-ratio: 3 / 2; }
  .home .dock { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home .dock .control { justify-content: start; }
  .app:has(.rooms) { width: min(calc(100% - 48px), 1030px); }
}

.tablet-choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.tablet-choices:empty { display: none; }
.tablet-person { min-width: 7.5rem; }
.tablet-person[aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: 2px; }
.family .tablet-form { max-width: 26rem; }
.family .tablet-form input { scroll-margin-block: 16px 110px; }
.family .tablet-form button { justify-self: start; }
.family summary, .family button, .family a.control, .family input:not([type=checkbox]):not([type=hidden]) {
  min-height: 44px;
}
.family summary { display: list-item; align-content: center; }
.family .family-main > section.family-card { grid-column: 1 / -1; }
.family .family-main:has(.tablet-form) { max-width: 44rem; margin-inline: auto; }

.tablet-switch { font-weight: 500; }
.family label:has(input[type=checkbox]) { min-height: 44px; }
@media (min-width: 740px) and (max-height: 850px) {
  .home .hero { max-height: 420px; }
  .home .hero img { max-height: 305px; object-fit: cover; }
}

.app:has(.tablet-choices) { max-width: 42rem; }
.screen.memory-young { grid-template-rows: none; align-content: start; }
.memory-young > .memory-tiles {
  width: min(100%, 32rem);
  justify-self: center;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto;
}
.memory-young .memory-tile { min-height: 44px; aspect-ratio: 1; }
.memory-young .memory-tile img { object-fit: contain; }
.memory-young > .primary { width: min(100%, 20rem); justify-self: center; }
@media (max-width: 550px) {
  .memory-young > .memory-tiles {
    width: min(100%, 20rem);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .memory-young .memory-tile { aspect-ratio: 5 / 4; }
}
.home > .ubicacion-aviso-menor { grid-row: 2; }
.home > .intro { grid-row: 1; }
@media (min-width: 700px) {
  .home > .ubicacion-aviso-menor { grid-column: 1 / -1; }
  .home:has(> .ubicacion-aviso-menor) { grid-template-rows: repeat(5, auto); }
  .home:has(> .ubicacion-aviso-menor) > .hero { grid-row: 3 / span 3; }
}

/* La pantalla táctil de tamaño completo conserva sus proporciones al girar. */
@media screen and (768px <= width <= 1366px) and (min-height: 680px) and (pointer: coarse),
       screen and (768px <= width <= 1024px) and (min-height: 900px) and (orientation: portrait),
       screen and (768px <= width <= 1024px) and (min-height: 680px) and (orientation: landscape) {
  .app:has(:is(.home, .memory-young, .memory-older, .tablet-choices, .family-main > article.family-card)),
  .family .app:has(:is(.tablet-choices, .family-main > article.family-card)) {
    width: 100%;
    max-width: none;
    min-height: 100svh;
  }
  .app:has(:is(.home, .memory-young, .memory-older, .tablet-choices, .family-main > article.family-card)) .topbar {
    min-height: 64px;
    padding-inline: clamp(20px, 3vw, 42px);
  }
  :is(.home, .memory-young, .memory-older, .family-main:has(> :is(.tablet-choices, article.family-card))) {
    --tableta-texto: calc(1rem * var(--ge-escala-tableta, 1.12));
    font-size: var(--tableta-texto);
    gap: 16px;
    padding: 20px clamp(20px, 3vw, 42px) 24px;
  }
  .screen:is(.memory-young, .memory-older) .intro h1,
  :is(.home, .family-main:has(> :is(.tablet-choices, article.family-card))) h1 {
    font-size: clamp(2.45rem, calc(5vw * var(--ge-letra, 1)), 3.3rem);
  }
  :is(.home, .memory-young, .memory-older, .family-main) .control {
    min-height: 52px;
    font-size: var(--tableta-texto, 1rem);
  }
  .home .overline, .home .small, .home .hero-info .label,
  .older .home .description, .older .home .hero-info .split-copy strong {
    font-size: .96em;
  }
  .home, .home:has(> .ubicacion-aviso-menor) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    grid-template-rows: none;
    align-content: start;
  }
  .home { --tableta-fila-escena: 2; }
  .home:has(> .ubicacion-aviso-menor) { --tableta-fila-escena: 3; }
  .home > .intro { grid-column: 1 / -1; }
  .home > .ubicacion-aviso-menor { margin: 0; }
  .home > .hero, .home:has(> .ubicacion-aviso-menor) > .hero {
    grid-column: 1 / -1;
    grid-row: var(--tableta-fila-escena);
    width: 100%;
    min-height: 0;
    max-height: 55svh;
    aspect-ratio: 6 / 5;
  }
  .home .hero-info { padding: clamp(18px, 3vw, 36px); }
  .home .hero-info .control { min-height: 54px; width: fit-content; max-width: 100%; }
  .home .hero-info .label { max-width: none; }
  .home > .guide {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-column: 1;
    grid-row: calc(var(--tableta-fila-escena) + 1);
    min-height: 116px;
    padding: 14px;
  }
  .home .guide .control { grid-column: 1 / -1; min-height: 44px; }
  .home .guide .mini-asset { width: 56px; }
  .home > .dock {
    grid-column: 2;
    grid-row: calc(var(--tableta-fila-escena) + 1);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .home .dock .control { min-height: 116px; justify-content: center; flex-direction: column; gap: 9px; }
  .home .dock { align-self: stretch; }
  .home .dock .icon { width: 30px; height: 30px; }
  .home > .follow-up { grid-column: 1 / -1; grid-row: calc(var(--tableta-fila-escena) + 2); }

  .family .family-main:has(> article.family-card) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .family .family-main > .family-card { gap: .38rem; padding: 1rem; min-width: 0; overflow-wrap: anywhere; }
  .family .family-main > .family-card h2 { font-size: 1.4rem; }
  .family .family-main > .family-card :is(summary, select, input:not([type=checkbox], [type=hidden])) {
    min-height: 48px;
  }
  .family .family-stats dt { font-size: .875rem; }
  .tablet-choices:not(:empty) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .tablet-choices > .tablet-person {
    min-width: 0;
    min-height: clamp(260px, 39vw, 380px);
    padding: 16px;
    flex-direction: column;
    gap: 14px;
    font-size: 1.35em;
    overflow-wrap: anywhere;
  }
  .tablet-person:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 16px) / 2);
  }
  .tablet-person > span { font-size: clamp(3rem, calc(8vw * var(--ge-letra, 1)), 6rem); line-height: 1.15; }

  .screen.memory-young { --tableta-reserva-juego: 350px; text-align: center; }
  .memory-young:has(> .ubicacion-aviso-menor) { --tableta-reserva-juego: 425px; }
  .memory-young > .memory-tiles {
    width: min(100%, calc((100svh - var(--tableta-reserva-juego)) * 2 / 3));
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(10px, 1.3vw, 18px);
    padding: clamp(10px, 1.3vw, 18px);
  }
  .memory-young > .primary { width: min(100%, 25rem); min-height: 56px; }
  .screen.memory-older { text-align: center; align-content: start; }
  .memory-older > .rotation-stage {
    max-width: none;
    min-height: clamp(285px, 45svh, 600px);
    grid-template-rows: auto auto;
    place-content: center;
  }
  .memory-older .rotation-stage img { width: min(100%, 420px); max-height: 38svh; }
  .memory-older .rotation-choices { gap: 16px; }
  .memory-older .rotation-option { min-height: clamp(130px, 20svh, 265px); justify-items: center; }
  .memory-older .rotation-option img { width: min(100%, 17svh, 185px); }
  .memory-older > .control { justify-self: center; width: fit-content; }
}

@media screen and (768px <= width <= 1366px) and (min-height: 680px) and (pointer: coarse) and (orientation: landscape),
       screen and (768px <= width <= 1024px) and (min-height: 680px) and (orientation: landscape) {
  .home, .home:has(> .ubicacion-aviso-menor) {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  }
  .home { grid-template-rows: auto auto 1fr; }
  .home:has(> .ubicacion-aviso-menor) { grid-template-rows: auto auto auto 1fr; }
  .home > .hero, .home:has(> .ubicacion-aviso-menor) > .hero {
    grid-column: 1;
    grid-row: var(--tableta-fila-escena) / span 2;
    max-height: calc(100svh - 185px);
  }
  .home:has(> .ubicacion-aviso-menor) > .hero { max-height: calc(100svh - 265px); }
  .home > .guide { display: flex; grid-column: 2; grid-row: var(--tableta-fila-escena); }
  .home > .dock { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .home .dock .control { min-height: 88px; justify-content: start; flex-direction: row; padding-inline: 18px; }
  .home > .follow-up { grid-column: 2; }
  .tablet-choices:not(:empty) {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  }
  .tablet-choices > .tablet-person { min-height: clamp(220px, 40svh, 400px); }
  .tablet-person:last-child:nth-child(odd) { grid-column: auto; justify-self: stretch; width: auto; }
  .screen.memory-young {
    grid-template-columns: minmax(0, 3fr) minmax(0, 1.1fr);
    grid-template-rows: 1fr repeat(5, auto) 1fr;
    text-align: start;
  }
  .memory-young > :not(.memory-tiles) { grid-column: 2; }
  .memory-young > .intro { grid-row: 2; justify-items: start; text-align: start; }
  .memory-young > .ubicacion-aviso-menor { grid-row: 3; margin: 0; }
  .memory-young > [data-team-note] { grid-row: 4; }
  .memory-young > .memory-tiles {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: center;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .memory-young .memory-tile { width: 100%; align-self: start; }
  .memory-young > .memory-status { grid-row: 5; place-items: center start; text-align: start; }
  .memory-young > .primary { grid-row: 6; }
  .memory-young > [data-child-status] { grid-row: 7; }
  .memory-older > .rotation-stage { min-height: clamp(250px, 44svh, 535px); }
}

#alta { max-height: calc(100dvh / var(--ge-vista, 1) - 32px); overflow: auto; padding: 14px; gap: 8px; }
#alta h2 { margin: 0; }
#new-child { gap: 8px; }
#new-child label { gap: 4px; }
#new-child .ge-notice { padding: 8px 10px; font-size: .9rem; line-height: 1.4; }
#new-child .ge-notice > :is(h3, p, ul) { margin-block: 4px; }
#new-child .ge-dialog-actions .ge-secondary { border-color: #7096b1; background: var(--ge-aviso-secundario); }
#alta [data-alta-recomendados] { margin: 6px 0; padding: 6px 10px; border: 1px solid currentColor; border-radius: 8px; }
#alta [data-alta-recomendados][hidden] { display: none; }
.recomendados-grupo { padding: 3px 0 6px; }
.recomendados-grupo p { margin: 4px 0; font-weight: 500; }
.recomendados-grupo .family-check { display: flex; align-items: center; gap: 8px; margin: 0; min-height: 34px; }
[data-recomendados] { margin: 6px 0; }

[data-alta-lista] { max-height: min(230px, 27dvh); overflow: auto; padding-inline-end: 6px; }

@media (max-width: 639px) {
  .home:not(:has(> .ubicacion-aviso-menor)) {
    grid-template-rows: auto minmax(0, 360px) auto auto;
    align-content: start;
  }
}

.voz-lectura {
  position: sticky; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap;
  padding: 6px 10px; gap: 8px; align-items: center;
  width: fit-content; max-width: calc(100% - 58px); background: var(--surface, #182b40);
  margin: 0 8px 8px; border: 1px solid var(--line, #496681); border-radius: 12px;
}
.voz-lectura button { min-height: 44px; }
.voz-lectura p { margin: 0; }
.family-main:has(.family-letter) + .voz-lectura { margin-inline: auto 4.25rem; }
.voz-palabra:not(:empty) { padding: 4px 8px; background: #234660; color: #e9faff; border-radius: 6px; }
[data-lumbre-charla] button { min-height: 44px; }

[data-lumbre-charla], .lumbre-actividad { padding: 14px; }
[data-lumbre-charla] { display: grid; gap: 8px; }
[data-lumbre-charla] .actions { display: grid; gap: 7px; }
[data-lumbre-charla] .actions button { width: 100%; }
.lumbre-actividad[open] summary { margin-block-end: 12px; }
.lumbre-actividad > :is(.steps, .lesson, .control) { margin-block: 8px; }

/* La ilustración de Lumbre conserva su encuadre frente a las reglas generales del escenario. */
.app .home .hero img.floating {
  height: auto; max-height: 56%; aspect-ratio: 1; object-fit: contain;
}
