/* ── Game Board ── */
#game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  perspective: 1000px;
  position: relative;
  z-index: 1;
}

/* ── Card ── */
.card {
  aspect-ratio: 3 / 4;
  cursor: pointer;
  position: relative;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

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

.card-front,
.card-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  border: 2px solid;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: 'Courier New', monospace;
}

/* ── Card Back ── */
.card-back {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 243, 255, 0.03) 0px,
      rgba(0, 243, 255, 0.03) 2px,
      transparent 2px,
      transparent 4px
    ),
    rgba(5, 5, 8, 0.95);
  border-color: rgba(0, 243, 255, 0.4);
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.2), inset 0 0 10px rgba(0, 243, 255, 0.1);
}

.card-back::before {
  content: "?";
  font-size: 36px;
  color: rgba(0, 243, 255, 0.3);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.card:hover .card-back {
  border-color: #00f3ff;
  box-shadow: 0 0 25px rgba(0, 243, 255, 0.5), inset 0 0 15px rgba(0, 243, 255, 0.2);
}

/* ── Card Front ── */
.card-front {
  transform: rotateY(180deg);
  background: rgba(5, 5, 8, 0.95);
  gap: 8px;
}

.card-symbol {
  font-size: 38px;
  text-shadow: 0 0 15px currentColor;
  line-height: 1;
}

.card-name {
  font-size: 13px;
  letter-spacing: 2px;
  text-shadow: 0 0 8px currentColor;
  text-transform: uppercase;
}

/* ── Color Classes ── */
.card.cyan .card-front {
  color: #00f3ff;
  border-color: #00f3ff;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.4), inset 0 0 10px rgba(0, 243, 255, 0.2);
}

.card.pink .card-front {
  color: #fff; /* NOSONAR */
  border-color: #fff; /* NOSONAR */
  box-shadow: 0 0 20px rgba(255, 0, 85, 0.4), inset 0 0 10px rgba(255, 0, 85, 0.2);
}

/* ── Match Animation ── */
.card.matched .card-inner {
  animation: match-glow 0.6s ease;
}

.card.matched.cyan .card-front {
  box-shadow: 0 0 40px rgba(0, 243, 255, 0.8), inset 0 0 20px rgba(0, 243, 255, 0.4);
}

.card.matched.pink .card-front {
  box-shadow: 0 0 40px rgba(255, 0, 85, 0.8), inset 0 0 20px rgba(255, 0, 85, 0.4);
}

@keyframes match-glow {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.08); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* ── Error Animation ── */
.card.error .card-front {
  animation: error-flash 0.5s ease;
}

@keyframes error-flash {
  0%, 100% { box-shadow: inherit; }
  25% { box-shadow: 0 0 30px rgba(255, 0, 0, 0.8); border-color: #ff0000; }
  50% { transform: rotateY(180deg) translateX(-4px); }
  75% { transform: rotateY(180deg) translateX(4px); box-shadow: 0 0 30px rgba(255, 0, 0, 0.8); border-color: #ff0000; }
}

/* ── Glitch on hover (unflipped only) ── */
.card:not(.flipped):not(.matched) .card-back::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.3s;
}

.card:not(.flipped):not(.matched):hover .card-back::after {
  opacity: 0.5;
  animation: glitch-anim 0.2s infinite;
  background: rgba(0, 243, 255, 0.3);
}

@keyframes glitch-anim {
  0%, 100% {
    transform: translate(0);
    opacity: 0.5;
  }
  33% {
    transform: translate(-2px, 2px);
    clip-path: inset(20% 0 20% 0);
    opacity: 0.6;
  }
  66% {
    transform: translate(2px, -2px);
    clip-path: inset(40% 0 40% 0);
    opacity: 0.6;
  }
}

/* ── Grid Variants for Difficulty ── */
#game-board.grid-easy {
  grid-template-columns: repeat(3, 1fr);
  max-width: 400px;
  margin: 0 auto;
}

#game-board.grid-medium {
  grid-template-columns: repeat(4, 1fr);
}

#game-board.grid-hard {
  grid-template-columns: repeat(6, 1fr);
}

#game-board.grid-extreme {
  grid-template-columns: repeat(6, 1fr);
  max-width: 900px;
}

.grid-extreme .card-symbol {
  font-size: 30px;
}

.grid-extreme .card-name {
  font-size: 14px;
}

.grid-extreme .card-back::before {
  font-size: 28px;
}

/* ── EXTREME Countdown Critical ── */
@keyframes screen-shake {
  0%, 100% { transform: translate(0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -3px); }
}

.countdown-critical .cyber-table {
  animation: screen-shake 0.15s infinite;
}

.countdown-critical #timer {
  color: #ff0000 !important;
  text-shadow: 0 0 15px rgba(255, 0, 0, 0.8) !important;
  animation: blink-text 0.5s steps(2) infinite;
}
