/* ============ Weather Bar ============ */
.weather-bar {
  align-items: center;
  background: rgba(255,255,250,0.92);
  border: 1.5px solid #d8dcd0;
  border-radius: 10px;
  color: #2d3828;
  display: flex;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  font-weight: 600;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
  padding: 8px 18px;
  transition: opacity 0.35s;
  width: 100%;
}

.weather-bar.hidden {
  opacity: 0;
  pointer-events: none;
}

#weatherIcon { font-size: 18px; }
#weatherName { font-size: 15px; font-weight: 800; }
#weatherBuff { color: #5b6840; font-size: 13px; }
#weatherTimer { color: #8a9480; font-size: 12px; margin-left: auto; }

@media (max-width: 560px) {
  .weather-bar {
    font-size: 12px;
    gap: 6px;
    padding: 6px 10px;
  }
  #weatherName { font-size: 13px; }
  #weatherBuff { font-size: 11px; }
}

/* ============ Reset & Base ============ */
* {
  box-sizing: border-box;
}

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

body {
  align-items: center;
  background: linear-gradient(135deg, #e8ede4 0%, #d5ddd2 30%, #e2e8dc 60%, #eef1ea 100%);
  color: #18201c;
  display: flex;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  justify-content: center;
  margin: 0;
  min-height: 100%;
  overflow: hidden;
}

.game-wrapper {
  align-items: center;
  display: flex;
  flex-direction: column;
  width: min(960px, calc(100vw - 20px));
}

/* ============ Game Shell ============ */
.game-shell {
  background: #fefefb;
  border: 2px solid #d0d8cd;
  border-radius: 14px;
  box-shadow:
    0 4px 8px rgba(44, 52, 42, 0.06),
    0 16px 48px rgba(44, 52, 42, 0.12);
  max-width: 960px;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.4s;
  width: min(960px, calc(100vw - 20px));
}

.game-shell:has(.overlay:not(.hidden)) {
  box-shadow:
    0 4px 8px rgba(44, 52, 42, 0.04),
    0 24px 64px rgba(44, 52, 42, 0.18);
}

/* ============ HUD ============ */
.hud {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #e6ebe3;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 18px;
  user-select: none;
}

.hud-title {
  align-items: center;
  display: flex;
  gap: 10px;
}

.hud-icon {
  font-size: 26px;
  line-height: 1;
}

.hud-title strong {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.hud-title small {
  color: #7f897b;
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* ---- Score Chips ---- */
/* ---- HP 爱心 ---- */
.hud-hp {
  display: flex;
  gap: 3px;
  margin-left: auto;
  margin-right: 10px;
}

.hp-heart {
  font-size: 20px;
  line-height: 1;
  transition: transform 0.2s, opacity 0.3s;
}

.hp-heart.lost {
  opacity: 0.22;
  transform: scale(0.75);
}

.hp-heart.hurt {
  animation: heartShake 0.35s ease-out;
}

.hp-heart.hidden {
  display: none;
}

@keyframes heartShake {
  0%   { transform: scale(1); }
  20%  { transform: scale(1.35); }
  40%  { transform: scale(0.85); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---- Top Buttons ---- */
.top-btns {
  align-self: flex-end;
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  z-index: 40;
}

/* ---- Settings Button (Global) ---- */
.settings-btn-global {
  background: rgba(255,255,250,0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1.5px solid #d8dcd0;
  border-radius: 10px;
  color: #5b6850;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  min-width: auto;
  min-height: auto;
  padding: 7px 10px;
  transition: background 0.2s, box-shadow 0.2s;
}
.settings-btn-global:hover {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ---- Toast ---- */
.toast {
  background: rgba(30,30,25,0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 10px;
  color: #fff;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  font-weight: 600;
  left: 50%;
  opacity: 0;
  padding: 12px 24px;
  pointer-events: none;
  position: fixed;
  top: 60px;
  transform: translateX(-50%) translateY(-10px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hud-scores {
  display: flex;
  gap: 8px;
}

.score-chip {
  background: #f4f6f1;
  border: 1.5px solid #dde3d8;
  border-radius: 8px;
  color: #1e2d22;
  font-family: "SF Mono", "Cascadia Code", "Courier New", monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  min-width: 72px;
  padding: 8px 12px;
  text-align: center;
  transition:
    background 0.25s,
    border-color 0.25s,
    transform 0.15s;
}

.score-chip--best {
  background: #fffdf5;
  border-color: #ede4c8;
  color: #8b6914;
}

.score-chip.pop {
  animation: scorePop 0.32s ease-out;
}

@keyframes scorePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* ============ Canvas ============ */
canvas {
  aspect-ratio: 16 / 11;
  background: #f7fbff;
  display: block;
  height: auto;
  touch-action: manipulation;
  width: 100%;
}

/* ============ Overlay ============ */
.overlay {
  align-items: center;
  background: rgba(30, 34, 26, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 1;
  padding: 20px;
  position: absolute;
  text-align: center;
  transition: opacity 0.35s ease;
  z-index: 10;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---- Card inside overlay ---- */
.overlay-card {
  background: #fffef8;
  border: 1.5px solid #e2ded0;
  border-radius: 18px;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.06),
    0 12px 42px rgba(0,0,0,0.14);
  max-width: 420px;
  padding: 32px 28px 28px;
  transform: translateY(0);
  transition: transform 0.35s ease;
  width: 100%;
}

.overlay:not(.hidden) .overlay-card {
  animation: cardIn 0.4s ease-out;
}

@keyframes cardIn {
  0%   { transform: translateY(18px); opacity: 0.6; }
  100% { transform: translateY(0);    opacity: 1; }
}

.overlay-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 6px;
  transition: transform 0.3s;
}

/* ---- Game Over variant ---- */
.overlay[data-state="over"] .overlay-icon {
  animation: iconShake 0.45s ease-out;
}

@keyframes iconShake {
  0%   { transform: rotate(0); }
  20%  { transform: rotate(-15deg); }
  40%  { transform: rotate(12deg); }
  60%  { transform: rotate(-8deg); }
  80%  { transform: rotate(4deg); }
  100% { transform: rotate(0); }
}

.overlay h1 {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.15;
  margin: 0 0 10px;
}

.overlay[data-state="over"] h1 {
  color: #c0392b;
}

.overlay p {
  color: #5b6357;
  font-size: clamp(13px, 2vw, 15px);
  line-height: 1.65;
  margin: 0 0 12px;
}

/* ---- 加载进度条 ---- */
.load-bar-wrap {
  align-items: center;
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
  width: 100%;
}

.load-bar {
  background: #e8ece4;
  border-radius: 6px;
  flex: 1;
  height: 10px;
  overflow: hidden;
}

.load-bar::after {
  background: linear-gradient(90deg, #27ae60, #2ecc71);
  border-radius: 6px;
  content: "";
  display: block;
  height: 100%;
  transition: width 0.25s ease;
  width: 0%;
}

#loadPercent {
  color: #7f897b;
  font-size: 13px;
  font-weight: 700;
  min-width: 32px;
  text-align: right;
}

.overlay[data-state="over"] p {
  color: #8b4035;
  font-weight: 600;
}

/* ============ Buttons ============ */
button {
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  outline: none;
  padding: 0 36px;
  position: relative;
  transition:
    transform 0.12s ease,
    box-shadow 0.18s ease,
    background 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.55);
}

.btn {
  font-size: 17px;
  min-height: 50px;
  min-width: 140px;
}

/* ---- Go (开始) button ---- */
.btn--go {
  background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
  box-shadow: 0 4px 14px rgba(39, 174, 96, 0.35);
  color: #fff;
}

.btn--go:hover {
  box-shadow: 0 6px 22px rgba(39, 174, 96, 0.48);
  transform: translateY(-2px);
}

.btn--go:active {
  box-shadow: 0 2px 6px rgba(39, 174, 96, 0.25);
  transform: translateY(1px) scale(0.98);
}

/* ---- Retry (重来) button ---- */
.btn--retry {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  box-shadow: 0 4px 14px rgba(231, 76, 60, 0.35);
  color: #fff;
}

.btn--retry:hover {
  box-shadow: 0 6px 22px rgba(231, 76, 60, 0.48);
  transform: translateY(-2px);
}

.btn--retry:active {
  box-shadow: 0 2px 6px rgba(231, 76, 60, 0.25);
  transform: translateY(1px) scale(0.98);
}

/* ============ Responsive ============ */
@media (max-width: 560px) {
  body {
    align-items: flex-start;
    padding-top: 8px;
  }

  .game-shell {
    border-radius: 10px;
  }

  .hud {
    padding: 10px 12px;
  }

  .hud-icon {
    font-size: 22px;
  }

  .hud-title strong {
    font-size: 15px;
  }

  .hud-title small {
    font-size: 10px;
  }

  .hp-heart {
    font-size: 16px;
  }

  .score-chip {
    font-size: 13px;
    min-width: 56px;
    padding: 6px 10px;
  }

  .overlay-card {
    padding: 24px 18px 22px;
  }

  .overlay-icon {
    font-size: 40px;
  }

  .btn {
    font-size: 15px;
    min-height: 44px;
    min-width: 120px;
    padding: 0 28px;
  }
}

/* ============ Announce Popup ============ */
.announce {
  align-items: center;
  background: rgba(24, 28, 20, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: absolute;
  text-align: center;
  z-index: 20;
  transition: opacity 0.35s ease;
}

.announce.hidden {
  opacity: 0;
  pointer-events: none;
}

.announce-card {
  animation: announceIn 0.5s ease-out;
  background: #fffef8;
  border: 1.5px solid #e2ded0;
  border-radius: 20px;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.05),
    0 14px 48px rgba(0,0,0,0.15);
  max-width: 400px;
  padding: 30px 26px 26px;
  width: 100%;
}

@keyframes announceIn {
  0%   { transform: translateY(24px) scale(0.94); opacity: 0; }
  100% { transform: translateY(0) scale(1);      opacity: 1; }
}

.announce-avatar {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 8px;
}

.announce-card h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 12px;
  color: #1e2d22;
}

.announce-card p {
  color: #4b5549;
  font-size: 14px;
  line-height: 1.75;
  margin: 0 0 10px;
}

.announce-sign {
  color: #8b6914;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 18px !important;
}

/* ---- Changelog 滚动区 ---- */
.announce-changelog {
  max-width: 440px;
  padding: 24px 20px 20px;
}

.announce-body {
  color: #3b4539;
  font-size: 13px;
  line-height: 1.8;
  margin: 0 0 14px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 8px;
  text-align: left;
}

.announce-body p {
  margin: 0 0 4px;
}

.announce-body strong {
  color: #1e2d22;
  font-size: 14px;
}

.announce-date {
  color: #a0a090 !important;
  font-size: 12px !important;
  margin-top: 8px !important;
  text-align: center;
}

/* 滚动条美化 */
.announce-body::-webkit-scrollbar {
  width: 5px;
}
.announce-body::-webkit-scrollbar-track {
  background: #f0f0ea;
  border-radius: 4px;
}
.announce-body::-webkit-scrollbar-thumb {
  background: #c8c8b8;
  border-radius: 4px;
}

.announce-card .btn {
  display: inline-block;
}

@media (max-width: 560px) {
  .announce-card {
    padding: 24px 16px 20px;
  }
  .announce-changelog {
    padding: 18px 12px 16px;
  }
  .announce-body {
    max-height: 200px;
    font-size: 12px;
  }
  .announce-avatar {
    font-size: 42px;
  }
  .announce-card h2 {
    font-size: 18px;
  }
  .announce-card p {
    font-size: 13px;
  }
}

/* ============ Pause Overlay ============ */
.pause-overlay {
  align-items: center;
  background: rgba(20, 24, 16, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  inset: 0;
  justify-content: center;
  position: absolute;
  z-index: 25;
  transition: opacity 0.25s;
}

.pause-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.pause-card {
  animation: cardIn 0.3s ease-out;
  background: #fffef8;
  border: 1.5px solid #e0dcc8;
  border-radius: 16px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.14);
  padding: 30px 28px 24px;
  text-align: center;
}

.pause-card h2 {
  font-size: 28px;
  margin: 0 0 10px;
}

.pause-card p {
  color: #6b7060;
  font-size: 14px;
  margin: 0 0 18px;
}

/* ============ Settings Panel ============ */
.settings-panel {
  align-items: center;
  background: rgba(20, 24, 16, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  inset: 0;
  justify-content: center;
  position: absolute;
  z-index: 30;
  transition: opacity 0.3s;
}

.settings-panel.hidden {
  opacity: 0;
  pointer-events: none;
}

.settings-card {
  animation: cardIn 0.35s ease-out;
  background: #fffef8;
  border: 1.5px solid #e0dcc8;
  border-radius: 16px;
  box-shadow: 0 8px 36px rgba(0,0,0,0.18);
  max-width: 380px;
  padding: 26px 24px 22px;
  width: 90%;
}

.settings-card h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 16px;
  text-align: center;
}

.settings-group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.settings-group label {
  font-size: 14px;
  font-weight: 600;
  min-width: 80px;
}

.settings-group input[type="range"] {
  flex: 1;
  accent-color: #27ae60;
}

.settings-group span {
  font-size: 13px;
  font-weight: 700;
  min-width: 28px;
  text-align: right;
}

.settings-radios {
  display: flex;
  gap: 16px;
}

.settings-radios label {
  font-size: 14px;
  font-weight: 500;
  min-width: auto;
}

.settings-version {
  color: #b0a890;
  font-size: 12px;
  margin-bottom: 8px;
  text-align: center;
}

@media (max-width: 560px) {
  .settings-card {
    padding: 20px 16px 18px;
  }
  .settings-group {
    gap: 6px;
  }
}
