/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #111;
  display: flex; justify-content: center; align-items: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}

/* ── Wrapper ──────────────────────────────────────────────── */
#game-wrapper {
  position: relative;
  width:  min(430px, 100vw);
  height: min(800px, 100svh);
  background: #F5C59F;
  border-radius: 36px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
@media (max-width: 430px) { #game-wrapper { border-radius: 0; } }

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  justify-content: center; align-items: center;
  gap: 16px; z-index: 10;
}
.screen.active { display: flex; }
#start-screen, #win-screen { background: #F5C59F; }
#game-screen { background: #F5C59F; pointer-events: auto; justify-content: flex-start; }

/* ── HUD ──────────────────────────────────────────────────── */
#hud {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  padding: 24px 32px 12px;
  flex-shrink: 0;
}
.hud-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.hud-lbl {
  font-size: 11px; font-weight: 700;
  letter-spacing: 3px; color: rgba(58,42,26,.5);
}
.hud-val {
  font-size: 40px; font-weight: 900;
  letter-spacing: -2px; color: #3a2a1a;
  line-height: 1;
}

/* ── Board ────────────────────────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 8px 20px 24px;
  width: 100%;
  flex: 1;
  align-content: center;
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  aspect-ratio: 1;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .35s ease;
  touch-action: manipulation;
}

.card.flipped,
.card.matched {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute; inset: 0;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* back = face-down side shown by default */
.card-back {
  background: #3a2a1a;
  font-size: 1.6rem;
  color: #C4956A;
}

/* front = emoji, shown when flipped */
.card-front {
  background: #ffe8cc;
  transform: rotateY(180deg);
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  box-shadow: inset 0 0 0 2px rgba(58,42,26,.12);
}

.card.matched .card-front {
  background: #c8f0c8;
  box-shadow: inset 0 0 0 2px rgba(40,120,40,.2);
}

/* ── Logo ─────────────────────────────────────────────────── */
.logo {
  font-size: 5rem; line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(58,42,26,.3));
  animation: logoBounce 2s ease-in-out infinite;
}
@keyframes logoBounce {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ── Typography ───────────────────────────────────────────── */
.title {
  font-size: 56px; font-weight: 900;
  letter-spacing: -3px; color: #3a2a1a;
}
.subtitle {
  font-size: 18px; line-height: 1.5;
  color: #7a5a3a; text-align: center;
}

/* ── Score block ──────────────────────────────────────────── */
.score-block {
  background: rgba(0,0,0,.08);
  border-radius: 20px;
  padding: 20px 40px;
  display: flex; flex-direction: column; gap: 8px;
  text-align: center;
}
.score-row {
  display: flex; flex-direction: column; align-items: center;
}
.score-lbl {
  font-size: 11px; font-weight: 700;
  letter-spacing: 4px; color: #9a7a5a;
}
.score-val {
  font-size: 64px; font-weight: 900;
  line-height: 1; letter-spacing: -3px;
  color: #3a2a1a;
}
.score-val.accent { color: #C4956A; font-size: 44px; }

/* ── Button ───────────────────────────────────────────────── */
.btn {
  padding: 18px 52px;
  border: none; border-radius: 50px;
  background: #3a2a1a; color: #F5C59F;
  font-size: 17px; font-weight: 800;
  letter-spacing: 2px; cursor: pointer;
  transition: transform .1s, background .15s;
  touch-action: manipulation;
}
.btn:hover  { background: #5a4030; }
.btn:active { transform: scale(.95); }
