:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #111827;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--ink);
}

.wrap {
  max-width: 1100px;
  margin: 32px auto 48px;
  padding: 0 20px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

h1 { margin: 0 0 4px; font-size: 28px; }
.sub { margin: 0; color: var(--muted); }

.hud {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

#reset {
  border: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

#reset:hover { opacity: 0.9; }

.grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
}

.card {
  perspective: 1000px;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}

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

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.front {
  background: #e5e7eb;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #9ca3af;
}

.back {
  transform: rotateY(180deg);
  background: var(--card);
}

.back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.help {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}
