/* style.css - Styling for "Itsy Bitsy Spider" web game */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Press+Start+2P&display=swap');

:root {
  --color-bg: #0d0a08;
  --color-brick: #4d2f24;
  --color-brick-dark: #2d1c16;
  --color-brick-highlight: #6e4435;
  --color-accent: #ff4a1c;
  --color-accent-glow: rgba(255, 74, 28, 0.4);
  --color-fly: #00ffcc;
  --color-stamina: #2ecc71;
  --color-stamina-low: #e74c3c;
  --color-text: #f5ede8;
  --color-panel: rgba(30, 24, 20, 0.85);
  --font-main: 'Outfit', sans-serif;
  --font-retro: 'Press Start 2P', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none; /* Prevents double-tap zoom and scrolling */
}

/* Background animated brick pattern for body */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(30deg, #150f0c 12%, transparent 12.5%, transparent 87%, #150f0c 87.5%, #150f0c),
    linear-gradient(150deg, #150f0c 12%, transparent 12.5%, transparent 87%, #150f0c 87.5%, #150f0c),
    linear-gradient(30deg, #150f0c 12%, transparent 12.5%, transparent 87%, #150f0c 87.5%, #150f0c),
    linear-gradient(150deg, #150f0c 12%, transparent 12.5%, transparent 87%, #150f0c 87.5%, #150f0c),
    linear-gradient(60deg, #1a130f 25%, transparent 25.5%, transparent 75%, #1a130f 75.5%, #1a130f),
    linear-gradient(60deg, #1a130f 25%, transparent 25.5%, transparent 75%, #1a130f 75.5%, #1a130f);
  background-size: 80px 140px;
  background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;
  opacity: 0.3;
  z-index: -1;
}

/* Main Game Wrapper */
#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 600px;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  overflow: hidden;
  background-color: #221612;
}

/* Canvas viewport */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background-color: #1e130f;
}

/* HUD System (Overlay on top of canvas) */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none; /* Let clicks pass through to canvas if needed */
  z-index: 10;
}

.hud-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto; /* Re-enable pointer events for buttons */
}

/* Stamina Bar */
.stamina-container {
  width: 160px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 3px;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.stamina-icon {
  font-size: 14px;
  margin-left: 4px;
  color: var(--color-stamina);
  animation: heartbeat 1.5s infinite alternate;
}

.stamina-bar-outer {
  flex-grow: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.stamina-bar-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  border-radius: 10px;
  transition: width 0.1s ease, background 0.3s ease;
}

.stamina-bar-inner.low {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
  animation: flash-red 0.5s infinite alternate;
}

/* Score Display */
.score-container {
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 8px 14px;
  backdrop-filter: blur(4px);
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.score-label {
  font-family: var(--font-retro);
  font-size: 8px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.score-value {
  font-family: var(--font-retro);
  font-size: 14px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Action Controls (Mute & Pause) */
.controls-container {
  display: flex;
  gap: 8px;
}

.hud-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: var(--color-text);
  font-size: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(4px);
  transition: transform 0.1s ease, background-color 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--color-accent);
}

.hud-btn:active {
  transform: scale(0.9);
}

/* Warning Alerts */
#storm-warning {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 400px;
  padding: 12px;
  background: rgba(194, 54, 22, 0.95);
  border: 2px solid #e74c3c;
  box-shadow: 0 10px 30px rgba(231, 76, 60, 0.4), inset 0 0 15px rgba(0,0,0,0.3);
  border-radius: 8px;
  text-align: center;
  z-index: 15;
  display: none;
  animation: slide-down 0.3s ease-out, warning-shake 0.2s infinite alternate;
}

.warning-title {
  font-family: var(--font-retro);
  font-size: 10px;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.warning-timer-bar {
  height: 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  overflow: hidden;
}

.warning-timer-fill {
  width: 100%;
  height: 100%;
  background: #f1c40f;
  transition: width 0.1s linear;
}

/* Overlays (Screens) */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* Titles */
h1 {
  font-family: var(--font-retro);
  font-size: 26px;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--color-accent);
  text-shadow: 0 4px 0 var(--color-brick-dark), 0 0 20px var(--color-accent-glow);
  letter-spacing: 1px;
  animation: title-float 3s ease-in-out infinite alternate;
}

.subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 24px;
  max-width: 80%;
  font-weight: 300;
}

/* Buttons */
.btn {
  background: linear-gradient(135deg, var(--color-accent), #d32f2f);
  color: white;
  border: none;
  padding: 14px 36px;
  font-family: var(--font-retro);
  font-size: 11px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--color-accent-glow), inset 0 2px 4px rgba(255,255,255,0.3);
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease;
  margin-top: 20px;
  letter-spacing: 1px;
}

.btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 8px 25px rgba(255, 74, 28, 0.6), inset 0 2px 4px rgba(255,255,255,0.4);
}

.btn:active {
  transform: scale(0.96) translateY(2px);
}

/* Info Cards */
.info-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  max-width: 440px;
  text-align: left;
}

.info-card h3 {
  font-family: var(--font-retro);
  font-size: 9px;
  color: var(--color-accent);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.instruction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.8);
}

.instruction-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.instruction-list li span.key {
  background: rgba(255, 255, 255, 0.15);
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: bold;
  font-size: 11px;
}

.instruction-list li span.icon {
  width: 20px;
  text-align: center;
}

/* Mobile Controls Overlay */
#mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 180px;
  padding: 0 20px 20px 20px;
  display: none; /* Set in JS depending on touch support */
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.joystick-container {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4), inset 0 2px 10px rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  pointer-events: auto;
  touch-action: none;
  backdrop-filter: blur(2px);
}

.joystick-knob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent), #b71c1c);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255,255,255,0.4);
  position: absolute;
  top: 33px;
  left: 33px;
  cursor: pointer;
  transition: transform 0.05s ease;
}

/* Stats list for GameOver */
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin: 16px 0;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.15);
  padding-bottom: 6px;
  font-size: 14px;
}

.stats-label {
  color: rgba(255,255,255,0.6);
  font-weight: 300;
}

.stats-val {
  font-family: var(--font-retro);
  font-size: 10px;
  color: #fff;
}

.stats-val.highlight {
  color: #f1c40f;
  text-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
}

/* Animations */
@keyframes heartbeat {
  0% { transform: scale(1); }
  100% { transform: scale(1.15); }
}

@keyframes flash-red {
  0% { opacity: 1; }
  100% { opacity: 0.6; }
}

@keyframes title-float {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

@keyframes slide-down {
  0% { transform: translate(-50%, -20px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes warning-shake {
  0% { margin-left: -2px; }
  100% { margin-left: 2px; }
}

/* Mobile adjustments */
@media (max-width: 600px) {
  #game-wrapper {
    max-height: 100%;
    border-radius: 0;
  }

  h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 12px;
    margin-bottom: 16px;
  }

  .info-card {
    padding: 10px 14px;
  }

  .instruction-list {
    font-size: 12px;
  }

  .stamina-container {
    width: 130px;
  }
}
