/*
 * EcoGame premium interaction theme.
 * Spotlight, tilt and click feedback patterns are adapted for EcoGame from
 * React Bits by David Haz: https://reactbits.dev/
 */

:root {
  --eco-ink: #123b32;
  --eco-mint: #89ddbe;
  --eco-lime: #ccec65;
  --eco-sun: #ffd260;
  --eco-coral: #ff7968;
}

.eco-rights-notice {
  padding: 24px max(20px, calc((100vw - 1120px) / 2)) 30px;
  border-top: 1px solid rgba(18,59,50,.12);
  background: #edf2e9;
  color: #405c51;
  font-size: 12px;
  line-height: 1.8;
}
.eco-rights-notice strong { color: #123b32; font-size: 14px; }
.eco-rights-notice p { margin: 8px 0; word-break: keep-all; overflow-wrap: anywhere; }
.eco-rights-notice nav { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; }
.eco-rights-notice a { color: #1f6652; text-decoration: underline; text-underline-offset: 3px; }
.eco-rights-notice a:focus-visible { outline: 2px solid #1f6652; outline-offset: 4px; }

body {
  background:
    radial-gradient(circle at 10% 12%, rgba(204, 236, 101, .2), transparent 24rem),
    radial-gradient(circle at 88% 28%, rgba(90, 211, 190, .16), transparent 28rem),
    #f7f6ee;
}

body::before,
body::after {
  content: "";
  pointer-events: none;
  position: fixed;
  z-index: -1;
  filter: blur(12px);
  opacity: .62;
}

body::before {
  width: 64vw;
  height: 34vw;
  min-height: 320px;
  top: -16vw;
  left: -8vw;
  border-radius: 48% 52% 66% 34%;
  background: conic-gradient(from 110deg, rgba(204,236,101,.72), rgba(105,220,192,.35), rgba(255,210,96,.25), rgba(204,236,101,.72));
  animation: eco-aurora-drift 14s ease-in-out infinite alternate;
}

body::after {
  width: 46vw;
  height: 46vw;
  right: -21vw;
  top: 32vh;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(123,220,205,.3), rgba(255,121,104,.09) 46%, transparent 70%);
  animation: eco-aurora-pulse 11s ease-in-out infinite alternate;
}

@keyframes eco-aurora-drift {
  to { transform: translate3d(12vw, 6vh, 0) rotate(8deg) scale(1.12); }
}

@keyframes eco-aurora-pulse {
  to { transform: translate3d(-8vw, -5vh, 0) scale(1.18); opacity: .82; }
}

header {
  top: 12px;
  z-index: 70;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 22px;
  background: rgba(250,250,244,.76);
  box-shadow: 0 14px 40px rgba(18,59,50,.08), inset 0 1px rgba(255,255,255,.82);
  backdrop-filter: blur(18px) saturate(1.25);
}

.sound[aria-pressed="true"] {
  color: #0e5a48;
  background: rgba(137,221,190,.28);
  box-shadow: 0 0 0 5px rgba(137,221,190,.12), 0 8px 18px rgba(18,59,50,.1);
}

.hero,
.games-section,
.mission {
  isolation: isolate;
}

.hero {
  perspective: 1300px;
}

.hero-copy {
  position: relative;
  z-index: 3;
}

.hero-copy h1 em {
  color: transparent;
  background: linear-gradient(100deg, #ff725f 0%, #f5b931 35%, #ff725f 62%, #d9475e 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  animation: eco-shiny-text 5s linear infinite;
  filter: drop-shadow(0 8px 16px rgba(255,114,95,.16));
}

@keyframes eco-shiny-text {
  to { background-position: -220% center; }
}

.hero-visual,
.mission-card,
.game-card,
.trash-stage,
.eco-city,
.word-scene,
.sentence-board,
.eco-link-card {
  --eco-rx: 0deg;
  --eco-ry: 0deg;
  --eco-lift: 0px;
  transform-style: preserve-3d;
  will-change: transform;
}

.hero-visual {
  transform: perspective(1100px) rotateX(var(--eco-rx)) rotateY(var(--eco-ry)) translate3d(0,var(--eco-lift),0);
  transition: transform .18s ease-out;
}

.hero-visual .planet {
  filter: drop-shadow(0 34px 36px rgba(18,59,50,.2));
}

.hero-visual .float-tag {
  transform: translateZ(78px);
  box-shadow: 0 20px 42px rgba(18,59,50,.15), inset 0 1px rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
}

.game-cards {
  perspective: 1500px;
}

.game-card {
  --spot-x: 50%;
  --spot-y: 50%;
  position: relative;
  border: 1px solid rgba(255,255,255,.86);
  background: rgba(255,255,255,.84);
  transform: perspective(950px) rotateX(var(--eco-rx)) rotateY(var(--eco-ry)) translate3d(0,var(--eco-lift),0);
  transition: transform .16s ease-out, box-shadow .25s ease, border-color .25s ease;
  box-shadow: 0 18px 42px rgba(17,56,47,.11), inset 0 1px rgba(255,255,255,.9);
  backdrop-filter: blur(12px) saturate(1.15);
  overflow: hidden;
}

.game-card::after,
.mission-card::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  opacity: 0;
  background: radial-gradient(340px circle at var(--spot-x) var(--spot-y), rgba(255,255,255,.62), rgba(255,255,255,.14) 28%, transparent 66%);
  transition: opacity .25s ease;
}

.game-card:hover::after,
.mission-card:hover::after { opacity: 1; }

.game-card:hover {
  transform: perspective(950px) rotateX(var(--eco-rx)) rotateY(var(--eco-ry)) translate3d(0,-10px,26px);
  border-color: rgba(204,236,101,.9);
  box-shadow: 0 28px 60px rgba(9,45,36,.2), 0 0 0 1px rgba(204,236,101,.18);
}

.game-card .card-top,
.game-card .card-content,
.game-card .game-art {
  transform-style: preserve-3d;
}

.game-card .game-art { transform: translateZ(55px) scale(.98); }
.game-card .card-top > span { transform: translateZ(38px); }
.game-card .card-top > button { transform: translateZ(62px); box-shadow: 0 13px 28px rgba(18,59,50,.2); }
.game-card .card-content { position: relative; z-index: 6; transform: translateZ(28px); }

.game-card:nth-child(1) .card-top { background: radial-gradient(circle at 30% 20%, #f6ffd4, transparent 38%), linear-gradient(145deg,#dff59b,#aed965); }
.game-card:nth-child(2) .card-top { background: radial-gradient(circle at 72% 24%, #e9ffff, transparent 35%), linear-gradient(145deg,#b8eee6,#72c8ba); }
.game-card:nth-child(3) .card-top { background: radial-gradient(circle at 35% 18%, #fff4bc, transparent 34%), linear-gradient(145deg,#ffd976,#e9a936); }
.game-card:nth-child(4) .card-top { background: radial-gradient(circle at 70% 20%, #e8eeff, transparent 36%), linear-gradient(145deg,#c5d2ff,#899ee7); }
.game-card:nth-child(5) .card-top { background: radial-gradient(circle at 28% 16%, #ffeddd, transparent 36%), linear-gradient(145deg,#fac8ae,#df8f6a); }
.game-card:nth-child(6) .card-top { background: radial-gradient(circle at 74% 18%, #ffe7f3, transparent 34%), linear-gradient(145deg,#f4b9d4,#d77fa8); }

.match-art span,
.recycle-art > *,
.energy-art > *,
.word-art > *,
.sentence-art > *,
.eco-link-art > * {
  filter: drop-shadow(0 13px 12px rgba(18,59,50,.2));
  transition: transform .3s cubic-bezier(.2,.8,.2,1);
}

.game-card:hover .match-art span:nth-child(odd),
.game-card:hover .recycle-art > :first-child,
.game-card:hover .energy-art > :first-child { transform: translate3d(-5px,-8px,22px) rotate(-5deg); }
.game-card:hover .match-art span:nth-child(even),
.game-card:hover .recycle-art > :last-child,
.game-card:hover .energy-art > :last-child { transform: translate3d(6px,-3px,34px) rotate(5deg); }

.mission-card {
  --spot-x: 50%;
  --spot-y: 50%;
  position: relative;
  transform: perspective(1100px) rotateX(var(--eco-rx)) rotateY(var(--eco-ry)) translate3d(0,var(--eco-lift),0);
  transition: transform .18s ease-out;
  box-shadow: 0 30px 64px rgba(18,59,50,.16), inset 0 1px rgba(255,255,255,.35);
}

.trash-stage,
.eco-city,
.word-scene,
.sentence-board {
  transform: perspective(900px) rotateX(var(--eco-rx)) rotateY(var(--eco-ry)) translateZ(6px);
  transition: transform .18s ease-out, filter .4s;
  box-shadow: 0 20px 44px rgba(18,59,50,.13), inset 0 1px rgba(255,255,255,.6);
}

.bins-grid button,
.word-options button,
.sentence-actions button {
  transition: transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 8px 20px rgba(18,59,50,.09);
}

.bins-grid button:hover,
.word-options button:hover,
.sentence-actions button:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 15px 28px rgba(18,59,50,.16);
}

.game-overlay {
  background: rgba(8,35,29,.72);
  backdrop-filter: blur(14px) saturate(1.2);
}

.game-modal {
  border: 1px solid rgba(255,255,255,.8);
  background: linear-gradient(155deg,rgba(255,255,252,.96),rgba(242,247,238,.94));
  box-shadow: 0 38px 110px rgba(4,25,20,.48), inset 0 1px rgba(255,255,255,.95);
}

.game-modal:has(.memory-stage-panel) {
  width: min(860px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  overflow-x: hidden;
}

.memory-stage-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 13px 15px;
  border: 1px solid rgba(119,151,67,.18);
  border-radius: 17px;
  background: linear-gradient(130deg,rgba(222,244,164,.82),rgba(186,235,213,.58));
  box-shadow: inset 0 1px rgba(255,255,255,.82), 0 9px 24px rgba(18,59,50,.08);
}

.memory-stage-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #536c62;
  font-family: Manrope, sans-serif;
  font-size: 12px;
}

.memory-stage-copy b { color: var(--eco-ink); letter-spacing: 1.6px; }

.memory-stage-track {
  display: grid;
  grid-template-columns: repeat(10,1fr);
  gap: 5px;
}

.memory-stage-track i {
  height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 1px 2px rgba(18,59,50,.08);
}

.memory-stage-track i.complete { background: #7dc9a6; }
.memory-stage-track i.current { background: #ff7b67; box-shadow: 0 0 0 3px rgba(255,123,103,.14); }

.memory-stats { grid-template-columns: repeat(3,1fr); display: grid; }
.memory-stats span { justify-content: center; }

.memory-grid {
  grid-template-columns: repeat(var(--memory-columns,4),minmax(0,1fr));
  gap: 10px;
  perspective: 1300px;
  align-items: stretch;
}

.memory-card {
  min-width: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .5s cubic-bezier(.22,.9,.26,1.22), filter .25s ease;
  /* A filter flattens preserve-3d and keeps the card back over the GIF. */
  filter: none;
  box-shadow: 0 10px 20px rgba(18,59,50,.12);
}

.memory-card:hover:not(.visible) { transform: translateY(-5px) rotateX(8deg) rotateY(-7deg); }
.memory-card.visible { transform: rotateY(180deg) translateZ(10px); }
.memory-card.done { filter: none; box-shadow: 0 0 24px rgba(137,221,190,.75); }

.memory-card > span {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  overflow: hidden;
  border-radius: 16px;
}

.memory-card .card-back {
  color: #244e42;
  border: 1px solid rgba(255,255,255,.7);
  background:
    radial-gradient(circle at 30% 22%,rgba(255,255,255,.65),transparent 28%),
    linear-gradient(145deg,#dff3a0,#90d7ad);
  box-shadow: inset 0 -6px rgba(83,117,60,.16), 0 8px 18px rgba(18,59,50,.12);
}

.memory-card .card-face {
  opacity: 0;
  border: 1px solid rgba(255,255,255,.82);
  background: #f8faef;
  box-shadow: 0 12px 26px rgba(18,59,50,.14), inset 0 1px rgba(255,255,255,.9);
  transition: opacity .08s linear .2s;
}

.memory-card.visible .card-face { opacity: 1; }

.memory-card .card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
}

.memory-card .card-face b {
  position: absolute;
  right: 7px;
  bottom: 6px;
  min-width: 25px;
  padding: 3px 6px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 99px;
  color: #fff;
  background: rgba(18,59,50,.78);
  font: 800 10px/1 Manrope,sans-serif;
  box-shadow: 0 5px 12px rgba(18,59,50,.18);
  backdrop-filter: blur(8px);
}

.memory-card.done .card-face::after {
  content: "✓";
  position: absolute;
  top: 6px;
  left: 7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  background: #54b68e;
  box-shadow: 0 7px 15px rgba(35,112,81,.3);
  font: 900 13px/1 Manrope,sans-serif;
}

.memory-result { margin-top: 12px; }

.eco-click-spark {
  pointer-events: none;
  position: fixed;
  z-index: 9999;
  inset: 0;
  width: 100%;
  height: 100%;
}

[data-eco-reveal="pending"] {
  opacity: 0;
  translate: 0 28px;
  scale: .975;
}

[data-eco-reveal="visible"] {
  opacity: 1;
  translate: 0 0;
  scale: 1;
  transition: opacity .7s ease var(--eco-reveal-delay,0ms), translate .8s cubic-bezier(.2,.75,.25,1) var(--eco-reveal-delay,0ms), scale .8s cubic-bezier(.2,.75,.25,1) var(--eco-reveal-delay,0ms);
}

@media (max-width: 760px) {
  .game-overlay:has(.memory-stage-panel) { padding: 8px; }
  header { top: 6px; border-radius: 17px; }
  .game-card { transform: none; }
  .game-card:hover { transform: translateY(-5px); }
  .game-modal:has(.memory-stage-panel) { width: calc(100vw - 16px); max-width: calc(100vw - 16px); margin: 0; }
  .game-modal:has(.memory-stage-panel) .game-body { min-width: 0; padding-inline: 14px; }
  .memory-grid { --memory-columns: 3 !important; gap: 7px; }
  .memory-card > span { border-radius: 12px; }
  .memory-card .card-face b { right: 4px; bottom: 4px; font-size: 8px; }
  .memory-stage-panel { padding: 10px 11px; }
}

@media (max-width: 420px) {
  .memory-grid { gap: 5px; }
  .memory-stats { gap: 4px; }
  .memory-stats span { padding-inline: 4px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .hero-copy h1 em { animation: none !important; }
  .hero-visual,
  .mission-card,
  .game-card,
  .trash-stage,
  .eco-city,
  .word-scene,
  .sentence-board,
  .eco-link-card { transform: none !important; transition-duration: .01ms !important; }
  .eco-click-spark { display: none; }
  [data-eco-reveal] { opacity: 1 !important; translate: none !important; scale: 1 !important; transition: none !important; }
}
