@font-face {
  font-family: Fredoka;
  src: url("../fonts/fredoka-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Fredoka;
  src: url("../fonts/fredoka-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Caveat Brush";
  src: url("../fonts/caveat-brush.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #241c38;
  --cream: #fff8ee;
  --gold: #ffd56a;
  --gold-deep: #e09a2e;
  --sky: #7ec8ea;
  --rose: #ff7a8a;
  color: var(--ink);
  font-family: Fredoka, "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; background: #e7b15f; overscroll-behavior: none; }
h1.title-hilo {
  color: #e23a3a;
  font-family: "Caveat Brush", cursive;
  font-weight: 400;
  font-size: clamp(3.4rem, 9vw, 6.4rem);
  letter-spacing: 0;
  line-height: 0.85;
  text-shadow: 0 2px 0 rgba(140, 24, 24, 0.18);
  transform: rotate(-3deg);
  transform-origin: left center;
  margin: 4px 0 0 4px;
}
.old-trip { margin-top: 14px; color: #fff8ee; text-shadow: 0 1px 6px rgba(50, 24, 8, 0.55); }
.old-trip summary { cursor: pointer; font-weight: 600; }
button, input { font: inherit; }
button { cursor: pointer; }
canvas#view, canvas#view2d { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 0; }
canvas#view2d { display: none; }
body.flat canvas#view { visibility: hidden; }
body.flat canvas#view2d { display: block; }
#webgl-fail {
  display: none;
  position: fixed;
  z-index: 32;
  top: 8px;
  right: 8px;
  bottom: auto;
  left: auto;
  transform: none;
  width: auto;
  max-width: 168px;
  background: #241c38;
  color: #fff8ee;
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  gap: 6px;
  align-items: center;
}
#webgl-fail button {
  border: 0;
  background: transparent;
  color: #fff8ee;
  font-weight: 700;
  padding: 0 4px;
  cursor: pointer;
}
#webgl-fail.on { display: flex; }
#grade {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(20, 12, 8, 0.5) 100%);
}
#grade::after { content: none; }
@keyframes grain { 50% { transform: translate(2%, -1%); } }
body.q-baja #grade::after { display: none; }

.screen, .overlay {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 5;
  padding: max(16px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom));
}
.screen {
  background:
    url("../art/hilo/barranco/front_blur.webp") center/cover no-repeat,
    url("../art/hilo/barranco/mid_floor.webp") center/cover no-repeat,
    url("../art/hilo/barranco/far_sky.webp") center/cover no-repeat;
}
.screen.on, .overlay.on { display: grid; place-items: center; animation: rise 0.4s ease; }
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }
.overlay { z-index: 20; background: rgba(62, 32, 12, 0.22); }
.panel {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100% - 12px);
  overflow: auto;
  background: rgba(255, 246, 230, 0.78);
  transition: transform 0.15s ease;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(60, 30, 10, 0.16);
  padding: 22px 22px 18px;
  backdrop-filter: blur(10px);
}
#screen-title.on { place-items: start start; padding: max(22px, env(safe-area-inset-top)) 36px 20px; }
#screen-title .eyebrow { display: none; }
#screen-title .panel {
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  width: min(460px, 92vw);
  padding: 0;
  overflow: visible;
}
#screen-title .sub {
  color: #fff8ee;
  text-shadow: 0 1px 8px rgba(50, 24, 8, 0.5);
  max-width: 28rem;
  margin-left: 10px;
}
#screen-title .row { flex-direction: column; align-items: flex-start; gap: 0; margin-top: 10px; }
#screen-title .btn {
  background: transparent;
  color: #fff8ee;
  text-shadow: 0 2px 8px rgba(50, 24, 8, 0.55);
  padding: 5px 2px;
  font-weight: 500;
}
#screen-title .btn.big { font-size: 1.35rem; font-weight: 700; }
h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); line-height: 0.95; margin: 0; letter-spacing: -0.03em; }
h2 { margin: 0 0 8px; font-size: clamp(1.6rem, 4vw, 2.2rem); }
.eyebrow { letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.82rem; margin: 0 0 6px; color: #6a5678; }
.sub { margin: 8px 0 0; font-size: 1.15rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn {
  border: 0;
  background: rgba(255, 248, 238, 0.86);
  color: #5c3414;
  border-radius: 999px;
  padding: 12px 18px;
  box-shadow: none;
  font-weight: 600;
}
.btn { transition: transform 0.12s ease, box-shadow 0.12s ease; }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn.alt { background: rgba(255, 248, 238, 0.62); }
.btn.ghost { background: transparent; color: #5c3414; }
.btn.big { font-size: 1.25rem; padding: 14px 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; }
.maker { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 12px 0; }
.maker label, .check { display: grid; gap: 4px; font-size: 0.92rem; }
.maker input, .maker select { padding: 8px 10px; border-radius: 10px; border: 3px solid #241c38; background: #fff; }
.check { grid-template-columns: auto 1fr; align-items: center; }
#create-error { color: #9a2a2a; font-weight: 700; min-height: 1.2em; }
.panel.finale { box-shadow: 0 0 0 6px #74acdf, 0 0 0 12px #fff, 0 0 0 18px #74acdf; }
.card, .kid {
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #fff;
  padding: 12px;
  text-align: left;
}
.card { overflow: hidden; }
.faces { display: flex; justify-content: center; align-items: flex-end; height: 112px; width: 100%; }
.faces canvas { flex: 1 1 0; width: 0; min-width: 0; height: 112px; border-radius: 12px; }
.painted-screen { background: none; }
.cast-note { margin: 0 0 8px; color: #5c4530; }
@media (max-height: 540px) {
  #screen-teams .panel.cast {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: min(1100px, 100%);
  }
  #screen-teams .cast-note { display: none; }
  #screen-teams h2 { font-size: 1.35rem; }
  #screen-teams .cast-grid {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }
  #screen-teams .row { margin-top: 8px; }
}
#cast-error, #gate-note { color: #9a2a2a; font-weight: 700; min-height: 0; margin: 6px 0 0; }
.cast-name { display: grid; gap: 4px; margin-top: 8px; font-weight: 700; }
.cast-name select { padding: 10px 12px; border-radius: 12px; border: 3px solid #241c38; background: #fff; font: inherit; }
.presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.presets button {
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 248, 238, 0.8);
  padding: 6px 12px;
  font-weight: 700;
}
.presets button.on { background: linear-gradient(#ffe58a, var(--gold)); }
.cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.cast-card {
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: linear-gradient(#fff8ee, #f6d7a8);
  padding: 4px 4px 8px;
  text-align: center;
}
.cast-card.on { background: linear-gradient(#fff1b0, #f0c14a); box-shadow: 0 0 0 3px #e09a2e; }
.cast-card .sprite {
  height: 86px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.cast-card img, .cast-card canvas { width: auto; max-width: 100%; object-fit: contain; }
.cast-card b { font-size: 0.92rem; }
.cast-card span { display: block; color: #6a5678; font-size: 0.75rem; }
.cast-tray {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  min-height: 36px;
}
.cast-slot {
  flex: 1;
  border: 2px dashed #8a6a48;
  border-radius: 14px;
  background: rgba(255, 248, 238, 0.72);
  padding: 6px 8px;
  text-align: center;
}
.cast-slot b { display: block; }
.cast-slot span { color: #6a5678; font-size: 0.78rem; }
.rank {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) minmax(140px, 1.3fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(36, 28, 56, 0.12);
}
.rank-coins, .rank-points {
  justify-self: end;
  background: #fff6d8;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}
.rank-points { background: #ffe08a; }
.panel > :not(canvas.fw) { position: relative; z-index: 1; }
canvas.fw { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.card b, .kid b { display: block; font-size: 1.15rem; }
.card span, .kid span { color: #5c5068; font-size: 0.92rem; }
.card small, .kid small { display: block; margin-top: 4px; }
.kid.mine { outline: 4px solid #3aa0ff; }
.kid.taken { opacity: 0.55; }
code.room {
  display: block;
  font-size: clamp(2rem, 8vw, 3.4rem);
  letter-spacing: 0.18em;
  background: #241c38;
  color: #fff8ee;
  border-radius: 16px;
  padding: 10px 12px;
  margin: 8px 0;
}
#hud {
  position: fixed;
  z-index: 8;
  top: max(8px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: none;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 1px 4px rgba(40, 20, 0, 0.45);
}
#hud.on { display: flex; }
#hud-label { font-size: clamp(0.85rem, 2.2vw, 1.05rem); font-weight: 600; }
.hud-spacer { flex: 1; }
.hud-coin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff1b0, #e0a84a 55%, #b47820);
  color: #8a5a12;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
#hud-coins { font-size: 1rem; }
#hud button {
  pointer-events: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.28);
  color: #fff;
  text-shadow: none;
  box-shadow: none;
}
#pads-hilo { display: none; position: fixed; inset: auto 0 0 0; z-index: 30; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 8px; align-items: end; justify-content: space-between; pointer-events: none; }
#pads-hilo.on { display: flex; }
.hilo-pad { display: none; gap: 8px; pointer-events: auto; }
.hilo-pad.on { display: flex; }
.hilo-pad button {
  width: 68px; height: 68px; min-width: 68px; min-height: 68px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, 0.28); color: #fff; font-size: 1.5rem; font-weight: 500;
  text-shadow: 0 1px 4px rgba(40, 20, 0, 0.35);
  backdrop-filter: blur(6px); touch-action: manipulation;
}
#pads-hilo .hilo-act { background: rgba(226, 58, 58, 0.55); font-size: 0.95rem; }
#hilo-hint { margin: 0; color: #fff8ee; text-shadow: 0 1px 6px rgba(40,20,0,.45); font-weight: 500; pointer-events: none; text-align: center; flex: 1; }
#screen-hilo-done.on { background: transparent; align-items: start center; pointer-events: none; }
#screen-hilo-done.on .panel { pointer-events: auto; margin-top: 8px; width: min(280px, 70vw); padding: 8px 12px; }
body.hilo-play canvas#view { visibility: hidden; }
body.hilo-play canvas#view2d { display: block; }
body.hilo-play .hud-coin, body.hilo-play #hud-coins { display: none; }
body.hilo-play #hud-label {
  font-family: "Caveat Brush", cursive;
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  color: #e23a3a;
  text-shadow: 0 2px 0 rgba(140, 24, 24, 0.16);
  transform: rotate(-3deg);
  margin-left: 8px;
}
.pads { position: fixed; inset: auto 0 0 0; z-index: 9; display: none; justify-content: space-between; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); pointer-events: none; }
.pads.on { display: flex; z-index: 30; }
@media (orientation: landscape) {
  #rotate { display: none; }
  .pads.on { display: flex; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .screen.on, .overlay.on { place-items: start center; padding: 6px; }
  .panel { max-height: calc(100vh - 8px); padding: 8px 10px; }
  .row { margin-top: 6px; }
  #screen-intro h2, #screen-done h2, #screen-map h2 { font-size: 1.2rem; margin: 0; }
  #screen-intro .sub, #intro-extra, #screen-map .eyebrow, #screen-intro .eyebrow { display: none; }
  #intro-flag, #done-flag { width: 148px; height: 72px; }
  .worlds { flex-wrap: nowrap; overflow-x: auto; margin: 4px 0; }
  #screen-map.on { align-items: stretch; }
  #screen-map .panel {
    display: flex;
    flex-direction: column;
    width: min(100%, 1100px);
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
    overflow: hidden;
  }
  #screen-map #map-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1 1 auto;
    min-height: 0;
    margin: 4px 0;
  }
  #screen-map .flag-card {
    flex: 0 0 112px;
    padding: 6px;
    min-height: 0;
  }
  #screen-map .flag-card canvas { height: 28px; }
  #screen-map .flag-card b, #screen-map .flag-card small { font-size: 0.68rem; line-height: 1.15; }
  #screen-map .row { flex: 0 0 auto; margin-top: 4px; }
  #screen-map #map-list > p { flex: 0 0 160px; align-self: center; margin: 0; font-size: 0.75rem; }
  .dancers { height: 42px; }
}
.dancers { display: none; }
.dancers span {
  width: 26px;
  height: 42px;
  border-radius: 12px 12px 6px 6px;
  background: #3d5afe;
  transform-origin: 50% 100%;
  animation: dance 0.42s ease-in-out infinite alternate;
}
.dancers span:nth-child(2) { background: #e23b4a; animation-delay: 0.12s; }
.dancers span:nth-child(3) { background: #ffd56a; animation-delay: 0.24s; }
@keyframes dance {
  from { transform: translateY(0) rotate(-10deg); }
  to { transform: translateY(-10px) rotate(10deg); }
}
#lobby-error { color: #9a2a2a; font-weight: 700; min-height: 0; }
#net-warn {
  display: none;
  position: fixed;
  z-index: 36;
  top: auto;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 220px));
  background: #241c38;
  color: #fff8ee;
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
#net-warn.on { display: block; }
#bell-note {
  display: none;
  position: fixed;
  z-index: 35;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffe58a;
  color: #241c38;
  border: 3px solid #241c38;
  border-radius: 14px;
  padding: 6px 12px;
  font-weight: 700;
  pointer-events: none;
}
#bell-note.on { display: block; }
.coach {
  display: none;
  position: fixed;
  z-index: 34;
  right: 12px;
  bottom: 118px;
  width: 168px;
  pointer-events: none;
  text-align: center;
}
.coach.on { display: block; }
.coach.for-others { left: 50%; right: auto; bottom: 18px; transform: translateX(-50%); width: 240px; }
.coach.for-others .coach-arrow { display: none; }
.coach p {
  margin: 2px 0 0;
  background: #ffe58a;
  color: #241c38;
  border: 3px solid #241c38;
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}
.coach-arrow {
  font-size: 1.6rem;
  line-height: 1;
  animation: coach-bob 0.55s ease-in-out infinite alternate;
}
.ghost-track { position: relative; height: 42px; margin-bottom: 2px; }
.ghost-kid {
  position: absolute;
  left: 6px;
  bottom: 0;
  width: 16px;
  height: 24px;
  border-radius: 8px 8px 4px 4px;
  background: rgba(255, 236, 150, 0.9);
  animation: ghost-float 2.4s linear infinite;
}
.ghost-bell {
  position: absolute;
  right: 10px;
  bottom: 2px;
  width: 14px;
  height: 16px;
  border-radius: 0 0 8px 8px;
  background: #ffe14a;
  box-shadow: 0 0 12px #ffe14a;
  animation: bell-glow 0.8s ease-in-out infinite;
}
@keyframes ghost-float {
  0% { left: 8px; bottom: 0; }
  45% { left: 46%; bottom: 18px; }
  75% { left: 72%; bottom: 0; }
  100% { left: 72%; bottom: 0; }
}
@keyframes bell-glow {
  from { transform: scale(1); }
  to { transform: scale(1.18); }
}
@keyframes coach-bob {
  from { transform: translateY(0); }
  to { transform: translateY(6px); }
}
#screen-done .fw { z-index: 0; }
.overlay.finale-scene { background: transparent; pointer-events: none; }
.overlay.finale-scene .panel {
  pointer-events: auto;
  width: min(440px, 100%);
  background: rgba(8, 12, 28, 0.78);
  color: #fff8ee;
  border-color: #f4efe4;
}
.overlay.finale-scene .eyebrow,
.overlay.finale-scene #done-stars { color: #d5e6f7; }
.overlay.finale-scene .dancers,
.overlay.finale-scene canvas.fw,
.overlay.finale-scene #done-extra { display: none; }
.trophy { margin: 4px 0 8px; }
.trophy p { margin: 4px 0 0; font-weight: 700; }
.cup {
  width: 46px;
  height: 28px;
  margin: 0 auto;
  background: linear-gradient(#fff1b0, #e0a84a);
  border-radius: 4px 4px 16px 16px;
  position: relative;
}
.cup::before, .cup::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 12px;
  height: 16px;
  border: 3px solid #e0a84a;
  border-radius: 0 10px 10px 0;
}
.cup::before { left: -12px; border-left: 0; }
.cup::after { right: -12px; border-right: 0; border-radius: 10px 0 0 10px; }
@media (orientation: landscape) and (max-height: 540px) {
  .overlay.finale-scene.on { place-items: end center; padding-bottom: 8px; }
  .overlay.finale-scene .panel { max-height: 34vh; width: min(360px, 92%); padding: 8px 12px; }
}
.pads button {
  pointer-events: auto;
  touch-action: none;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.28);
  color: #fff;
  font-size: 1.5rem;
  box-shadow: none;
  backdrop-filter: blur(4px);
}
.pads .act { width: 78px; height: 78px; background: rgba(255,255,255,0.32); font-size: 0.78rem; line-height: 1.05; padding: 6px; }
#rotate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: #e7b15f url("../art/hilo/barranco/far_sky.webp") center/cover no-repeat;
  color: #fff8ee;
  text-align: center;
  padding: 24px;
}
#rotate strong { font-size: 2rem; display: block; margin-bottom: 8px; }
@media (orientation: portrait) and (max-width: 900px) {
  #rotate { display: grid; }
}
.worlds { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.worlds button { flex: 0 0 auto; white-space: nowrap; }
.pads button { width: 68px; height: 68px; }
.pads .act { width: 72px; height: 72px; }
@media (max-height: 520px) {
  .pads { padding-bottom: 6px; }
  .pads button { width: 60px; height: 60px; font-size: 1.3rem; }
  .pads .act { width: 64px; height: 64px; }
}
.flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.flag-card canvas { width: 100%; height: 42px; border-radius: 6px; }
.flag-card { font-size: 0.86rem; }
.feed { margin: 0; padding-left: 18px; }
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #241c38;
  color: #fff8ee;
  padding: 10px 14px;
  border-radius: 999px;
  display: none;
  z-index: 40;
}
#intro-flag, #done-flag { width: min(280px, 70vw); height: 150px; border-radius: 12px; }
.letter { box-shadow: none; }

/* Entrada al juego. Primero el hilo rojo que se dibuja mientras habla el narrador; después el cartel del nivel. */
#hilo-card {
  position: fixed; inset: 0; z-index: 60; display: none; place-items: center; text-align: center; cursor: pointer;
  background: #fffdf7; color: #1d1a16; opacity: 1; transition: opacity 1.4s ease, background-color .8s ease;
}
#hilo-card.on { display: grid; }
#hilo-card.out { opacity: 0; pointer-events: none; }
#hilo-card > div { position: relative; }
#hilo-card p { margin: 0; }
#hilo-card-kicker { font-weight: 700; letter-spacing: .28em; text-transform: uppercase; font-size: clamp(14px, 2.2vw, 26px); min-height: 1.2em; }
#hilo-card-title { margin: .12em 0 .2em; font-family: "Caveat Brush", cursive; font-weight: 400; font-size: clamp(44px, 9vw, 120px); line-height: 1; color: #1d1a16; }
#hilo-card-sub { font-weight: 500; font-size: clamp(16px, 2.6vw, 30px); max-width: 26em; padding: 0 1em; opacity: .8; }
#hilo-card .hilo-card-skip { position: fixed; left: 0; right: 0; bottom: 5vh; font-size: clamp(11px, 1.4vw, 15px); opacity: .45; }
/* etapa 1: solo el hilo */
#hilo-card-thread { position: absolute; inset: 0; width: 100%; height: 100%; display: none; overflow: visible; }
#hilo-card.intro { background: #fff3d6; }
#hilo-card.intro #hilo-card-thread { display: block; }
#hilo-card.intro #hilo-card-kicker, #hilo-card.intro #hilo-card-title, #hilo-card.intro #hilo-card-sub { display: none; }
#hilo-card-thread path { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1000; stroke-dashoffset: 1000; }
#hilo-card-thread .glow { stroke: rgba(255, 90, 90, .32); stroke-width: 16; filter: blur(5px); }
#hilo-card-thread .body { stroke: #E0303A; stroke-width: 5; }
#hilo-card.intro #hilo-card-thread path { animation: hilo-dibuja 19s cubic-bezier(.45, .05, .35, 1) .4s forwards; }
#hilo-card.intro #hilo-card-thread g { animation: hilo-flota 6s ease-in-out infinite alternate; transform-origin: 50% 45%; }
@keyframes hilo-dibuja { to { stroke-dashoffset: 0; } }
@keyframes hilo-flota { from { transform: translateY(-1.2%) rotate(-.5deg); } to { transform: translateY(1.4%) rotate(.5deg); } }
@media (prefers-reduced-motion: reduce) {
  #hilo-card { transition: none; }
  #hilo-card.intro #hilo-card-thread path { animation: none; stroke-dashoffset: 0; }
  #hilo-card.intro #hilo-card-thread g { animation: none; }
}

/* Portada: tapa el menú hasta el primer toque. Con ese toque arranca la música del menú. */
#hilo-portada {
  all: unset; position: fixed; inset: 0; z-index: 70; display: grid; place-items: end center; cursor: pointer;
  background: linear-gradient(to top, rgba(58, 40, 20, .55), rgba(58, 40, 20, 0) 45%);
  -webkit-tap-highlight-color: transparent; transition: opacity .6s ease;
}
#hilo-portada span {
  margin-bottom: 12vh; padding: .5em 1.3em; border-radius: 999px; background: rgba(255, 243, 214, .92); color: #3a2814;
  font: 700 clamp(18px, 3vw, 30px) Fredoka, "Trebuchet MS", sans-serif; letter-spacing: .04em;
  animation: portada-late 1.8s ease-in-out infinite alternate;
}
#hilo-portada.fuera { opacity: 0; pointer-events: none; }
@keyframes portada-late { from { transform: scale(1); } to { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { #hilo-portada span { animation: none; } }
