@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

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

body {
  background: linear-gradient(135deg, #e8b796 0%, #d4a57b 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: "Press Start 2P", "Courier New", monospace;
  overflow: hidden;
}

#game-container {
  position: relative;
  border: 6px solid #5c4033;
  border-radius: 4px;
  box-shadow:
    0 0 0 3px #8b6914,
    0 0 0 6px #5c4033,
    8px 8px 0 rgba(0, 0, 0, 0.3);
  background: #3d2817;
  padding: 8px;
}

#gameCanvas {
  display: block;
  background: linear-gradient(180deg, #4a6741 0%, #3d5a35 100%);
  cursor: grab;
  image-rendering: pixelated;
  border: 4px solid #2a1a0a;
}

#gameCanvas:active {
  cursor: grabbing;
}

#hud {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 10;
  pointer-events: none;
}

#hud > * {
  pointer-events: auto;
}

.hud-panel {
  background: linear-gradient(180deg, #c9a66b 0%, #a68544 100%);
  border: 3px solid #5c4033;
  border-radius: 4px;
  padding: 8px 14px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2),
    3px 3px 0 rgba(0, 0, 0, 0.3);
}

.hud-panel span {
  color: #2a1a0a;
  font-size: 10px;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
}

.hud-panel .value {
  color: #8b0000;
  font-weight: bold;
}

#fetch-display {
  background: linear-gradient(180deg, #ffd700 0%, #daa520 100%);
}

#fetch-display .value {
  color: #5c4033;
}

.subtitle {
  font-size: 12px;
  color: #8b6914;
  margin-bottom: 20px;
}

#fetch-notify {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  font-size: 20px;
  color: #ffd700;
  text-shadow:
    3px 3px 0 #5c4033,
    -1px -1px 0 #8b6914;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease-out;
}

#fetch-notify.show {
  opacity: 1;
  animation: fetchPop 1s ease-out forwards;
}

@keyframes fetchPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3);
  }
  40% {
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(1);
  }
}

#exit-btn {
  background: linear-gradient(180deg, #cd5c5c 0%, #8b0000 100%);
  border: 3px solid #5c4033;
  border-radius: 4px;
  padding: 8px 12px;
  color: #fff;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  cursor: pointer;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3),
    3px 3px 0 rgba(0, 0, 0, 0.3);
  transition: all 0.1s;
  text-transform: uppercase;
}

#exit-btn:hover {
  background: linear-gradient(180deg, #ff6b6b 0%, #cd5c5c 100%);
  transform: translate(-1px, -1px);
}

#exit-btn:active {
  transform: translate(2px, 2px);
}

#level-up {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  animation: levelUp 1.5s ease-out forwards;
}

#level-up h2 {
  font-size: 32px;
  color: #ffd700;
  text-shadow:
    3px 3px 0 #5c4033,
    -1px -1px 0 #8b6914;
  animation: pulse 0.3s ease-in-out infinite;
}

@keyframes levelUp {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  40% {
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

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

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(42, 26, 10, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-panel {
  background: linear-gradient(180deg, #c9a66b 0%, #a68544 100%);
  border: 6px solid #5c4033;
  border-radius: 8px;
  padding: 30px 50px;
  text-align: center;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.3),
    inset 0 -4px 0 rgba(0, 0, 0, 0.2),
    0 0 0 3px #8b6914,
    8px 8px 0 rgba(0, 0, 0, 0.4);
  max-width: 90%;
}

.modal-panel h1 {
  font-size: 24px;
  margin-bottom: 20px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.modal-panel p {
  font-size: 10px;
  margin-bottom: 12px;
  color: #3d2817;
}

.modal-panel .highlight {
  color: #8b0000;
  font-weight: bold;
}

#game-over .modal-panel h1 {
  color: #8b0000;
}

#victory .modal-panel h1 {
  color: #228b22;
  animation: bounce 0.6s ease-in-out infinite;
}

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

#start-screen .modal-panel h1 {
  color: #5c4033;
  font-size: 20px;
}

.pixel-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  padding: 14px 28px;
  margin: 10px 5px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s;
}

.pixel-btn-green {
  background: linear-gradient(180deg, #5cb85c 0%, #449d44 100%);
  color: #fff;
  border: 3px solid #3d7a3d;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 4px 0 #2d5a2d,
    3px 6px 0 rgba(0, 0, 0, 0.3);
  text-shadow: 1px 1px 0 #2d5a2d;
}

.pixel-btn-green:hover {
  background: linear-gradient(180deg, #6fcf6f 0%, #5cb85c 100%);
  transform: translateY(-2px);
}

.pixel-btn-green:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 2px 0 #2d5a2d;
}

.pixel-btn-red {
  background: linear-gradient(180deg, #d9534f 0%, #c9302c 100%);
  color: #fff;
  border: 3px solid #a02622;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 4px 0 #761b17,
    3px 6px 0 rgba(0, 0, 0, 0.3);
  text-shadow: 1px 1px 0 #761b17;
}

.pixel-btn-red:hover {
  background: linear-gradient(180deg, #e66460 0%, #d9534f 100%);
  transform: translateY(-2px);
}

.pixel-btn-red:active {
  transform: translateY(2px);
}

.pixel-btn-orange {
  background: linear-gradient(180deg, #f0ad4e 0%, #ec971f 100%);
  color: #fff;
  border: 3px solid #c77c11;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -3px 0 rgba(0, 0, 0, 0.2),
    0 4px 0 #946010,
    3px 6px 0 rgba(0, 0, 0, 0.3);
  text-shadow: 1px 1px 0 #946010;
}

.pixel-btn-orange:hover {
  background: linear-gradient(180deg, #f5c06e 0%, #f0ad4e 100%);
  transform: translateY(-2px);
}

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

#exit-confirm {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(42, 26, 10, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

#exit-confirm .modal-panel h2 {
  font-size: 16px;
  color: #5c4033;
  margin-bottom: 20px;
}

.hidden {
  display: none !important;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(5px);
  }
}

#game-over .modal-panel {
  animation: shake 0.5s ease-in-out;
}
