html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #90c9f5;
  color: #123042;
  font-family: "Trebuchet MS", "Avenir Next Condensed", "Segoe UI", sans-serif;
  touch-action: none;
}

body {
  margin: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-canvas {
  position: absolute;
  inset: 0;
}

.grid-debug-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 8;
  min-width: 62px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: rgba(14, 73, 110, 0.88);
  color: #ffffff;
  font: 800 12px/1 "Trebuchet MS", "Avenir Next Condensed", "Segoe UI", sans-serif;
  letter-spacing: 0.14em;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.grid-debug-toggle.is-hidden {
  display: none;
}

.grid-debug-toggle.is-active {
  background: rgba(255, 255, 255, 0.94);
  color: #0e496e;
}

.debug-panel {
  position: absolute;
  top: 52px;
  right: 10px;
  z-index: 7;
  margin: 0;
  padding: 0;
  color: #ffffff;
  font: 600 13px/1.45 "Trebuchet MS", "Avenir Next Condensed", "Segoe UI", sans-serif;
  white-space: pre-line;
  text-align: right;
  pointer-events: auto;
  cursor: copy;
  user-select: text;
  -webkit-user-select: text;
  text-shadow: 0 1px 2px rgba(18, 39, 54, 0.72);
}

.debug-panel.is-hidden {
  display: none;
}

.decision-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.decision-marker {
  position: absolute;
  width: 72px;
  height: 28px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(14, 73, 110, 0.86);
  color: #ffffff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  pointer-events: none;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.decision-plane-button {
  position: absolute;
  z-index: 5;
  width: clamp(30px, 7vw, 52px);
  height: clamp(30px, 7vw, 52px);
  margin: 0;
  border: 0;
  border-radius: clamp(8px, 1.8vw, 10px);
  background: rgba(14, 73, 110, 0.92);
  color: #ffffff;
  font: inherit;
  font-family: "Trebuchet MS", "Avenir Next Condensed", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(20px, 4.8vw, 32px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.decision-plane-button:active {
  transform: translate(-50%, -50%) scale(0.98);
}

.decision-panel {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 28px));
  padding: 10px 12px 12px;
  border-radius: 22px;
  background: rgba(14, 73, 110, 0.88);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

.decision-panel.is-hidden {
  display: none;
}

.decision-caption {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.decision-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.decision-action {
  min-height: 64px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  color: #d34c3f;
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.decision-action:active {
  transform: scale(0.98);
}

.hud {
  display: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 0;
}

.overlay.is-hidden {
  display: none;
}

.overlay.start-mode .gameover-panel,
.overlay.gameover-mode .start-button {
  display: none;
}

.overlay.gameover-mode {
  background: rgba(17, 36, 48, 0.26);
}

.start-button {
  width: 100%;
  padding: 20px 24px;
  border: 0;
  border-radius: 0;
  background: rgba(14, 73, 110, 0.74);
  color: #ffffff;
  font: inherit;
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 14px 40px rgba(26, 80, 118, 0.22);
}

.start-button:active {
  transform: scale(0.985);
}

.gameover-panel {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: 100%;
  padding: 20px 24px 24px;
  color: #ffffff;
}

.gameover-title {
  margin: 0;
  width: 100%;
  padding: 18px 24px;
  background: rgba(14, 73, 110, 0.74);
  color: #ffffff;
  text-align: center;
  font-size: clamp(36px, 9vw, 52px);
  letter-spacing: 0.18em;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 16px;
  width: min(88vw, 400px);
}

.score-card {
  padding: 14px 12px;
  text-align: center;
}

.score-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  letter-spacing: 0.2em;
  color: rgba(240, 248, 255, 0.72);
}

.score-card strong {
  display: block;
  font-size: clamp(38px, 8vw, 48px);
}

.reason-display {
  margin: 0;
  padding: 0 18px;
  text-align: center;
  color: rgba(240, 248, 255, 0.88);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
}

.retry-button {
  width: 96px;
  height: 96px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(21, 63, 92, 0.2);
}

.retry-icon {
  display: block;
  font-size: 44px;
  line-height: 1;
}

@media (max-width: 640px) {
  .hud {
    font-size: 12px;
    gap: 8px;
  }

  .hud span {
    padding: 6px 8px;
  }

  .start-button {
    padding: 18px 14px;
    font-size: clamp(22px, 7vw, 28px);
  }

  .decision-panel {
    bottom: calc(14px + env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    padding: 10px;
  }

  .decision-action {
    min-height: 58px;
    font-size: 18px;
  }

  .gameover-panel {
    padding: 18px 0 24px;
  }

  .retry-button {
    width: 88px;
    height: 88px;
  }
}
