body {
  font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1a1f35, #242e4c);
  color: #f5f5f5;
  text-align: center;
  padding: 20px;
  margin: 0;
  line-height: 1.6;
  min-height: 100vh;
  background-attachment: fixed;
}

h1 {
  font-size: 3.2rem;
  margin-bottom: 30px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  animation: glow 2.5s infinite alternate;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-top: 40px;
}

h2 {
  color: #7ee8fa;
  margin-bottom: 20px;
  font-weight: 600;
}

h3 {
  color: #9ee5ff;
  font-weight: 500;
  margin-top: 20px;
  margin-bottom: 10px;
}

#game, #room-controls {
  max-width: 850px;
  margin: 0 auto 40px;
  background: rgba(44, 55, 86, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 
              0 0 30px rgba(78, 202, 244, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.3s, box-shadow 0.3s;
}

#game:hover, #room-controls:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 
              0 0 40px rgba(78, 202, 244, 0.2);
}

#game-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 25px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

.health-display {
  font-size: 1.3rem;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
}

.health-display span:first-child {
  margin-right: 5px;
  opacity: 0.9;
}

#player-health {
  color: #4cff50;
  text-shadow: 0 0 8px rgba(76, 255, 80, 0.6);
}

#opponent-health {
  color: #ff4336;
  text-shadow: 0 0 8px rgba(255, 67, 54, 0.6);
}

.turn-indicator {
  padding: 8px 20px;
  font-weight: bold;
  border-radius: 25px;
  background: linear-gradient(45deg, #333, #444);
  animation: pulse 1.5s infinite alternate;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#play-area-container {
  display: flex;
  justify-content: space-around;
  margin: 30px 0;
  gap: 20px;
}

.play-area-section {
  flex: 1;
  max-width: 45%;
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s;
}

.play-area-section:hover {
  transform: translateY(-5px);
}

.played-card-area {
  min-height: 180px;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.played-card-area:hover {
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.05);
}

.effect-message {
  min-height: 65px;
  margin: 25px 0;
  font-size: 1.2rem;
  font-style: italic;
  color: #ffeb3b;
  text-shadow: 0 0 10px rgba(255, 235, 59, 0.3);
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  transition: transform 0.3s;
}

.effect-message:not(:empty) {
  animation: effectAppear 0.5s ease-out;
}

.bonus {
  color: #ff9800;
  font-weight: bold;
  font-size: 1.3rem;
  text-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

.player-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin: 25px 0;
  min-height: 180px;
  perspective: 1000px;
}

.card {
  position: relative;
  width: 125px;
  height: 190px;
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.4s, box-shadow 0.4s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: #ddd;
  color: #000;
  transform-style: preserve-3d;
  transform-origin: center;
}

.card:hover {
  transform: translateY(-15px) rotateY(5deg);
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 255, 255, 0.2);
  z-index: 5;
}

.card-element {
  font-size: 1.3rem;
  font-weight: bold;
  padding: 10px;
  color: white;
  background-color: rgba(0, 0, 0, 0.75);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.card-action {
  font-size: 1.15rem;
  padding: 8px;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.card-power {
  font-size: 1rem;
  padding: 8px;
  background-color: rgba(0, 0, 0, 0.75);
  color: white;
  font-weight: bold;
}

/* Element-specific styles with improved gradients */
.fire {
  background: linear-gradient(135deg, #ff5722, #ff9800, #ffeb3b);
  box-shadow: 0 5px 15px rgba(255, 87, 34, 0.5);
}

.water {
  background: linear-gradient(135deg, #03a9f4, #00bcd4, #80deea);  
  box-shadow: 0 5px 15px rgba(3, 169, 244, 0.5);
}

.earth {
  background: linear-gradient(135deg, #8bc34a, #4caf50, #009688);
  box-shadow: 0 5px 15px rgba(139, 195, 74, 0.5);
}

.air {
  background: linear-gradient(135deg, #eceff1, #b0bec5, #78909c);
  box-shadow: 0 5px 15px rgba(236, 239, 241, 0.5);
}

.lightning {
  background: linear-gradient(135deg, #ffeb3b, #ffc107, #ff9800);
  box-shadow: 0 5px 15px rgba(255, 235, 59, 0.5);
}

/* Played card styling */
.played-card {
  width: 150px;
  height: 210px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 255, 255, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #000;
  animation: cardEntrance 0.6s cubic-bezier(0.215, 0.61, 0.355, 1);
  transform-style: preserve-3d;
}

/* Button styling */
.btn {
  padding: 14px 28px;
  margin: 15px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 30px;
  background: linear-gradient(to right, #3a7bd5, #00d2ff);
  color: white;
  cursor: pointer;
  transition: all 0.4s;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2), 0 0 5px rgba(0, 210, 255, 0.5);
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 10px rgba(0, 210, 255, 0.7);
  background: linear-gradient(-45deg, #4a8be5, #10e2ff);
}

.btn:hover::before {
  transform: translateX(100%);
}

.btn:active {
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.rules-box {
  margin-top: 40px;
  padding: 25px;
  border-radius: 15px;
  background-color: rgba(0, 0, 0, 0.25);
  text-align: left;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.rules-box h3 {
  color: #7ee8fa;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
  margin-top: 0;
}

.rules-box ul {
  padding-left: 25px;
  color: #e0e0e0;
}

.rules-box li {
  margin-bottom: 8px;
}

.rules-box ul ul {
  margin-top: 8px;
}

/* Animations */
@keyframes glow {
  from {
    text-shadow: 0 0 5px rgba(126, 232, 250, 0.5);
  }
  to {
    text-shadow: 0 0 20px rgba(126, 232, 250, 0.8), 0 0 30px rgba(126, 232, 250, 0.4);
  }
}

@keyframes pulse {
  from {
    opacity: 0.8;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes cardEntrance {
  0% {
    transform: translateY(70px) scale(0.8);
    opacity: 0;
  }
  60% {
    transform: translateY(-10px) scale(1.05);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes effectAppear {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

#waiting-message {
  padding: 30px;
  background: rgba(44, 55, 86, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  margin: 30px auto;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 30px rgba(78, 202, 244, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: pulse 2s infinite alternate;
}

#room-id-display {
  font-size: 1.4rem;
  font-weight: bold;
  margin-top: 15px;
  padding: 12px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  letter-spacing: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* Game notifications */
.game-notification {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  padding: 20px 30px;
  border-radius: 12px;
  color: white;
  font-weight: bold;
  z-index: 1000;
  box-shadow: 0 8px 25px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
  text-align: center;
  max-width: 80%;
  backdrop-filter: blur(8px);
}

.notification-success {
  background: linear-gradient(45deg, #4CAF50, #8BC34A);
  border-left: 5px solid #2E7D32;
}

.notification-error {
  background: linear-gradient(45deg, #F44336, #E91E63);
  border-left: 5px solid #C62828;
}

.notification-info {
  background: linear-gradient(45deg, #2196F3, #03A9F4);
  border-left: 5px solid #0D47A1;
}

.notification-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive design */
@media (max-width: 850px) {
  body {
    padding: 15px;
  }
  
  h1 {
    font-size: 2.5rem;
    margin-top: 20px;
  }
  
  #game, #room-controls {
    padding: 20px;
    max-width: 95%;
  }
}

@media (max-width: 768px) {
  #play-area-container {
    flex-direction: column;
    gap: 30px;
  }
  
  .play-area-section {
    max-width: 100%;
  }
  
  .card {
    width: 110px;
    height: 165px;
  }
  
  .played-card {
    width: 130px;
    height: 190px;
  }
  
  .rules-box {
    padding: 15px;
  }
  
  .btn {
    padding: 12px 20px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 2rem;
  }
  
  .health-display {
    font-size: 1rem;
  }
  
  .card {
    width: 90px;
    height: 140px;
  }
  
  .card-element {
    font-size: 1rem;
    padding: 5px;
  }
  
  .card-action {
    font-size: 0.9rem;
  }
  
  .effect-message {
    font-size: 1rem;
  }
}

.game-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(26, 31, 53, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
  perspective: 1000px;
}

.dialog-active {
  opacity: 1;
}

.dialog-closing {
  opacity: 0;
  transform: scale(0.95);
}

.dialog-content {
  background: rgba(44, 55, 86, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 30px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 
              0 0 40px rgba(78, 202, 244, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateY(20px);
  transition: transform 0.5s cubic-bezier(0.215, 0.61, 0.355, 1);
  animation: dialogEntry 0.5s forwards;
}

.dialog-active .dialog-content {
  transform: translateY(0);
}

.dialog-content h3 {
  color: #7ee8fa;
  text-align: center;
  margin-top: 0;
  margin-bottom: 25px;
  font-weight: 600;
  font-size: 1.8rem;
  text-shadow: 0 0 10px rgba(126, 232, 250, 0.5);
}

.input-group {
  margin-bottom: 25px;
}

.input-group label {
  display: block;
  margin-bottom: 12px;
  color: #9ee5ff;
  font-weight: 500;
  text-align: left;
  font-size: 1.1rem;
}

.input-group input {
  width: 100%;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  color: white;
  font-size: 1.1rem;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.input-group input:focus {
  outline: none;
  border-color: rgba(126, 232, 250, 0.5);
  box-shadow: 0 0 15px rgba(126, 232, 250, 0.3),
              inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.input-error {
  border-color: #ff4336 !important;
  box-shadow: 0 0 15px rgba(255, 67, 54, 0.4),
              inset 0 2px 10px rgba(0, 0, 0, 0.2) !important;
  animation: shake 0.5s;
}

.button-group {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 30px;
}

.primary-button, .secondary-button {
  padding: 14px 28px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.4s;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.primary-button {
  background: linear-gradient(to right, #3a7bd5, #00d2ff);
  color: white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2), 
              0 0 5px rgba(0, 210, 255, 0.5);
}

.primary-button:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 
              0 0 10px rgba(0, 210, 255, 0.7);
  background: linear-gradient(-45deg, #4a8be5, #10e2ff);
}

.primary-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.primary-button:hover::before {
  transform: translateX(100%);
}

.secondary-button {
  background: rgba(44, 55, 86, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #9ee5ff;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.secondary-button:hover {
  background: rgba(44, 55, 86, 0.9);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes dialogEntry {
  0% { 
    opacity: 0; 
    transform: translateY(30px) scale(0.95); 
  }
  100% { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

.game-controls-container {
  margin: 40px auto 30px;
  padding: 25px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.8s ease-out;
  max-width: 600px;
}

.game-controls-container h3 {
  color: #ffeb3b;
  text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 20px;
}

.game-control-buttons {
  display: flex;
  justify-content: center;
  gap: 25px;
  flex-wrap: wrap;
}

/* Play again button specific styling */
.btn-play-again {
  background: linear-gradient(to right, #4CAF50, #8BC34A);
  box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3), 0 0 5px rgba(139, 195, 74, 0.5);
}

.btn-play-again:hover {
  background: linear-gradient(-45deg, #5bc75e, #9cda5a);
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4), 0 0 10px rgba(139, 195, 74, 0.7);
}

.btn-play-again::before {
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
}

/* Leave game button specific styling */
.btn-leave-game {
  background: linear-gradient(to right, #FF5722, #F44336);
  box-shadow: 0 5px 15px rgba(244, 67, 54, 0.3), 0 0 5px rgba(255, 87, 34, 0.5);
}

.btn-leave-game:hover {
  background: linear-gradient(-45deg, #ff6a3c, #ff5252);
  box-shadow: 0 8px 20px rgba(244, 67, 54, 0.4), 0 0 10px rgba(255, 87, 34, 0.7);
}

.btn-leave-game::before {
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
}

/* Animation for the game controls appearance */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive styling for the game controls */
@media (max-width: 768px) {
  .game-controls-container {
    padding: 20px;
  }
  
  .game-control-buttons {
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .game-controls-container h3 {
    font-size: 1.3rem;
  }
  
  .btn-play-again, .btn-leave-game {
    padding: 12px 20px;
    font-size: 0.9rem;
  }
}

/* Optional Google Font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');