/* ============================================================
   Casitas contra el Ruido — estilos base y componentes
   Paleta: rosa pastel + celeste + morado + amarillo + verde
   ============================================================ */

:root {
  --pink:      #f7b7d6;
  --pink-soft: #ffe3f1;
  --pink-deep: #e86ba8;
  --lav:       #b79cf0;
  --lav-soft:  #ece2ff;
  --purple:    #9b5de5;
  --sky:       #4fb6e8;
  --sky-soft:  #e0f4ff;
  --yellow:    #f2b705;
  --yellow-soft:#fff3cf;
  --green:     #4cc38a;
  --green-soft:#dcf6ea;
  --red:       #e4482e;
  --red-soft:  #ffe0da;

  --ink:       #4a3357;
  --ink-soft:  #7c6a88;
  --bg:        #fff5fa;
  --card:      #ffffff;
  --line:      #f0d9e8;

  --radius:    22px;
  --radius-lg: 32px;
  --shadow:    0 10px 30px rgba(155, 93, 229, .16);
  --shadow-sm: 0 4px 14px rgba(155, 93, 229, .12);

  --tap:       48px;
  --font: "Segoe UI", "Comic Sans MS", "Baloo 2", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* El atributo [hidden] siempre gana, aunque el elemento tenga display:flex/grid */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--pink-soft), transparent 60%),
    radial-gradient(1000px 700px at 110% 0%, var(--lav-soft), transparent 55%),
    radial-gradient(900px 800px at 50% 120%, var(--sky-soft), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  overscroll-behavior-y: contain;
  -webkit-user-select: none;
  user-select: none;
}

#app-root { min-height: 100vh; min-height: 100dvh; }

h1, h2, h3, p { margin: 0; }

/* ---------- Boot splash ---------- */
.boot-splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  background: linear-gradient(160deg, var(--pink-soft), var(--lav-soft));
  z-index: 50;
}
.boot-logo { font-size: 64px; animation: pop .6s ease; }
.boot-title { font-size: 22px; font-weight: 800; color: var(--purple); }
.boot-spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 5px solid var(--pink); border-top-color: var(--purple);
  animation: spin 1s linear infinite;
}

/* ---------- Screen scaffold ---------- */
.screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  gap: 16px;
  animation: screen-in .35s ease;
}
.screen-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.topbar {
  display: flex; align-items: center; gap: 10px;
}
.topbar .spacer { flex: 1; }
.topbar h2 {
  font-size: clamp(18px, 4.5vw, 26px);
  font-weight: 800;
  color: var(--purple);
  display: flex; align-items: center; gap: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 800;
  min-height: var(--tap);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: clamp(14px, 3vw, 16.5px);
  color: #fff;
  background: linear-gradient(180deg, var(--pink-deep), var(--purple));
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  line-height: 1.15;
  text-align: center;
}
.btn.sm { min-height: 44px; padding: 8px 14px; font-size: 13.5px; border-radius: 14px; gap: 6px; }
.btn:active { transform: translateY(2px) scale(.985); filter: brightness(.97); }
.btn:disabled { opacity: .5; filter: grayscale(.3); cursor: not-allowed; }
.btn.block { display: flex; width: 100%; }

.btn.secondary { background: linear-gradient(180deg, #fff, var(--pink-soft)); color: var(--purple); border: 2px solid var(--pink); }
.btn.sky      { background: linear-gradient(180deg, var(--sky), #2f9fd6); }
.btn.green    { background: linear-gradient(180deg, var(--green), #33a06f); }
.btn.yellow   { background: linear-gradient(180deg, var(--yellow), #d99e00); color: #6a4b00; }
.btn.red      { background: linear-gradient(180deg, #ff6a4d, var(--red)); }
.btn.ghost    { background: transparent; color: var(--purple); box-shadow: none; border: 2px dashed var(--lav); }
.btn.big      { min-height: 56px; font-size: clamp(16px, 4vw, 20px); padding: 14px 24px; }
.icon-btn {
  width: var(--tap); height: var(--tap); min-height: var(--tap);
  padding: 0; border-radius: 18px;
  background: #fff; color: var(--purple);
  box-shadow: var(--shadow-sm);
  font-size: 22px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.pad-lg { padding: 26px; }
.card h3 { font-size: 18px; color: var(--purple); margin-bottom: 8px; }
.muted { color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.center { text-align: center; }

/* ---------- Houses grid ---------- */
.houses-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.house-card {
  position: relative;
  border: none; cursor: pointer;
  border-radius: var(--radius-lg);
  padding: 16px 12px 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
  font-family: inherit;
  transition: transform .14s ease, box-shadow .14s ease;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-height: 172px;
}
.house-card:active { transform: translateY(3px) scale(.98); }
.house-card .roof {
  width: 92px; height: 46px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  margin-bottom: -6px;
}
.house-card .body {
  width: 84px; height: 62px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  background: #fff;
  border: 3px solid rgba(0,0,0,.06);
}
.house-card .name { font-weight: 900; font-size: 15px; color: var(--ink); letter-spacing: .3px; }
.house-card .tag {
  font-size: 11px; font-weight: 800; color: #fff;
  padding: 3px 10px; border-radius: 999px;
}
.house-card .desc { font-size: 11px; color: var(--ink-soft); line-height: 1.4; }
.house-card .state-chip {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; font-weight: 800;
  background: var(--lav-soft); color: var(--purple);
  padding: 3px 8px; border-radius: 999px;
}
.house-card.control-badge::before {
  content: "CONTROL";
  position: absolute; top: 10px; left: 10px;
  font-size: 10px; font-weight: 900; letter-spacing: .5px;
  background: var(--red); color: #fff;
  padding: 3px 8px; border-radius: 999px;
}
.house-card.locked { filter: grayscale(.55) opacity(.75); }
.house-card.done { outline: 3px solid var(--green); }

.house-card.red    .roof { background: var(--red); }
.house-card.yellow .roof { background: var(--yellow); }
.house-card.blue   .roof { background: var(--sky); }
.house-card.purple .roof { background: var(--purple); }
.house-card.red    .tag  { background: var(--red); }
.house-card.yellow .tag  { background: #d99e00; }
.house-card.blue   .tag  { background: #2f9fd6; }
.house-card.purple .tag  { background: var(--purple); }

/* ---------- Selected house banner ---------- */
.house-banner {
  border-radius: var(--radius-lg);
  padding: 18px;
  color: #fff;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow);
}
.house-banner .emoji { font-size: 40px; }
.house-banner.red    { background: linear-gradient(135deg, #ff6a4d, var(--red)); }
.house-banner.yellow { background: linear-gradient(135deg, #ffd45e, #d99e00); color: #5b3d00; }
.house-banner.blue   { background: linear-gradient(135deg, #7fd0f5, #2f9fd6); }
.house-banner.purple { background: linear-gradient(135deg, #c19bff, var(--purple)); }
.house-banner .h-name { font-size: 22px; font-weight: 900; }
.house-banner .h-sub  { font-size: 13px; opacity: .95; }

/* ---------- Checklist ---------- */
.checklist { display: grid; gap: 10px; }
.check-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--green-soft);
  border-radius: 16px; padding: 12px 14px;
  font-weight: 700; font-size: 14px; color: var(--ink);
}
.check-row .dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.check-row.pending { background: var(--pink-soft); }
.check-row.pending .dot { background: var(--pink); }

/* ---------- Big readouts ---------- */
.readout {
  text-align: center;
  background: linear-gradient(160deg, var(--lav-soft), #fff);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.readout .big {
  font-size: clamp(44px, 14vw, 84px);
  font-weight: 900;
  color: var(--purple);
  line-height: 1;
}
.readout .unit { font-size: .4em; color: var(--pink-deep); }
.readout .label { font-size: 14px; font-weight: 800; color: var(--ink-soft); letter-spacing: 1px; }
.readout .mini { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }

/* level meter bar */
.level-bar {
  height: 22px; border-radius: 999px; overflow: hidden;
  background: var(--pink-soft); margin-top: 14px;
}
.level-bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  transition: width .08s linear;
}

/* progress */
.progress {
  height: 26px; border-radius: 999px; background: var(--pink-soft); overflow: hidden;
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
}
.progress > i { display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--pink-deep), var(--purple)); transition: width .2s linear; }
.progress-text { text-align: center; font-weight: 800; color: var(--purple); margin-top: 8px; }

/* ---------- Countdown ---------- */
.countdown {
  position: fixed; inset: 0; z-index: 40;
  background: linear-gradient(160deg, var(--purple), var(--pink-deep));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; text-align: center;
}
.countdown .word { font-size: clamp(22px, 7vw, 40px); font-weight: 800; letter-spacing: 2px; opacity: .9; }
.countdown .num {
  font-size: clamp(120px, 44vw, 280px); font-weight: 900; line-height: 1;
  animation: count-pop .9s ease;
}
.countdown .go { font-size: clamp(40px, 12vw, 90px); font-weight: 900; animation: pop .5s ease; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 18px; }
table.results-table {
  border-collapse: separate; border-spacing: 0;
  width: 100%; min-width: 520px;
  background: #fff; border-radius: 18px; overflow: hidden;
  font-size: 13px;
}
.results-table th, .results-table td { padding: 12px 10px; text-align: center; }
.results-table thead th {
  background: var(--lav-soft); color: var(--purple); font-weight: 900;
}
.results-table tbody tr + tr td { border-top: 1px solid var(--line); }
.results-table .house-cell { text-align: left; font-weight: 800; white-space: nowrap; }
.results-table .dot-mini { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.results-table td.strong { font-weight: 900; color: var(--purple); }
.diff-down { color: #1f9d63; font-weight: 900; }
.diff-up { color: var(--red); font-weight: 900; }
.diff-base { color: var(--ink-soft); font-weight: 800; }

/* ---------- Chart ---------- */
.chart-card { padding: 18px; }
.chart-title { text-align: center; font-weight: 900; color: var(--purple); font-size: 16px; margin-bottom: 6px; }
.chart-holder { position: relative; width: 100%; }
.chart-holder canvas { width: 100%; display: block; touch-action: manipulation; }
.chart-tip {
  position: absolute; pointer-events: none;
  background: #fff; border: 2px solid var(--purple); border-radius: 14px;
  padding: 8px 12px; font-size: 12px; font-weight: 700; color: var(--ink);
  box-shadow: var(--shadow); transform: translate(-50%, -110%); white-space: nowrap;
  transition: opacity .15s ease;
}
.chart-axis-label { text-align: center; font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Winner ---------- */
.winner-screen {
  text-align: center;
  background: linear-gradient(160deg, var(--lav-soft), var(--pink-soft));
}
.trophy { font-size: clamp(64px, 20vw, 120px); animation: bounce 1.4s ease infinite; }
.winner-name { font-size: clamp(24px, 8vw, 40px); font-weight: 900; color: var(--purple); }
.winner-db { font-size: clamp(30px, 10vw, 54px); font-weight: 900; color: var(--pink-deep); }
.winner-card { background: #fff; border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }

/* ---------- Character ---------- */
.character {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 22px; padding: 12px 14px;
  box-shadow: var(--shadow-sm); border: 2px solid var(--pink-soft);
}
.character img { width: 56px; height: 56px; flex-shrink: 0; }
.character .bubble { font-size: 14px; font-weight: 700; color: var(--purple); line-height: 1.35; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 800; font-size: 14px; color: var(--ink); }
.field .hint-sm { font-size: 12px; color: var(--ink-soft); }
.field input[type="number"], .field input[type="text"], .field select {
  font-family: inherit; font-size: 16px;
  padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--lav); background: #fff; color: var(--ink);
  min-height: var(--tap);
}
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  flex: 1; min-width: 64px; min-height: 48px;
  border: 2px solid var(--lav); background: #fff; color: var(--purple);
  border-radius: 14px; font-weight: 800; font-family: inherit; font-size: 15px; cursor: pointer;
}
.seg button.active { background: var(--purple); color: #fff; border-color: var(--purple); }

.kv-list { display: grid; gap: 8px; }
.kv-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px;
  background: var(--lav-soft); padding: 10px 14px; border-radius: 12px; }
.kv-row b { color: var(--purple); }
.status-yes { color: #1f9d63; font-weight: 800; }
.status-no  { color: var(--red); font-weight: 800; }

/* ---------- Toast / Modal ---------- */
.toast-layer {
  position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 60; pointer-events: none; padding: 0 16px;
}
.toast {
  background: var(--purple); color: #fff; font-weight: 700; font-size: 14px;
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
  animation: toast-in .25s ease;
}
.modal-layer {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(74, 51, 87, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 24px;
  max-width: 380px; width: 100%; box-shadow: var(--shadow); text-align: center;
  animation: pop .3s ease;
}
.modal h3 { color: var(--purple); font-size: 20px; margin-bottom: 8px; }
.modal p { color: var(--ink-soft); font-size: 14px; line-height: 1.5; margin-bottom: 18px; }
.modal .row { display: flex; gap: 10px; }
.modal .row .btn { flex: 1; }

.confetti-canvas { position: fixed; inset: 0; z-index: 65; pointer-events: none; }

/* ---------- Waves animation holder ---------- */
.waves {
  display: flex; align-items: flex-end; justify-content: center; gap: 6px; height: 70px;
}
.waves i {
  width: 10px; border-radius: 999px;
  background: linear-gradient(var(--pink-deep), var(--purple));
  animation: wave 1s ease-in-out infinite;
}
.waves i:nth-child(1){ animation-delay: 0s }
.waves i:nth-child(2){ animation-delay: .1s }
.waves i:nth-child(3){ animation-delay: .2s }
.waves i:nth-child(4){ animation-delay: .3s }
.waves i:nth-child(5){ animation-delay: .4s }
.waves i:nth-child(6){ animation-delay: .5s }
.waves i:nth-child(7){ animation-delay: .6s }

/* ---------- Utility ---------- */
.stack { display: grid; gap: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 2px solid var(--lav); color: var(--purple);
  font-weight: 800; font-size: 12px; padding: 6px 12px; border-radius: 999px;
}
.spacer-lg { height: 8px; }
.hidden { display: none !important; }
.fine-print { font-size: 11px; color: var(--ink-soft); text-align: center; line-height: 1.5; }

/* ============================================================
   REDISENO: inicio compacto, barra de sonido, casitas con
   imagen y medicion en modal (version para el aula)
   ============================================================ */

/* ---- Chip pequeño (instalar / actualizar) ---- */
.install-slot { flex-shrink: 0; display: flex; gap: 6px; }
.chip-btn {
  appearance: none; cursor: pointer; font-family: inherit;
  font-weight: 800; font-size: 12px; line-height: 1;
  color: var(--purple); background: #fff;
  border: 2px solid var(--lav); border-radius: 999px;
  padding: 8px 12px; min-height: 36px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.chip-btn:active { transform: translateY(1px); }
.chip-btn.update { background: var(--green-soft); border-color: var(--green); color: #1f7a54; }

/* ============================================================
   PANEL PRINCIPAL v2 (estilo mockup)
   ============================================================ */
.home-v2 { padding: 0; }
.home-v2 .screen-scroll { padding: max(10px, env(safe-area-inset-top)) 0 16px; }

/* Ancho común del "dashboard": la cabecera y el cuerpo comparten estos límites */
.hv-hero, .hv-body {
  max-width: 1180px; width: 100%; margin-left: auto; margin-right: auto;
  padding-left: clamp(14px, 3vw, 28px);
  padding-right: clamp(14px, 3vw, 28px);
}
.hv-body {
  position: relative; z-index: 3;
  margin-top: -46px;              /* la tarjeta de sonido queda ENCIMA de la cabecera */
}
.home-v2 .hv-body { gap: clamp(9px, 1.3vw, 12px); }

/* ---- Cabecera: imagen configurable DETRÁS del contenido, solo el ancho del panel ---- */
.hv-hero {
  position: relative;
  padding-top: 0; padding-bottom: 0;
  overflow: visible;
}
.hv-bg-wrap {
  position: absolute; z-index: 0;
  left: clamp(14px, 3vw, 28px); right: clamp(14px, 3vw, 28px);
  top: 0; bottom: 0;
  border-radius: 28px; overflow: hidden;
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, #fdeaf4, #efe6ff 70%, #e9f3ff); /* respaldo si la imagen no carga */
}
.hv-bg {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  display: block;
}
.hv-bg-wrap::after {   /* velo suave para que el texto se lea sobre cualquier imagen */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg,
    rgba(255,255,255,.34) 0%,
    rgba(255,255,255,.06) 34%,
    rgba(255,255,255,.02) 60%,
    rgba(255,245,250,.30) 100%);
}
.hv-hero-inner {
  position: relative; z-index: 2;
  min-height: clamp(108px, 13.4vw, 182px);   /* alto del contenedor de la imagen */
  padding: clamp(11px, 1.6vw, 18px) clamp(6px, 2vw, 20px) clamp(34px, 4.6vw, 58px);
  display: flex; align-items: flex-start; gap: 10px 16px; flex-wrap: wrap;
}
.hv-bg-chip {
  appearance: none; cursor: pointer; border: none; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow);
  font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.hv-bg-chip:active { transform: translateY(1px); }
.hv-brand { display: flex; align-items: center; gap: 14px; flex: 1 1 260px; min-width: 220px; }
.hv-logo { width: clamp(46px, 8vw, 62px); height: auto; flex-shrink: 0;
  filter: drop-shadow(0 6px 12px rgba(232,107,168,.35)); }
.hv-brand-txt h1 {
  font-size: clamp(22px, 4.4vw, 34px); font-weight: 900; color: #3b2b63; line-height: 1.05;
  text-shadow: 0 1px 0 rgba(255,255,255,.75), 0 2px 10px rgba(255,255,255,.55);
}
.hv-brand-txt p {
  font-size: clamp(13px, 2.6vw, 17px); color: #6b5f96; font-weight: 800; margin-top: 3px;
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
}
.hv-top-right {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  flex: 1 1 100%;                 /* fila propia, centrada horizontalmente */
  justify-content: center;
  margin-left: 0;
  margin-top: 4px;
}
.user-chip {
  appearance: none; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: none; border-radius: 999px;
  padding: 8px 12px; box-shadow: var(--shadow);
}
.user-chip:active { transform: translateY(1px); }
.uc-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(160deg, var(--lav), var(--purple));
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.uc-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; min-width: 0; }
.uc-txt b { font-size: 13.5px; color: var(--ink); font-weight: 800; white-space: nowrap; }
.uc-txt small { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }
.uc-caret { color: var(--ink-soft); font-size: 12px; }

/* ---- Tarjeta de sonido (flota ENCIMA de la cabecera) ---- */
.sound-card {
  position: relative; z-index: 4;
  display: flex; align-items: center; gap: clamp(12px, 2.5vw, 20px);
  padding: clamp(10px, 1.9vw, 16px) clamp(15px, 3vw, 24px);
  border-radius: 24px;
  box-shadow: 0 16px 38px rgba(155, 93, 229, .2);
}
.play-fab {
  appearance: none; cursor: pointer; border: none; flex-shrink: 0;
  width: clamp(50px, 9vw, 64px); height: clamp(50px, 9vw, 64px);
  border-radius: 50%; color: #fff; font-size: 22px;
  background: radial-gradient(circle at 35% 30%, #ff9ecb, var(--pink-deep));
  box-shadow: 0 10px 22px rgba(232,107,168,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease;
}
.play-fab .pf-icon { transform: translateX(1px); }
.play-fab:active { transform: scale(.94); }
.play-fab.is-on {
  background: radial-gradient(circle at 35% 30%, #ff9d84, var(--red));
  animation: ring-pulse 1.6s ease-out infinite;
}
.play-fab.is-on .pf-icon { transform: none; }
.sc-copy { flex: 1; min-width: 0; }
.sc-copy h2 { font-size: clamp(16px, 3vw, 20px); font-weight: 900; color: var(--ink); }
.sc-copy p { font-size: clamp(11px, 2.2vw, 13px); color: var(--ink-soft); margin-top: 2px; line-height: 1.35; }
.sc-copy p b { color: var(--purple); }
.sc-vol { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; min-width: 160px; max-width: 460px; }
.sc-vol-ico { font-size: 20px; flex-shrink: 0; }
.sc-vol-val { font-size: 13px; font-weight: 900; color: var(--pink-deep); min-width: 44px; text-align: right; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; height: 26px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, var(--pink-deep), #ff9ecb);
}
input[type="range"]::-moz-range-track {
  height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, var(--pink-deep), #ff9ecb);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; margin-top: -6px;
  border-radius: 50%; background: var(--pink-deep);
  border: 4px solid #fff; box-shadow: 0 3px 10px rgba(232,107,168,.5);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--pink-deep); border: 4px solid #fff; box-shadow: 0 3px 10px rgba(232,107,168,.5);
}

/* ---- Encabezado de sección "Materiales a evaluar" ---- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.sh-left { display: flex; align-items: center; gap: 10px; }
.sh-ico { width: 32px; height: 32px; flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(232,107,168,.3)); }
.sh-left h2 { font-size: clamp(16px, 3vw, 22px); font-weight: 900; color: #3b2b63; }
.sh-left p { font-size: clamp(11px, 2.2vw, 13px); color: var(--ink-soft); margin-top: 1px; }
.sh-count {
  display: flex; align-items: center; gap: 9px;
  background: #fff; border-radius: 999px; padding: 6px 13px; box-shadow: var(--shadow-sm);
}
.sh-count b {
  background: var(--lav-soft); color: var(--purple); font-weight: 900;
  padding: 3px 12px; border-radius: 999px; font-size: 15px;
}
.sh-count span { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }

/* ---- Tarjetas de material ---- */
.mat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: clamp(10px, 1.6vw, 15px);
}
.mat-card {
  position: relative; cursor: pointer; font-family: inherit; text-align: center;
  display: flex; flex-direction: column; gap: 5px;
  padding: 9px 9px 11px;
  border-radius: 22px;
  background: #fff;
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease;
}
.mat-card:active { transform: translateY(3px) scale(.99); }
.mat-card.red    { border-color: #f6c6da; background: linear-gradient(180deg, #fff, #fff5f9); }
.mat-card.yellow { border-color: #f4e0a8; background: linear-gradient(180deg, #fff, #fffaf0); }
.mat-card.blue   { border-color: #bfe0f4; background: linear-gradient(180deg, #fff, #f3faff); }
.mat-card.purple { border-color: #d9c7f4; background: linear-gradient(180deg, #fff, #f8f5ff); }
.mat-card.is-done { box-shadow: 0 0 0 3px var(--green), var(--shadow-sm); }

.mc-img {
  position: relative; width: 100%; aspect-ratio: 16 / 11;
  border-radius: 15px; overflow: hidden;
  background: linear-gradient(160deg, #dff0ff, #eae2ff);
  display: flex; align-items: center; justify-content: center;
}
.mc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 12px; font-weight: 900;
  background: rgba(255,255,255,.92); color: var(--purple);
  padding: 3px 10px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.mat-card.is-done .mc-badge { background: var(--green); color: #fff; }
.mat-card.red .mc-badge    { color: var(--red); }
.mat-card.yellow .mc-badge { color: #b98600; }
.mat-card.blue .mc-badge   { color: #2f7fb8; }
.mat-card.purple .mc-badge { color: var(--purple); }
.mat-card.is-done .mc-badge { color: #fff; }
.mc-control {
  position: absolute; top: 8px; left: 8px;
  font-size: 9px; font-weight: 900; letter-spacing: .6px;
  background: var(--red); color: #fff; padding: 3px 8px; border-radius: 999px;
}

.mc-fallback { display: none; flex-direction: column; align-items: center; }
.mat-card.noimg .mc-img img { display: none; }
.mat-card.noimg .mc-fallback { display: flex; }
.mc-fallback .roof { width: 92px; height: 46px; clip-path: polygon(50% 0, 100% 100%, 0 100%); margin-bottom: -4px; }
.mc-fallback .body {
  width: 80px; height: 58px; border-radius: 10px; background: #fff;
  border: 3px solid rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.mat-card.red .mc-fallback .roof    { background: var(--red); }
.mat-card.yellow .mc-fallback .roof { background: var(--yellow); }
.mat-card.blue .mc-fallback .roof   { background: var(--sky); }
.mat-card.purple .mc-fallback .roof { background: var(--purple); }

.mc-name { font-weight: 900; font-size: clamp(13px, 2.3vw, 16px); color: #3b2b63; }
.mc-desc { font-size: 11.5px; color: var(--ink-soft); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Pista de acción: la tarjeta entera abre el modal de medición */
.mc-go {
  position: absolute; right: 8px; bottom: 8px;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff;
  background: linear-gradient(180deg, #ff7bb0, var(--pink-deep));
  box-shadow: 0 4px 12px rgba(232,107,168,.5);
}
.mat-card.yellow .mc-go { background: linear-gradient(180deg, #ffc542, #e79a00); }
.mat-card.blue   .mc-go { background: linear-gradient(180deg, #63bff0, #2f9fd6); }
.mat-card.purple .mc-go { background: linear-gradient(180deg, #b384f0, var(--purple)); }
.mat-card:active .mc-go { transform: scale(.9); }

/* ---- Tarjetas de navegación inferiores ---- */
.nav-grid {
  display: grid; grid-template-columns: 1fr;
  gap: clamp(8px, 1.3vw, 13px);
  margin-top: 2px;
}
@media (min-width: 480px) { .nav-grid { grid-template-columns: repeat(2, 1fr); } }
.nav-card {
  appearance: none; cursor: pointer; font-family: inherit; text-align: left;
  display: flex; align-items: center; gap: 11px;
  background: #fff; border: none; border-radius: 18px;
  padding: 10px 13px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.nav-card:active { transform: translateY(2px); }
.nc-ico {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.nc-ico.pink   { background: var(--pink-soft); }
.nc-ico.blue   { background: var(--sky-soft); }
.nc-ico.violet { background: var(--lav-soft); }
.nc-ico.green  { background: var(--green-soft); }
.nc-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.18; }
.nc-txt b { font-size: 14px; font-weight: 900; color: #3b2b63; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-txt small { font-size: 11px; color: var(--ink-soft); }
.nc-caret { color: var(--lav); font-size: 20px; font-weight: 900; flex-shrink: 0; margin-left: auto; }

/* ---- Pie ---- */
.home-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  padding: 2px 4px 0;
  font-size: 11px; color: var(--ink-soft);
}
.home-footer b { color: var(--pink-deep); }
.home-footer span:nth-child(2) { color: var(--pink-deep); font-weight: 700; }
.hf-credits {
  flex: 1 1 100%;
  text-align: center;
  margin-top: 4px;
  color: var(--ink-soft);
}
.hf-credits a {
  color: var(--purple); font-weight: 800; text-decoration: none;
}
.hf-credits a:hover { text-decoration: underline; }

/* ---- Botones secundarios pequenos ---- */
.home-secondary {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.btn.mini { font-size: 12.5px; min-height: 42px; padding: 8px 10px; }

/* ---- Modal de medicion ---- */
.measure-modal {
  max-width: 420px; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.measure-modal h3 { color: var(--purple); font-size: 19px; }
.measure-modal p { color: var(--ink-soft); font-size: 14px; line-height: 1.5; margin: 0; }
.mm-emoji { font-size: 52px; line-height: 1; }
.mm-house { position: relative; border-radius: 18px; overflow: hidden; background: var(--lav-soft); }
.mm-house img { width: 100%; max-height: 150px; object-fit: cover; display: block; }
.mm-house .mm-title {
  font-weight: 900; color: var(--ink); font-size: 15px;
  padding: 8px 10px;
}
.mm-badge {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; font-weight: 900; letter-spacing: .5px;
  background: var(--red); color: #fff; padding: 3px 8px; border-radius: 999px;
}
.mm-silence { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mm-silence h3 { margin: 0; }
.mm-status {
  font-size: 13px; font-weight: 700; border-radius: 14px; padding: 10px 12px; line-height: 1.4;
}
.mm-status.ok   { background: var(--green-soft); color: #1f7a54; }
.mm-status.wait { background: var(--yellow-soft); color: #8a6400; }
.mm-status b { color: inherit; }
.mm-row { display: flex; gap: 10px; }
.mm-row .btn { flex: 1; }
.btn.measure-go {
  min-height: 54px; font-size: 17px;
  background: linear-gradient(180deg, var(--green), #2f9f6c);
}

.mm-count { padding: 4px 0; }
.mm-count-num {
  font-size: clamp(56px, 22vw, 96px); font-weight: 900; color: var(--purple); line-height: 1;
  animation: count-pop-soft .5s ease;
}
.mm-count-label { font-size: 13px; font-weight: 800; color: var(--ink-soft); letter-spacing: 1px; }
@keyframes count-pop-soft { from { transform: scale(1.25); opacity: .4; } to { transform: scale(1); opacity: 1; } }

.measure-modal .waves { height: 46px; }
.measure-modal .readout { padding: 14px; }
.measure-modal .readout .big { font-size: clamp(34px, 12vw, 56px); }

.mm-diff {
  border-radius: 16px; padding: 12px 14px; font-weight: 900; font-size: 17px;
  background: var(--lav-soft);
}
.mm-diff.diff-down { background: var(--green-soft); color: #1f7a54; }
.mm-diff.diff-up   { background: var(--red-soft); color: #b7331f; }
.mm-diff.base      { background: var(--lav-soft); color: var(--ink-soft); font-size: 14px; }
.mm-diff-sub { display: block; margin-top: 4px; font-weight: 700; font-size: 12px; color: var(--ink-soft); }

/* ---- Panel principal: tablet horizontal (fila de 4) ---- */
/* Vista previa de la imagen de cabecera en Configuración */
.hero-preview {
  width: 100%; aspect-ratio: 1600 / 400;
  border-radius: 14px; overflow: hidden;
  background: linear-gradient(160deg, var(--lav-soft), var(--pink-soft));
  border: 2px solid var(--line);
}
.hero-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (min-width: 820px) {
  .mat-grid { grid-template-columns: repeat(4, 1fr); }
  .nav-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 560px) and (max-width: 819px) {
  .nav-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 559px) {
  .hv-bg-chip { width: 36px; height: 36px; font-size: 16px; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .sh-count { align-self: stretch; justify-content: center; }
  .home-footer { justify-content: center; text-align: center; }
}

/* ============================================================
   RESULTADOS — material ganador (mejor aislante) resaltado
   ============================================================ */
.winner-strip {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #ffffff, var(--green-soft));
  border: 2px solid var(--green);
  border-radius: 18px;
  padding: 12px 16px;
  color: #1f7a54; font-weight: 700; font-size: 14px; line-height: 1.4;
  box-shadow: 0 8px 22px rgba(76,195,138,.22);
  animation: strip-pulse 2.2s ease-in-out infinite;
}
.winner-strip b { color: var(--purple); }
.winner-strip .ws-cup { font-size: 26px; flex-shrink: 0; animation: bounce 1.5s ease-in-out infinite; }
@keyframes strip-pulse {
  0%,100% { box-shadow: 0 8px 22px rgba(76,195,138,.22); }
  50%     { box-shadow: 0 10px 34px rgba(76,195,138,.42); }
}

.card.is-winner {
  position: relative;
  overflow: visible;
  margin-top: clamp(66px, 12vw, 94px);   /* deja sitio para el globo de arriba */
  border: 3px solid var(--green);
  animation: winner-glow 2s ease-in-out infinite;
}
@keyframes winner-glow {
  0%,100% { box-shadow: 0 0 0 4px rgba(76,195,138,.22), 0 14px 32px rgba(76,195,138,.3); }
  50%     { box-shadow: 0 0 0 10px rgba(76,195,138,.12), 0 18px 44px rgba(76,195,138,.45); }
}
.winner-trophy {
  position: absolute; top: -16px; right: 16px; font-size: 30px; z-index: 3;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.18));
  animation: bounce 1.4s ease infinite;
}

/* Globo tipo "modal" encima del material ganador */
.winner-callout {
  position: absolute; left: 50%; top: -12px;
  transform: translate(-50%, -100%);
  width: max-content; max-width: min(94%, 320px);
  background: linear-gradient(180deg, #ffffff, var(--green-soft));
  border: 3px solid var(--green);
  border-radius: 20px;
  padding: 11px 18px;
  text-align: center;
  box-shadow: 0 16px 38px rgba(76,195,138,.45);
  z-index: 6;
  animation: callout-pop .55s cubic-bezier(.2,1.5,.4,1) both,
             callout-pulse 2s ease-in-out .7s infinite;
}
.winner-callout::after {
  content: ""; position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%);
  border: 11px solid transparent; border-top-color: var(--green);
}
.winner-callout .wc-title { font-weight: 900; color: #1f7a54; font-size: 13px; letter-spacing: .6px; }
.winner-callout .wc-name  { font-weight: 900; color: var(--purple); font-size: 20px; margin: 2px 0 3px; }
.winner-callout .wc-sub   { font-size: 12px; color: var(--ink-soft); font-weight: 700; line-height: 1.35; }
.winner-callout .wc-star  { position: absolute; font-size: 15px; animation: star-twinkle 1.8s ease-in-out infinite; }
.winner-callout .wc-s1 { left: -10px; top: -10px; }
.winner-callout .wc-s2 { right: -8px; bottom: 2px; animation-delay: .5s; }
@keyframes callout-pop {
  from { opacity: 0; transform: translate(-50%, -100%) scale(.4); }
  to   { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}
@keyframes callout-pulse {
  0%,100% { box-shadow: 0 14px 32px rgba(76,195,138,.4); }
  50%     { box-shadow: 0 16px 46px rgba(76,195,138,.62); }
}

/* Fila ganadora en la tabla general */
.results-table tr.winner-row td { background: var(--green-soft); font-weight: 800; }
.results-table tr.winner-row .house-cell { color: #1f7a54; }
.wr-cup { margin-right: 4px; }

@media (prefers-reduced-motion: reduce) {
  .winner-strip, .card.is-winner, .winner-trophy, .winner-callout, .winner-callout .wc-star { animation: none !important; }
}
