/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 50% -20%, rgba(124, 92, 255, 0.2) 0%, rgba(0,0,0,0) 60%), #0b0c0f;
  color: #e6e7ea;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}

.game-shell {
  width: 100%;
  max-width: 28rem;          
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  row-gap: 1rem;
  background: #13151a;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 48px rgba(0,0,0,0.8);
  padding: 1rem 1rem 1.5rem;
}

.top {
  display: grid;
  row-gap: .5rem;
}

.title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  text-align: left;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
  color: #a9adba;
  font-size: .9rem;
}

.stat {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: .4rem .6rem;
  color: #fff;
  font-weight: 500;
  min-width: 4.5rem;
  text-align: center;
}

.reset-btn {
  background: #ef4444;
  border: 1px solid transparent;
  color: #fff;
  border-radius: 8px;
  font-size: .9rem;
  line-height: 1;
  padding: .5rem .6rem;
  cursor: pointer;
}

.hint {
  font-size: .8rem;
  color: #a9adba;
  line-height: 1.4;
}

.board {
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(0,0,0,.4));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: .75rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.grid {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;

  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);

  gap: .5rem;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 800px;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
}

.card-inner {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: transparent;
  transform-style: preserve-3d;
  transition: transform .4s ease;
}

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

.card-face,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;

  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.5));
  border: 1px solid rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 32px rgba(0,0,0,.7);
}

.card-back {
  color: #a9adba;
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.card-face {
  transform: rotateY(180deg);
  background: #1a1c24;
  border: 1px solid rgba(124,92,255,.4);
}

.card-face img {
  max-width: 70%;
  max-height: 70%;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.8));
}

.announce {
  text-align: center;
  min-height: 1.4em;
  font-size: .8rem;
  line-height: 1.4;
  color: #a9adba;
}

.foot {
  text-align: center;
  font-size: .7rem;
  color: #444a5b;
  line-height: 1.4;
  margin-top: .5rem;
}