:root {
  --bg: #04070f;
  --surface: rgba(15, 23, 42, 0.85);
  --surface-solid: #111b34;
  --text: #f8fbff;
  --muted: rgba(200, 210, 230, 0.75);
  --primary: #60a5fa;
  --accent: #f472b6;
  --success: #10b981;
  --warning: #f59e0b;
  --border: rgba(96, 165, 250, 0.25);
  --radius: 24px;
  --shadow: 0 32px 64px rgba(3, 8, 20, 0.55);
  --glow: 0 0 40px rgba(96, 165, 250, 0.3);
}

[data-theme="light"] {
  --bg: #f8fafc;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-solid: #ffffff;
  --text: #0f172a;
  --muted: rgba(15, 23, 42, 0.6);
  --primary: #2563eb;
  --accent: #db2777;
  --success: #059669;
  --warning: #d97706;
  --border: rgba(37, 99, 235, 0.22);
  --shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
  --glow: 0 0 30px rgba(37, 99, 235, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: 
    radial-gradient(circle at 20% 30%, rgba(249, 168, 37, 0.15), transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(244, 114, 182, 0.12), transparent 50%),
    radial-gradient(circle at 40% 90%, rgba(59, 130, 246, 0.08), transparent 50%),
    linear-gradient(135deg, var(--bg) 0%, #020617 100%);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
}

.container {
  width: min(1000px, 100%);
  padding: 48px 40px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.5;
}

.header {
  text-align: center;
  margin-bottom: 32px;
}

.title {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 50%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(96, 165, 250, 0.4));
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.subtitle {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 500;
}

.hud {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.hud-item {
  min-width: 150px;
  padding: 16px 20px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 
    0 8px 32px rgba(5, 10, 20, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.hud-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.5), transparent);
}

.hud-item:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 40px rgba(5, 10, 20, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.hud-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.hud-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-area {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 
    0 20px 40px rgba(3, 8, 20, 0.6),
    inset 0 0 0 1px rgba(96, 165, 250, 0.2);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(30, 41, 59, 0.8) 100%);
  margin-bottom: 24px;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn {
  padding: 14px 28px;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 120px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  color: white;
  box-shadow: 
    0 8px 20px rgba(96, 165, 250, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 32px rgba(96, 165, 250, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.theme-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.theme-toggle:hover {
  transform: scale(1.1);
  background: rgba(148, 163, 184, 0.2);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.overlay-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  max-width: 480px;
  margin: 0 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  position: relative;
  overflow: hidden;
}

.overlay-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
}

.overlay-title {
  margin: 0 0 16px;
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.overlay-message {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.slide-up {
  animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 32px 24px;
  }
  
  .hud {
    gap: 12px;
  }
  
  .hud-item {
    min-width: 120px;
    padding: 12px 16px;
  }
  
  .btn {
    padding: 12px 24px;
    font-size: 0.9rem;
    min-width: 100px;
  }
  
  .overlay-content {
    padding: 36px 28px;
  }
  
  .title {
    font-size: clamp(2rem, 8vw, 2.8rem);
  }
}

@media (max-width: 480px) {
  .container {
    padding: 24px 16px;
  }
  
  .hud {
    flex-direction: column;
    align-items: center;
  }
  
  .hud-item {
    width: 100%;
    text-align: center;
  }
  
  .controls {
    flex-direction: column;
    align-items: center;
  }
  
  .btn {
    width: 100%;
    max-width: 200px;
  }
}
  text-align: center;
}

.hud-item span:first-child {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 4px;
}

.hud-item strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  word-break: keep-all;
}

[data-theme="light"] .hud-item {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(37, 99, 235, 0.15);
  box-shadow: 0 12px 24px rgba(148, 163, 184, 0.25);
}

#level {
  font-size: 1.1rem;
}

#harvest {
  font-size: 1.3rem;
}

.hud .settings {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.hud .settings input {
  accent-color: var(--primary);
}

#game {
  width: 100%;
  height: auto;
  border-radius: 26px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #fdf7e3 0%, #f6e6bc 55%, #e9cf8b 70%, #d3b678 100%);
  box-shadow: 0 22px 44px rgba(5, 9, 18, 0.55);
  image-rendering: pixelated;
}

body.night #game {
  background: linear-gradient(180deg, #111827 0%, #0f172a 60%, #1f2937 100%);
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  pointer-events: none;
}

.overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4, 7, 15, 0.4), rgba(4, 7, 15, 0.65));
  border-radius: 26px;
}

.overlay.overlay--visible {
  display: grid;
}

.overlay-card {
  pointer-events: auto;
  background: rgba(12, 18, 31, 0.82);
  padding: 28px 32px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  backdrop-filter: blur(22px);
  text-align: center;
  box-shadow: 0 32px 52px rgba(5, 9, 18, 0.6);
  max-width: clamp(260px, 60vw, 340px);
}

[data-theme="light"] .overlay-card {
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  border: 1px solid rgba(99, 102, 241, 0.22);
  box-shadow: 0 28px 46px rgba(148, 163, 184, 0.35);
}

.row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  box-shadow: 0 18px 36px rgba(96, 165, 250, 0.35);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(7, 11, 22, 0.45);
}

.hint {
  color: var(--muted);
  text-align: center;
  margin-top: 18px;
}

.theme-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(4, 8, 20, 0.45);
  font-size: 1.1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 36px rgba(8, 12, 24, 0.5);
}

@media (max-width: 720px) {
  .container {
    padding: 28px 22px;
  }

  .hud-item {
    min-width: 100px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-card,
  .btn,
  .theme-toggle {
    transition: none;
  }
}
