/* 猫窝守卫 —— 手机竖屏样式：顶部资源/波次 HUD + 底部操作区（design §7） */

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: #efe2cc;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: #f7ead7;
  box-shadow: 0 0 24px rgba(90, 62, 44, 0.25);
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#app .hidden {
  display: none;
}

/* ---------- 菜单 ---------- */

.menu {
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.75), transparent 40%),
    radial-gradient(circle at 80% 85%, rgba(255, 214, 165, 0.5), transparent 45%),
    #f7ead7;
}

.menu-title {
  font-size: 34px;
  color: #5a3e2c;
  letter-spacing: 2px;
}

.menu-sub {
  font-size: 14px;
  color: #8a6b50;
  text-align: center;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 10px;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  border: 2px solid #d9b98c;
  border-radius: 16px;
  background: #fffaf0;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.level-card:active {
  transform: scale(0.97);
}

.level-card.locked {
  opacity: 0.6;
  background: #efe6d8;
  cursor: not-allowed;
}

.level-name {
  font-weight: 700;
  color: #5a3e2c;
}

.level-state {
  font-size: 13px;
  color: #4a90d9;
}

.level-card.locked .level-state {
  color: #8a6b50;
}

.level-req {
  font-size: 12px;
  color: #a08868;
}

.menu-hint {
  font-size: 12px;
  color: #a08868;
}

/* ---------- 战斗屏 ---------- */

.level-screen {
  position: relative;
}

.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px;
  background: linear-gradient(#fff6e5, #f7e6c8);
  border-bottom: 2px solid #d9b98c;
  z-index: 5;
}

.hud.warning {
  background: linear-gradient(#ffe9d6, #ffd6c0);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% { filter: brightness(0.94); }
}

.hud-stat {
  font-size: 15px;
  font-weight: 700;
  color: #5a3e2c;
  white-space: nowrap;
}

.hud-btn {
  border: 2px solid #d9b98c;
  border-radius: 12px;
  background: #fffaf0;
  color: #5a3e2c;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.hud-btn:disabled {
  opacity: 0.5;
}

.hud .pause {
  margin-left: auto;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #f2e4cb;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- 底部操作区 ---------- */

.bottom-bar {
  border-top: 2px solid #d9b98c;
  background: linear-gradient(#f7e6c8, #fff6e5);
  padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
  min-height: 92px;
  z-index: 5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 60px;
}

.action {
  border: 2px solid #d9b98c;
  border-radius: 12px;
  background: #fffaf0;
  color: #5a3e2c;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}

.action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action.clear {
  background: #e8f1fb;
  border-color: #a9c9e8;
}

.action.build {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
}

.action.build img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.build-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tower-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: #5a3e2c;
  font-size: 13px;
}

.action-note {
  color: #8a6b50;
  font-size: 13px;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(90, 62, 44, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 86%;
  text-align: center;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 覆盖层 ---------- */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(90, 62, 44, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.overlay-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: min(84%, 320px);
  padding: 22px;
  border-radius: 20px;
  border: 3px solid #d9b98c;
  background: #fffaf0;
  box-shadow: 0 8px 30px rgba(90, 62, 44, 0.35);
  text-align: center;
}

.overlay-card h2 {
  font-size: 22px;
  color: #5a3e2c;
}

.overlay-card p {
  font-size: 14px;
  color: #8a6b50;
}

.overlay-card.win {
  border-color: #a8d5a2;
}

.overlay-card.lose {
  border-color: #e8a7a0;
}

.overlay-btn {
  width: 100%;
  padding: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #5a3e2c;
  background: #fff;
  border: 2px solid #d9b98c;
  border-radius: 12px;
  cursor: pointer;
}

.overlay-btn.primary {
  background: #ffe3a9;
}

/* ---------- 加载 ---------- */

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #8a6b50;
  z-index: 50;
}

.loading.error {
  color: #c0392b;
}

#smoke-result {
  display: none;
}
