:root {
  --sand-light: #f4e4c1;
  --sand-medium: #e8c98b;
  --sand-dark: #c9a86c;
  --ochre: #cc8b3c;
  --burnt-orange: #d4652f;
  --ui-dark: #2d1f14;
  --ui-light: #fff8e7;
  --ui-accent: #ff9f43;
  --overlay-bg: rgba(45, 31, 20, 0.92);
  --glass-bg: rgba(255, 248, 231, 0.15);
  --glass-border: rgba(255, 248, 231, 0.25);
  --font-primary: "Outfit", sans-serif;
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-primary);
  background: linear-gradient(180deg, #87ceeb 0%, var(--sand-medium) 100%);
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-user-select: none;
  user-select: none;
}

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

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 800px;
  overflow: hidden;
  background: var(--sand-light);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

#hud>* {
  pointer-events: auto;
}

#score-container,
#weather-indicator {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  padding: 0.5rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

#score-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ui-light);
  opacity: 0.8;
}

#score {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ui-light);
  min-width: 4ch;
  text-align: right;
}

#score-unit {
  font-size: 0.75rem;
  color: var(--ui-light);
  opacity: 0.7;
}

#weather-indicator {
  align-items: center;
  gap: 0.5rem;
}

#weather-icon {
  font-size: 1.2rem;
}

#weather-text {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ui-light);
  text-transform: uppercase;
}

#pause-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  color: var(--ui-light);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

#pause-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 100;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

.overlay-content {
  text-align: center;
  padding: 3rem;
  max-width: 400px;
  width: 90%;
}

.game-title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  color: var(--ui-light);
  text-shadow: 0 0 40px rgba(255, 159, 67, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
  margin-bottom: 0.5rem;
  animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {

  0%,
  100% {
    text-shadow: 0 0 40px rgba(255, 159, 67, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
  }

  50% {
    text-shadow: 0 0 60px rgba(255, 159, 67, 0.8), 0 4px 8px rgba(0, 0, 0, 0.3);
  }
}

.game-subtitle {
  font-size: 1rem;
  font-weight: 300;
  color: var(--sand-medium);
  margin-bottom: 2rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.instruction-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.key {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 50px;
  padding: 0.5rem 1rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ui-light);
}

.action {
  font-size: 0.85rem;
  color: var(--sand-light);
  opacity: 0.8;
}

.primary-btn {
  position: relative;
  padding: 1rem 3rem;
  background: linear-gradient(135deg,
      var(--ui-accent) 0%,
      var(--burnt-orange) 100%);
  border: none;
  border-radius: 20px;
  font-family: var(--font-primary);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ui-dark);
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(255, 159, 67, 0.4);
  transition: all var(--transition-fast);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(255, 159, 67, 0.5);
}

.btn-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle,
      rgba(255, 255, 255, 0.3) 0%,
      transparent 70%);
  opacity: 0;
}

.primary-btn:hover .btn-glow {
  opacity: 1;
}

.hint {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--sand-dark);
  letter-spacing: 0.05em;
}

.gameover-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ui-light);
  margin-bottom: 2rem;
}

#final-score-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.5rem;
}

.final-score-label {
  font-size: 0.8rem;
  color: var(--sand-medium);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

#final-score {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--ui-accent);
  text-shadow: 0 0 30px rgba(255, 159, 67, 0.5);
  line-height: 1;
}

.final-score-unit {
  font-size: 1.2rem;
  color: var(--sand-light);
  opacity: 0.8;
  margin-top: 0.25rem;
}

#high-score-container {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--glass-bg);
  border-radius: 12px;
}

.high-score-label {
  font-size: 0.7rem;
  color: var(--sand-medium);
  text-transform: uppercase;
}

#high-score {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ui-light);
}

.high-score-unit {
  font-size: 0.7rem;
  color: var(--sand-light);
  opacity: 0.7;
}

#pause-screen h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ui-light);
  margin-bottom: 2rem;
}

#game-canvas.sandstorm {
  animation: sandstormShake 0.1s infinite;
}

@keyframes sandstormShake {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(-2px);
  }
}

#game-canvas.heatwave {
  animation: heatwaveDistort 2.5s ease-in-out infinite;
}

@keyframes heatwaveDistort {

  0%,
  100% {
    filter: blur(0px) saturate(1.1);
  }

  50% {
    filter: blur(0.6px) saturate(1.2);
  }
}

#game-canvas.monsoon {
  animation: monsoonDarken 3s ease-in-out infinite;
}

@keyframes monsoonDarken {

  0%,
  100% {
    filter: brightness(0.95) contrast(1.05);
  }

  50% {
    filter: brightness(0.88) contrast(1.08);
  }
}

@media (max-width: 768px) {
  #game-container {
    max-width: 100%;
    max-height: 100%;
  }

  #hud {
    padding: 0.5rem 1rem;
  }

  #score {
    font-size: 1.2rem;
  }

  #weather-text {
    display: none;
  }

  .game-title {
    font-size: 2.5rem;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 2rem;
  }

  #final-score {
    font-size: 2.5rem;
  }

  .primary-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
  }
}

button:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--glass-bg);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ui-light);
  font-size: 0.9rem;
}

.toggle-btn {
  padding: 0.4rem 1rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--ui-light);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 50px;
}

.toggle-btn[aria-pressed="true"] {
  background: var(--ui-accent);
  color: var(--ui-dark);
}

.toggle-btn:hover {
  transform: scale(1.05);
}

#mobile-controls {
  display: none;
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  padding: 0 20px;
  justify-content: space-between;
  pointer-events: none;
  z-index: 50;
}

.mobile-btn {
  pointer-events: auto;
  width: 80px;
  height: 80px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--ui-light);
  font-family: var(--font-primary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  opacity: 0.8;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.mobile-btn:active {
  opacity: 1;
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 20px rgba(255, 159, 67, 0.3);
}

#weather-banner {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1.5rem;
  background: var(--overlay-bg);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  color: var(--ui-light);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 20;
}

#weather-banner.active {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 768px) {
  #mobile-controls {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
  }
}