:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --background: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
    --ring: #bfdbfe;
}   

.light-mode {
    --background: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
    --ring: #bfdbfe;
}

.dark-mode {
    --background: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --border: #334155;
    --ring: #1e40af;
}

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

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--background);
    font-family: system-ui, -apple-system, sans-serif;
    color: var(--text);
    line-height: 1.5;
    transition: background-color 0.3s ease;
}

#mode-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
}

.apple-simulator {
    width: 90%;
    max-width: 500px;
    background: var(--card);
    border-radius: 24px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
    padding: 1.5rem; 
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

  .simulator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
  }

  .simulator-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sound-toggle, .mode-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 9999px;
    transition: background-color 0.2s;
  }

  .sound-toggle:hover, .mode-toggle:hover {
    background: var(--background);
  }
  .apple-container {
    position: relative;
    height: 200px;
    margin: 1.5rem 0; 
    perspective: 1000px;
}       

.apple {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 140px;
    height: 140px; 
    border-radius: 50%;
    transition: all 0.5s ease;
    box-shadow: 
      inset -20px -20px 30px rgba(0,0,0,0.2),
      10px 10px 30px rgba(0,0,0,0.1),
      0 0 50px rgba(0,0,0,0.05);
}

.fly {
    position: absolute;
    width: 8px;
    height: 4px;
    background: #333;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none; 
}

@keyframes fly {
    0% { transform: translate(0, 0); }
    25% { transform: translate(20px, -15px); }
    50% { transform: translate(-15px, 10px); }
    75% { transform: translate(10px, -5px); }
    100% { transform: translate(0, 0); }
}

@keyframes flyAway {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(50px, -50px) scale(0); opacity: 0; }
}

.fly.visible {
    opacity: 1;
}
.progress-container {
    margin: 1rem 0; 
}
.fly:nth-child(1) { top: 45%; left: 45%; }
.fly:nth-child(2) { top: 40%; left: 55%; }
.fly:nth-child(3) { top: 55%; left: 45%; }
.fly:nth-child(4) { top: 50%; left: 55%; }

  .apple-stem {
    position: absolute;
    top: 30px;
    left: 50%;
    width: 12px;
    height: 40px;
    background: #2d4029;
    border-radius: 6px;
    transform-origin: bottom center;
    transition: transform 0.5s ease;
  }

  .apple-leaf {
    position: absolute;
    top: 25px;
    left: 50%;
    width: 40px;
    height: 40px;
    background: #6db33f;
    border-radius: 50% 0;
    transform-origin: bottom center;
    transition: transform 0.5s ease;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.1);
  }

  .progress-container {
    margin: 2rem 0;
  }

  .progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 9999px;
    overflow: hidden;
  }

  .progress-indicator {
    height: 100%;
    background: var(--primary);
    border-radius: 9999px;
    transition: width 0.3s ease;
  }

  .ripeness-display {
    text-align: center;
    font-weight: 600;
    margin: 1rem 0;
    color: var(--text);
  }

  .control-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
}
.button {
    padding: 0.5rem 1rem; 
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
}
  .button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
  }

  .button:active {
    transform: translateY(1px);
  }

  .info-display {
    background: var(--background);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
  }

  .info-details {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.6;
    word-wrap: break-word; 
    white-space: normal;
  }

  .fly.escape {
    animation: flyAway 1s forwards;
  }

.weather-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.rain {
    position: absolute;
    width: 2px;
    height: 100px;
    background: linear-gradient(transparent, #00000080);
    animation: rain-fall linear infinite;
}

@keyframes rain-fall {
    0% {
        transform: translateY(-100px) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 100px)) translateX(20px);
        opacity: 0;
    }
}

.snow {
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: snow-fall linear infinite;
    filter: blur(1px);
}

@keyframes snow-fall {
    0% {
        transform: translateY(-10px) translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 10px)) translateX(100px) rotate(360deg);
        opacity: 0;
    }
}

.apple {
    transition: background-color 0.5s ease, filter 0.5s ease;
}

.apple.snowy {
    background-color: #ffffff !important;
    filter: brightness(1.2) saturate(0.8);
}

.weather-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem; 
    flex-wrap: wrap;
}

.weather-button {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    min-width: 100px;
}

.weather-button:hover {
    background: var(--background);
    transform: translateY(-1px);
}

.weather-button.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.weather-button .icon {
    font-size: 1.2em;
}

.weather-settings {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    display: none;
}

.weather-settings.visible {
    display: block;
}

.weather-setting-group {
    margin-bottom: 1rem;
}

.weather-setting-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-size: 0.9rem;
}

.weather-setting-group input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.weather-setting-value {
    font-size: 0.8rem;
    color: var(--text);
    text-align: right;
}

@media (max-width: 640px) {
    .apple-simulator {
        padding: 1.25rem; 
    }

    .apple-container {
        height: 200px; 
    }

    .apple {
        width: 130px;
        height: 130px;
    }

    .control-panel {
        grid-template-columns: 1fr; 
    }

    .button {
        width: 100%; 
        font-size: 0.875rem;
    }
}

  @media (prefers-color-scheme: dark) {
    :root {
      --background: #0f172a;
      --card: #1e293b;
      --text: #f8fafc;
      --border: #334155;
      --ring: #1e40af;
    }

    .apple-simulator {
      box-shadow: 0 20px 40px -10px rgba(0,0,0,0.3);
    }
  }
