:root {
  --papel: #f1f0ed;
  --tinta: #0b0b0b;
  --noche: #0a0a0a;
  --hueso: #e9e7e2;
  --gris: #85827b;
  --gris-claro: #b9b6af;
  --linea: #2b2a27;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --sans: 'Inter Tight', system-ui, sans-serif;
  --salida: cubic-bezier(.16, 1, .3, 1);
  --lado: clamp(16px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--noche);
  color: var(--hueso);
  font: 400 15px/1.65 var(--mono);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
::selection { background: var(--hueso); color: var(--noche); }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* ── Entrada ───────────────────────────────────────── */

.entrada { display: none; }
html.js .entrada {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(70% 60% at 50% 45%, #fafaf8 0%, var(--papel) 60%, #e4e3df 100%);
  color: var(--tinta);
}
html.js.saltar .entrada, html.ya-entro .entrada { display: none; }
html.js:not(.ya-entro) body { overflow: hidden; }
.entrada.con-mano, .entrada.con-mano * { cursor: none; }

#hilos { position: absolute; inset: 0; width: 100%; height: 100%; }

.pildora {
  position: relative;
  z-index: 2;
  padding: 26px 58px;
  border: 0;
  border-radius: 999px;
  font: 600 30px/1 var(--sans);
  letter-spacing: -0.02em;
  color: #f5f5f3;
  background:
    radial-gradient(120% 95% at 50% 0%, #4d4d4d 0%, #1b1b1b 40%, #050505 72%),
    #050505;
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, .38),
    inset 0 12px 20px rgba(255, 255, 255, .10),
    inset 0 -7px 12px rgba(255, 255, 255, .07),
    0 22px 34px -14px rgba(0, 0, 0, .5),
    0 5px 10px rgba(0, 0, 0, .22);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .7), 0 0 14px rgba(255, 255, 255, .18);
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.pildora span { position: relative; z-index: 1; }
/* reflejo de arriba, como plástico mojado */
.pildora::before {
  content: '';
  position: absolute;
  inset: 4px 18px auto;
  height: 44%;
  border-radius: 999px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  filter: blur(.6px);
}
/* destello que cruza al pasar el cursor */
.pildora::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .2) 47%, transparent 56%) 130% 0 / 260% 100% no-repeat;
  transition: background-position 1s var(--salida);
}
.pildora:hover::after, .pildora:focus-visible::after { background-position: -30% 0; }
.pildora:focus-visible { outline: 2px solid var(--tinta); outline-offset: 6px; }

.entrada-pie {
  position: absolute;
  left: var(--lado);
  right: var(--lado);
  bottom: 18px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  font: 400 13px/1.4 var(--mono);
  color: #77746d;
}
.entrada-pie a { text-decoration: none; }
.entrada-pie a:hover { color: var(--tinta); }

.mano {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  display: none;
  pointer-events: none;
  transform-origin: 20px 3px;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .18));
  will-change: transform;
}
.con-mano .mano { display: block; }
.mano.fuera, .pildora.se-va, .mano.se-va { opacity: 0; transition: opacity .25s; }

.telon {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--noche);
  pointer-events: none;
}
.telon[hidden] { display: none; }

/* ── Home ──────────────────────────────────────────── */

html.js .home { visibility: hidden; }
html.ya-entro .home { visibility: visible; }

.barra {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px var(--lado);
  border-bottom: 1px dashed var(--linea);
  background: rgba(10, 10, 10, .86);
  backdrop-filter: blur(8px);
}
.marca { font-weight: 600; text-decoration: none; white-space: nowrap; }
.tenue { color: var(--gris); font-weight: 400; }
.barra nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; }
.barra nav a { text-decoration: none; padding: 1px 4px; }
.barra nav a::before { content: '['; color: var(--gris); margin-right: 3px; }
.barra nav a::after { content: ']'; color: var(--gris); margin-left: 3px; }
.barra nav a:hover { background: var(--hueso); color: var(--noche); }
.barra nav a:hover::before, .barra nav a:hover::after { color: var(--noche); }

/* portada: la gota manda; el nombre, chico y al centro */
.portada {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100svh - 60px);
  padding: 24px var(--lado) 32px;
  text-align: center;
}
.gota {
  width: min(620px, 100%);
  height: clamp(240px, 52svh, 520px);
  margin: 0 0 8px;
  overflow: hidden;
  font: 400 clamp(7px, 0.95vw, 12px)/1 var(--mono);
  color: #d9d6cf;
  user-select: none;
}
.portada h1 {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.bajada { max-width: 36ch; margin: 12px 0 0; font-size: 14px; color: var(--gris); }

.seccion { padding: 56px var(--lado) 24px; scroll-margin-top: 40px; }
.seccion h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 28px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gris);
}
.seccion h2::before { content: '──'; }
.seccion h2::after { content: ''; flex: 1; border-bottom: 1px dashed var(--linea); }

/* proyectos: burbujas sueltas con aire alrededor para que el imán se luzca */
.burbujas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 40vw), 1fr));
  gap: 24px clamp(16px, 4vw, 64px);
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: 72px;
}
.burbuja {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}
.burbuja:nth-child(even) { transform: translateY(72px); }
.burbuja canvas { display: block; width: 100%; max-width: 300px; aspect-ratio: 1; }
.burbuja figcaption { margin-top: -18px; font-size: 14px; font-weight: 500; text-align: center; }

/* gotitas que persiguen al cursor: encima de todo, sin estorbar los clics */
.gotitas { position: fixed; inset: 0; z-index: 6; width: 100%; height: 100%; pointer-events: none; }

/* minijuego */
.cancha { position: relative; max-width: 800px; margin: 0 auto; }
.cancha canvas {
  display: block;
  width: 100%;
  aspect-ratio: 400 / 250;
  image-rendering: pixelated;
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* marcador como el de la cancha central: verde oscuro, números claros, puntos en dorado */
.tablero {
  --verde-t: #0c3a2c;
  --verde-c: #0a2e23;
  --filo: #1f5a45;
  --oro: #e6c46a;
  max-width: 560px;
  margin: 16px auto 0;
  padding: 10px 12px 12px;
  border: 2px solid #072319;
  background: var(--verde-t);
  box-shadow: inset 0 0 0 1px var(--filo), 0 10px 24px -12px #000;
  color: #f3eedd;
  font-variant-numeric: tabular-nums;
}
.t-cabeza {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 2px 6px 8px;
  border-bottom: 1px solid var(--filo);
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 600;
}
.t-cabeza span:last-child { text-align: right; }
.t-marca { font-size: 13px; font-weight: 600; color: var(--oro); }
.t-marca::before, .t-marca::after { content: '◆'; margin: 0 8px; font-size: 9px; vertical-align: 2px; }
.t-titulos, .t-fila {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px 44px 52px;
  gap: 4px;
  align-items: center;
}
.t-titulos { padding: 8px 0 4px; font-size: 10px; color: #9fbfb2; text-align: center; }
.t-fila { margin-top: 4px; }
.t-num, .t-nombre { background: var(--verde-c); box-shadow: inset 0 0 0 1px var(--filo); }
.t-num { display: flex; align-items: center; justify-content: center; gap: 2px; height: 46px; font-size: 22px; font-weight: 600; }
.t-pts { color: var(--oro); }
.t-nombre { display: flex; flex-direction: column; justify-content: center; height: 46px; padding: 0 12px; font-size: 15px; }
.t-nombre b { font-weight: 700; }
.t-sub { font-size: 10px; color: #9fbfb2; }
.t-sub i { font-style: normal; color: var(--oro); }
.saca { color: #ffe14d; font-size: 14px; }

.remate {
  display: block;
  margin: 12px auto 0;
  padding: 10px 18px;
  border: 1px solid #ff7a2a;
  background: transparent;
  color: #ff7a2a;
  font: 600 14px var(--mono);
  cursor: pointer;
  animation: late 0.9s ease-in-out infinite;
}
.remate.armado { background: #ff7a2a; color: var(--noche); animation: none; }
.remate[hidden] { display: none; }
@keyframes late { 50% { box-shadow: 0 0 0 4px rgba(255, 122, 42, .25); } }
.ayuda { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--gris); }
.sonido { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

@media (max-width: 520px) {
  .t-titulos, .t-fila { grid-template-columns: 34px minmax(0, 1fr) 30px 34px 42px; }
  .t-num { height: 40px; font-size: 18px; }
  .t-nombre { height: 40px; padding: 0 8px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .remate { animation: none; } }
.aviso {
  position: absolute;
  left: 0;
  right: 0;
  top: 34%;
  margin: 0;
  text-align: center;
  font-size: 14px;
  pointer-events: none;
  text-shadow: 0 1px 0 #000, 0 0 8px #000;
}

/* revancha */
.revancha {
  width: min(92vw, 360px);
  padding: 28px 24px 22px;
  border: 1px solid var(--linea);
  background: var(--noche);
  color: var(--hueso);
  font: inherit;
}
.revancha::backdrop { background: rgba(0, 0, 0, .6); }
.revancha form { display: flex; flex-direction: column; gap: 12px; }
.revancha-titulo { margin: 0 0 4px; font-weight: 600; }
.revancha input, .revancha button[type="submit"] {
  padding: 12px;
  border: 1px solid var(--linea);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}
.revancha button[type="submit"] { background: var(--hueso); color: var(--noche); font-weight: 600; cursor: pointer; }
.revancha button[disabled] { opacity: .5; cursor: default; }
.revancha .trampa { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.chico { margin: 0; font-size: 12px; color: var(--gris); }
.chico a { color: inherit; }
.cerrar {
  position: absolute;
  top: 6px;
  right: 8px;
  border: 0;
  background: none;
  color: var(--gris);
  font: 400 22px/1 var(--mono);
  cursor: pointer;
}

.pie {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 64px;
  padding: 22px var(--lado);
  border-top: 1px dashed var(--linea);
  font-size: 13px;
  color: var(--gris);
}
.pie a { text-decoration: none; }
.pie a:hover { color: var(--hueso); }

/* ── Celular ───────────────────────────────────────── */

@media (max-width: 520px) {
  .pildora { padding: 20px 40px; font-size: 24px; }
  .entrada-pie span { display: none; }
  .entrada-pie { justify-content: center; }
  .marca .tenue { display: none; }
  .burbujas { gap: 8px 12px; }
  .burbuja:nth-child(even) { transform: translateY(48px); }
  .burbuja figcaption { font-size: 13px; margin-top: -12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
