/* =======================================
   VARIABLES
======================================= */
:root {
  --cyan: #00ffff;
  --magenta: #ff00ff;
  --yellow: #ffeb3b;
  --card-size: 110px;
  --gap: 12px;
  --title-size: 2.2rem;
  --instructions-size: 1rem;
  --button-size: 0.9rem;
  --feedback-size: 1.4rem;
  --winner-size: 2rem;
}

/* =======================================
   GLOBAL BODY & BASE STYLES
======================================= */
html, body { height: 100%; }
body {
  font-family: 'Press Start 2P', cursive;
  background: radial-gradient(circle at center, #0a0a0a, #000);
  color: #fff;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  padding: 20px;
  animation: flicker 3s infinite;
  text-align: center;
}

/* =======================================
   HEADINGS
======================================= */
h1 {
  font-size: var(--title-size);
  color: var(--cyan);
  text-shadow: 0 0 10px var(--magenta), 0 0 20px var(--magenta), 0 0 30px var(--cyan);
  margin: 0 0 24px 0;
  letter-spacing: 2px;
}

/* =======================================
   INSTRUCTIONS
======================================= */
#instructions {
  font-size: var(--instructions-size);
  max-width: 600px;
  margin: 0 auto 20px auto;
  line-height: 1.5;
}

/* =======================================
   BUTTONS
======================================= */
.button-row {
  display: flex;
  gap: 15px;
  margin: 15px 0;
}

button {
  padding: 14px 22px;
  font-size: var(--button-size);
  background: var(--magenta);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 8px var(--cyan), 0 0 16px var(--magenta);
  position: relative;
  overflow: hidden;
  font-family: 'Press Start 2P', cursive;
}

button:hover { animation: glow 1.5s infinite alternate; }

@keyframes glow {
  from { box-shadow: 0 0 8px var(--cyan), 0 0 16px var(--magenta); }
  to   { box-shadow: 0 0 16px var(--cyan), 0 0 32px var(--magenta); }
}

button::after {
  content: "";
  position: absolute; inset: -100% 0 0 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.07) 0px,
    rgba(255,255,255,0.07) 2px,
    transparent 2px,
    transparent 4px
  );
  animation: scan 4s linear infinite;
  pointer-events: none;
}
@keyframes scan { from { transform: translateY(0); } to { transform: translateY(50%); } }

/* =======================================
   SCREENS (HOME / GAME)
======================================= */
#homeScreen, #gameScreen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
  border-radius: 20px;
  transform: perspective(900px) rotateX(2deg);
  box-shadow: inset 0 0 40px rgba(0,255,255,0.25);
  margin: 12px;
}

/* =======================================
   CARD GRID & CARDS
======================================= */
.grid {
  display: grid;
  grid-template-columns: repeat(5, var(--card-size));
  grid-auto-rows: var(--card-size);
  gap: var(--gap);
  justify-content: center;
  margin-top: 20px;
}

.card { width: var(--card-size); height: var(--card-size); perspective: 800px; cursor: pointer; }
.card-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.6s; }
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--cyan); border-radius: 8px; backface-visibility: hidden;
  text-shadow: 0 0 6px var(--cyan);
}
.card-front { background: #111; color: #0af; }
.card-back { background: #222; color: #fff; transform: rotateY(180deg); font-size: 2rem; }

.card.matched { pointer-events: none; filter: saturate(1.2) drop-shadow(0 0 8px var(--cyan)); }
.card.shake .card-inner { animation: shake 0.4s; }
@keyframes shake {
  0%,100% { transform: rotateY(0) translateX(0); }
  25% { transform: rotateY(0) translateX(-6px); }
  50% { transform: rotateY(0) translateX(6px); }
  75% { transform: rotateY(0) translateX(-6px); }
}

/* =======================================
   FEEDBACK & WINNER
======================================= */
#feedback { font-size: var(--feedback-size); margin-top: 12px; min-height: 1.2rem; }
#winner {
  display: none;
  font-size: var(--winner-size);
  margin-top: 18px;
  color: var(--yellow);
  text-shadow: 0 0 10px orange, 0 0 20px red;
  animation: pulse 1.5s infinite;
  text-align: center;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

#chicken { display: none; width: 200px; margin-top: 20px; }

/* =======================================
   BODY OVERLAYS & EFFECTS
======================================= */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.03) 0px,
    rgba(255,255,255,0.03) 2px,
    transparent 2px,
    transparent 4px
  );
  animation: crt-scan 6s linear infinite; z-index: 9999;
}

@keyframes crt-scan { from { transform: translateY(0); } to { transform: translateY(50%); } }
@keyframes flicker { 0%,19%,21%,23%,25%,54%,56%,100%{opacity:1;} 20%,24%,55%{opacity:.97;} }
