/* Reset và base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Nunito", sans-serif;
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  min-height: 100vh;
  color: #2d3436;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header styles */
header {
  text-align: center;
  margin-bottom: 30px;
  background: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #e17055;
  margin-bottom: 10px;
}

header p {
  font-size: 1.2rem;
  color: #636e72;
}

/* Added level indicator styling */
.level-info {
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.level-info h3 {
  color: #e17055;
  font-size: 1.3rem;
  margin-bottom: 5px;
}

.level-info p {
  color: #636e72;
  font-size: 1rem;
}

/* Game info styles */
.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px 25px;
  border-radius: 10px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.score-container,
.timer-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.label {
  font-weight: 600;
  color: #2d3436;
}

#score,
#timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #00b894;
}

#timer {
  color: #e17055;
}

/* Game area styles */
.game-area {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
  margin-bottom: 20px;
}

.items-container,
.backpack-container {
  background: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.items-container h3,
.backpack-container h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: #2d3436;
}

/* Items grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 15px;
}

.item {
  background: #ffffff;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  cursor: grab;
  transition: all 0.3s ease;
  user-select: none;
  /* Enhanced touch support */
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.item:active {
  cursor: grabbing;
}

.item:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.item.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
}

.item-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.item span {
  font-size: 0.9rem;
  font-weight: 600;
  color: #2d3436;
}

/* Essential vs non-essential items */
.item.essential {
  border-color: #00b894;
  background: linear-gradient(135deg, #00cec9, #00b894);
  color: white;
}

.item.non-essential {
  border-color: #e17055;
  background: linear-gradient(135deg, #fd79a8, #e84393);
  color: white;
}

/* Backpack styles */
.backpack {
  background: #f8f9fa;
  border: 3px dashed #74b9ff;
  border-radius: 15px;
  padding: 40px 20px;
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
}

.backpack.drag-over {
  background: #e3f2fd;
  border-color: #2196f3;
  transform: scale(1.05);
}

.backpack-icon {
  font-size: 4rem;
  margin-bottom: 10px;
}

.backpack p {
  font-size: 1.1rem;
  font-weight: 600;
  color: #636e72;
}

/* Dropped items */
.dropped-items {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.dropped-item {
  background: #00b894;
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  animation: dropIn 0.5s ease;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropped-item:hover {
  background: #00a085;
  transform: scale(1.05);
}

.remove-btn {
  background: rgba(255, 255, 255, 0.3);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  color: white;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  margin: 8% auto;
  padding: 40px;
  border-radius: 20px;
  width: 85%;
  max-width: 700px;
  min-height: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow-y: auto;
  max-height: 85vh;
  backdrop-filter: blur(10px);
}

/* Desktop specific enhancements */
@media (min-width: 769px) {
  .modal-content {
    margin: 5% auto;
    padding: 50px;
    width: 80%;
    max-width: 800px;
    min-height: 500px;
    border-radius: 25px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2), 0 10px 30px rgba(0, 0, 0, 0.15);
  }

  .modal-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #74b9ff, #0984e3, #00b894);
    border-radius: 25px 25px 0 0;
  }

  .modal-content h2 {
    font-size: 2.5rem;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #e17055, #d63031);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .final-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
  }

  .completion-message {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
    padding: 25px;
    border-radius: 15px;
    font-size: 1.2rem;
    margin-bottom: 20px;
  }

  .total-score {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 25px;
  }

  .level-breakdown {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    border-left: 5px solid #74b9ff;
  }

  .key-takeaways {
    background: #fff3cd;
    padding: 25px;
    border-radius: 15px;
    border-left: 5px solid #ffc107;
  }

  .disaster-tips {
    grid-column: 1 / -1;
    background: #d1ecf1;
    padding: 25px;
    border-radius: 15px;
    border-left: 5px solid #17a2b8;
  }

  .final-message {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #fd79a8, #e84393);
    color: white;
    padding: 25px;
    border-radius: 15px;
    font-size: 1.3rem;
  }
  .final-actions {
    grid-column: 1 / -1;
  }
}

/* Tablet specific styles */
@media (min-width: 481px) and (max-width: 768px) {
  .modal-content {
    margin: 8% auto;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
  }

  .modal-content h2 {
    font-size: 2rem;
  }

  .final-summary {
    padding: 15px;
  }

  .completion-message,
  .total-score,
  .level-breakdown,
  .key-takeaways,
  .disaster-tips,
  .final-message {
    margin: 20px 0;
    padding: 20px;
    border-radius: 12px;
  }
}

/* Mobile specific optimizations */
@media (max-width: 480px) {
  .modal-content {
    margin: 2% auto;
    padding: 20px;
    width: 95%;
    max-width: none;
    border-radius: 15px;
    max-height: 95vh;
    min-height: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  }

  .modal-content h2 {
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: #e17055;
  }

  .final-summary {
    padding: 10px;
  }

  .completion-message {
    background: #74b9ff;
    color: white;
    padding: 15px;
    border-radius: 10px;
    font-size: 1rem;
    margin-bottom: 15px;
  }

  .total-score {
    background: #00b894;
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
  }

  .total-score h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }

  .score-percentage {
    font-size: 2rem;
    font-weight: 800;
  }

  .level-breakdown,
  .key-takeaways,
  .disaster-tips {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    border-left: 4px solid #74b9ff;
  }

  .key-takeaways {
    background: #fff3cd;
    border-left-color: #ffc107;
  }

  .disaster-tips {
    background: #d1ecf1;
    border-left-color: #17a2b8;
  }

  .key-takeaways li,
  .tip-item {
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 8px 0;
  }

  .final-message {
    background: linear-gradient(135deg, #fd79a8, #e84393);
    color: white;
    padding: 20px;
    border-radius: 12px;
    font-size: 1.1rem;
    margin-top: 20px;
  }

  .restart-btn {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 184, 148, 0.3);
  }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
  .modal-content {
    margin: 1% auto;
    padding: 15px;
    width: 98%;
    border-radius: 12px;
  }

  .modal-content h2 {
    font-size: 1.4rem;
  }

  .completion-message,
  .total-score,
  .level-breakdown,
  .key-takeaways,
  .disaster-tips,
  .final-message {
    padding: 12px;
    margin: 12px 0;
  }

  .score-percentage {
    font-size: 1.8rem;
  }

  .key-takeaways li,
  .tip-item {
    font-size: 0.85rem;
  }

  .restart-btn {
    padding: 12px 25px;
    font-size: 1rem;
  }
}

/* Enhanced fireworks with better visual effects and proper z-index layering */
/* Fireworks animation */
.fireworks {
  position: fixed;
  /* dùng fixed để luôn full màn */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  /* thấp hơn modal và text */
  overflow: hidden;
}


.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: enhancedFirework 6s infinite;
}

/* More vibrant colors and enhanced glow effects */
.firework:nth-child(1) {
  left: 15%;
  top: 25%;
  background: radial-gradient(circle, #ff6b6b, #ff3838);
  animation-delay: 0s;
  box-shadow: 0 0 30px #ff6b6b, 0 0 60px #ff6b6b, 0 0 90px #ff6b6b;
}

.firework:nth-child(2) {
  left: 85%;
  top: 15%;
  background: radial-gradient(circle, #4ecdc4, #26d0ce);
  animation-delay: 0.8s;
  box-shadow: 0 0 30px #4ecdc4, 0 0 60px #4ecdc4, 0 0 90px #4ecdc4;
}

.firework:nth-child(3) {
  left: 65%;
  top: 35%;
  background: radial-gradient(circle, #45b7d1, #3498db);
  animation-delay: 1.6s;
  box-shadow: 0 0 30px #45b7d1, 0 0 60px #45b7d1, 0 0 90px #45b7d1;
}

.firework:nth-child(4) {
  left: 25%;
  top: 55%;
  background: radial-gradient(circle, #f9ca24, #f39c12);
  animation-delay: 2.4s;
  box-shadow: 0 0 30px #f9ca24, 0 0 60px #f9ca24, 0 0 90px #f9ca24;
}

.firework:nth-child(5) {
  left: 75%;
  top: 65%;
  background: radial-gradient(circle, #6c5ce7, #5f3dc4);
  animation-delay: 1.2s;
  box-shadow: 0 0 30px #6c5ce7, 0 0 60px #6c5ce7, 0 0 90px #6c5ce7;
}

.firework:nth-child(6) {
  left: 40%;
  top: 20%;
  background: radial-gradient(circle, #fd79a8, #e84393);
  animation-delay: 2s;
  box-shadow: 0 0 30px #fd79a8, 0 0 60px #fd79a8, 0 0 90px #fd79a8;
}

.firework:nth-child(7) {
  left: 90%;
  top: 45%;
  background: radial-gradient(circle, #00b894, #00a085);
  animation-delay: 0.4s;
  box-shadow: 0 0 30px #00b894, 0 0 60px #00b894, 0 0 90px #00b894;
}

.firework:nth-child(8) {
  left: 10%;
  top: 70%;
  background: radial-gradient(circle, #e17055, #d63031);
  animation-delay: 3.2s;
  box-shadow: 0 0 30px #e17055, 0 0 60px #e17055, 0 0 90px #e17055;
}

.firework:nth-child(9) {
  left: 55%;
  top: 10%;
  background: radial-gradient(circle, #fdcb6e, #e17055);
  animation-delay: 1.8s;
  box-shadow: 0 0 30px #fdcb6e, 0 0 60px #fdcb6e, 0 0 90px #fdcb6e;
}

.firework:nth-child(10) {
  left: 30%;
  top: 80%;
  background: radial-gradient(circle, #a29bfe, #6c5ce7);
  animation-delay: 2.6s;
  box-shadow: 0 0 30px #a29bfe, 0 0 60px #a29bfe, 0 0 90px #a29bfe;
}

/* Enhanced sparkle effects with rainbow colors */
.sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  animation: enhancedSparkle 4s infinite;
}

.sparkle:nth-child(11) {
  left: 20%;
  top: 30%;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
  animation-delay: 0.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(12) {
  left: 80%;
  top: 20%;
  background: linear-gradient(45deg, #45b7d1, #f9ca24);
  animation-delay: 1.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(13) {
  left: 60%;
  top: 40%;
  background: linear-gradient(45deg, #6c5ce7, #fd79a8);
  animation-delay: 2.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(14) {
  left: 30%;
  top: 60%;
  background: linear-gradient(45deg, #00b894, #e17055);
  animation-delay: 3.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(15) {
  left: 70%;
  top: 70%;
  background: linear-gradient(45deg, #fdcb6e, #a29bfe);
  animation-delay: 1s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(16) {
  left: 50%;
  top: 15%;
  background: linear-gradient(45deg, #ff6b6b, #6c5ce7);
  animation-delay: 2s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(17) {
  left: 15%;
  top: 50%;
  background: linear-gradient(45deg, #4ecdc4, #f9ca24);
  animation-delay: 3s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(18) {
  left: 85%;
  top: 60%;
  background: linear-gradient(45deg, #45b7d1, #fd79a8);
  animation-delay: 0.2s;
  box-shadow: 0 0 20px currentColor;
}

/* Enhanced firework animation with more dramatic effects */
@keyframes enhancedFirework {
  0% {
    transform: scale(0.2) rotate(0deg);
    opacity: 0;
    box-shadow: 0 0 0 0 currentColor;
  }

  5% {
    transform: scale(0.5) rotate(18deg);
    opacity: 0.8;
    box-shadow: 0 0 20px 10px currentColor;
  }

  15% {
    transform: scale(2) rotate(72deg);
    opacity: 1;
    box-shadow: 0 0 50px 25px currentColor, 0 0 100px 50px currentColor;
  }

  30% {
    transform: scale(6) rotate(144deg);
    opacity: 0.9;
    box-shadow: 0 0 80px 40px currentColor, 0 0 160px 80px currentColor;
  }

  50% {
    transform: scale(8) rotate(216deg);
    opacity: 0.8;
    box-shadow: 0 0 120px 60px currentColor, 0 0 240px 120px currentColor;
  }

  70% {
    transform: scale(6) rotate(288deg);
    opacity: 0.6;
    box-shadow: 0 0 80px 40px currentColor, 0 0 160px 80px currentColor;
  }

  85% {
    transform: scale(3) rotate(324deg);
    opacity: 0.3;
    box-shadow: 0 0 40px 20px currentColor, 0 0 80px 40px currentColor;
  }

  100% {
    transform: scale(0.5) rotate(360deg);
    opacity: 0;
    box-shadow: 0 0 0 0 currentColor;
  }
}

/* Enhanced sparkle animation with twinkling effect */
@keyframes enhancedSparkle {

  0%,
  100% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
    box-shadow: 0 0 0 0 currentColor;
  }

  10% {
    opacity: 0.8;
    transform: scale(1.5) rotate(45deg);
    box-shadow: 0 0 15px 8px currentColor;
  }

  25% {
    opacity: 1;
    transform: scale(2.5) rotate(90deg);
    box-shadow: 0 0 25px 12px currentColor, 0 0 50px 25px currentColor;
  }

  50% {
    opacity: 0.9;
    transform: scale(3) rotate(180deg);
    box-shadow: 0 0 30px 15px currentColor, 0 0 60px 30px currentColor;
  }

  75% {
    opacity: 0.6;
    transform: scale(2) rotate(270deg);
    box-shadow: 0 0 20px 10px currentColor, 0 0 40px 20px currentColor;
  }

  90% {
    opacity: 0.3;
    transform: scale(1) rotate(315deg);
    box-shadow: 0 0 10px 5px currentColor;
  }
}

/* Ensure modal content stays on top of fireworks */
.modal-content {
  position: relative;
  z-index: 1000;
  /* Higher than fireworks to stay on top */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Added detailed feedback styling */
.detailed-feedback {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 15px;
  margin: 20px 0;
  text-align: left;
}

.feedback-section {
  margin-bottom: 15px;
}

.feedback-section h4 {
  color: #2d3436;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.feedback-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-item {
  background: #e17055;
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.feedback-item.good {
  background: #00b894;
}

.restart-btn {
  background: linear-gradient(135deg, #74b9ff, #0984e3);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(116, 185, 255, 0.4);
}

/* Perfect score celebration and fireworks animation */
.celebration {
  position: relative;
  overflow: hidden;
}

.celebration-btn {
  background: linear-gradient(135deg, #00b894, #00cec9);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

.perfect-message {
  margin: 20px 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: #00b894;
}

.perfect-message p {
  margin: 10px 0;
}

/* Fireworks animation */
.fireworks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
  /* Lower than modal content to stay behind text */
  overflow: hidden;
}

.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: enhancedFirework 6s infinite;
  opacity: 0.7;
  /* giảm chói */

}

/* More vibrant colors and enhanced glow effects */
.firework:nth-child(1) {
  left: 15%;
  top: 25%;
  background: radial-gradient(circle, #ff6b6b, #ff3838);
  animation-delay: 0s;
  box-shadow: 0 0 30px #ff6b6b, 0 0 60px #ff6b6b, 0 0 90px #ff6b6b;
}

.firework:nth-child(2) {
  left: 85%;
  top: 15%;
  background: radial-gradient(circle, #4ecdc4, #26d0ce);
  animation-delay: 0.8s;
  box-shadow: 0 0 30px #4ecdc4, 0 0 60px #4ecdc4, 0 0 90px #4ecdc4;
}

.firework:nth-child(3) {
  left: 65%;
  top: 35%;
  background: radial-gradient(circle, #45b7d1, #3498db);
  animation-delay: 1.6s;
  box-shadow: 0 0 30px #45b7d1, 0 0 60px #45b7d1, 0 0 90px #45b7d1;
}

.firework:nth-child(4) {
  left: 25%;
  top: 55%;
  background: radial-gradient(circle, #f9ca24, #f39c12);
  animation-delay: 2.4s;
  box-shadow: 0 0 30px #f9ca24, 0 0 60px #f9ca24, 0 0 90px #f9ca24;
}

.firework:nth-child(5) {
  left: 75%;
  top: 65%;
  background: radial-gradient(circle, #6c5ce7, #5f3dc4);
  animation-delay: 1.2s;
  box-shadow: 0 0 30px #6c5ce7, 0 0 60px #6c5ce7, 0 0 90px #6c5ce7;
}

.firework:nth-child(6) {
  left: 40%;
  top: 20%;
  background: radial-gradient(circle, #fd79a8, #e84393);
  animation-delay: 2s;
  box-shadow: 0 0 30px #fd79a8, 0 0 60px #fd79a8, 0 0 90px #fd79a8;
}

.firework:nth-child(7) {
  left: 90%;
  top: 45%;
  background: radial-gradient(circle, #00b894, #00a085);
  animation-delay: 0.4s;
  box-shadow: 0 0 30px #00b894, 0 0 60px #00b894, 0 0 90px #00b894;
}

.firework:nth-child(8) {
  left: 10%;
  top: 70%;
  background: radial-gradient(circle, #e17055, #d63031);
  animation-delay: 3.2s;
  box-shadow: 0 0 30px #e17055, 0 0 60px #e17055, 0 0 90px #e17055;
}

.firework:nth-child(9) {
  left: 55%;
  top: 10%;
  background: radial-gradient(circle, #fdcb6e, #e17055);
  animation-delay: 1.8s;
  box-shadow: 0 0 30px #fdcb6e, 0 0 60px #fdcb6e, 0 0 90px #fdcb6e;
}

.firework:nth-child(10) {
  left: 30%;
  top: 80%;
  background: radial-gradient(circle, #a29bfe, #6c5ce7);
  animation-delay: 2.6s;
  box-shadow: 0 0 30px #a29bfe, 0 0 60px #a29bfe, 0 0 90px #a29bfe;
}

/* Enhanced sparkle effects with rainbow colors */
.sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  animation: enhancedSparkle 4s infinite;
}

.sparkle:nth-child(11) {
  left: 20%;
  top: 30%;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
  animation-delay: 0.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(12) {
  left: 80%;
  top: 20%;
  background: linear-gradient(45deg, #45b7d1, #f9ca24);
  animation-delay: 1.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(13) {
  left: 60%;
  top: 40%;
  background: linear-gradient(45deg, #6c5ce7, #fd79a8);
  animation-delay: 2.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(14) {
  left: 30%;
  top: 60%;
  background: linear-gradient(45deg, #00b894, #e17055);
  animation-delay: 3.5s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(15) {
  left: 70%;
  top: 70%;
  background: linear-gradient(45deg, #fdcb6e, #a29bfe);
  animation-delay: 1s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(16) {
  left: 50%;
  top: 15%;
  background: linear-gradient(45deg, #ff6b6b, #6c5ce7);
  animation-delay: 2s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(17) {
  left: 15%;
  top: 50%;
  background: linear-gradient(45deg, #4ecdc4, #f9ca24);
  animation-delay: 3s;
  box-shadow: 0 0 20px currentColor;
}

.sparkle:nth-child(18) {
  left: 85%;
  top: 60%;
  background: linear-gradient(45deg, #45b7d1, #fd79a8);
  animation-delay: 0.2s;
  box-shadow: 0 0 20px currentColor;
}

/* Enhanced firework animation with more dramatic effects */
@keyframes enhancedFirework {
  0% {
    transform: scale(0.2) rotate(0deg);
    opacity: 0;
    box-shadow: 0 0 0 0 currentColor;
  }

  5% {
    transform: scale(0.5) rotate(18deg);
    opacity: 0.8;
    box-shadow: 0 0 20px 10px currentColor;
  }

  15% {
    transform: scale(2) rotate(72deg);
    opacity: 1;
    box-shadow: 0 0 50px 25px currentColor, 0 0 100px 50px currentColor;
  }

  30% {
    transform: scale(6) rotate(144deg);
    opacity: 0.9;
    box-shadow: 0 0 80px 40px currentColor, 0 0 160px 80px currentColor;
  }

  50% {
    transform: scale(8) rotate(216deg);
    opacity: 0.8;
    box-shadow: 0 0 120px 60px currentColor, 0 0 240px 120px currentColor;
  }

  70% {
    transform: scale(6) rotate(288deg);
    opacity: 0.6;
    box-shadow: 0 0 80px 40px currentColor, 0 0 160px 80px currentColor;
  }

  85% {
    transform: scale(3) rotate(324deg);
    opacity: 0.3;
    box-shadow: 0 0 40px 20px currentColor, 0 0 80px 40px currentColor;
  }

  100% {
    transform: scale(0.5) rotate(360deg);
    opacity: 0;
    box-shadow: 0 0 0 0 currentColor;
  }
}

/* Enhanced sparkle animation with twinkling effect */
@keyframes enhancedSparkle {

  0%,
  100% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
    box-shadow: 0 0 0 0 currentColor;
  }

  10% {
    opacity: 0.8;
    transform: scale(1.5) rotate(45deg);
    box-shadow: 0 0 15px 8px currentColor;
  }

  25% {
    opacity: 1;
    transform: scale(2.5) rotate(90deg);
    box-shadow: 0 0 25px 12px currentColor, 0 0 50px 25px currentColor;
  }

  50% {
    opacity: 0.9;
    transform: scale(3) rotate(180deg);
    box-shadow: 0 0 30px 15px currentColor, 0 0 60px 30px currentColor;
  }

  75% {
    opacity: 0.6;
    transform: scale(2) rotate(270deg);
    box-shadow: 0 0 20px 10px currentColor, 0 0 40px 20px currentColor;
  }

  90% {
    opacity: 0.3;
    transform: scale(1) rotate(315deg);
    box-shadow: 0 0 10px 5px currentColor;
  }
}

/* Ensure modal content stays on top of fireworks */
.modal-content {
  position: relative;
  z-index: 1000;
  /* Higher than fireworks to stay on top */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

#finalScore {
  font-size: 1.5rem;
  font-weight: 700;
  color: #00b894;
  margin-bottom: 15px;
}

#gameResult {
  font-size: 1.2rem;
  margin-bottom: 25px;
  color: #2d3436;
}

/* Enhanced responsive design for better mobile experience */
@media (max-width: 1024px) {
  .container {
    padding: 15px;
  }

  .game-area {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .items-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }
}

@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  header h1 {
    font-size: 2rem;
  }

  header p {
    font-size: 1rem;
  }

  .game-info {
    padding: 12px 20px;
  }

  .items-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
  }

  .item {
    padding: 12px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .item span {
    font-size: 0.8rem;
  }

  .item-icon {
    font-size: 1.5rem;
  }

  .backpack {
    padding: 30px 15px;
    min-height: 150px;
  }

  .backpack-icon {
    font-size: 3rem;
  }

  .modal-content {
    margin: 8% auto;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
  }

  .modal-content h2 {
    font-size: 2rem;
  }

  .final-summary {
    padding: 15px;
  }

  .completion-message,
  .total-score,
  .level-breakdown,
  .key-takeaways,
  .disaster-tips,
  .final-message {
    margin: 20px 0;
    padding: 20px;
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  .game-info {
    flex-direction: column;
    gap: 10px;
    padding: 15px;
  }

  .items-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .item {
    padding: 10px;
    min-height: 70px;
  }

  .item span {
    font-size: 0.7rem;
  }

  .item-icon {
    font-size: 1.3rem;
  }

  .backpack {
    padding: 25px 15px;
    min-height: 140px;
  }

  .backpack-icon {
    font-size: 2.5rem;
  }

  .modal-content {
    margin: 2% auto;
    padding: 20px;
    width: 95%;
    max-width: none;
    border-radius: 15px;
    max-height: 95vh;
    min-height: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  }

  .modal-content h2 {
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: #e17055;
  }

  .final-summary {
    padding: 10px;
  }

  .completion-message {
    background: #74b9ff;
    color: white;
    padding: 15px;
    border-radius: 10px;
    font-size: 1rem;
    margin-bottom: 15px;
  }

  .total-score {
    background: #00b894;
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
  }

  .total-score h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }

  .score-percentage {
    font-size: 2rem;
    font-weight: 800;
  }

  .level-breakdown,
  .key-takeaways,
  .disaster-tips {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    border-left: 4px solid #74b9ff;
  }

  .key-takeaways {
    background: #fff3cd;
    border-left-color: #ffc107;
  }

  .disaster-tips {
    background: #d1ecf1;
    border-left-color: #17a2b8;
  }

  .key-takeaways li,
  .tip-item {
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 8px 0;
  }

  .final-message {
    background: linear-gradient(135deg, #fd79a8, #e84393);
    color: white;
    padding: 20px;
    border-radius: 12px;
    font-size: 1.1rem;
    margin-top: 20px;
  }

  .restart-btn {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 184, 148, 0.3);
  }
}

@media (max-width: 360px) {
  .container {
    padding: 8px;
  }

  header {
    padding: 15px;
  }

  header h1 {
    font-size: 1.7rem;
  }

  .items-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .item {
    padding: 6px;
  }

  .item span {
    font-size: 0.7rem;
  }

  .modal-content {
    margin: 1% auto;
    padding: 15px;
    width: 98%;
    border-radius: 12px;
  }

  .modal-content h2 {
    font-size: 1.4rem;
  }

  .modal-content {
    position: relative;
    z-index: 10;
    /* cao hơn pháo hoa */
  }

  .completion-message,
  .total-score,
  .level-breakdown,
  .key-takeaways,
  .disaster-tips,
  .final-message {
    padding: 12px;
    margin: 12px 0;
  }

  .score-percentage {
    font-size: 1.8rem;
  }

  .key-takeaways li,
  .tip-item {
    font-size: 0.85rem;
  }

  .restart-btn {
    padding: 12px 25px;
    font-size: 1rem;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}