* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #24313a;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: grid;
  place-items: center;
}

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

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

.hud {
  position: absolute;
  inset: 18px 18px auto 18px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.stage-badge,
.toggle-button,
.icon-button {
  min-height: 42px;
  border: 2px solid rgba(31, 42, 46, 0.82);
  background: rgba(255, 255, 255, 0.86);
  color: #1f2a2e;
  box-shadow: 0 4px 0 rgba(31, 42, 46, 0.16);
}

.stage-badge {
  display: inline-grid;
  place-items: center;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0;
}

.toggle-button {
  min-width: 104px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  pointer-events: auto;
  cursor: pointer;
}

.toggle-button.is-on {
  background: rgba(255, 236, 143, 0.94);
  color: #242018;
}

#audioToggleButton {
  grid-column: 3;
  min-width: 0;
}

#bodyToggleButton {
  grid-column: 4;
}

#homeButton {
  grid-column: 5;
}

#retryButton {
  grid-column: 6;
}

.icon-button {
  width: 46px;
  border-radius: 8px;
  padding: 0;
  font-size: 27px;
  font-weight: 800;
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
}

.icon-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(31, 42, 46, 0.16);
}

.home-menu {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 86px 40px 36px;
  background: rgba(237, 247, 245, 0.72);
}

.home-menu.is-hidden {
  display: none;
}

.help-menu {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 86px 40px 36px;
  background: rgba(255, 251, 231, 0.88);
}

.help-menu.is-hidden {
  display: none;
}

.home-panel {
  width: min(760px, 100%);
  display: grid;
  gap: 18px;
  justify-items: center;
}

.help-panel {
  width: min(700px, 100%);
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 34px 42px;
  border: 3px solid rgba(31, 42, 46, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 0 rgba(31, 42, 46, 0.14);
}

.home-panel h1 {
  margin: 0;
  color: #1f2a2e;
  font-size: 54px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 5px 0 rgba(255, 255, 255, 0.72);
}

.help-panel h1 {
  margin: 0 0 8px;
  color: #1f2a2e;
  font-size: 48px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.help-panel p {
  margin: 0;
  color: #26343a;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
}

.stage-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stage-select-button,
.debug-ending-button,
.help-start-button {
  min-height: 72px;
  border: 3px solid rgba(31, 42, 46, 0.88);
  border-radius: 8px;
  background: rgba(255, 247, 214, 0.96);
  color: #1f2a2e;
  box-shadow: 0 6px 0 rgba(31, 42, 46, 0.18);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  cursor: pointer;
}

.stage-select-button:disabled {
  background: rgba(218, 225, 225, 0.82);
  color: rgba(31, 42, 46, 0.42);
  border-color: rgba(31, 42, 46, 0.32);
  box-shadow: none;
  cursor: default;
}

.stage-select-button:not(:disabled):active,
.debug-ending-button:active,
.help-start-button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(31, 42, 46, 0.18);
}

.debug-ending-button,
.help-start-button {
  min-width: 220px;
  min-height: 52px;
  background: rgba(220, 244, 255, 0.96);
  font-size: 15px;
}

.help-start-button {
  margin-top: 16px;
  background: rgba(255, 236, 143, 0.96);
}
