@charset "utf-8";

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background-color: #f0f0f0;
  font-family: "Minecraft", "Press Start 2P", cursive;
  /* background: #7b7b7b url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAIklEQVQIW2NkQAKrVq36zwjjgzhhYWGMYAEYB8RmROaABADeOQ8CXl/xfgAAAABJRU5ErkJggg=="); */
}

.game-container {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  flex-wrap: wrap;
}

#gameCanvas {
  border: 4px solid #5b5b5b;
  background-color: #8ab8a5;
  box-shadow: 8px 8px 0 #4a4a4a, inset 4px 4px 0 #b0c9bf;
  margin-right: 12px;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
  width: 90vmin;
  height: auto;
  aspect-ratio: 1;
}

#gameControls {
  text-align: center;
  margin: 0 auto;
  padding: 0 8px;
}

#gameScore {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 300px;
}

#score {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  color: #fff;
  text-shadow: 3px 3px #000;
  background: #404040;
  padding: 10px 20px;
  border: 4px solid #707070;
  margin: 15px 0;
  box-shadow: 4px 4px 0 #2d2d2d;
  width: 80%;
  text-align: center;
}

#startBtn {
  font-family: "Minecraft", "Press Start 2P", cursive;
  background: #727272;
  color: #fff;
  border: 4px solid;
  border-color: #a0a0a0 #5a5a5a #5a5a5a #a0a0a0;
  padding: 12px 24px;
  text-shadow: 2px 2px #000;
  transition: all 0.1s;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
  position: relative;
  margin: 10px 0;
  font-size: 20px;
}

#startBtn:hover {
  background: #808080;
  transform: translateY(-2px);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.2);
}

#startBtn:active {
  transform: translateY(2px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
  border-color: #5a5a5a #a0a0a0 #a0a0a0 #5a5a5a;
}

#startBtn::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), transparent);
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 200px;
  margin: 20px auto;
}

.control-btn {
  width: 60px;
  height: 60px;
  background: #727272;
  border: 4px solid;
  border-color: #a0a0a0 #5a5a5a #5a5a5a #a0a0a0;
  color: #fff;
  font-size: 28px;
  text-shadow: 2px 2px #000;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
  transition: all 0.1s;
  border-radius: 0;
}

.control-btn::before {
  content: "";
  position: absolute;
  top: 5%;
  left: 5%;
  right: 5%;
  bottom: 5%;
  border-radius: 50%;
  z-index: -1;
}

.control-btn:hover {
  background: #808080;
  transform: translateY(-2px);
}

.control-btn:active {
  transform: translateY(2px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
  border-color: #5a5a5a #a0a0a0 #a0a0a0 #5a5a5a;
}

#up {
  grid-column: 2;
  background: #4a752d;
  border-color: #6ea64a #2d4a1a #2d4a1a #6ea64a;
}

#left {
  grid-column: 1;
  grid-row: 2;
  background: #4a752d;
  border-color: #6ea64a #2d4a1a #2d4a1a #6ea64a;
}

#right {
  grid-column: 3;
  grid-row: 2;
  background: #4a752d;
  border-color: #6ea64a #2d4a1a #2d4a1a #6ea64a;
}

#down {
  grid-column: 2;
  grid-row: 3;
  background: #4a752d;
  border-color: #6ea64a #2d4a1a #2d4a1a #6ea64a;
}

/* Minecraft 风格提示框样式 */
.minecraft-modal,
#game-paused {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #404040;
  border: 4px solid #707070;
  padding: 20px;
  color: white;
  font-family: "Minecraft", Arial, sans-serif;
  text-align: center;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.minecraft-title,
#game-paused span {
  font-size: 24px;
  margin-bottom: 10px;
  text-shadow: 2px 2px #000;
}

.minecraft-button {
  background: #727272;
  border: 3px solid #a0a0a0;
  color: white;
  padding: 8px 16px;
  margin-top: 10px;
  cursor: pointer;
  font-family: "Minecraft", Arial, sans-serif;
  transition: all 0.1s;
}

.minecraft-button:hover {
  background: #808080;
  border-color: #b0b0b0;
}

.minecraft-button:active {
  transform: translateY(2px);
}

#finalScore,
#rankingInfo {
  margin-bottom: 10px;
}

#submitSection {
  margin-bottom: 20px;
}

#playerName {
  padding:0 6px;
  line-height: 22px;
  border-radius: 4px;
}

.result-btns {
  display: flex;
  width: 140px;
  margin: 0 auto;
  justify-content: center;
}

.result-btns button {
  padding: 4px 8px;
  cursor: pointer;
}

#submitScore + #restartBtn {
  margin-left: 20px;
}

#submitScore[disabled] + #restartBtn {
  margin-left: 0;
}

.submit-error {
  color: #dc3f3f;
  margin: 10px 0;
}

#rankingList {
  list-style: none;
  padding: 0;
}

/* 移动端，简单判断屏幕宽度 */
@media (max-width: 768px) {
  #gameCanvas {
    margin: 2vw 0;
  }

  #score {
    margin: 2vw 0;
    font-size: 6.4vw;
    padding: 2vw 4vw;
  }

  #startBtn {
    font-size: 5.6vw;
    padding: 2.4vw 4.8vw;
    margin: 2vw 0;
  }

  .controls {
    margin: 2vw auto;
    gap: 2vw;
    width: 48vw;
  }
  
  .control-btn {
    width: 15vmin;
    height: 15vmin;
    font-size: 6vmin;
  }
}

@media (hover: none) {
  .control-btn {
  }
}