@scope (.memory-embed-host) {
:scope {
--pink: #ff74bc;
  --pink-deep: #e84099;
  --lavender: #ad86ff;
  --violet: #7141c6;
  --violet-dark: #4d289e;
  --cream: #fff2f8;
  --panel: rgba(255, 226, 252, 0.86);
  --panel-edge: rgba(255, 255, 255, 0.9);
  --gold: #ffd85a;
  --shell-pad-x: clamp(10px, 3.5vw, 28px);
  --shell-pad-y: clamp(12px, 2.8vw, 24px);
  --star-url: url("https://cdn-icons-png.flaticon.com/512/1985/1985879.png");
  --timer-url: url("https://cdn-icons-png.flaticon.com/512/10473/10473518.png");
  --card-url: url("assets/Card.webp");
  --board-sky-url: url("assets/Sky.webp");
  --diamond-url: url("https://cdn-icons-png.flaticon.com/512/6313/6313281.png");
  --crown-url: url("https://cdn-icons-png.flaticon.com/512/1722/1722197.png");
  --heart-url: url("https://cdn-icons-png.flaticon.com/512/9484/9484251.png");
  --gift-url: url("https://cdn-icons-png.flaticon.com/512/8146/8146553.png");
  --shadow: 0 14px 30px rgba(85, 47, 164, 0.32);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;

}
* {
box-sizing: border-box;
}

:scope {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--violet-dark);
  background: #94a7ff;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.game-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--shell-pad-y) + env(safe-area-inset-top, 0px));
  padding-left: max(var(--shell-pad-x), env(safe-area-inset-left, 0px));
  padding-right: max(var(--shell-pad-x), env(safe-area-inset-right, 0px));
  padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
  overflow-x: clip;
  overflow-y: auto;
  background:
    linear-gradient(rgba(135, 103, 230, 0.08), rgba(255, 151, 218, 0.1)),
    url("assets/sx.webp") center center / cover no-repeat;
}

.sky-haze,
.sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sky-haze {
  background:
    radial-gradient(ellipse at 50% 49%, rgba(255, 255, 255, 0.08) 0 23%, transparent 52%),
    radial-gradient(ellipse at 85% 85%, rgba(255, 244, 255, 0.12) 0 16%, transparent 35%);
  filter: blur(1px);
}

.sparkles {
  opacity: 0.26;
  background-image:
    radial-gradient(circle, #fff 0 1.2px, transparent 2.4px),
    radial-gradient(circle, #ffe782 0 1.8px, transparent 3px),
    radial-gradient(circle, rgba(255, 255, 255, 0.85) 0 1.2px, transparent 2.8px),
    radial-gradient(circle, rgba(255, 223, 255, 0.7) 0 1px, transparent 3px);
  background-size: 88px 92px, 138px 126px, 52px 58px, 72px 80px;
  animation: twinkle 4s ease-in-out infinite alternate;
}

/* Estrellas decorativas flotantes (capa detrás del UI principal) */
.magic-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.deco-star {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--z);
  height: var(--z);
  background: var(--star-url) center / contain no-repeat;
  opacity: 0.55;
  filter: drop-shadow(0 0 8px rgba(255, 248, 200, 0.95))
    drop-shadow(0 4px 0 rgba(120, 60, 200, 0.15));
  animation: decoFloat var(--d) ease-in-out infinite,
    decoTwinkle calc(var(--d) * 0.42) ease-in-out infinite;
}

.deco-star.dim {
  opacity: 0.32;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
}

.deco-star:nth-child(3n) { animation-delay: -2s, -1.2s; }
.deco-star:nth-child(5n) { animation-delay: -5s, -2.8s; }
.deco-star:nth-child(7n) { animation-delay: -3.8s, -0.9s; }
.deco-star:nth-child(11n) { animation-delay: -7s, -4s; }

@keyframes decoFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1) rotate(-14deg);
  }
  33% {
    transform: translate3d(6px, -16px, 0) scale(1.12) rotate(6deg);
  }
  66% {
    transform: translate3d(-10px, 10px, 0) scale(0.94) rotate(14deg);
  }
}

@keyframes decoTwinkle {
  0%,
  100% {
    opacity: 0.35;
    filter: drop-shadow(0 0 4px rgba(255, 255, 240, 0.7))
      drop-shadow(0 3px 0 rgba(100, 50, 180, 0.12));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 14px #fffacd) drop-shadow(0 5px 0 rgba(100, 50, 180, 0.2));
  }
}

@media (prefers-reduced-motion: reduce) {
  .deco-star {
    animation: none;
    opacity: 0.4;
    transform: none;
  }

  .sparkles {
    animation: none;
  }
}

.topbar,
.hero-stack,
.stats-row,
.content-grid,
.bottom-controls {
  position: relative;
  z-index: 3;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(8px, 2vw, 16px);
  width: 100%;
  max-width: min(1600px, 100%);
  margin-inline: auto;
}

.nav-cluster:not(.right) {
  grid-column: 1;
  justify-self: start;
  align-self: center;
}

.hero-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(22px, 3.8vw, 36px);
  width: max-content;
  max-width: min(1040px, min(92vw, 100%));
  min-width: 0;
  margin-bottom: clamp(10px, 2.4vw, 22px);
}

.nav-cluster.right {
  display: none;
}

.nav-cluster {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 16px);
  flex-wrap: wrap;
  min-width: 0;
}

.square-btn {
  width: 68px;
  height: 82px;
  border: 0;
  background: transparent;
  color: #fff;
  text-shadow: 0 3px 0 rgba(79, 37, 157, 0.45), 0 0 8px #7530b5;
  font-weight: 900;
  transition: transform 180ms ease, filter 180ms ease;
}

.square-btn .icon {
  display: grid;
  place-items: center;
  height: 58px;
  border-radius: 20px;
  font-size: 34px;
  line-height: 1;
  background: linear-gradient(#d6b5ff, #9864ee 54%, #7b48d8);
  border: 3px solid rgba(255, 238, 255, 0.86);
  box-shadow: inset 0 4px 8px rgba(255,255,255,0.55), inset 0 -6px 10px rgba(72,23,148,0.25), 0 7px 14px rgba(69,35,154,0.3);
}

.square-btn small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.home-image-btn {
  flex-shrink: 0;
  width: 82px;
  height: 96px;
}

.home-image-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 7px 12px rgba(69,35,154,0.32));
  pointer-events: none;
}

.square-btn:hover,
.action-btn:hover,
.card:hover {
  transform: translateY(-3px);
  filter: brightness(1.05);
}

.logo-badge {
  display: none;
}

@media (min-width: 780px) {
  .logo-badge {
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }

  .logo-badge img {
    display: block;
    height: clamp(48px, 6.5vw, 68px);
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(69, 35, 154, 0.3));
  }
}

.title-lockup {
  position: relative;
  text-align: center;
  min-width: 0;
  width: 100%;
  max-width: min(640px, 100%);
  margin-top: 0;
  margin-inline: auto;
}

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

.title-image {
  display: block;
  width: min(540px, min(94vw, 100%));
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 8px 0 rgba(80, 47, 155, 0.34)) drop-shadow(0 0 12px rgba(255,255,255,0.85));
}

.title-lockup::before,
.title-lockup::after {
  content: "";
  position: absolute;
  top: 39px;
  width: 30px;
  height: 30px;
  background: var(--star-url) center / contain no-repeat;
  filter: drop-shadow(0 0 6px #fff);
}

.title-lockup::before { margin-left: -310px; }
.title-lockup::after { margin-left: 286px; }

.stats-row {
  width: min(980px, 100%);
  margin: clamp(6px, 1.2vw, 14px) auto 0;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1.15fr 0.95fr 1.18fr;
  gap: clamp(8px, 1.5vw, 12px);
}

.stat-card,
.side-panel,
.board-wrap {
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(
    165deg,
    rgba(255, 248, 254, 0.5) 0%,
    rgba(236, 210, 255, 0.36) 46%,
    rgba(208, 176, 252, 0.28) 100%
  );
  backdrop-filter: blur(16px) saturate(126%);
  -webkit-backdrop-filter: blur(16px) saturate(126%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.82),
    inset 0 -14px 28px rgba(94, 52, 176, 0.12),
    0 10px 36px rgba(45, 26, 118, 0.2);
}

.stat-card {
  min-height: 78px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 16px;
}

.stat-card small,
.side-panel h2 {
  display: block;
  color: #5831b2;
  font-weight: 1000;
  font-size: 13px;
  text-shadow: 0 1px 0 #fff;
}

.stat-card strong {
  display: block;
  color: #5c2fc0;
  font-size: clamp(22px, 4.2vw, 31px);
  line-height: 1.05;
  text-shadow: 0 2px 0 #fff;
}

.timer-card strong { color: var(--pink-deep); }
.stat-orb,
.star-icon,
.crown-icon,
.mini-symbol {
  font-size: 42px;
  line-height: 1;
  filter: drop-shadow(0 4px 0 rgba(77,40,158,0.25));
}

.asset-star {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  background: var(--star-url) center / contain no-repeat;
  filter: drop-shadow(0 3px 0 rgba(173, 108, 19, 0.25)) drop-shadow(0 0 5px rgba(255, 246, 171, 0.75));
  vertical-align: -0.12em;
}

.asset-star.dim {
  opacity: 0.58;
  filter: saturate(0.75) hue-rotate(34deg) drop-shadow(0 2px 0 rgba(97, 66, 174, 0.25));
}

.asset-diamond,
.asset-crown,
.asset-heart,
.asset-gift {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  vertical-align: -0.12em;
  filter: drop-shadow(0 4px 4px rgba(77,40,158,0.24));
}

.asset-diamond { background-image: var(--diamond-url); }
.asset-crown { background-image: var(--crown-url); }
.asset-heart { background-image: var(--heart-url); }
.asset-gift { background-image: var(--gift-url); }

.stat-orb {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fff, #d99fff 45%, #9a54e8);
  border: 4px solid #bd78f5;
}

.timer-icon {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 0;
  background: var(--timer-url) center / contain no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 5px 7px rgba(74, 36, 145, 0.28));
}

.timer-icon::before {
  content: none;
}

.mini-symbol { color: #8e5bec; }

.progress-card {
  flex-direction: column;
  gap: 4px;
}

.star-line {
  font-size: 37px;
  letter-spacing: 4px;
  line-height: 1;
  display: flex;
  gap: 7px;
}

.progress-track {
  width: min(146px, 100%);
  max-width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #8a62df;
  border: 2px solid rgba(92, 43, 175, 0.5);
  overflow: hidden;
}

.progress-track i {
  display: block;
  width: 64%;
  height: 100%;
  background: linear-gradient(90deg, #ff8a48, #ffdf56);
  border-radius: inherit;
}

.content-grid {
  display: grid;
  grid-template-columns:
    minmax(200px, 260px)
    minmax(280px, 1fr)
    minmax(200px, 260px);
  gap: clamp(14px, 2.2vw, 28px);
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: min(1500px, 100%);
  margin: clamp(8px, 2.4vw, 24px) auto 0;
  perspective: 1200px;
}

.side-panel {
  border-radius: 26px;
  padding: 18px 14px;
  position: relative;
  transform: translateZ(0);
  box-shadow:
    inset 0 2px 12px rgba(255, 255, 255, 0.62),
    inset 0 -12px 26px rgba(122, 63, 191, 0.1),
    0 8px 26px rgba(55, 34, 132, 0.18);
}

.side-panel::before,
.board-wrap::before {
  content: "";
  position: absolute;
  inset: 7px 9px auto;
  height: 36%;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.32), transparent);
  pointer-events: none;
}

.side-panel h2 {
  margin: 0 0 14px;
  text-align: center;
  font-size: 18px;
}

.side-panel h2 span {
  margin-right: 8px;
  font-size: 1.1em;
}

.how-panel {
  align-self: stretch;
  min-height: 0;
  margin-top: 0;
  display: flex;
  flex-direction: column;
}

.instruction-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 18px;
  padding: clamp(12px, 2vw, 16px) 12px clamp(14px, 2.5vw, 20px);
  text-align: left;
  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(12px) saturate(118%);
  -webkit-backdrop-filter: blur(12px) saturate(118%);
  border: 2px solid rgba(255, 255, 255, 0.68);
}

.instruction-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.how-image {
  display: block;
  align-self: center;
  width: min(296px, 100%);
  height: auto;
  min-height: 0;
  max-height: min(340px, 55vh);
  margin: -8px auto 12px;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 8px 10px rgba(78, 43, 147, 0.2));
}

.instruction-card p,
.mission-panel p {
  color: #5530b9;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
  margin: 0;
}

.instruction-card p strong {
  color: #4a28a3;
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-radius: 32px;
  padding: clamp(9px, 2vw, 20px);
  container-type: inline-size;
  container-name: board;
  overflow: hidden;
  backdrop-filter: blur(18px) saturate(118%);
  -webkit-backdrop-filter: blur(18px) saturate(118%);
  background:
    radial-gradient(circle at 50% 6%, rgba(255,255,255,0.22), transparent 45%),
    linear-gradient(
      180deg,
      rgba(178, 126, 243, 0.26),
      rgba(92, 57, 194, 0.34)
    ),
    radial-gradient(ellipse at 50% 100%, rgba(255,255,255,0.14), transparent 50%),
    var(--board-sky-url) center center / cover no-repeat;
  background-color: rgba(107, 78, 196, 0.72);
  border-color: rgba(255, 255, 255, 0.52);
  box-shadow:
    inset 0 5px 14px rgba(255, 255, 255, 0.48),
    inset 0 -14px 26px rgba(50, 24, 134, 0.26),
    0 10px 36px rgba(54, 28, 130, 0.26);
  transform: rotateX(1.2deg);
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(7px, 1.55vw, 16px);
  width: 100%;
  max-width: min(860px, 98%);
  margin-inline: auto;
  justify-content: center;
}

.card {
  position: relative;
  aspect-ratio: 1 / 1.08;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  perspective: 900px;
  transition: transform 180ms ease, filter 180ms ease;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 480ms cubic-bezier(.2,.75,.2,1.15);
}

.card.flipped .card-inner,
.card.matched .card-inner,
.card.hinting .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 17px;
  border: 3px solid rgba(255,255,255,0.82);
  box-shadow:
    inset 0 5px 10px rgba(255,255,255,0.5),
    inset 0 -8px 12px rgba(132,44,150,0.18),
    0 6px 10px rgba(56,28,124,0.35);
  backface-visibility: hidden;
  overflow: hidden;
}

.card-front {
  color: transparent;
  font-size: 0;
  text-shadow: none;
  border: 0;
  background: var(--card-url) center / 100% 100% no-repeat;
  box-shadow: none;
}

.card-back::before {
  content: "✦";
  position: absolute;
  left: 14px;
  top: 10px;
  color: rgba(255,255,255,0.9);
  font-size: 18px;
}

.card-back::after {
  content: "✦";
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
}

.card-back:has(.card-symbol-img)::before,
.card-back:has(.card-symbol-img)::after {
  content: none;
}

.card-symbol-img {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  /* Igual que .card-front: Card.png usa 100% 100% — llena toda la cara de la carta */
  object-fit: fill;
  object-position: center;
  pointer-events: none;
  user-select: none;
}

.card-back {
  transform: rotateY(180deg);
  display: grid;
  place-items: center;
  padding: 4px;
  box-sizing: border-box;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.2) 25%, transparent 25%) 0 0 / 30px 30px,
    linear-gradient(150deg, #fff2ea, #f4d8ff 48%, #b98dfd);
}

/* Symbol PNGs (01–10) are full card art: show them edge-to-edge, no Card.png underneath */
.card-face.card-back:has(.card-symbol-img) {
  border: 0;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

.card-back[data-color="purple"] { background: linear-gradient(150deg, #eedcff, #b98eff 60%, #8b61eb); }
.card-back[data-color="peach"] { background: linear-gradient(150deg, #fff2e3, #ffd7bd 58%, #eca4bf); }
.card-back[data-color="glow"] { box-shadow: inset 0 5px 10px rgba(255,255,255,0.65), 0 0 0 4px #ffe07d, 0 0 20px #ffe07d, 0 6px 10px rgba(56,28,124,0.35); }

.card-face.card-back[data-color]:has(.card-symbol-img),
.card-face.card-back:has(.card-symbol-img) {
  box-shadow: none;
}

.card.matched .card-face.card-back:has(.card-symbol-img),
.card.hinting .card-face.card-back:has(.card-symbol-img) {
  box-shadow:
    inset 0 5px 10px rgba(255,255,255,0.65),
    0 6px 10px rgba(56,28,124,0.35);
}

.card-back[data-color="glow"]:has(.card-symbol-img),
.card-face.card-back[data-color="glow"]:has(.card-symbol-img) {
  box-shadow: inset 0 5px 10px rgba(255,255,255,0.65), 0 0 0 4px #ffe07d, 0 0 20px #ffe07d, 0 6px 10px rgba(56,28,124,0.35);
}

.card.matched .card-back {
  box-shadow:
    inset 0 5px 10px rgba(255,255,255,0.7),
    0 0 0 4px #ffe78a,
    0 0 24px #fff08a,
    0 8px 14px rgba(56,28,124,0.35);
}

.card.matched .card-face.card-back:has(.card-symbol-img) {
  box-shadow:
    inset 0 5px 10px rgba(255,255,255,0.72),
    0 0 0 4px #ffe78a,
    0 0 22px #fff08a,
    0 8px 14px rgba(56,28,124,0.38);
}

.right-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: clamp(14px, 2vw, 20px);
  min-width: 0;
}

.mission-panel {
  min-height: 0;
  flex: 0 0 auto;
}

.mission-panel p {
  margin: 0 8px 15px;
  text-align: center;
}

.star-goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.star-goals li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.55);
  color: #5530b9;
  font-size: 13px;
  font-weight: 1000;
}

.star-goals span { font-size: 25px; }

.best-panel {
  text-align: center;
  padding-block: 16px;
}

.best-panel strong {
  display: block;
  color: var(--pink-deep);
  font-size: 33px;
  text-shadow: 0 2px 0 #fff;
}

.reward-row {
  display: flex;
  justify-content: space-around;
  gap: 5px;
  border-radius: 15px;
  padding: 13px 5px 8px;
  background: rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.reward-row span {
  display: grid;
  justify-items: center;
  gap: 2px;
  text-align: center;
  font-size: 34px;
}

.reward-star,
.reward-diamond,
.reward-heart {
  font-size: 36px;
  margin-top: 1px;
}

.reward-row b {
  font-size: 15px;
}

.bottom-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 46px;
  margin-top: clamp(0px, 0.6vw, 6px);
  width: 100%;
  max-width: min(1500px, 100%);
  margin-inline: auto;
  padding-inline: clamp(8px, 2vw, 24px);
  box-sizing: border-box;
}

.action-btn {
  position: relative;
  min-width: 220px;
  height: 70px;
  border: 3px solid rgba(255,255,255,0.82);
  border-radius: 28px;
  color: #fff;
  font-weight: 1000;
  font-size: 24px;
  text-shadow: 0 3px 0 rgba(86, 39, 148, 0.42);
  box-shadow: inset 0 5px 12px rgba(255,255,255,0.45), inset 0 -8px 14px rgba(103,37,131,0.22), 0 9px 16px rgba(68,35,147,0.32);
  transition: transform 160ms ease, filter 160ms ease;
}

.image-action {
  min-width: 0;
  width: 272px;
  height: 88px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.image-action img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 12px 15px rgba(68,35,147,0.38));
  pointer-events: none;
}

.restart-action {
  width: 336px;
  height: 92px;
}

.image-action.hint-action {
  position: relative;
}

.hint-badge {
  position: absolute;
  top: -2px;
  right: clamp(10px, 3.5vw, 28px);
  z-index: 2;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  border: 2px solid rgba(255, 250, 255, 0.95);
  background: linear-gradient(180deg, #ff9fe0, var(--pink-deep));
  color: #fff;
  font-size: 13px;
  font-weight: 1000;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(86, 39, 148, 0.35);
  pointer-events: none;
}

.hint-action--disabled {
  opacity: 0.52;
  filter: saturate(0.72);
  cursor: not-allowed;
}

.hint-action--disabled:hover {
  transform: none;
  filter: saturate(0.72) brightness(1);
}

.action-btn span {
  margin-right: 8px;
  font-size: 30px;
}

.action-btn.purple {
  background: linear-gradient(#d4aeff, #8f66f0 58%, #7040d3);
}

.action-btn.pink {
  min-width: 280px;
  background: linear-gradient(#ff98ce, #f35aa8 58%, #df318d);
}

.action-btn i {
  position: absolute;
  top: -13px;
  right: -12px;
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 50%;
  border: 3px solid #fff0ff;
  background: #8f64ec;
  font-style: normal;
  font-size: 21px;
}

.cloud,
.castle,
.crystals {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  display: none;
}

.cloud {
  width: 230px;
  height: 72px;
  border-radius: 999px;
  background: rgba(255, 237, 255, 0.72);
  filter: blur(2px);
  box-shadow: 40px -20px 0 8px rgba(255,237,255,0.65), 95px 6px 0 14px rgba(255,237,255,0.5);
}

.cloud-a { left: 235px; top: 72px; }
.cloud-b { right: 220px; top: 142px; transform: scale(.75); }

.castle {
  width: 250px;
  height: 235px;
  opacity: 0.62;
  filter: blur(.2px);
}

.castle-left {
  left: 18px;
  top: 118px;
}

.island-right {
  right: 30px;
  top: 128px;
  transform: scale(.9);
}

.castle span {
  position: absolute;
  bottom: 0;
  width: 68px;
  border-radius: 28px 28px 8px 8px;
  background: linear-gradient(#ffe6fa, #c28dff 62%, #8fd8f4);
  border: 3px solid rgba(255,255,255,0.42);
}

.castle span::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% - 4px);
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 28px solid transparent;
  border-right: 28px solid transparent;
  border-bottom: 82px solid #ff82c6;
}

.castle span:nth-child(1) { left: 12px; height: 130px; }
.castle span:nth-child(2) { left: 84px; height: 190px; width: 82px; }
.castle span:nth-child(3) { left: 174px; height: 118px; }

.crystals {
  bottom: -15px;
  width: 170px;
  height: 160px;
  background:
    linear-gradient(130deg, transparent 0 31%, rgba(255,255,255,.8) 31% 34%, transparent 35%),
    linear-gradient(45deg, #713de0, #e983ff 55%, #93dcff);
  clip-path: polygon(9% 100%, 24% 18%, 42% 100%, 52% 33%, 75% 100%, 90% 7%, 100% 100%);
  opacity: 0.78;
  filter: drop-shadow(0 0 14px rgba(238,168,255,0.8));
}

.crystals-left { left: -8px; }
.crystals-right { right: -8px; transform: scaleX(-1); }

@keyframes twinkle {
  from { opacity: 0.65; transform: translateY(0); }
  to { opacity: 1; transform: translateY(-4px); }
}

@media (max-width: 1180px) {
  :scope { overflow-x: clip; overflow-y: auto; }
  .game-shell {
    padding-top: calc(var(--shell-pad-y) + env(safe-area-inset-top, 0px));
    padding-left: max(var(--shell-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--shell-pad-x), env(safe-area-inset-right, 0px));
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
    overflow-x: clip;
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 12px;
  }

  .nav-cluster:not(.right) {
    grid-column: auto;
    justify-self: center;
    position: relative;
    left: auto;
    top: auto;
    transform: none;
  }

  .hero-stack {
    grid-column: auto;
    width: 100%;
    max-width: min(1040px, 100%);
    order: -1;
    gap: clamp(18px, 4vw, 28px);
    margin-bottom: clamp(8px, 2.6vw, 18px);
  }
  .title-image { width: min(580px, 92vw); }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-card { grid-column: 1 / -1; }
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(14px, 3vw, 22px);
    max-width: min(920px, 100%);
    width: 100%;
  }
  .board-wrap { order: -1; width: 100%; }
  .how-panel { order: 1; margin-top: 0; width: 100%; }
  /* Móvil / responsive apilado: sin panel lateral bajo el tablero — ocultamos misión / best / rewards */
  .right-stack {
    display: none;
  }
  .castle { opacity: 0.28; }
}

@media (min-width: 1181px) {
  :scope {
    overflow-x: clip;
    overflow-y: auto;
  }

  .game-shell {
    min-height: 100dvh;
    height: auto;
    max-height: none;
    overflow-x: clip;
    overflow-y: auto;
    padding-top: max(8px, calc(var(--shell-pad-y) + env(safe-area-inset-top, 0px)));
  }

  .content-grid {
    align-items: start;
    margin-top: clamp(4px, 1.6vw, 14px);
  }

  .bottom-controls {
    margin-top: clamp(0px, 0.5vw, 5px);
  }

  .board-wrap {
    align-self: start;
  }

  .right-stack {
    align-self: start;
  }

  .nav-cluster.right {
    display: flex;
    grid-column: 3;
    justify-self: end;
    align-self: center;
    flex-shrink: 0;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: clamp(8px, 2vw, 16px);
    width: 100%;
    max-width: min(1600px, 100%);
    margin-inline: auto;
  }

  .nav-cluster:not(.right) {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    grid-column: 1;
    justify-self: start;
    align-self: center;
    z-index: 4;
    flex-wrap: nowrap;
  }

  .hero-stack {
    grid-column: 2;
    justify-self: center;
    margin-inline: 0;
    margin-bottom: clamp(8px, 2.2vw, 18px);
    width: max-content;
    max-width: min(1040px, min(92vw, 100%));
  }

  .title-image {
    width: min(500px, 45vw);
  }
}

@media (max-width: 900px) {
  .title-lockup::before,
  .title-lockup::after {
    display: none !important;
  }
}

@media (max-width: 720px) {
  .nav-cluster { flex-wrap: wrap; justify-content: center; gap: 10px; }
  .square-btn { width: 62px; height: 74px; }
  .home-image-btn { width: 72px; height: 84px; }
  .square-btn .icon { height: 52px; border-radius: 18px; }
  .title-image { width: min(448px, 94vw); }
  .stats-row {
    width: 100%;
    gap: 6px;
    margin-top: clamp(4px, 1vw, 10px);
  }
  .bottom-controls {
    flex-wrap: nowrap;
    gap: clamp(6px, 2vw, 14px);
    margin-top: clamp(0px, 1.2vw, 8px);
    padding-inline: clamp(4px, 1.8vw, 16px);
  }

  .bottom-controls .restart-action.image-action {
    flex: 1.22 1 0%;
    min-width: 0;
    width: auto;
    height: auto;
    aspect-ratio: 336 / 92;
    max-width: none;
  }

  .bottom-controls .hint-action.image-action {
    flex: 1 1 0%;
    min-width: 0;
    width: auto;
    height: auto;
    aspect-ratio: 272 / 88;
    max-width: none;
  }
  .stat-orb,
  .mini-symbol {
    font-size: clamp(28px, 8vw, 42px);
  }
  .stat-orb { width: 48px; height: 48px; }
}

@media (max-width: 520px) {
  .game-shell {
    --shell-pad-x: clamp(8px, 4.2vw, 18px);
  }

  .topbar {
    gap: 8px;
  }

  .stat-card {
    padding: 6px 10px;
    gap: 8px;
    min-height: 64px;
    border-radius: 18px;
  }

  .stat-card small {
    font-size: clamp(11px, 3vw, 13px);
  }

  .stat-card strong {
    font-size: clamp(18px, 5vw, 28px);
  }

  .side-panel {
    padding: 14px 11px;
  }

  .side-panel h2 {
    font-size: clamp(14px, 4vw, 18px);
  }

  .content-grid {
    gap: clamp(10px, 3vw, 18px);
    margin-inline: 0;
  }

  .memory-board {
    gap: clamp(4px, 1.3vw, 10px);
  }

  .board-wrap {
    padding: clamp(6px, 1.6vw, 14px);
    border-radius: clamp(22px, 6vw, 30px);
  }

  .mission-panel p {
    font-size: clamp(14px, 3.8vw, 15px);
  }

  .bottom-controls {
    gap: clamp(10px, 4vw, 28px);
  }
}

@media (max-width: 380px) {
  .stats-row {
    gap: 5px;
  }

  .bottom-controls {
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding-inline: 4px;
  }
}
}
