* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: "Kanit", sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #fff;
  overflow: hidden;
  transition: background 0.5s;
}
.container {
  background: #f5f5f5;
  border: 6px solid #000;
  border-radius: 15px;
  padding: 25px;
  max-width: 700px;
  width: 95%;
  text-align: center;
  box-shadow: 10px 10px #000;
  transition: all 0.4s ease;
  position: relative;
  animation: fadeIn 1s forwards;
}
@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(-30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Title */
h1 {
  font-size: 2rem;
  color: #111;
  text-shadow: 2px 2px #fff;
  margin-bottom: 10px;
  position: relative;
}
h1 .info-icon {
  font-size: 1.5rem;
  margin-left: 10px;
  cursor: pointer;
  color: #000;
  border: 2px solid #000;
  border-radius: 50%;
  padding: 2px 6px;
  display: inline-block;
  transition: all 0.3s ease;
}
h1 .info-icon:hover {
  background: #000;
  color: #fff;
  transform: scale(1.1);
}

/* Buttons */
.btn {
  padding: 12px 25px;
  margin: 10px;
  font-size: 1.1rem;
  font-weight: bold;
  border: 4px solid #000;
  border-radius: 12px;
  background: #ddd;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
}
.btn:hover {
  background: #fff;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 5px 5px #000;
}

/* Game Area */
.game {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  transition: all 0.4s ease;
}
.scoreboard {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin: 10px 0;
  transition: all 0.3s;
  flex-wrap: wrap;
  gap: 10px;
}
.score {
  flex: 1;
  margin: 5px;
  border: 3px solid #000;
  background: #ddd;
  padding: 10px;
  font-size: 1.2rem;
  border-radius: 10px;
  position: relative;
  transition: all 0.3s ease;
  min-width: 120px;
}
.score.winner {
  background: #fffa65;
  border-color: #000;
  animation: flash 0.6s;
}
@keyframes flash {
  0%,
  100% {
    background: #fffa65;
  }
  50% {
    background: #fff;
  }
}

/* Turn Glow Narrow & Pulse for Friend mode */
.current-turn {
  border-color: #00ff00 !important;
  box-shadow: 0 0 6px 3px #00ff00 inset, 0 0 6px 3px #00ff00;
  animation: glowPulse 1s infinite alternate;
}
@keyframes glowPulse {
  0% {
    box-shadow: 0 0 4px 2px #00ff00 inset;
  }
  100% {
    box-shadow: 0 0 12px 4px #00ff00 inset;
  }
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 20px;
  background: #bbb;
  border-radius: 10px;
  overflow: hidden;
  margin: 10px 0;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: #4caf50;
  transition: width 0.5s;
}

/* Round & Turn Display */
.round-display {
  margin: 10px 0;
  font-size: 1.1rem;
  font-weight: bold;
}
.turn-display {
  margin: 5px 0;
  font-size: 1.1rem;
  color: #000;
  font-weight: bold;
}

/* Cards */
.cards {
  display: flex;
  justify-content: center;
  margin: 25px 0;
  flex-wrap: wrap;
  perspective: 1000px;
  gap: 15px;
}
.card {
  border: 4px solid #000;
  background: #ddd;
  width: 100px;
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.4s ease, transform 0.4s;
  position: relative;
  transform-style: preserve-3d;
}
.card:hover {
  transform: translateY(-10px) scale(1.1);
  background: #fff;
  box-shadow: 5px 5px #000;
}
.card-inner {
  transition: transform 0.6s;
  transform-style: preserve-3d;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.card.flipped .card-inner {
  transform: rotateY(180deg);
}
.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  border-radius: 12px;
  flex-direction: column;
}
.card-back {
  transform: rotateY(180deg);
  background: #ddd;
}
.card-label {
  font-size: 1rem;
  margin-top: 5px;
  font-weight: bold;
}

/* Winner Card highlight */
.card.winner {
  animation: winnerAnim 1s ease forwards;
}
@keyframes winnerAnim {
  0% {
    transform: scale(1) rotateY(0deg) translateY(0);
  }
  50% {
    transform: scale(1.3) rotateY(360deg) translateY(-10px);
  }
  100% {
    transform: scale(1) rotateY(0deg) translateY(0);
  }
}

/* Result & Winner */
.result {
  font-size: 1.3rem;
  margin: 15px;
  min-height: 28px;
  font-weight: bold;
  transition: all 0.3s ease;
}

/* Info Modal */
#infoModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 1.2rem;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
#infoModal.show {
  opacity: 1;
  pointer-events: auto;
}
#infoModal .close-btn {
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 1rem;
  border: 3px solid #fff;
  border-radius: 8px;
  cursor: pointer;
}

/* Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Winner Overlay */
#winnerOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 3rem;
  text-align: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
#winnerOverlay.show {
  opacity: 1;
  pointer-events: auto;
}
.control-btns {
  margin-top: 20px;
}
.control-btns .btn {
  margin: 10px;
}

/* Dropdowns */
.select-group {
  margin: 15px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.select-group select {
  margin: 5px;
  padding: 8px 12px;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 3px solid #000;
  background: #ddd;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 700px) {
  .cards {
    gap: 10px;
  }
  .card {
    width: 80px;
    height: 100px;
    font-size: 1.8rem;
  }
  .score {
    min-width: 100px;
  }
}
@media (max-width: 450px) {
  .container {
    padding: 15px;
  }
  .btn {
    padding: 8px 16px;
    font-size: 1rem;
  }
  .select-group select {
    font-size: 1rem;
    padding: 6px 10px;
  }
}
/* Universal Home Button Styling */
.home-button {
  position: fixed;
  top: 20px;
  left: 20px;
  background: #ffffff;
  color: #000000;
  text-decoration: none;
  padding: 12px 18px;
  border: 4px solid #000000;
  box-shadow: 6px 6px 0 #808080;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  cursor: pointer;
  user-select: none;
}

.home-button:hover {
  background: #000000;
  color: #ffffff;
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 #808080;
}

.home-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #808080;
}
