/* Itsy Bitsy Spider - Game Stylesheet */

:root {
  --primary-glow: #38bdf8;
  --danger-color: #ef4444;
  --safe-color: #10b981;
  --warning-color: #f59e0b;
  --bg-dark: #090d16;
  --panel-bg: rgba(15, 23, 42, 0.88);
  --panel-border: rgba(56, 189, 248, 0.25);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #f8fafc;
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Glassmorphic Top HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 20;
}

.hud-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-badge {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-badge {
  color: #38bdf8;
  font-size: 16px;
}

.high-badge {
  color: #fbbf24;
}

/* Stamina Row */
.hud-stamina-row {
  display: flex;
  justify-content: center;
  width: 100%;
  pointer-events: none;
}

.stamina-wrapper {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  padding: 6px 14px;
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  width: 100%;
  max-width: 280px;
}

.stamina-header {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#stamina-pct-val {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
}

.stamina-track {
  width: 100%;
  height: 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7);
  position: relative;
}

#stamina-fill {
  width: 100%;
  height: 100%;
  background: #10b981;
  transition: width 0.08s linear, background-color 0.2s ease;
  border-radius: 5px;
}

.pulse-danger {
  animation: pulse-border 0.6s infinite alternate;
}

@keyframes pulse-border {
  from { box-shadow: 0 0 4px #ef4444; border-color: #ef4444; }
  to { box-shadow: 0 0 16px #ef4444; border-color: #f87171; }
}

/* Interactive Top Buttons */
.hud-btn {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: #f8fafc;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hud-btn:active {
  transform: scale(0.94);
  background: #334155;
}

/* Weather & Alert Banners */
.weather-banner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  pointer-events: none;
}

.weather-banner {
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  display: none;
}

.banner-calm {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #94a3b8;
}

.banner-warning {
  background: rgba(180, 83, 9, 0.92);
  border: 2px solid #f59e0b;
  color: #fffbeb;
  animation: banner-pulse 0.6s infinite alternate;
}

.banner-danger {
  background: rgba(185, 28, 28, 0.95);
  border: 2px solid #ef4444;
  color: #ffffff;
  animation: banner-shake 0.3s infinite ease-in-out;
}

.banner-safe {
  background: rgba(6, 95, 70, 0.92);
  border: 2px solid #10b981;
  color: #ecfdf5;
}

.shelter-beacon {
  background: rgba(16, 185, 129, 0.9);
  color: #022c22;
  font-size: 13px;
  font-weight: 800;
  padding: 5px 14px;
  border-radius: 9999px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  display: none;
  animation: beacon-bounce 1s infinite alternate;
}

@keyframes banner-pulse {
  from { transform: scale(0.98); opacity: 0.9; }
  to { transform: scale(1.04); opacity: 1; }
}

@keyframes banner-shake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-2px, 1px) rotate(-0.5deg); }
  75% { transform: translate(2px, -1px) rotate(0.5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes beacon-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

/* Modals & Overlays */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  padding: 20px;
}

.modal-content {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(14, 165, 233, 0.15);
  animation: modal-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 20px;
}

/* Instructions Cards */
.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
  text-align: left;
}

.rule-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
}

.rule-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.rule-title {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
}

.rule-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
}

.control-tip {
  font-size: 12px;
  color: #38bdf8;
  margin-bottom: 20px;
  background: rgba(14, 165, 233, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
}

/* Primary Action Buttons */
.action-btn {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border: none;
  color: #ffffff;
  padding: 14px 24px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.6);
}

.action-btn:active {
  transform: translateY(1px) scale(0.98);
}

/* Game Over Stats */
.game-over-stats {
  background: rgba(30, 41, 59, 0.7);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-around;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
}

.stat-value {
  font-size: 26px;
  font-weight: 900;
  color: #38bdf8;
  margin-top: 2px;
}

.death-cause-banner {
  color: #f87171;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
}

/* Virtual Joystick for Mobile */
#touch-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 48%;
  pointer-events: auto;
  z-index: 30;
  touch-action: none;
}

#joystick-base {
  position: absolute;
  left: 50%;
  bottom: 90px;
  width: 130px;
  height: 130px;
  margin-left: -65px;
  margin-top: -65px;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.75) 100%);
  border: 2.5px solid rgba(56, 189, 248, 0.6);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 16px rgba(56, 189, 248, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.2s ease;
}

#joystick-base::before {
  content: "▲";
  position: absolute;
  top: 8px;
  font-size: 11px;
  color: rgba(56, 189, 248, 0.7);
}

#joystick-base::after {
  content: "▼";
  position: absolute;
  bottom: 8px;
  font-size: 11px;
  color: rgba(56, 189, 248, 0.7);
}

#joystick-knob {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #38bdf8 0%, #0284c7 70%, #0369a1 100%);
  border: 2px solid #bae6fd;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.7);
  pointer-events: none;
  transform: translate(0px, 0px);
  will-change: transform;
}

.hidden {
  display: none !important;
}

/* Safe areas for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #hud {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  #joystick-base {
    bottom: calc(90px + env(safe-area-inset-bottom));
  }
}
