* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  align-items: center;
  background: #f4f6f1;
  color: #18201c;
  display: flex;
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  justify-content: center;
  margin: 0;
  min-height: 100%;
  overflow: hidden;
}

.page-shell {
  max-width: 960px;
  width: min(960px, calc(100vw - 24px));
}

.game-shell {
  background: #fffdf6;
  border: 2px solid #28342d;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(32, 42, 35, 0.16);
  overflow: hidden;
  position: relative;
  width: 100%;
}

.hud {
  align-items: center;
  background: #ffffff;
  border-bottom: 2px solid #28342d;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 56px;
  padding: 10px 16px;
}

.hud strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.hud span {
  color: #5e665d;
  display: block;
  font-size: 13px;
  line-height: 1.4;
}

.scoreboard {
  color: #1b2f25;
  display: flex;
  flex-wrap: wrap;
  font-family: "Courier New", monospace;
  font-size: 18px;
  font-weight: 700;
  gap: 14px;
  justify-content: flex-end;
  min-width: 170px;
  text-align: right;
}

canvas {
  aspect-ratio: 8 / 3;
  background: #f7fbff;
  display: block;
  height: auto;
  touch-action: manipulation;
  width: 100%;
}

.mobile-controls {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
  touch-action: none;
  user-select: none;
}

.control-button {
  border-radius: 8px;
  font-size: 20px;
  min-height: 58px;
  min-width: 0;
  padding: 0 12px;
  touch-action: none;
  width: 100%;
}

.jump-button {
  background: #1f6f4a;
}

.duck-button {
  background: #45534a;
}

.overlay {
  align-items: center;
  background: rgba(255, 253, 246, 0.88);
  display: flex;
  flex-direction: column;
  inset: 56px 0 0;
  justify-content: center;
  padding: 24px;
  position: absolute;
  text-align: center;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-size: clamp(30px, 7vw, 64px);
  letter-spacing: 0;
  line-height: 1;
  margin: 0 0 12px;
}

.overlay p {
  color: #4d554d;
  font-size: clamp(14px, 2.5vw, 18px);
  line-height: 1.6;
  margin: 0 0 18px;
  max-width: 520px;
}

button {
  background: #1f6f4a;
  border: 2px solid #163826;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: 700 18px/1 Arial, "Microsoft YaHei", sans-serif;
  min-height: 44px;
  min-width: 112px;
  padding: 0 22px;
}

button:active {
  transform: translateY(1px);
}

@media (max-width: 560px) {
  body {
    align-items: flex-start;
    padding-top: 10px;
  }

  .hud {
    align-items: flex-start;
    min-height: 72px;
    padding: 9px 10px;
  }

  .hud strong {
    font-size: 16px;
  }

  .hud span {
    font-size: 12px;
  }

  .scoreboard {
    font-size: 15px;
    gap: 6px;
    min-width: 112px;
  }

  .overlay {
    inset: 72px 0 0;
  }

  .page-shell {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 10px);
  }

  .game-shell {
    flex-shrink: 0;
  }

  .mobile-controls {
    flex: 1;
    align-content: center;
    gap: 14px;
    padding: 4px 10px 20px;
  }

  .control-button {
    font-size: 28px;
    min-height: 110px;
  }
}
