
:root {
  --green: #244b2a;
  --green-2: #6d8b60;
  --rose: #dca6a6;
  --cream: #fffdf7;
  --gold: #c99b2d;
  --ink: #203323;
  --shadow: 0 10px 28px rgba(35, 64, 39, .15);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background-color: #fff;
  background-image: url("assets/brand/fondo-memorama.png");
  background-repeat: no-repeat;
  background-position: center top;
  background-size: 100% 100%;
  background-attachment: fixed;
}

button { font: inherit; }
.page-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 34px;
}
.hero {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 24px;
  padding: 18px 26px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(36,75,42,.12);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.logo {
  width: 142px;
  max-height: 105px;
  object-fit: contain;
  background: #fff;
  border-radius: 16px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--green-2);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .16em;
}
h1,h2,p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--green);
  font-size: clamp(2rem, 4vw, 3.75rem);
  line-height: 1;
}
.hero-copy > p:last-child { margin: 0; max-width: 700px; line-height: 1.55; }
.game-wrap { margin-top: 22px; }

.difficulty-panel {
  display: grid;
  grid-template-columns: minmax(180px, .7fr) 1.8fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px;
  background: rgba(255,255,255,.94);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.difficulty-copy { padding: 8px 12px; }
.difficulty-copy span {
  display: block; color: #738071; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
}
.difficulty-copy strong {
  display: block; margin-top: 4px; color: var(--green); font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem;
}
.difficulty-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.difficulty-btn {
  min-height: 58px; border: 1px solid rgba(36,75,42,.14); border-radius: 13px; background: #f7f4eb; color: var(--green); cursor: pointer;
  transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}
.difficulty-btn span, .difficulty-btn small { display: block; }
.difficulty-btn span { font-weight: 800; font-size: .98rem; }
.difficulty-btn small { margin-top: 2px; color: #738071; font-size: .7rem; }
.difficulty-btn:hover { transform: translateY(-1px); }
.difficulty-btn.is-active { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(36,75,42,.18); }
.difficulty-btn.is-active small { color: rgba(255,255,255,.78); }
.difficulty-btn:focus-visible { outline: 4px solid rgba(201,155,45,.45); outline-offset: 3px; }
.toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr)) auto;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,.94);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.stat {
  padding: 10px 14px;
  border-radius: 13px;
  background: #f7f4eb;
  border: 1px solid rgba(36,75,42,.08);
}
.stat span { display:block; color:#738071; font-size:.72rem; text-transform:uppercase; letter-spacing:.08em; }
.stat strong { display:block; margin-top:3px; font-size:1.08rem; color:var(--green); }
.restart {
  border: 0;
  border-radius: 13px;
  padding: 0 19px;
  min-height: 54px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(36,75,42,.18);
}
.restart:hover { filter: brightness(1.08); }
.restart:focus-visible, .memory-card:focus-visible { outline: 4px solid rgba(201,155,45,.45); outline-offset: 3px; }
.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-top: 16px;
  padding: 16px;
  background: rgba(255,255,255,.72);
  border-radius: 24px;
  box-shadow: var(--shadow);
  perspective: 1200px;
}

.board[data-difficulty="easy"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}
.board[data-difficulty="medium"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.board[data-difficulty="hard"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1.10 / 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}
.memory-card[disabled] { cursor: default; }
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .48s cubic-bezier(.2,.72,.2,1);
}
.memory-card.is-flipped .card-inner,
.memory-card.is-matched .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 14px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 6px 15px rgba(27,67,35,.18);
  border: 2px solid rgba(36,75,42,.24);
}
.card-back {
  display: grid;
  place-items: center;
  background: #fff url("assets/brand/fondo-memorama.png") center/cover no-repeat;
}
.card-back::after {
  content: "CONAPLOR";
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(255,255,255,.88);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: clamp(.52rem, .9vw, .8rem);
  letter-spacing: .05em;
}
.card-front {
  transform: rotateY(180deg);
  background: var(--cream);
}
.card-front img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
}
.memory-card.is-matched .card-face { box-shadow: 0 0 0 4px rgba(201,155,45,.42), 0 8px 20px rgba(36,75,42,.2); }
footer {
  margin-top: 18px;
  padding: 14px 18px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  color:#526653;
  font-size:.76rem;
  background: rgba(255,255,255,.8);
  border-radius: 14px;
}
.win-dialog {
  border: 0;
  padding: 0;
  border-radius: 22px;
  width: min(520px, calc(100% - 32px));
  box-shadow: 0 24px 70px rgba(24,45,27,.28);
}
.win-dialog::backdrop { background: rgba(22,49,27,.58); backdrop-filter: blur(4px); }
.win-card { padding: 34px; text-align:center; background:#fffdf7; }
.win-card h2 { color:var(--green); font-family:Georgia, "Times New Roman", serif; font-size:2rem; }
.win-card .restart { min-width: 170px; }

@media (max-width: 950px) {
  .difficulty-panel { grid-template-columns: 1fr; gap: 6px; }
  .toolbar { grid-template-columns: repeat(3, 1fr); }
  .restart { grid-column: 1 / -1; }
  .board[data-difficulty="hard"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  body { background-size: auto 100%; }
  .page-shell { width: min(100% - 18px, 1220px); padding-top: 10px; }
  .hero { grid-template-columns: 86px 1fr; gap:12px; padding:12px; border-radius:18px; }
  .logo { width:82px; max-height:78px; }
  .hero-copy > p:last-child { font-size:.82rem; }
  h1 { font-size: 1.75rem; }
  .difficulty-panel { padding:8px; gap:4px; }
  .difficulty-copy { padding:6px 8px; }
  .difficulty-buttons { gap:6px; }
  .difficulty-btn { min-height:52px; padding:6px 4px; }
  .difficulty-btn span { font-size:.86rem; }
  .difficulty-btn small { font-size:.64rem; }
  .toolbar { gap:7px; padding:8px; }
  .stat { padding:8px; }
  .stat strong { font-size:.92rem; }
  .board[data-difficulty="easy"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board[data-difficulty="medium"],
  .board[data-difficulty="hard"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .board { gap:8px; padding:9px; border-radius:18px; }
  .card-face { border-radius:10px; border-width:1px; }
  footer { flex-direction:column; }
}
@media (prefers-reduced-motion: reduce) {
  .card-inner { transition: none; }
}
