@font-face {
  font-family: "DotFont";
  src: local("Dot Font"), local("DotFont");
}

html,
body {
  margin: 0;
  padding: 0;
  background: #9bbc0f;
  font-family: "DotFont", "Dot Font", monospace;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  text-align: center;
}

.hidden {
  display: none !important;
}

.screen {
  width: 100vw;
  height: 100dvh;
  box-sizing: border-box;
}

/* ===== TITLE ===== */

#titleScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 22px;
}

#titleImage {
  width: min(330px, 90vw);
  image-rendering: pixelated;
  cursor: pointer;
}

#titleText {
  margin-top: 12px;
  font-size: 18px;
  line-height: 1.55;
  color: #0f380f;
}

#startBtn {
  margin-top: 18px;
  width: min(300px, 84vw);
  height: 54px;
  font-size: 18px;
  border: 4px solid #0f380f;
  background: #ff7f00;
  color: white;
  font-family: "DotFont", "Dot Font", monospace;
  cursor: pointer;
}

/* ===== GAME ===== */

#gameArea {
  width: min(320px, 100vw);
  margin: 0 auto;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #8bac0f;
  image-rendering: pixelated;
}

#dialogBox {
  width: 100%;
  min-height: 74px;
  background: #0f380f;
  color: #9bbc0f;
  padding: 8px 10px;
  box-sizing: border-box;
  line-height: 1.5;
  font-size: 14px;
  text-align: left;
}

#controls {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(360px, 96vw);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== 十字キー ===== */

#dpad {
  position: relative;
  width: 130px;
  height: 130px;
}

.dpad-btn {
  position: absolute;
  width: 42px;
  height: 42px;
  background: #0f380f;
  color: #9bbc0f;
  border: 2px solid #306230;
  font-size: 18px;
  font-family: "DotFont", "Dot Font", monospace;
}

.dpad-btn.up { left: 44px; top: 0; }
.dpad-btn.left { left: 0; top: 44px; }
.dpad-btn.right { left: 88px; top: 44px; }
.dpad-btn.down { left: 44px; top: 88px; }

/* ===== アクション ===== */

#actionButtons {
  width: 145px;
  height: 112px;
  position: relative;
}

.action-btn {
  position: absolute;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: #0f380f;
  color: #9bbc0f;
  border: 2px solid #306230;
  font-size: 14px;
  font-family: "DotFont", "Dot Font", monospace;
}

#talkBtn {
  right: 0;
  top: 8px;
}

#stopBtn {
  left: 0;
  top: 38px;
}

/* ===== RESULT ===== */

#resultScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: #9bbc0f;
  overflow-y: auto;
}

#resultImage {
  width: min(300px, 84vw);
  image-rendering: pixelated;
}

#resultText {
  margin-top: 10px;
  color: #0f380f;
  font-size: 17px;
  line-height: 1.5;
}

#password {
  font-size: 21px;
  font-weight: bold;
}

#resultButtons {
  width: min(300px, 84vw);
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-btn {
  width: 100%;
  min-height: 46px;
  border: 3px solid #0f380f;
  background: white;
  color: #0f380f;
  font-size: 17px;
  font-family: "DotFont", "Dot Font", monospace;
}

button:active {
  transform: scale(0.96);
}

@media (max-height: 620px) {
  #resultImage {
    width: min(260px, 76vw);
  }

  #resultText {
    margin-top: 8px;
    font-size: 15px;
    line-height: 1.4;
  }

  #password {
    font-size: 18px;
  }

  #resultButtons {
    margin-top: 10px;
    gap: 7px;
  }

  .result-btn {
    min-height: 42px;
    font-size: 15px;
  }
}

@media (max-height: 540px) {
  #resultImage {
    width: min(220px, 68vw);
  }

  #resultText {
    font-size: 14px;
    line-height: 1.3;
  }

  #password {
    font-size: 16px;
  }

  .result-btn {
    min-height: 38px;
    font-size: 14px;
  }
}