* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Courier New", monospace;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.game-container {
  max-width: 800px;
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.game-header {
  text-align: center;
  margin-bottom: 20px;
}

.game-title {
  font-size: 2.5rem;
  color: #ffd700;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin-bottom: 10px;
}

.game-stats {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: bold;
}

.dungeon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 2px;
  background: #0f0f23;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 20px;
  aspect-ratio: 4 / 3;
}

.room {
  background: #2a2a4a;
  border: 2px solid #404060;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
}

.room:hover {
  border-color: #6060ff;
  box-shadow: 0 0 10px rgba(96, 96, 255, 0.3);
}

.room.visited {
  background: #3a3a5a;
  border-color: #505070;
}

.room.current {
  background: #4a4aff;
  border-color: #6060ff;
  box-shadow: 0 0 15px rgba(74, 74, 255, 0.6);
  animation: pulse 2s infinite;
}

.room.trap {
  background: #ff4a4a;
  border-color: #ff6060;
}

.room.treasure {
  background: #ffd700;
  border-color: #ffed4e;
  color: #000;
}

.room.enemy {
  background: #ff6b35;
  border-color: #ff8c69;
}

.player {
  font-size: 2rem;
  animation: bounce 1s infinite alternate;
}

/* Animations */
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes bounce {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-3px);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Controls */
.controls {
  text-align: center;
  margin-bottom: 20px;
}

.controls h3 {
  margin-bottom: 10px;
  color: #ffd700;
}

.arrow-keys {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(2, 50px);
  gap: 5px;
  justify-content: center;
  margin: 10px 0;
}

.key {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: bold;
  transition: all 0.2s ease;
}

.key:nth-child(1) {
  grid-column: 2;
  grid-row: 1;
}
.key:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}
.key:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}
.key:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
}

.key.active {
  background: rgba(255, 215, 0, 0.3);
  border-color: #ffd700;
  transform: scale(0.95);
}

/* Event Log */
.event-log {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  padding: 15px;
  height: 120px;
  overflow-y: auto;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.event-log h3 {
  color: #ffd700;
  margin-bottom: 10px;
}

.event {
  margin-bottom: 8px;
  padding: 5px;
  border-radius: 5px;
  animation: fadeIn 0.5s ease-in;
}

.event.treasure {
  background: rgba(255, 215, 0, 0.2);
}
.event.trap {
  background: rgba(255, 74, 74, 0.2);
}
.event.enemy {
  background: rgba(255, 107, 53, 0.2);
}
.event.move {
  background: rgba(74, 74, 255, 0.2);
}

/* Reset Button */
.reset-btn {
  background: linear-gradient(45deg, #ff6b35, #ff8c69);
  border: none;
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 15px;
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255, 107, 53, 0.4);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .game-title {
    font-size: 2rem;
  }

  .dungeon-grid {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(8, 1fr);
  }

  .room {
    font-size: 1.2rem;
  }

  .game-stats {
    flex-direction: column;
    gap: 5px;
  }

  .stat {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .game-container {
    padding: 15px;
  }

  .game-title {
    font-size: 1.5rem;
  }

  .dungeon-grid {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(6, 1fr);
  }

  .room {
    font-size: 1rem;
  }
}