* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f2ddc6;
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

body {
  display: grid;
  place-items: center;
  overscroll-behavior: none;
}

.game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  max-width: 720px;
  max-height: 1280px;
  overflow: hidden;
  background: #fff3e4;
  box-shadow: 0 0 60px rgba(214, 143, 77, 0.35);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

.audio-button {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  min-width: 112px;
  height: 44px;
  padding: 0 14px;
  border: 2px solid rgba(184, 108, 48, 0.55);
  border-radius: 22px;
  color: #8a5a2b;
  background: rgba(255, 250, 242, 0.9);
  box-shadow: 0 2px 10px rgba(184, 108, 48, 0.22);
  font: 800 14px/1 "Segoe UI", sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(5px);
}

.audio-button.is-on {
  color: #ffffff;
  border-color: #ff9d5c;
  background: #ff9d5c;
  box-shadow: 0 2px 14px rgba(255, 157, 92, 0.55);
}

.audio-button:active {
  transform: scale(0.96);
}

.home-button,
.title-button {
  position: absolute;
  z-index: 5;
  border: 2px solid #ff8fab;
  color: #ffffff;
  background: #ff8fab;
  box-shadow: 0 2px 14px rgba(255, 143, 171, 0.5);
  font: 900 15px/1 "Yu Gothic", "Meiryo", sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(5px);
}

.home-button {
  top: max(18px, env(safe-area-inset-top));
  right: 142px;
  min-width: 86px;
  height: 44px;
  padding: 0 14px;
  border-radius: 22px;
}

.title-button {
  left: 50%;
  width: min(62%, 320px);
  height: 58px;
  border-radius: 29px;
  transform: translateX(-50%);
  font-size: 18px;
}

.title-button.is-ending {
  top: 88%;
}

.home-button:active {
  transform: scale(0.96);
}

.title-button:active {
  transform: translateX(-50%) scale(0.97);
}

.reset-button {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 6.5%;
  width: min(46%, 280px);
  height: 52px;
  border: 2px solid rgba(138, 90, 43, 0.42);
  border-radius: 26px;
  color: #8a5a2b;
  background: rgba(255, 250, 242, 0.92);
  box-shadow: 0 2px 12px rgba(138, 90, 43, 0.2);
  transform: translateX(-50%);
  font: 900 16px/1 "Yu Gothic", "Meiryo", sans-serif;
  cursor: pointer;
  backdrop-filter: blur(5px);
}

.reset-button:active {
  transform: translateX(-50%) scale(0.97);
}

.home-dialog {
  width: min(86vw, 430px);
  margin: auto;
  padding: 28px;
  border: 2px solid #ffb27a;
  border-radius: 20px;
  color: #6b4423;
  background: #fffaf2;
  box-shadow: 0 0 45px rgba(214, 143, 77, 0.4);
}

.home-dialog::backdrop {
  background: rgba(80, 48, 20, 0.5);
  backdrop-filter: blur(4px);
}

.home-dialog p {
  margin: 0 0 26px;
  text-align: center;
  font: 900 22px/1.5 "Yu Gothic", "Meiryo", sans-serif;
}

.home-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dialog-button {
  min-height: 52px;
  border: 2px solid;
  border-radius: 12px;
  font: 900 16px/1 "Yu Gothic", "Meiryo", sans-serif;
  cursor: pointer;
}

.dialog-button.is-cancel {
  border-color: rgba(138, 90, 43, 0.4);
  color: #8a5a2b;
  background: #f7ead9;
}

.dialog-button.is-ok {
  border-color: #ff8fab;
  color: #ffffff;
  background: #ff8fab;
  box-shadow: 0 2px 12px rgba(255, 143, 171, 0.4);
}

.dialog-button:active {
  transform: scale(0.97);
}

@media (max-width: 430px) {
  .audio-button {
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
    min-width: 96px;
    height: 38px;
    font-size: 12px;
  }

  .home-button {
    top: max(10px, env(safe-area-inset-top));
    right: 116px;
    min-width: 72px;
    height: 38px;
    padding: 0 10px;
    font-size: 12px;
  }

  .title-button {
    height: 52px;
    font-size: 16px;
  }

  .reset-button {
    height: 46px;
    font-size: 14px;
  }
}
