/* Modern Tropical Summer Game UI Styles & Native Fullscreen Portrait Adaptation */
:root {
  --primary-blue: #0288d1;
  --accent-cyan: #00e5ff;
  --accent-yellow: #ffd600;
  --accent-pink: #ff4081;
  --card-bg: rgba(10, 30, 50, 0.85);
  --card-border: rgba(255, 255, 255, 0.28);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background-color: #011627;
  font-family: var(--font-family);
  color: #ffffff;
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Exact viewport height for mobile browsers */
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #0288d1 0%, #011627 100%);
  overflow: hidden;
  touch-action: none;
}

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

#game-canvas.shake {
  animation: screen-shake 0.25s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes screen-shake {
  10%, 90% { transform: translate3d(-3px, 2px, 0); }
  20%, 80% { transform: translate3d(4px, -3px, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 4px, 0); }
  40%, 60% { transform: translate3d(5px, -2px, 0); }
}

/* Heads-Up Display (HUD) Layer */
#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  z-index: 10;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 8px;
}

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

/* Glassmorphism Badge */
.glass-panel {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

/* Health Bar */
.hp-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.hp-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #b3e5fc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bar-track {
  width: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 6px;
  transition: width 0.15s ease-out, background 0.3s ease;
}

#hp-fill {
  background: linear-gradient(90deg, #00e676, #76ff03);
  box-shadow: 0 0 10px rgba(0, 230, 118, 0.6);
}

/* Wave Badge */
.wave-badge {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-yellow);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  padding: 8px 12px;
  white-space: nowrap;
  background: linear-gradient(135deg, rgba(255, 179, 0, 0.25), rgba(255, 87, 34, 0.35));
}

/* Score Panel */
.score-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 80px;
}

.score-title {
  font-size: 11px;
  color: #81d4fa;
  font-weight: 600;
}

.score-value {
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 1px;
  text-shadow: 0 0 12px var(--accent-cyan);
}

/* Combo Meter */
.combo-badge {
  font-size: 18px;
  font-weight: 900;
  color: var(--accent-pink);
  text-shadow: 0 0 10px var(--accent-pink);
  transform: scale(0.8);
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.combo-badge.active {
  transform: scale(1.1);
  opacity: 1;
}

/* Control Icon Buttons */
.btn-icon {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  pointer-events: auto;
  touch-action: manipulation;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.btn-icon:active {
  transform: scale(0.92);
}

/* Bottom HUD (Water Tank & Pump) */
.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.water-tank-container {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

#water-fill {
  background: linear-gradient(90deg, #00b0ff, #00e5ff);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

/* Pump Button */
.pump-btn {
  background: linear-gradient(135deg, #ff9100, #ff3d00);
  border: 2px solid #ffffff;
  border-radius: 22px;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  padding: 9px 20px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(255, 61, 0, 0.55);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  pointer-events: auto;
  touch-action: manipulation;
  white-space: nowrap;
}

.pump-btn.pulse-low {
  animation: pump-pulse 0.75s infinite alternate ease-in-out;
}

@keyframes pump-pulse {
  0% { transform: scale(1); box-shadow: 0 0 10px #ff3d00; }
  100% { transform: scale(1.1); box-shadow: 0 0 25px #ff1744, 0 0 40px #ff9100; }
}

.pump-btn:active {
  transform: scale(0.92) !important;
  box-shadow: 0 2px 8px rgba(255, 61, 0, 0.9);
}

/* Controls Tip */
.controls-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Fullscreen Modals / Screens */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(1, 22, 39, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.3s ease;
  padding: 16px;
}

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

.modal-card {
  background: linear-gradient(145deg, rgba(13, 71, 161, 0.96), rgba(2, 136, 209, 0.92));
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 26px;
  padding: 28px 24px;
  text-align: center;
  max-width: 440px;
  width: 100%;
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: modal-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.game-title {
  font-size: 28px;
  font-weight: 900;
  color: #fff59d;
  text-shadow: 0 4px 15px rgba(255, 214, 0, 0.6);
  margin-bottom: 6px;
}

.game-subtitle {
  font-size: 14px;
  color: #e1f5fe;
  margin-bottom: 14px;
}

.enemy-preview {
  width: 100px;
  height: 115px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.enemy-preview img {
  width: 95%;
  height: 95%;
  object-fit: contain;
}

.instructions {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
  margin-bottom: 18px;
  color: #b3e5fc;
}

.btn-primary {
  background: linear-gradient(135deg, #00e5ff, #00b0ff);
  color: #011627;
  font-size: 18px;
  font-weight: 900;
  border: none;
  border-radius: 30px;
  padding: 12px 36px;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(0, 229, 255, 0.5);
  transition: all 0.2s ease;
  letter-spacing: 1px;
  touch-action: manipulation;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 30px rgba(0, 229, 255, 0.8);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.96);
}

.final-stats-list {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 14px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.8;
  text-align: left;
  margin: 14px 0 18px;
  color: #e1f5fe;
}

/* =================================================== */
/* 📱 NATIVE PORTRAIT SCREEN ADAPTATION (竖屏沉浸适配) */
/* =================================================== */

@media (orientation: portrait), (max-width: 600px) {
  #hud-overlay {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .hud-top {
    gap: 6px;
  }

  .hud-group {
    gap: 6px;
  }

  .glass-panel {
    padding: 6px 10px;
    border-radius: 12px;
  }

  .hp-container {
    min-width: 105px;
  }

  .hp-label {
    font-size: 11px;
  }

  .bar-track {
    height: 9px;
  }

  .wave-badge {
    font-size: 12px;
    padding: 6px 8px;
  }

  .score-panel {
    min-width: 70px;
  }

  .score-title {
    font-size: 10px;
  }

  .score-value {
    font-size: 17px;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .water-tank-container {
    min-width: 110px;
    gap: 6px;
  }

  .pump-btn {
    font-size: 13px;
    padding: 9px 14px;
    border-radius: 18px;
  }

  .controls-hint {
    display: none;
  }

  .modal-card {
    padding: 22px 18px;
    border-radius: 22px;
  }

  .game-title {
    font-size: 24px;
  }

  .game-subtitle {
    font-size: 13px;
    margin-bottom: 12px;
  }

  .enemy-preview {
    width: 85px;
    height: 100px;
    margin-bottom: 12px;
  }

  .instructions {
    font-size: 12px;
    padding: 10px 12px;
    margin-bottom: 14px;
  }

  .btn-primary {
    font-size: 16px;
    padding: 11px 30px;
  }
}
