/* Card Styles - Grid, Flip Animation, States */

.tiles-container {
  display: flex;
  flex-direction: row;
  width: 98vw;
  min-height: 80vh;
  justify-content: center;
  align-items: center;
  margin: 1.5rem auto 0 auto;
  /* Added top margin to prevent touching the top of the screen */
  box-sizing: border-box;
  z-index: 1;
}

/* Grid System */
.tiles-grid {
  display: grid;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  flex: 1 1 auto;
  padding: 0;
  gap: var(--gap-sm);
  align-items: stretch;
  justify-items: stretch;
  contain: layout;
}

.tiles-grid[data-count="10"] {
  grid-template-columns: repeat(5, 1fr) !important;
  grid-template-rows: repeat(2, 1fr) !important;
}

.tiles-grid[data-count="12"] {
  grid-template-columns: repeat(4, 1fr) !important;
  grid-template-rows: repeat(3, 1fr) !important;
}

.tiles-grid[data-count="20"] {
  grid-template-columns: repeat(5, 1fr) !important;
  grid-template-rows: repeat(4, 1fr) !important;
}

.tiles-grid[data-count="28"] {
  grid-template-columns: repeat(4, 1fr) !important;
  grid-template-rows: repeat(7, 1fr) !important;
}

.tiles-grid[data-count="30"] {
  grid-template-columns: repeat(6, 1fr) !important;
  grid-template-rows: repeat(5, 1fr) !important;
}

/* Card Inner - 3D Flip Container */
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s ease-in-out;
  transform-style: preserve-3d;
  transform-origin: center center;
  box-sizing: border-box;
}

/* 3D Flip Effect */
.question-card.flipped .card-inner {
  transform: rotateY(180deg);
}

/* Shared Card Face Styles */
.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Concert One", cursive;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8);
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 4px 20px rgba(132, 250, 176, 0.4),
    0 2px 8px rgba(1, 87, 155, 0.2), 0 0 0 3px rgba(168, 237, 234, 0.3) inset;
  border: 2.5px solid rgba(79, 195, 247, 0.6);
  overflow: hidden;
  box-sizing: border-box;
}

/* Back Face - Card Number */
.card-back {
  background: linear-gradient(
    135deg,
    #667eea 0%,
    #764ba2 25%,
    #f093fb 50%,
    #f5576c 75%,
    #4facfe 100%
  );
  background-size: 300% 300%;
  color: #fff;
  font-size: 4em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 3;
  position: relative;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4),
    0 4px 16px rgba(245, 87, 108, 0.2), 0 0 0 3px rgba(255, 255, 255, 0.3) inset;
  border: 3px solid rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 255, 255, 0.3);
  font-weight: 900;
  letter-spacing: 0.05em;
}

.card-back::before {
  content: "";
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(
      circle at 30% 30%,
      rgba(255, 255, 255, 0.25) 2px,
      transparent 2px
    ),
    radial-gradient(
      circle at 70% 70%,
      rgba(255, 255, 255, 0.2) 1px,
      transparent 1px
    ),
    radial-gradient(
      circle at 50% 10%,
      rgba(255, 255, 255, 0.15) 1px,
      transparent 1px
    ),
    radial-gradient(
      circle at 20% 80%,
      rgba(255, 255, 255, 0.18) 1px,
      transparent 1px
    );
  background-size: 40px 40px, 60px 60px, 50px 50px, 45px 45px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.8;
}

.card-back::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2) 0%,
    transparent 30%,
    transparent 70%,
    rgba(255, 255, 255, 0.1) 100%
  );
  z-index: 2;
  border-radius: inherit;
}

/* Front Face - Question & Answer */
.card-front {
  background: #3dacbb;
  color: white;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
  font-size: 1em;
  box-sizing: border-box;
  overflow: hidden;
}

/* Question Text */
.card-question {
  font-size: 0.9em;
  margin-bottom: var(--gap-sm);
  color: #fff;
  line-height: 1.3;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  word-wrap: break-word;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 2px 6px rgba(0, 0, 0, 0.7);
  font-weight: bold;
  background: var(--black-20);
  padding: var(--gap-sm);
  border-radius: var(--border-radius-sm);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* Hide question when card is flipped - show only answer */
.question-card.flipped .card-question {
  display: none;
}

/* Answer Text */
.card-answer {
  font-size: 0.95em;
  color: #ffeb3b;
  font-weight: bold;
  /* background: var(--black-20); - Removed to prevent scaling background */
  /* padding: 6px var(--gap-sm); - Removed to prevent scaling background */
  /* border-radius: 6px; - Removed to prevent scaling background */
  /* border: 2px solid rgba(255, 235, 59, 0.3); - Removed to prevent scaling background */
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  word-wrap: break-word;
  text-align: center;
}

/* Make answer take full space when question is hidden */
.question-card.flipped .card-answer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Container-based responsive font size */
  font-size: min(4vw, 3vh, 1.8em);
  padding: var(--gap-sm);
  color: #ffeb3b;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  line-height: 1.1;
  /* Handle text overflow */
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
  max-width: 100%;
  max-height: 100%;
}

/* Hover Effects */
.question-card:not(.answered):not(.flipped):hover .card-back {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
  box-shadow: 0 8px 35px rgba(255, 154, 158, 0.6),
    0 4px 15px rgba(254, 207, 239, 0.4);
  transform: scale(1.08) rotate(-3deg);
  border-color: #ff9a9e;
  animation: hoverPulse 0.6s ease-in-out;
}

/* Answered State */
.question-card.answered {
  pointer-events: none;
}

.question-card.answered .card-front {
  opacity: 0.9;
}

/* Card Points Badge */
.card-points-badge {
  display: inline-block;
  background: linear-gradient(90deg, #ffd700 0%, #ff9800 100%);
  color: #fff;
  font-size: 1.1em;
  font-weight: bold;
  padding: 0.25em 0.8em;
  border-radius: 1em;
  box-shadow: 0 2px 8px rgba(255, 168, 0, 0.18);
  margin-top: 0.7em;
  margin-bottom: 0.2em;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px #b76e00;
  animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* Steal Card Special Face */
.steal-card-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  font-size: 1.4em;
  color: #fff;
  background: rgba(240, 55, 55, 0.5);
  border-radius: var(--border-radius-md);
  box-shadow: 0 2px 12px rgba(255, 193, 7, 0.18);
  padding: 0.5em 0.2em;
}

.steal-label {
  font-size: 1.3em;
  color: #ffd700;
  font-weight: bold;
  margin-bottom: 0.2em;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px #b76e00;
}

/* Power Cards & Steal Modal */
/* Steal Card Modal Message */
.steal-modal-message {
  font-size: 1.15em;
  color: #ffb300;
  font-weight: bold;
  text-align: center;
  padding: 0.7em 0.2em;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px #fffbe6, 0 2px 6px rgba(255, 193, 7, 0.12);
}

.steal-modal-message .steal-label {
  font-size: 1.4em;
  color: #ffd700;
  display: block;
  margin-bottom: 0.2em;
}

/* Double Edge Modal and Card Face */
.doubleedge-modal-message {
  font-size: 1.15em;
  color: #00bcd4;
  font-weight: bold;
  text-align: center;
  padding: 0.7em 0.2em;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px #e0f7fa, 0 2px 6px rgba(0, 188, 212, 0.12);
}

.doubleedge-modal-message .doubleedge-label {
  font-size: 1.4em;
  color: #00e5ff;
  display: block;
  margin-bottom: 0.2em;
}

.doubleedge-card-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  font-size: 1.2em;
  color: #fff;
  background: rgba(0, 188, 212, 0.5);
  border-radius: var(--border-radius-md);
  box-shadow: 0 2px 12px rgba(0, 188, 212, 0.18);
  padding: 0.5em 0.2em;
}

.doubleedge-label {
  font-size: 1.2em;
  color: #00e5ff;
  font-weight: bold;
  margin-bottom: 0.2em;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px #0097a7;
}

.doubleedge-label-inline {
  display: inline-block;
  background: #00bcd4;
  color: #fff;
  font-size: 0.95em;
  font-weight: bold;
  border-radius: 0.7em;
  padding: 0.1em 0.7em;
  margin-right: 0.5em;
  margin-bottom: 0.1em;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px #0097a7;
  vertical-align: middle;
}

/* Card Number Enhancement */
.card-back .card-number {
  position: relative;
  z-index: 3;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

/* Quiz Timer Styles */

@keyframes timerPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(229, 57, 53, 0.4), 0 0 0 0 #e5393555;
  }
  100% {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(229, 57, 53, 0.6), 0 0 20px 10px #e5393533;
  }
}
