@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Nunito:wght@600;700;800;900&display=swap');

:root {
  --night: #0c1227;
  --night-soft: #151d3a;
  --plum: #2e2147;
  --violet: #9275da;
  --lavender: #cbbaf5;
  --mint: #69d6c4;
  --gold: #f6d47b;
  --cream: #fff6dc;
  --ink: #f8f4ff;
  --muted: #b8b4ce;
  --shadow: 0 28px 70px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 5%, rgba(75,92,157,.35), transparent 32%),
    linear-gradient(180deg, #101933 0%, var(--night) 75%);
  font-family: "Nunito", system-ui, sans-serif;
  overflow-x: hidden;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-decoration: none; }

.forest-haze {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 22%, rgba(102,218,198,.08), transparent 18%),
    radial-gradient(circle at 90% 48%, rgba(150,105,209,.09), transparent 22%),
    radial-gradient(circle at 25% 75%, rgba(246,212,123,.05), transparent 16%);
}

.forest-haze::before,
.forest-haze::after {
  content: "";
  width: 280px;
  height: 620px;
  position: absolute;
  top: 120px;
  background: #080d1d;
  border-radius: 48% 52% 15% 15%;
  filter: blur(1px);
  opacity: .44;
}
.forest-haze::before { left: -190px; transform: rotate(9deg); }
.forest-haze::after { right: -190px; transform: rotate(-9deg); }

.site-header {
  min-height: 76px;
  padding: 12px max(20px, calc((100% - 1040px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(203,186,245,.12);
  background: rgba(9,14,31,.75);
  backdrop-filter: blur(15px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--cream); font: 800 1.65rem/1 "Baloo 2", sans-serif; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(246,212,123,.6); border-radius: 50% 50% 43% 57%; color: var(--gold); background: linear-gradient(145deg, #3a2b56, #1d2c4b); box-shadow: 0 0 20px rgba(246,212,123,.18), inset 0 0 12px rgba(105,214,196,.12); transform: rotate(-8deg); }

.sound-button { min-height: 44px; padding: 8px 14px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid rgba(203,186,245,.25); border-radius: 14px; color: var(--lavender); background: rgba(39,48,85,.65); font-weight: 900; cursor: pointer; }
.sound-button[aria-pressed="true"] { color: #bff5e8; border-color: rgba(105,214,196,.5); background: rgba(40,99,95,.35); }

.hero { padding: 64px 22px 34px; text-align: center; }
.eyebrow { margin: 0 0 9px; color: var(--mint); font-size: .72rem; font-weight: 900; letter-spacing: .16em; }
h1, h2 { font-family: "Baloo 2", sans-serif; }
.hero h1 { margin: 0; font-size: clamp(3.7rem, 8vw, 6.5rem); line-height: .78; letter-spacing: -.045em; text-shadow: 0 5px 30px rgba(0,0,0,.35); }
.hero h1 span { color: var(--gold); }
.hero > p:last-child { max-width: 600px; margin: 28px auto 0; color: var(--muted); font-size: 1.02rem; line-height: 1.65; }

.game-shell { width: min(880px, calc(100% - 28px)); margin: 10px auto 65px; padding: 16px; position: relative; border: 1px solid rgba(203,186,245,.19); border-radius: 30px; background: rgba(22,29,56,.86); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06); backdrop-filter: blur(12px); }
.game-bar { min-height: 72px; padding: 6px 12px 14px; display: grid; grid-template-columns: 115px 1fr 125px 130px; align-items: center; gap: 14px; }
.stat { display: grid; text-align: center; }
.stat > span { color: var(--muted); font-size: .65rem; font-weight: 900; letter-spacing: .13em; }
.stat strong { color: var(--gold); font: 800 1.55rem/1.15 "Baloo 2"; }
.moon { height: 1px; position: relative; background: linear-gradient(90deg, transparent, rgba(203,186,245,.35), transparent); }
.moon span { width: 42px; height: 42px; display: grid; place-items: center; position: absolute; left: 50%; top: 50%; border: 1px solid rgba(246,212,123,.3); border-radius: 50%; color: var(--gold); background: #1a2342; box-shadow: 0 0 22px rgba(246,212,123,.16); font-size: 24px; transform: translate(-50%,-50%); }
.restart-button { min-height: 42px; border: 1px solid rgba(203,186,245,.22); border-radius: 13px; color: var(--lavender); background: rgba(45,52,88,.65); font-weight: 900; cursor: pointer; }
.restart-button:hover { background: rgba(60,68,112,.75); }

.memory-board { padding: clamp(10px, 2vw, 18px); display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(9px, 1.7vw, 16px); border: 1px solid rgba(105,214,196,.18); border-radius: 22px; background:
  radial-gradient(circle at 50% 40%, rgba(88,112,145,.17), transparent 48%),
  linear-gradient(160deg, rgba(8,17,35,.82), rgba(27,20,52,.88));
}

.memory-card { aspect-ratio: 1; min-width: 0; position: relative; padding: 0; border: 0; border-radius: clamp(13px, 2vw, 19px); background: transparent; perspective: 900px; cursor: pointer; touch-action: manipulation; }
.card-inner { width: 100%; height: 100%; position: relative; display: block; transform-style: preserve-3d; transition: transform .48s cubic-bezier(.2,.75,.2,1); }
.memory-card.flipped .card-inner,
.memory-card.matched .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; overflow: hidden; display: grid; place-items: center; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-back { border: 2px solid rgba(203,186,245,.28); background:
  radial-gradient(circle at 50% 38%, rgba(105,214,196,.16), transparent 28%),
  repeating-radial-gradient(circle at 50% 50%, transparent 0 13px, rgba(203,186,245,.055) 14px 15px),
  linear-gradient(145deg, #2e2147, #172440); box-shadow: inset 0 0 24px rgba(0,0,0,.3), 0 8px 18px rgba(0,0,0,.22); }
.card-back::before { content: "✦"; width: 46%; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid rgba(246,212,123,.5); border-radius: 50% 50% 42% 58%; color: var(--gold); background: rgba(10,16,35,.35); box-shadow: 0 0 20px rgba(246,212,123,.12); font-size: clamp(1.4rem, 4vw, 2.5rem); transform: rotate(-8deg); }
.card-front { border: 2px solid rgba(246,212,123,.55); background: #172039; transform: rotateY(180deg); box-shadow: inset 0 0 15px rgba(0,0,0,.25); }
.card-front img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }
.memory-card:hover:not(.flipped,.matched) .card-inner { transform: translateY(-4px) rotateZ(.8deg); }
.memory-card.matched { cursor: default; }
.memory-card.matched .card-front { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(105,214,196,.16), 0 0 30px rgba(105,214,196,.28); animation: match-glow 1.2s ease-in-out infinite alternate; }
@keyframes match-glow { to { box-shadow: 0 0 0 3px rgba(105,214,196,.2), 0 0 42px rgba(105,214,196,.42); } }

.game-status { margin: 13px 0 0; text-align: center; color: var(--muted); font-size: .82rem; font-weight: 800; }
.game-overlay { position: absolute; inset: 0; z-index: 8; padding: 20px; display: grid; place-items: center; border-radius: inherit; background: rgba(7,12,29,.66); backdrop-filter: blur(8px); }
.game-overlay.hidden { display: none; }
.overlay-card { width: min(490px, 94%); padding: clamp(28px, 5vw, 46px); text-align: center; border: 1px solid rgba(203,186,245,.35); border-radius: 28px; background: linear-gradient(155deg, rgba(31,39,73,.97), rgba(32,23,54,.98)); box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.08); }
.overlay-moon { width: 78px; height: 78px; margin: 0 auto 18px; display: grid; place-items: center; border: 1px solid rgba(246,212,123,.45); border-radius: 50%; color: var(--gold); background: radial-gradient(circle, rgba(246,212,123,.12), transparent 67%); box-shadow: 0 0 36px rgba(246,212,123,.18); font-size: 46px; }
.overlay-card h2 { margin: 0 0 10px; font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.06; }
.overlay-card > p:not(.eyebrow) { margin: 0 auto 24px; color: var(--muted); line-height: 1.55; }
.start-button { width: 100%; min-height: 57px; display: flex; align-items: center; justify-content: center; gap: 15px; border: 1px solid rgba(246,212,123,.7); border-radius: 16px; color: #211b30; background: linear-gradient(135deg, #ffe8a5, #e7bd64); box-shadow: 0 7px 0 #997034, 0 16px 35px rgba(246,212,123,.13); font-weight: 900; cursor: pointer; }
.start-button:hover { transform: translateY(-2px); }
.start-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #997034; }
.overlay-card small { display: block; margin-top: 18px; color: #8f8aa4; }

.creature-strip { width: min(1040px, calc(100% - 32px)); margin: 0 auto 80px; padding: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; border-top: 1px solid rgba(203,186,245,.12); border-bottom: 1px solid rgba(203,186,245,.12); }
.creature-strip > p { margin: 0 10px 0 0; color: var(--muted); font-weight: 900; }
.creature-strip > div { padding: 8px 13px; border: 1px solid rgba(203,186,245,.14); border-radius: 99px; color: #d9d2ed; background: rgba(35,43,78,.55); font-size: .84rem; font-weight: 800; }

footer { min-height: 110px; padding: 24px max(20px, calc((100% - 1040px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid rgba(203,186,245,.13); color: white; background: #080d1c; }
.footer-brand { font-size: 1.4rem; }
footer p { color: #8f8ba3; font-size: .85rem; }

:focus-visible { outline: 4px solid var(--gold); outline-offset: 4px; }

@media (max-width: 700px) {
  .game-bar { grid-template-columns: 90px 1fr 105px; }
  .restart-button { grid-column: span 3; width: 100%; }
  .memory-board { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 470px) {
  .site-header { min-height: 68px; padding-inline: 14px; }
  .brand { font-size: 1.35rem; }
  .brand-mark { width: 34px; height: 34px; }
  #soundText { display: none; }
  .hero { padding: 48px 18px 28px; }
  .hero h1 { font-size: 4rem; }
  .game-shell { padding: 8px; border-radius: 22px; }
  .game-bar { gap: 7px; padding-inline: 4px; }
  .moon span { width: 35px; height: 35px; }
  .stat strong { font-size: 1.35rem; }
  .memory-board { padding: 8px; gap: 8px; border-radius: 17px; }
  .game-overlay { padding: 9px; }
  .overlay-card { padding: 26px 19px 30px; border-radius: 22px; }
  .overlay-moon { width: 64px; height: 64px; font-size: 38px; }
  .overlay-card h2 { font-size: 1.85rem; }
  .overlay-card > p:not(.eyebrow) { font-size: .9rem; }
  footer { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
