/* ── Memory Match — Memphis-design playroom ─────────────────────────
   Cream canvas, floating geometric confetti in tomato/cobalt/
   mustard/mint, zigzag card backs, paper-cutout drop shadows. */

:root {
  --cream: #faf3e3;
  --tomato: #e8503a;
  --cobalt: #2b50c8;
  --mustard: #eeb02c;
  --mint: #4fc39a;
  --ink: #2a2732;
  --ink-soft: #7d7a88;
  --card: #ffffff;
  --line: #e9e2d2;
  --err: #d84343;
  --font-display: 'Baloo 2', cursive;
  --font-body: 'Karla', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.hidden { display: none !important; }

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.page { position: relative; display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; }

.wrap { position: relative; width: 100%; max-width: 520px; margin: 0 auto; padding: 0 20px; z-index: 1; }

main { flex: 1 0 auto; padding-bottom: 70px; }

/* ── Memphis confetti ─────────────────────────────────────────────── */
.confetti-bg { position: absolute; inset: 0; pointer-events: none; }

.shape { position: absolute; opacity: 0.8; animation: floaty 9s ease-in-out infinite; }

.shape.sq { top: 9%; left: 7%; width: 26px; height: 26px; background: var(--mustard); transform: rotate(18deg); }
.shape.sq2 { bottom: 16%; right: 9%; width: 20px; height: 20px; background: var(--mint); transform: rotate(-12deg); animation-delay: 3s; }

.shape.tri {
  top: 16%; right: 8%;
  width: 0; height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 28px solid var(--tomato);
  animation-delay: 1.5s;
}

.shape.tri2 {
  bottom: 30%; left: 5%;
  width: 0; height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 22px solid var(--cobalt);
  animation-delay: 4.5s;
}

.shape.zig {
  top: 48%; right: 4%;
  width: 46px; height: 12px;
  background: repeating-linear-gradient(-45deg, var(--cobalt) 0 6px, transparent 6px 12px);
  animation-delay: 2s;
}

.shape.dot {
  top: 66%; left: 8%;
  width: 34px; height: 34px;
  background: radial-gradient(circle, var(--tomato) 3px, transparent 3.5px);
  background-size: 11px 11px;
  animation-delay: 5s;
}

@keyframes floaty {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -16px; }
}

/* ── Hero ─────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 48px 0 22px; }

.kicker {
  display: inline-block;
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--card);
  background: var(--ink);
  padding: 6px 16px;
  border-radius: 4px;
  transform: rotate(-1.5deg);
  margin-bottom: 16px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 11vw, 3.9rem);
  line-height: 1;
}

.hero h1 .c1 { color: var(--tomato); text-shadow: 4px 4px 0 var(--mustard); }
.hero h1 .c2 { color: var(--cobalt); text-shadow: 4px 4px 0 var(--mint); }

.hero .sub { margin-top: 14px; color: var(--ink-soft); font-weight: 600; max-width: 340px; margin-left: auto; margin-right: auto; }

/* ── Notes ────────────────────────────────────────────────────────── */
.note {
  margin: 18px 0;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--card);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  text-align: center;
  font-weight: 600;
}

/* ── Card grid ────────────────────────────────────────────────────── */
.pick-line { text-align: center; font-weight: 700; margin-bottom: 18px; font-size: 1.05rem; }

.pick-line strong { color: var(--tomato); font-size: 1.3rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  perspective: 900px;
}

.match-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.match-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.35, 1.2, 0.5, 1);
}

.match-card.flipped .match-inner { transform: rotateY(180deg); }

.match-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 12px;
  border: 3px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-back {
  background:
    repeating-linear-gradient(-45deg, transparent 0 8px, rgba(255, 255, 255, 0.22) 8px 16px),
    var(--cobalt);
  box-shadow: 5px 5px 0 var(--ink);
}

.match-card:nth-child(3n+2) .match-back { background: repeating-linear-gradient(-45deg, transparent 0 8px, rgba(255,255,255,0.22) 8px 16px), var(--tomato); }
.match-card:nth-child(3n) .match-back { background: repeating-linear-gradient(-45deg, transparent 0 8px, rgba(255,255,255,0.25) 8px 16px), var(--mustard); }

.match-back::after {
  content: '?';
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.9);
}

.match-front {
  background: var(--card);
  transform: rotateY(180deg);
  font-size: 2.4rem;
  box-shadow: 5px 5px 0 var(--ink);
}

.match-card:hover:not(:disabled):not(.flipped) .match-inner { transform: translateY(-5px); }
.match-card:disabled:not(.flipped) { opacity: 0.55; cursor: default; }
.match-card:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; border-radius: 12px; }

/* ── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 26px 24px 28px;
  box-shadow: 8px 8px 0 var(--ink);
}

.card h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  text-align: center;
  margin-bottom: 18px;
}

/* Fields */
.field { margin-bottom: 14px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label {
  display: block;
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"] {
  width: 100%;
  padding: 13px 15px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  transition: box-shadow 0.15s ease;
}

input:focus { outline: none; box-shadow: 3px 3px 0 var(--mint); }
input.error { border-color: var(--err); }
input::placeholder { color: var(--ink-soft); opacity: 0.7; }

.fine { margin-top: 12px; text-align: center; color: var(--ink-soft); font-size: 0.85rem; font-weight: 600; }

.form-error { color: var(--err); font-weight: 800; text-align: center; margin-top: 12px; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 13px 30px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  line-height: 1.2;
}

.btn:hover:not(:disabled) { transform: translate(-2px, -2px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }

.btn-primary {
  background: var(--tomato);
  color: #fff;
  box-shadow: 5px 5px 0 var(--ink);
}

.btn-primary:hover:not(:disabled) { box-shadow: 7px 7px 0 var(--ink); }

.btn-ghost {
  background: var(--cream);
  color: var(--ink);
  font-size: 0.9rem;
  padding: 9px 20px;
  box-shadow: 4px 4px 0 var(--ink);
}

.btn-block { width: 100%; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result ───────────────────────────────────────────────────────── */
.result-card { text-align: center; margin-top: 12px; }

.result-kicker {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mint);
  margin-bottom: 8px;
}

.lose-kicker { color: var(--ink-soft); }

.result-card h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; }

.code-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 6px;
  flex-wrap: wrap;
}

.code {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0.1em;
  background: var(--ink);
  color: var(--mustard);
  padding: 10px 22px;
  border-radius: 10px;
}

.qr-wrap { margin: 16px 0 6px; }

.qr-wrap img { width: 150px; height: 150px; border-radius: 10px; border: 4px solid var(--ink); }

.qr-note { color: var(--ink-soft); font-size: 0.88rem; font-weight: 600; margin-top: 8px; }

.expiry { color: var(--tomato); font-weight: 800; font-size: 0.9rem; margin-top: 12px; }

.result-note { color: var(--ink-soft); font-weight: 600; margin-top: 12px; font-size: 0.92rem; }

/* ── Footer ───────────────────────────────────────────────────────── */
.footer {
  flex-shrink: 0;
  text-align: center;
  padding: 24px 20px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

#wbx-powered-by-slot { margin-top: 12px; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
  .card-grid { gap: 10px; }
  .match-front { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .match-inner { transition: none; }
}
