* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Arial", sans-serif;
  background: #fdfbf7;
  background-image: radial-gradient(
      circle at 20% 80%,
      #ff6b6b10 0%,
      transparent 50%
    ),
    radial-gradient(circle at 80% 20%, #2ecc7110 0%, transparent 50%);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.game-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.category-selector {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 900px;
  padding: 40px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
  text-align: center;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.selector-header {
  margin-bottom: 30px;
}

.selector-header h3 {
  font-size: 2rem;
  color: #2c3e50;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.selector-header p {
  color: #7f8c8d;
  font-size: 1rem;
}

.category-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
}

.cat-btn {
  background: #fff;
  color: #555;
  border: 2px solid #e0e0e0;
  padding: 12px 24px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.cat-btn:hover {
  border-color: #a61c1c;
  color: #a61c1c;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(166, 28, 28, 0.15);
}

.cat-btn.selected {
  background: #a61c1c;
  color: white;
  border-color: #a61c1c;
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(166, 28, 28, 0.3);
}

.btn-primary {
  background: linear-gradient(135deg, #27ae60, #219150);
  color: white;
  border: none;
  padding: 15px 50px;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(46, 204, 113, 0.6);
  background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.game-wrapper {
  flex-grow: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 15px;
  overflow: hidden;
  justify-content: center;
  align-items: center;
}

.game-board {
  display: grid !important;
  grid-auto-flow: row !important;
  gap: 10px;
  width: 100%;
  height: 100%;
  max-height: 90vh, 800px;
  margin: 0 auto;
  justify-content: center;
  align-content: center;
  padding: 10px;
  overflow: hidden;
  grid-auto-rows: 1fr;
  max-width: 1200px;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: pointer;
  perspective: 1000px;

  min-width: 0;
  min-height: 0;

  overflow: hidden;
}

.card-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease-in-out;
  transform-style: preserve-3d;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  background: white;
  border: 2px solid #d4af37;
  box-sizing: border-box;
  overflow: hidden;
}

.card-front {
  border: 2px solid #d4af37;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front::after {
  content: "";
  width: 82%;
  height: 82%;
  background-image: url("../images/mari.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.card-back {
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 2px solid #d4af37;
  overflow: hidden;
  background: white;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.card-text-node {
  font-weight: bold;
  color: #2c3e50;
  font-size: clamp(0.6rem, 1.5vw, 0.9rem);
  text-align: center;
  line-height: 1.1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 2px;
  box-sizing: border-box;
}

.controls {
  flex-shrink: 0;
  margin-top: 8px;
  text-align: center;
  padding-bottom: 10px;
}

.controls .btn-primary {
  padding: 10px 30px;
  font-size: 1rem;
  background: linear-gradient(135deg, #95a5a6, #7f8c8d);
  box-shadow: 0 5px 15px rgba(149, 165, 166, 0.4);
}

.controls .btn-primary:hover {
  box-shadow: 0 8px 20px rgba(149, 165, 166, 0.6);
}

.win-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.win-content {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.win-content h2 {
  font-size: 2.5rem;
  margin-bottom: 15px;
  color: #2c3e50;
}

.win-content p {
  font-size: 1.2rem;
  margin: 8px 0;
  color: #555;
}

.win-stats {
  margin: 20px 0;
  font-size: 1.1rem;
  background: #f9f9f9;
  padding: 15px;
  border-radius: 10px;
}

.win-content button {
  background: #a61c1c;
  color: white;
  font-size: 1.1rem;
  padding: 12px 30px;
  margin-top: 10px;
}

.win-content button:hover {
  background: #8a1616;
}
@media (max-width: 1200px) {
  .game-board {
    max-width: 95vw;
    max-height: 85vh;
    gap: 6px;
    padding: 8px;
  }

  .card-text-node {
    font-size: clamp(0.45rem, 1.1vw, 0.7rem);
  }
}

@media (max-width: 768px) {
  .game-board {
    gap: 5px;
    padding: 6px;
  }

  .card-text-node {
    font-size: clamp(0.4rem, 1.3vw, 0.6rem);
  }
}

@media (max-width: 600px) {
  .category-selector {
    padding: 20px;
    width: 95%;
  }

  .selector-header h3 {
    font-size: 1.5rem;
  }

  .cat-btn {
    font-size: 0.85rem;
    padding: 8px 16px;
  }

  .win-content h2 {
    font-size: 2rem;
  }

  .game-board {
    gap: 4px;
    padding: 5px;
  }

  .card-text-node {
    font-size: clamp(0.35rem, 1.5vw, 0.55rem);
  }
}

@media (max-width: 480px) {
  .game-board {
    gap: 4px;
    padding: 4px;
  }

  .card-text-node {
    font-size: clamp(0.35rem, 1.5vw, 0.5rem);
  }
}

.rules-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.rules-modal.active {
  display: flex;
  opacity: 1;
}

.rules-content {
  background: white;
  padding: 30px;
  border-radius: 20px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.rules-modal.active .rules-content {
  transform: scale(1);
}

.rules-content h3 {
  font-size: 1.8rem;
  color: #2c3e50;
  margin-bottom: 20px;
}

.rules-content p {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 10px;
  line-height: 1.5;
}

.rules-content .btn-primary {
  margin-top: 20px;
  width: 100%;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card-inner {
    transition: none !important;
  }
}
@container (max-width: 400px) {
  .card-text-node {
    font-size: 0.5rem;
  }
}
