/* Souvenaid Memotest — estilos (fiel al prototipo de Claude Design) */

:root {
  --sv-green: #00843D;
  --sv-green-dark: #006B31;
  --sv-purple: #6B4FA0;
  --sv-ink: #2A3630;
  --sv-body: #3D4A42;
  --sv-muted: #5B6660;
  --sv-soft: #7A867F;
  --sv-footer: #8A948E;
  --sv-border: #C9D6CE;
  --sv-error: #B3261E;
  --sv-error-bg: #FDECEA;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: #F3F6F4;
  font-family: 'Nunito', system-ui, sans-serif;
}

a { color: var(--sv-green); }
a:hover { color: var(--sv-green-dark); }

input:focus { outline: 3px solid var(--sv-purple); outline-offset: 1px; }

[hidden] { display: none !important; }

@keyframes sv-match {
  0% { transform: scale(1); }
  40% { transform: scale(1.07); }
  100% { transform: scale(1); }
}
@keyframes sv-pop {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ===== Estructura ===== */

.app {
  height: 100dvh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, #F7FAF8 0%, #EDF3EF 100%);
}

.brand-header {
  width: 100%;
  background: var(--sv-purple);
  color: #FFFFFF;
  /* En celulares reales, baja para no chocar con la barra de estado */
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-lockup { text-align: center; }

.brand-eyebrow {
  font-size: 12px;
  letter-spacing: 0.22em;
  font-weight: 700;
  opacity: 0.85;
}

.brand-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand-reg { font-size: 13px; vertical-align: super; }

.main {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 20px);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.app-footer {
  width: 100%;
  text-align: center;
  padding: 16px;
  font-size: 14px;
  color: var(--sv-footer);
  flex-shrink: 0;
}

/* ===== Pantalla 1: Bienvenida ===== */

.screen-welcome {
  animation: sv-pop 0.4s ease-out;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
}

.welcome-copy {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.welcome-copy h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  color: var(--sv-green);
  line-height: 1.2;
}

.welcome-copy p {
  margin: 0;
  font-size: 19px;
  color: var(--sv-body);
  line-height: 1.5;
}

.lead-form {
  background: #FFFFFF;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(20, 60, 40, 0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 18px;
  font-weight: 700;
  color: var(--sv-ink);
}

.field input {
  font-size: 19px;
  font-family: inherit;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--sv-border);
  color: var(--sv-ink);
  background: #FFFFFF;
}

.consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  padding: 4px 0;
}

.consent input {
  width: 26px;
  height: 26px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--sv-green);
}

.consent span {
  font-size: 18px;
  color: var(--sv-body);
  line-height: 1.45;
}

.form-error {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--sv-error);
  background: var(--sv-error-bg);
  border-radius: 10px;
  padding: 10px 14px;
}

.btn-primary {
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  color: #FFFFFF;
  background: var(--sv-green);
  border: none;
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  min-height: 60px;
}
.btn-primary:hover { background: var(--sv-green-dark); }
.btn-primary:active { transform: scale(0.98); }

.privacy-note {
  margin: 0;
  text-align: center;
  font-size: 15px;
  color: var(--sv-soft);
}

/* ===== Pantalla 2: Juego ===== */

.screen-game {
  animation: sv-pop 0.4s ease-out;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 16px);
}

.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.greeting {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--sv-ink);
}

.stats { display: flex; gap: 8px; }

.stat-pill {
  font-size: 18px;
  color: #4E5A53;
  background: #FFFFFF;
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 1px 4px rgba(20, 60, 40, 0.08);
  white-space: nowrap;
}

.stat-pill strong { color: var(--sv-green); }

.game-hint {
  margin: 0;
  font-size: 18px;
  color: var(--sv-muted);
  flex-shrink: 0;
}

/* El tablero llena todo el espacio disponible: 4 × 4 que se estiran */
.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(8px, 2vw, 12px);
  width: 100%;
  margin: 0 auto;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 56px;
  perspective: 700px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.card:focus-visible {
  outline: 3px solid var(--sv-purple);
  outline-offset: 2px;
  border-radius: 16px;
}

.card.is-matched { animation: sv-match 0.5s ease-out; }

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform: rotateY(0deg);
  display: block;
}

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

.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 2px 6px rgba(20, 60, 40, 0.18);
}

.card-front { transform: rotateY(180deg); }

/* Acierto: la carta se agrisa (queda "resuelta") y aparece un check verde */
.card.is-matched .card-front {
  filter: grayscale(0.5) brightness(1.03);
}

.card-check {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  max-width: 48px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(0.5);
  border-radius: 50%;
  background: var(--sv-green);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 2px 10px rgba(20, 60, 40, 0.35);
  z-index: 3;
  pointer-events: none;
}

.card-check svg { width: 62%; height: 62%; }

.card.is-matched .card-check {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ===== Pantalla 3: Resultado ===== */

.screen-result {
  animation: sv-pop 0.45s ease-out;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  text-align: center;
  margin-top: 16px;
}

.result-badge {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  box-shadow: 0 4px 14px rgba(20, 60, 40, 0.18);
}

.screen-result h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--sv-green);
  line-height: 1.25;
}

.result-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.result-chip {
  font-size: 19px;
  color: var(--sv-ink);
  background: #FFFFFF;
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: 0 1px 6px rgba(20, 60, 40, 0.1);
}

.result-copy {
  margin: 0;
  font-size: 19px;
  color: var(--sv-body);
  line-height: 1.55;
  max-width: 420px;
}

.btn-result { padding: 18px 40px; }

.btn-secondary {
  font-family: inherit;
  font-size: 19px;
  font-weight: 700;
  color: var(--sv-purple);
  background: transparent;
  border: 2px solid var(--sv-purple);
  border-radius: 14px;
  padding: 12px 28px;
  cursor: pointer;
}
.btn-secondary:hover { background: #F1EDF8; }

/* ===== Desktop / tablet: tablero cuadrado que usa el ancho ===== */
@media (min-width: 700px) {
  .main { max-width: 780px; }

  /* Formulario y copy no se estiran de más; quedan centrados y legibles */
  .welcome-copy { max-width: 560px; align-self: center; }
  .lead-form { max-width: 520px; width: 100%; align-self: center; }

  /* Tablero: grid cuadrado, fichas cuadradas, más grande y centrado */
  .board {
    flex: 0 1 auto;
    aspect-ratio: 1 / 1;
    grid-template-rows: repeat(4, 1fr);
    width: 100%;
    max-width: 640px;
    margin: auto;              /* centra vertical y horizontalmente en el área de juego */
    gap: 14px;
  }

  /* Tipografía un toque más grande en desktop */
  .welcome-copy h1 { font-size: 34px; }
  .greeting { font-size: 21px; }
}

/* Respeto por usuarios con animaciones reducidas */
@media (prefers-reduced-motion: reduce) {
  .screen, .card.is-matched { animation: none; }
  .card-inner { transition: none; }
}
