:root {
    --primary-color: #00c853;
    --secondary-color: #009624;
    --soil-color: #795548;
    --border-radius: 8px;
    --text-light: #ffffff;
    --text-dark: #212121;
    --bg-light: #f5f5f5;
    --bg-dark: #1a1a1a;
    --success: #00e676;
    --warning: #ffd600;
    --error: #ff1744;
}

body {
    background: linear-gradient(135deg, #e0f2e9 0%, #c7e6d7 100%);
    font-family: 'Segoe UI', Arial, sans-serif;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.game-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    position: relative;
}

.game-container::before {
    content: 'Mystic Meadows Farm';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 200, 83, 0.5),
                 0 0 20px rgba(0, 200, 83, 0.3);
    white-space: nowrap;
}

.hud {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(to right, #f8f9fa, #e9ecef);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    padding: 15px;
    border-radius: var(--border-radius);
    color: var(--text-light);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.money, .level, .xp {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    color: var(--text-light);
    font-weight: bold;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.money:hover, .level:hover, .xp:hover {
    transform: translateY(-2px);
}

.farm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    padding: 20px;
    background: rgba(139, 69, 19, 0.1);
    border-radius: var(--border-radius);
}

.plot {
    aspect-ratio: 1;
    background: var(--soil-color);
    border: 3px solid rgba(85, 51, 17, 0.8);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.plot::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: translateX(-100%);
}

.plot:hover::before {
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.plot.growing {
    background: linear-gradient(45deg, #90EE90, #98FB98);
    animation: growing 2s infinite alternate;
}

@keyframes growing {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

.plot.ready {
    background: linear-gradient(45deg, #228B22, #32CD32);
    animation: ready 1s infinite alternate;
}

@keyframes ready {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

button, select {
    padding: 10px 20px;
    background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(1px);
}

select {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,...");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.tools {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 10px;
    max-width: 100%;
}

.tool {
    flex-shrink: 0;
    min-width: 120px;
    font-size: 1rem;
    padding: 10px 15px;
    margin: 5px 0;
    border: none;
    border-radius: 6px;
    background-color: #ffdf93;
    cursor: pointer;
    white-space: nowrap;
}

.tool:hover {
    background-color: #ffc967;
}

@media (max-width: 600px) {
    .tool {
        font-size: 0.9rem;
        min-width: 100px;
    }
}

.weather {
    padding: 15px;
    background: linear-gradient(135deg, #16a085, #2980b9);
    border-radius: var(--border-radius);
    font-size: 1.2em;
    text-align: center;
    color: var(--text-light);
}

.achievements {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #fff, #f8f9fa);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.achievement {
    padding: 10px 15px;
    margin: 10px 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transform: translateX(-100%);
    animation: slideIn 0.5s forwards;
}

@keyframes slideIn {
    to { transform: translateX(0); }
}

.plot.watered {
    position: relative;
}

.plot.watered::after {
    content: '💧';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 16px;
    animation: droplet 1s infinite;
}

@keyframes droplet {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(10px); opacity: 0; }
}

.plot.fertilized {
    border: 3px dashed #8b4513;
    animation: borderDash 1s linear infinite;
}

@keyframes borderDash {
    to { background-position: 20px 0; }
}

.price-notification {
    position: fixed;
    top: 20px;
    right: -300px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: var(--border-radius);
    transition: right 0.3s ease;
    z-index: 1000;
}

.price-notification.show {
    right: 20px;
}

.price-list {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    padding: 10px;
    margin-top: 10px;
}

.price-item {
    padding: 5px 10px;
    margin: 2px 0;
    border-radius: 3px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid;
    transition: transform 0.2s;
}

.price-item:hover {
    transform: translateX(5px);
}

.price-item.common { 
    background: linear-gradient(to right, #eceff1, #cfd8dc);
    border-left-color: #90a4ae;
}
.price-item.uncommon { 
    background: linear-gradient(to right, #c8e6c9, #a5d6a7);
    border-left-color: #4caf50;
}
.price-item.rare { 
    background: linear-gradient(to right, #bbdefb, #90caf9);
    border-left-color: #2196f3;
}
.price-item.epic { 
    background: linear-gradient(to right, #e1bee7, #ce93d8);
    border-left-color: #9c27b0;
}
.price-item.legendary { 
    background: linear-gradient(to right, #ffd700, #ffa000);
    border-left-color: #ff6f00;
}
.price-item.mythical { 
    background: linear-gradient(to right, #ff1744, #d50000);
    border-left-color: #b71c1c;
}

.crop-select {
    max-width: 400px;
    background: white;
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.crop-select select {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: rgb(29, 27, 27);
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1em;
}

.seed-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.seed-count {
    font-size: 1.1em;
    color: #666;
}

.crop-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px;
    padding: 10px;
    border-radius: var(--border-radius);
    margin-top: 10px;
}

.crop-details.mythical {
    background: linear-gradient(45deg, #ff00ff, #00ffff);
    color: white;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

optgroup {
    font-weight: bold;
}

optgroup[label="Mythical Crops"] {
    color: #ff00ff;
}

optgroup[label="Legendary Crops"] {
    color: #ffd700;
}

optgroup[label="Epic Crops"] {
    color: #9932cc;
}

@keyframes priceAlert {
    0% { transform: translateY(-20px); opacity: 0; }
    10% { transform: translateY(0); opacity: 1; }
    90% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-20px); opacity: 0; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .hud {
        flex-direction: column;
        gap: 15px;
    }
    
    .tools {
        flex-wrap: wrap;
    }
    
    .tool {
        min-width: 120px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a2f23 0%, #1c3326 100%);
        color: #e0e0e0;
    }

    .game-container {
        background: rgba(30, 30, 30, 0.9);
    }

    .hud {
        background: linear-gradient(to right, #2d2d2d, #1f1f1f);
    }

    .money, .level, .xp {
        background: #333;
        color: #fff;
    }

    .achievements {
        background: linear-gradient(135deg, #2d2d2d, #1f1f1f);
    }

    .achievement {
        background: #333;
        color: #fff;
    }

    .price-item {
        color: var(--text-dark);
    }

    .inventory-panel {
        background: rgba(26, 26, 26, 0.95);
        color: var(--text-light);
    }
}

.inventory-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 300px;
    backdrop-filter: blur(5px);
}

.inventory-panel.hidden {
    display: none;
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.inventory-header h3 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
    color: #666;
}

.close-btn:hover {
    color: #ff4444;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.inventory-slot {
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.05);
    border: 2px solid #ddd;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inventory-slot:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.inventory-slot.has-item {
    background: rgba(255, 255, 255, 0.9);
    border-color: #4CAF50;
}

.item-count {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
}

.inventory-stats {
    text-align: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--border-radius);
}

/* Dark mode support for inventory */
@media (prefers-color-scheme: dark) {
    .inventory-panel {
        background: rgba(40, 40, 40, 0.95);
    }

    .inventory-header h3 {
        color: #fff;
    }

    .inventory-slot {
        background: rgba(255, 255, 255, 0.1);
        border-color: #444;
    }

    .inventory-slot.has-item {
        background: rgba(40, 40, 40, 0.9);
        border-color: var(--primary-color);
    }

    .item-count {
        color: #ccc;
    }
}

.save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    background: var(--success);
    color: var(--text-light);
    border-radius: var(--border-radius);
    opacity: 0;
    transition: opacity 0.3s;
}

.save-indicator.show {
    opacity: 1;
}

.modal-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    backdrop-filter: blur(5px);
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s linear 0.3s, opacity 0.3s;
}

.modal-panel:not(.hidden) {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

.modal-panel.hidden {
    display: none;
}

/* Ensure modals are on top of each other properly */
#shopPanel { z-index: 1001; }
#inventoryPanel { z-index: 1002; }
#skillTreePanel { z-index: 1003; }

.shop-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    transition: transform 0.2s;
}

.shop-item:hover {
    transform: translateY(-2px);
}

.item-icon {
    font-size: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
}

.item-details {
    flex: 1;
}

.item-details h5 {
    margin: 0 0 5px 0;
}

.item-details p {
    margin: 0 0 10px 0;
    color: #666;
}

.buy-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
}

.buy-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.skill-tree {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 20px;
}

.skill-node {
    position: relative;
    padding: 15px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.skill-node::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    width: 2px;
    height: 10px;
    background: #666;
}

.skill-node.available {
    background: rgba(var(--primary-color), 0.1);
}

.skill-node.unlocked {
    background: var(--primary-color);
    color: white;
}

.skill-node.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.skill-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.skill-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.skill-description {
    font-size: 0.9em;
    color: #666;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modal-panel {
        background: rgba(30, 30, 30, 0.95);
        color: #fff;
    }

    .shop-item {
        background: rgba(255, 255, 255, 0.1);
    }

    .item-details p {
        color: #aaa;
    }

    .skill-node {
        background: rgba(255, 255, 255, 0.1);
    }

    .skill-description {
        color: #aaa;
    }
}

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-box {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    max-width: 400px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.tutorial-message {
    font-size: 1.2em;
    margin-bottom: 15px;
}

.tutorial-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.tutorial-highlight {
    position: relative;
    z-index: 1001;
    box-shadow: 0 0 0 4px var(--primary-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 200, 83, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(0, 200, 83, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 200, 83, 0); }
}

.welcome-modal {
    text-align: center;
}

.welcome-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.welcome-form input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1.1em;
}

.welcome-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.profile-badge {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.profile-icon {
    font-size: 1.5em;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .tutorial-box {
        background: #333;
        color: white;
    }

    .welcome-form input {
        background: #444;
        color: white;
        border-color: #555;
    }
}

.leaderboard-content {
    padding: 15px;
}

.leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: var(--border-radius);
    background: rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.tab.active {
    background: var(--primary-color);
    color: white;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    margin: 5px 0;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--border-radius);
    transition: transform 0.2s;
}

.leaderboard-entry:hover {
    transform: translateX(5px);
}

.leaderboard-entry.you {
    background: rgba(var(--primary-color), 0.2);
    border-left: 4px solid var(--primary-color);
}

.rank {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--primary-color);
}

.player-info {
    flex: 1;
}

.name {
    font-weight: bold;
}

.farm-name {
    font-size: 0.9em;
    color: #666;
}

.score {
    font-weight: bold;
    color: var(--primary-color);
}

.loading, .error {
    text-align: center;
    padding: 20px;
    color: #666;
}

.error {
    color: var(--error);
}

#collectAllAnimalsBtn, #buyPlotBtn {
  /* Example styling */
  margin: 5px;
  padding: 8px 12px;
  cursor: pointer;
}

.animal-stats {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    padding: 15px;
    border-radius: var(--border-radius);
    color: white;
    margin-top: 15px;
}

.animal-stats h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
}

.animal-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.animal-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.animal-item span {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#collectAllAnimalsBtn {
    background: linear-gradient(to right, #4CAF50, #2E7D32);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 10px;
    width: 100%;
}

#collectAllAnimalsBtn:hover {
    transform: translateY(-2px);
}

#collectAllAnimalsBtn:active {
    transform: translateY(0);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .animal-stats {
        background: linear-gradient(135deg, #2E7D32, #1B5E20);
    }
    
    .animal-item {
        background: rgba(255, 255, 255, 0.05);
    }
}
