* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1510;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: -webkit-optimize-contrast;
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

#score-display {
  background: rgba(20, 15, 10, 0.7);
  border-radius: 8px;
  padding: 6px 12px;
  color: #f5e6c8;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.3;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#height-score {
  font-size: 22px;
  letter-spacing: 0.5px;
}

#high-score-label {
  font-size: 12px;
  opacity: 0.7;
  font-weight: 400;
}

#stamina-container {
  flex: 1;
  max-width: 220px;
  min-width: 100px;
}

#stamina-label {
  color: #f5e6c8;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

#stamina-bar-bg {
  width: 100%;
  height: 14px;
  background: rgba(20, 15, 10, 0.7);
  border: 1px solid rgba(245, 230, 200, 0.3);
  border-radius: 7px;
  overflow: hidden;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#stamina-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6bdb5e, #a8f068);
  border-radius: 7px;
  transition: width 0.1s linear, background 0.3s;
  box-shadow: 0 0 8px rgba(168, 240, 104, 0.4);
}

#stamina-bar-fill.warning {
  background: linear-gradient(90deg, #f0a040, #f0c040);
  box-shadow: 0 0 8px rgba(240, 192, 64, 0.4);
}

#stamina-bar-fill.critical {
  background: linear-gradient(90deg, #f04040, #f06060);
  box-shadow: 0 0 8px rgba(240, 96, 96, 0.5);
  animation: pulse-critical 0.6s infinite alternate;
}

@keyframes pulse-critical {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

#rain-warning {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 60, 120, 0.85);
  color: #c5d5ff;
  padding: 6px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid rgba(150, 180, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 11;
  animation: warn-pulse 0.8s infinite alternate;
}

@keyframes warn-pulse {
  from { box-shadow: 0 0 12px rgba(100, 140, 255, 0.3); }
  to { box-shadow: 0 0 24px rgba(100, 140, 255, 0.6); }
}

#rain-warning-text {
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

#rain-warning-bar {
  width: 120px;
  height: 4px;
  background: rgba(100, 140, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

#rain-warning-bar-fill {
  height: 100%;
  background: #8ab0ff;
  border-radius: 2px;
  transition: width 0.1s linear;
}

#rain-active-indicator {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 80, 160, 0.9);
  color: #ffffff;
  padding: 6px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  z-index: 11;
  animation: rain-flash 0.5s infinite alternate;
}

@keyframes rain-flash {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

#mute-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(245, 230, 200, 0.3);
  background: rgba(20, 15, 10, 0.7);
  color: #f5e6c8;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#mute-btn:active {
  transform: scale(0.9);
}

/* Tutorial hints */
#tutorial-hints {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  pointer-events: none;
  text-align: center;
}

#hint-text {
  background: rgba(20, 15, 10, 0.75);
  color: #f5e6c8;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border: 1px solid rgba(245, 230, 200, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: hint-fade 0.5s ease;
}

@keyframes hint-fade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#tutorial-hints.hidden {
  display: none;
}

/* Touch controls */
#touch-controls {
  position: absolute;
  bottom: 30px;
  left: 30px;
  z-index: 15;
  pointer-events: auto;
}

#joystick-base {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(20, 15, 10, 0.3);
  border: 2px solid rgba(245, 230, 200, 0.25);
  position: relative;
  touch-action: none;
}

#joystick-knob {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(245, 230, 200, 0.3);
  border: 2px solid rgba(245, 230, 200, 0.5);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s;
  pointer-events: none;
}

#joystick-knob.active {
  background: rgba(168, 240, 104, 0.4);
  border-color: rgba(168, 240, 104, 0.7);
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: rgba(10, 8, 5, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.screen.hidden {
  display: none;
}

#hud.hidden {
  display: none;
}

#touch-controls.hidden {
  display: none;
}

.screen-content {
  text-align: center;
  max-width: 400px;
  padding: 30px;
}

.game-title {
  font-size: 42px;
  color: #f5e6c8;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
  letter-spacing: 2px;
  font-weight: 800;
}

.game-over-title {
  font-size: 36px;
  color: #f5b0a0;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
  letter-spacing: 2px;
  font-weight: 800;
}

.spider-icon {
  font-size: 56px;
  margin: 12px 0;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

.tagline {
  color: #c5b5a0;
  font-size: 15px;
  margin-bottom: 24px;
  line-height: 1.4;
}

.controls-info {
  background: rgba(30, 25, 18, 0.6);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 20px;
  text-align: left;
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(245, 230, 200, 0.1);
}

.control-row:last-child {
  border-bottom: none;
}

.control-label {
  color: #8a8a7a;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
  margin-right: 12px;
}

.control-keys {
  color: #f5e6c8;
  font-size: 13px;
  font-weight: 600;
}

.control-desc {
  color: #c5b5a0;
  font-size: 12px;
  text-align: right;
  line-height: 1.4;
}

.big-btn {
  background: linear-gradient(135deg, #8a6a3a, #c08540);
  color: #f5e6c8;
  border: 2px solid rgba(245, 230, 200, 0.3);
  padding: 14px 40px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(192, 133, 64, 0.3);
}

.big-btn:active {
  transform: scale(0.95);
}

.final-stats {
  color: #f5e6c8;
  font-size: 18px;
  margin: 12px 0;
  line-height: 1.6;
}

.death-reason {
  color: #f5b0a0;
  font-size: 14px;
  margin-bottom: 20px;
  font-style: italic;
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 480px) {
  .game-title { font-size: 32px; }
  .game-over-title { font-size: 28px; }
  #height-score { font-size: 18px; }
  #stamina-label { font-size: 10px; }
  #joystick-base { width: 110px; height: 110px; }
  #joystick-knob { width: 48px; height: 48px; }
  .screen-content { padding: 20px; }
  #touch-controls { bottom: 20px; left: 20px; }
}

@media (orientation: portrait) and (max-width: 600px) {
  #hud { padding: 8px 10px; }
  #stamina-container { max-width: 140px; }
}
