/* Gatos en la Alfombra — interfaz 32 bits */
@font-face {
  font-family: "Pixelify Sans";
  src: url("./fonts/pixelify-sans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("./fonts/silkscreen-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("./fonts/silkscreen-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #291a13;
  --ink-soft: #5d3d2a;
  --cream: #f8e8c5;
  --cream-deep: #e8cfa1;
  --gold: #e4a75b;
  --gold-deep: #b96c3f;
  --rose: #e86f8d;
  --rose-light: #ffb9c7;
  --teal: #1d4a48;
  --teal-deep: #102c2c;
  --shadow: rgba(8, 4, 2, 0.55);
  font-family: "Pixelify Sans", "Trebuchet MS", sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cream);
  background:
    radial-gradient(ellipse 75% 70% at 50% 42%, rgba(141, 79, 42, 0.26), transparent 70%),
    radial-gradient(ellipse at 50% 110%, #2a1710, transparent 58%),
    #100b09;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    repeating-linear-gradient(91deg, rgba(255, 219, 165, 0.035) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(0, 0, 0, 0.16) 27px 29px);
  z-index: 0;
}

.room-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(100vw, 177.78dvh);
  height: min(100dvh, 56.25vw);
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow:
    0 0 8vw rgba(0, 0, 0, 0.52),
    0 2.4vw 8vw rgba(0, 0, 0, 0.4);
  z-index: 0;
}

.stage {
  position: relative;
  width: min(100vw, 177.7778dvh);
  aspect-ratio: 16 / 9;
  max-height: 100dvh;
  container-type: size;
  overflow: hidden;
  isolation: isolate;
  background: #1c100a;
  box-shadow:
    0 0 0 1px rgba(250, 223, 173, 0.14),
    0 1.4vh 5vh rgba(0, 0, 0, 0.6);
  z-index: 1;
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: none;
  touch-action: none;
}

.screen-fx {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(24, 9, 4, 0.065) 0,
      rgba(24, 9, 4, 0.065) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse 77% 76% at 50% 46%, transparent 55%, rgba(14, 6, 3, 0.33) 100%);
  mix-blend-mode: multiply;
  opacity: 0.85;
}

/* ---------- Marcador superior izquierdo ---------- */
.hud {
  position: absolute;
  top: 3.1cqw;
  left: 2.9cqw;
  z-index: 12;
  pointer-events: none;
}

.score-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 1.1cqw;
  align-items: center;
  min-width: 20.2cqw;
  padding: 1cqw 1.4cqw 0.75cqw 1cqw;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 252, 232, 0.52), transparent 37%),
    linear-gradient(180deg, #f7e7c4 0%, #efd7a9 60%, #e2c18e 100%);
  border: 0.28cqw solid var(--ink);
  border-radius: 0.35cqw;
  box-shadow:
    0.4cqw 0.4cqw 0 0 #090503,
    0.4cqw 0.4cqw 0 0.22cqw rgba(236, 190, 117, 0.25),
    0 1.1cqw 2.2cqw rgba(20, 8, 3, 0.26);
  transform-origin: 20% 30%;
}

.score-card::before {
  content: "";
  position: absolute;
  inset: 0.33cqw;
  border: 0.12cqw solid rgba(112, 66, 36, 0.3);
  border-radius: 0.19cqw;
  pointer-events: none;
}

.score-card::after {
  content: "";
  position: absolute;
  left: 0.9cqw;
  right: 0.9cqw;
  bottom: 0.5cqw;
  height: 0.14cqw;
  background: rgba(131, 82, 43, 0.25);
}

.paw-badge {
  width: 4.2cqw;
  height: 4.2cqw;
  display: grid;
  place-items: center;
  align-self: start;
  margin-top: 0.18cqw;
  color: var(--cream);
  background: var(--teal);
  border: 0.22cqw solid var(--ink);
  border-radius: 0.18cqw;
  box-shadow: inset 0 -0.48cqw 0 rgba(0, 0, 0, 0.16), 0.22cqw 0.22cqw 0 rgba(255, 255, 255, 0.22);
}

.paw-badge svg {
  width: 3.1cqw;
  height: 3.1cqw;
  filter: drop-shadow(0.1cqw 0.12cqw 0 rgba(0, 0, 0, 0.18));
}

.score-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.score-label {
  font-family: "Silkscreen", monospace;
  font-weight: 700;
  font-size: 1.02cqw;
  letter-spacing: 0.095em;
  text-transform: uppercase;
  color: #74452e;
  white-space: nowrap;
}

.score-line {
  display: flex;
  align-items: flex-start;
  gap: 0.5cqw;
  height: 3.7cqw;
}

.score-value {
  font-family: "Silkscreen", monospace;
  font-weight: 700;
  font-size: 3.55cqw;
  line-height: 1.04;
  letter-spacing: -0.045em;
  color: #2c1a12;
  text-shadow: 0 0.22cqw 0 #b4804a, 0.1cqw 0.1cqw 0 rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.score-value.bump {
  animation: score-bump 320ms cubic-bezier(0.2, 1.8, 0.4, 1);
}

.score-pop {
  align-self: flex-start;
  margin-top: 0.5cqw;
  font-family: "Silkscreen", monospace;
  font-size: 1.08cqw;
  font-weight: 700;
  color: #c24b64;
  opacity: 0;
  transform: translateY(0.2cqw);
}

.score-pop.show {
  animation: score-pop 750ms ease-out;
}

.score-record {
  font-family: "Pixelify Sans", sans-serif;
  font-size: 1.06cqw;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #855a3a;
  margin-top: 0.1cqw;
}

.score-record b {
  font-family: "Silkscreen", monospace;
  font-weight: 700;
  font-size: 0.87cqw;
  color: #5c3b25;
}

.rug-chip {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.55cqw;
  margin-top: 0.45cqw;
  padding: 0.42cqw 0.1cqw 0;
  border-top: 0.12cqw dashed rgba(105, 64, 35, 0.4);
  font-family: "Pixelify Sans", sans-serif;
  font-size: 0.98cqw;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.025em;
  color: #68452e;
}

.rug-chip b {
  margin-left: auto;
  min-width: 1.35cqw;
  font-family: "Silkscreen", monospace;
  font-size: 0.98cqw;
  text-align: right;
  color: #2b1b12;
}

.rug-chip-dot {
  width: 0.52cqw;
  height: 0.52cqw;
  background: #65a66e;
  box-shadow: 0 0 0 0.16cqw rgba(101, 166, 110, 0.18);
}

/* ---------- Controles superiores ---------- */
.top-controls {
  position: absolute;
  top: 3.1cqw;
  right: 2.8cqw;
  z-index: 14;
  display: flex;
  align-items: stretch;
  gap: 0.66cqw;
}

.pixel-btn,
.icon-btn {
  appearance: none;
  border: 0.22cqw solid rgba(248, 232, 197, 0.72);
  color: var(--cream);
  background: linear-gradient(180deg, rgba(44, 85, 81, 0.94), rgba(17, 46, 46, 0.96));
  font-family: "Silkscreen", monospace;
  font-weight: 700;
  font-size: 0.96cqw;
  letter-spacing: 0.07em;
  border-radius: 0.22cqw;
  box-shadow:
    0.28cqw 0.28cqw 0 #0b0705,
    0 0.75cqw 1.7cqw rgba(0, 0, 0, 0.24),
    inset 0 0.13cqw 0 rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.pixel-btn:hover,
.icon-btn:hover {
  background: linear-gradient(180deg, #376b65, #1a4846);
  transform: translateY(-0.13cqw);
}

.pixel-btn:active,
.icon-btn:active {
  transform: translate(0.15cqw, 0.15cqw);
  box-shadow: 0.12cqw 0.12cqw 0 #0b0705;
}

.pixel-btn:focus-visible,
.icon-btn:focus-visible,
.dialog-x:focus-visible {
  outline: 0.22cqw solid var(--gold);
  outline-offset: 0.22cqw;
}

.pixel-btn[hidden],
.icon-btn[hidden] {
  display: none !important;
}

.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55cqw;
  padding: 0.58cqw 0.78cqw;
  color: #2b1d14;
  background: linear-gradient(180deg, #f2d495, #dca863);
  border-color: #1e2722;
  box-shadow:
    0.28cqw 0.28cqw 0 #0b0705,
    0 0.75cqw 1.7cqw rgba(0, 0, 0, 0.26),
    inset 0 0.16cqw 0 rgba(255, 255, 255, 0.4);
}

.install-btn:hover {
  background: linear-gradient(180deg, #ffe8b8, #e6b874);
  color: #1e1711;
}

.btn-icon {
  width: 1.18cqw;
  height: 1.18cqw;
}

.icon-btn {
  width: 3.15cqw;
  height: 2.78cqw;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn svg {
  width: 1.45cqw;
  height: 1.45cqw;
}

.icon-off { display: none; }
.icon-btn[aria-pressed="false"] .icon-on { display: none; }
.icon-btn[aria-pressed="false"] .icon-off { display: block; }

/* ---------- Pista de juego ---------- */
.hint {
  position: absolute;
  left: 2.9cqw;
  bottom: 3.2cqw;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 0.85cqw;
  padding: 0.72cqw 1cqw;
  color: #f7e8c8;
  background: linear-gradient(180deg, rgba(25, 58, 56, 0.89), rgba(12, 35, 34, 0.93));
  border: 0.18cqw solid rgba(248, 232, 197, 0.32);
  border-radius: 0.25cqw;
  box-shadow: 0.25cqw 0.25cqw 0 rgba(8, 5, 3, 0.32);
  transition: opacity 650ms ease, transform 650ms ease;
  pointer-events: none;
}

.hint.is-gone {
  opacity: 0;
  transform: translateY(0.8cqw);
}

.hint-copy {
  display: flex;
  flex-direction: column;
  gap: 0.2cqw;
  line-height: 1;
}

.hint-copy strong {
  font-family: "Silkscreen", monospace;
  font-size: 1.02cqw;
  font-weight: 700;
  letter-spacing: 0.035em;
  color: #ffeac2;
}

.hint-copy span {
  font-family: "Pixelify Sans", sans-serif;
  font-size: 1.03cqw;
  color: rgba(248, 232, 197, 0.72);
  letter-spacing: 0.02em;
}

.hint-copy b {
  font-family: "Trebuchet MS", "Segoe UI Symbol", sans-serif;
  font-size: 1.32cqw;
  font-weight: 700;
  color: var(--rose-light);
  letter-spacing: 0;
}

.hint-mouse {
  position: relative;
  width: 2.25cqw;
  height: 2.85cqw;
  flex: 0 0 auto;
  border: 0.22cqw solid #f4dfb8;
  border-radius: 1.2cqw 1.2cqw 0.9cqw 0.9cqw;
  background: rgba(255, 255, 255, 0.06);
}

.hint-mouse::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.4cqw;
  width: 0.18cqw;
  height: 0.78cqw;
  background: #f4dfb8;
  transform: translateX(-50%);
}

.hint-click {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.1cqw;
  height: 3.1cqw;
  border: 0.18cqw solid rgba(255, 195, 121, 0.85);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: tap-ping 1.8s ease-out infinite;
}

/* ---------- Intro en pantalla ---------- */
.intro {
  position: absolute;
  top: 13.2cqw;
  left: 50%;
  z-index: 10;
  width: 58cqw;
  padding: 1.8cqw 2cqw 1.65cqw;
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
  animation: intro-life 4.7s cubic-bezier(0.22, 0.8, 0.3, 1) both;
  filter: drop-shadow(0 0.75cqw 1.2cqw rgba(24, 9, 3, 0.45));
}

.intro::before,
.intro::after {
  content: "";
  position: absolute;
  left: 4cqw;
  right: 4cqw;
  height: 0.16cqw;
  background: linear-gradient(90deg, transparent, rgba(249, 217, 160, 0.6), transparent);
}
.intro::before { top: 0.2cqw; }
.intro::after { bottom: 0.2cqw; }

.intro-kicker {
  display: inline-block;
  padding: 0.35cqw 0.8cqw;
  margin-bottom: 0.7cqw;
  font-family: "Silkscreen", monospace;
  font-size: 0.88cqw;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #f6e0b3;
  background: rgba(20, 47, 45, 0.84);
  border: 0.12cqw solid rgba(247, 223, 177, 0.45);
}

.intro h1 {
  margin: 0;
  font-family: "Silkscreen", monospace;
  font-weight: 700;
  font-size: 5.55cqw;
  line-height: 0.92;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  color: #fff0cf;
  text-shadow:
    0.25cqw 0.25cqw 0 #3b2114,
    0.5cqw 0.5cqw 0 rgba(27, 11, 6, 0.48),
    0 0 2.4cqw rgba(255, 188, 100, 0.22);
}

.intro h1 em {
  font-style: normal;
  color: #ffc4c4;
  text-shadow:
    0.25cqw 0.25cqw 0 #6d2d34,
    0.5cqw 0.5cqw 0 rgba(27, 11, 6, 0.48);
}

.intro p {
  margin: 1.05cqw 0 0;
  font-family: "Pixelify Sans", sans-serif;
  font-size: 1.32cqw;
  font-weight: 600;
  letter-spacing: 0.045em;
  color: rgba(255, 238, 205, 0.82);
}

/* ---------- Avisos ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 4.2cqw;
  z-index: 30;
  max-width: 52cqw;
  padding: 0.78cqw 1.2cqw;
  font-family: "Pixelify Sans", sans-serif;
  font-size: 1.08cqw;
  font-weight: 600;
  line-height: 1.22;
  color: #2b1b12;
  text-align: center;
  background: #f8e7c0;
  border: 0.2cqw solid #28180f;
  border-radius: 0.2cqw;
  box-shadow: 0.32cqw 0.32cqw 0 #0a0603, 0 0.8cqw 2cqw rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translate(-50%, 0.8cqw);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Diálogo de instalación ---------- */
.pixel-dialog {
  width: min(92vw, 620px);
  max-width: 620px;
  padding: 0;
  color: var(--ink);
  background: #f7e5c1;
  border: 4px solid #29180f;
  border-radius: 4px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.28), 0 24px 70px rgba(0, 0, 0, 0.48);
}

.pixel-dialog::backdrop {
  background: rgba(8, 5, 3, 0.72);
  backdrop-filter: blur(3px);
}

.dialog-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 0.55rem 0 1rem;
  font-family: "Silkscreen", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f6e4bf;
  background: #1d4745;
  border-bottom: 3px solid #29180f;
}

.dialog-x {
  appearance: none;
  width: 30px;
  height: 30px;
  padding: 0;
  color: #f8e7c0;
  background: #873d40;
  border: 2px solid #29180f;
  font-family: "Silkscreen", monospace;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.dialog-body {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 1.3rem;
  padding: 1.45rem;
}

.dialog-art {
  align-self: start;
  width: 96px;
  height: 96px;
  border: 3px solid #29180f;
  background: #183f3e;
  box-shadow: 4px 4px 0 rgba(41, 24, 15, 0.22);
}

.dialog-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

.dialog-body h2 {
  margin: 0.05rem 0 0.6rem;
  font-family: "Silkscreen", monospace;
  font-size: 1rem;
  line-height: 1.35;
  letter-spacing: -0.03em;
  color: #2a1911;
}

.dialog-body p {
  margin: 0 0 0.8rem;
  font-family: "Pixelify Sans", sans-serif;
  font-size: 1.03rem;
  line-height: 1.4;
  color: #563824;
}

.dialog-body ol {
  margin: 0.35rem 0 0.85rem;
  padding-left: 1.2rem;
  font-family: "Pixelify Sans", sans-serif;
  font-size: 1.02rem;
  line-height: 1.45;
  color: #563824;
}

.dialog-body li { margin-bottom: 0.35rem; }
.dialog-body b { color: #2a1911; }

.dialog-note {
  margin: 0 !important;
  font-size: 0.91rem !important;
  color: #83604a !important;
}

.pixel-dialog .primary {
  display: inline-flex;
  padding: 0.7rem 0.9rem;
  color: #f8e7c0;
  background: #1d4a48;
  border: 3px solid #29180f;
  font-family: "Silkscreen", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  box-shadow: 3px 3px 0 #29180f;
  cursor: pointer;
}

.pixel-dialog .primary:hover { background: #2b635e; }
.pixel-dialog .primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #29180f; }

/* ---------- Utilidades ---------- */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.noscript {
  position: fixed;
  inset: auto 0 1rem;
  z-index: 50;
  margin: 0 auto;
  color: #f8e7c0;
  text-align: center;
  font-size: 1rem;
}

@keyframes score-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.22) rotate(-2deg); }
  65% { transform: scale(0.96) rotate(1deg); }
  100% { transform: scale(1); }
}

@keyframes score-pop {
  0% { opacity: 0; transform: translateY(0.3cqw) scale(0.8); }
  20% { opacity: 1; transform: translateY(-0.45cqw) scale(1.1); }
  65% { opacity: 1; transform: translateY(-1.2cqw) scale(1); }
  100% { opacity: 0; transform: translateY(-2.1cqw) scale(0.95); }
}

@keyframes tap-ping {
  0%, 25% { opacity: 0; transform: translate(-50%, -50%) scale(0.35); }
  38% { opacity: 0.9; }
  68%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}

@keyframes intro-life {
  0% { opacity: 0; transform: translate(-50%, 1.2cqw) scale(0.97); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  76% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -0.9cqw) scale(0.99); visibility: hidden; }
}

@media (max-width: 700px) {
  .hint-copy span { display: none; }
  .install-btn span { display: none; }
  .install-btn { padding: 0.75cqw; }
  .dialog-body { grid-template-columns: 1fr; }
  .dialog-art { display: none; }
}

@media (orientation: portrait) and (max-width: 900px) {
  .stage {
    box-shadow: 0 0 0 1px rgba(250, 223, 173, 0.2), 0 10px 40px rgba(0, 0, 0, 0.6);
  }
  .screen-fx { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
  .intro { opacity: 0; visibility: hidden; }
  .hint { opacity: 1; }
}
