* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: #0b2a4a;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: pointer;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}
#hud > * { pointer-events: auto; }

.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.hud-right { margin-left: auto; }

.pill {
  background: rgba(10, 30, 55, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
}

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(10, 30, 55, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.icon-btn:active { transform: scale(0.9); }

.bars {
  width: 100%;
  max-width: 340px;
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(10, 30, 55, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 14px;
  padding: 8px 12px;
}
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label { color: #fff; font-size: 13px; min-width: 40px; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.bar { flex: 1; height: 10px; border-radius: 999px; background: rgba(255,255,255,.18); overflow: hidden; }
.bar .fill { height: 100%; width: 0%; border-radius: 999px; transition: width .3s; }
.bar.xp .fill { background: linear-gradient(90deg, #ffd166, #ff9f1c); box-shadow: 0 0 8px #ffca3a; }
.bar.sat .fill { background: linear-gradient(90deg, #80ffdb, #48bfe3); box-shadow: 0 0 8px #64dfdf; }
.bar-num { color: #fff; font-size: 11px; min-width: 52px; text-align: right; opacity: .9; }
.tank-info { color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* ---------- 引导 & toast ---------- */
#hint {
  position: fixed;
  left: 50%; top: 38%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  color: #0b2a4a;
  font-size: 16px; font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
  z-index: 20;
  pointer-events: none;
  animation: floaty 2s ease-in-out infinite;
  transition: opacity .6s;
  white-space: nowrap;
}
#hint.hidden { opacity: 0; }

@keyframes floaty {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-8px); }
}

#toast {
  position: fixed;
  left: 50%; top: 26%;
  transform: translateX(-50%) scale(1);
  background: linear-gradient(135deg, #ff9ff3, #f368e0);
  color: #fff;
  font-size: 20px; font-weight: 700;
  padding: 14px 30px;
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(243, 104, 224, .5);
  z-index: 30;
  pointer-events: none;
  transition: opacity .4s, transform .4s;
  text-shadow: 0 2px 6px rgba(0,0,0,.25);
  white-space: nowrap;
}
#toast.hidden { opacity: 0; transform: translateX(-50%) scale(.8); }

/* ---------- 商店 ---------- */
#shop-overlay {
  position: fixed; inset: 0;
  background: rgba(4, 18, 34, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  transition: opacity .25s;
}
#shop-overlay.hidden { opacity: 0; pointer-events: none; }

#shop {
  width: 100%; max-width: 440px;
  max-height: 82vh;
  background: linear-gradient(160deg, #123a63, #0b2545);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.shop-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.shop-head h2 { color: #fff; font-size: 18px; flex: 1; }
.shop-coins { color: #ffd166; font-weight: 700; font-size: 16px; }

.shop-tabs { display: flex; padding: 10px 12px 0; gap: 8px; }
.tab {
  flex: 1; padding: 10px 0;
  border: none; border-radius: 12px 12px 0 0;
  background: transparent; color: rgba(255,255,255,.55);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.tab.active { background: rgba(255,255,255,.1); color: #fff; }

.shop-list {
  overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 12px;
}
.shop-emoji { font-size: 34px; }
.shop-info { flex: 1; min-width: 0; }
.shop-info h3 { color: #fff; font-size: 15px; margin-bottom: 2px; }
.shop-info p { color: rgba(255,255,255,.6); font-size: 12px; line-height: 1.5; }
.shop-info .lock { color: #ff9ff3; }
.buy-btn {
  border: none; border-radius: 12px;
  background: linear-gradient(135deg, #ff9ff3, #f368e0);
  color: #fff; font-weight: 700; font-size: 14px;
  padding: 10px 16px; cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(243,104,224,.4);
}
.buy-btn:disabled { background: rgba(255,255,255,.15); box-shadow: none; cursor: not-allowed; opacity: .6; }
.buy-btn:active:not(:disabled) { transform: scale(.94); }
.shop-empty { color: rgba(255,255,255,.5); text-align: center; padding: 24px; font-size: 14px; }

#credit {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  left: 0; right: 0;
  text-align: center;
  color: rgba(255,255,255,.45);
  font-size: 11px;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
