:root {
    --bg-color: #f4e8d1;
    --panel-bg: rgba(255, 253, 245, 0.95);
    --text-color: #4a3b32;
    --earth-brown: #795548;
    --earth-dark: #4e342e;
    --leaf-green: #689f38;
    --warm-yellow: #ffca28;
    --potato-color: #d7b572;
    --soil-light: #5d4037;
    --soil-dark: #3e2723;
    --market-up: #4CAF50;
    --market-down: #F44336;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Fredoka', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(#d5c3aa 1.5px, transparent 1.5px);
    background-size: 30px 30px;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* Top Navigation & Stats */
.top-bar {
    width: 100%;
    max-width: 1300px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 15px;
    padding: 0 20px;
    box-sizing: border-box;
    position: relative;
    z-index: 1000;
}

.stats-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 5px;
}

/* Profile Area */
.profile-area {
    margin-bottom: -5px;
}
.title-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-shadow: 1px 1px 0px rgba(0,0,0,0.3);
    color: white;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 2px solid rgba(255,255,255,0.4);
}
.title-badge.unranked { background: #9E9E9E; }
.title-badge.owned { background: linear-gradient(135deg, #FF9800, #F44336); }

/* Spud Stats */
.spud-header { 
    font-size: 2.5rem; 
    margin: 0; 
    color: var(--earth-brown);
    text-shadow: 2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white; 
}
.stats p { margin: 0; font-size: 1.1rem; font-weight: 600; color: var(--leaf-green); text-shadow: 1px 1px 0px white; }

.inventory {
    display: flex;
    gap: 15px;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 15px;
    border-radius: 12px;
    border: 2px solid rgba(121, 85, 72, 0.4);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.inv-item { font-weight: 600; font-size: 1.1rem; color: var(--earth-dark); }

.tabs { display: flex; gap: 8px; }
.tab-btn {
    background: rgba(255, 253, 245, 0.6);
    border: 3px solid rgba(121, 85, 72, 0.2);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 12px 20px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--earth-brown);
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn:hover { background: rgba(255, 253, 245, 0.8); transform: translateY(-2px); }
.tab-btn.active { background: var(--panel-bg); border-color: rgba(121, 85, 72, 0.4); color: var(--leaf-green); transform: translateY(3px); z-index: 10; }

/* Main Container */
.game-container {
    width: 95%;
    max-width: 1300px;
    height: calc(100vh - 140px);
    position: relative;
    z-index: 5;
}

.panel {
    background: var(--panel-bg);
    border-radius: 20px;
    border-top-right-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 40px rgba(121, 85, 72, 0.15);
    border: 3px solid rgba(121, 85, 72, 0.4);
    display: none;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto;
}
.panel.active-tab { display: flex; flex-direction: column; animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

h2 { font-size: 1.8rem; margin-top: 0; color: var(--earth-dark); border-bottom: 3px solid rgba(104, 159, 56, 0.2); padding-bottom: 8px;}
h3 { margin-top: 20px; color: var(--earth-brown); }
h4 { margin: 0; font-size: 1.2rem; }
p { margin: 5px 0; }
.hint { color: #888; font-style: italic; margin-bottom: 15px; }

/* Buttons */
.btn {
    background-color: var(--leaf-green); color: white; border: none; padding: 8px 15px; border-radius: 10px;
    font-family: 'Fredoka', sans-serif; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 0 #4a7525;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 #4a7525; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #4a7525; }
.btn:disabled { background-color: #a5d6a7; box-shadow: 0 4px 0 #81c784; cursor: not-allowed; transform: none; }

.buy-btn { background-color: var(--warm-yellow); color: var(--text-color); box-shadow: 0 4px 0 #e6aa00; }
.buy-btn:hover:not(:disabled) { box-shadow: 0 6px 0 #e6aa00; }
.buy-btn:active:not(:disabled) { box-shadow: 0 2px 0 #e6aa00; }
.buy-btn:disabled { background-color: #ffe082; box-shadow: 0 4px 0 #ffd54f; color: rgba(74,59,50,0.5); }

.sell-btn { background-color: #ef5350; color: white; box-shadow: 0 4px 0 #c62828; }
.sell-btn:hover:not(:disabled) { box-shadow: 0 6px 0 #c62828; }
.sell-btn:active:not(:disabled) { box-shadow: 0 2px 0 #c62828; }

/* Clicker Tab */
#tab-clicker { align-items: center; justify-content: center; position: relative; }
.potato-container { position: relative; width: 300px; height: 300px; display: flex; justify-content: center; align-items: center; z-index: 10; }
.potato-name-tag { font-size: 1.8rem; color: var(--earth-brown); margin-top: 20px; margin-bottom: 0; font-family: 'Fredoka', sans-serif; text-shadow: 2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white; z-index: 20; position: relative; }
.potato { width: 100%; height: 100%; cursor: pointer; transition: transform 0.1s; }
.potato:active { transform: scale(0.9) translateY(10px); }
.golden-potato .potato-body { fill: url(#gold-grad) !important; filter: drop-shadow(0 0 25px #FFD54F) !important; }

/* Rebirth Button */
#btn-rebirth {
    background-color: #9C27B0; color: white; box-shadow: 0 5px 0 #6A1B9A; font-size: 1.2rem; padding: 15px 30px;
    border-radius: 15px; animation: pulse 1.5s infinite alternate; margin-top: 30px; display: none; z-index: 20;
}
#btn-rebirth:hover { box-shadow: 0 7px 0 #6A1B9A; transform: translateY(-2px); }
#btn-rebirth:active { box-shadow: 0 2px 0 #6A1B9A; transform: translateY(3px); }

/* Particles Fix */
.particle {
    position: absolute; pointer-events: none; font-size: 1.8rem; font-weight: bold; color: var(--earth-dark);
    text-shadow: 2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white; 
    animation: floatUp 1s ease-out forwards; z-index: 1500;
}
@keyframes floatUp { 0% { transform: translateY(0) scale(0.8); opacity: 1; } 100% { transform: translateY(-100px) scale(1.2); opacity: 0; } }

/* Farm Tab */
.farm-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.farm-controls { display: flex; gap: 10px; }
.farm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; padding: 15px; background: #a1887f; border-radius: 15px; border: 5px solid #8d6e63; box-shadow: inset 0 10px 20px rgba(0,0,0,0.2); }
.plot { background: repeating-linear-gradient(0deg, var(--soil-light), var(--soil-light) 10px, var(--soil-dark) 10px, var(--soil-dark) 20px); border-radius: 8px; height: 130px; position: relative; cursor: pointer; border: 3px solid #4e342e; overflow: hidden; transition: transform 0.2s; }
.plot:hover { transform: scale(1.03); }
.plant { position: absolute; bottom: 10%; left: 50%; transform: translateX(-50%); font-size: 3.5rem; z-index: 2; animation: plantGrow 0.4s; filter: drop-shadow(0 3px 3px rgba(0,0,0,0.4)); }
@keyframes plantGrow { from { transform: translateX(-50%) scale(0); } to { transform: translateX(-50%) scale(1); } }
.plot-ready { border-color: var(--warm-yellow); animation: wiggle 2s infinite ease-in-out; }

/* Kitchen Tab */
.kitchen-layout { display: flex; gap: 20px; height: 100%; }
.recipes-book { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding-right: 10px; }
.recipe-card { background: white; border-radius: 12px; padding: 15px; margin-bottom: 15px; border: 2px solid rgba(121, 85, 72, 0.2); display: flex; flex-direction: column; gap: 10px; }
.recipe-header { display: flex; justify-content: space-between; align-items: center; }
.recipe-reqs { font-size: 0.9rem; color: #666; background: #f5f5f5; padding: 8px; border-radius: 8px; }

.cooking-stations { flex: 1.5; display: flex; flex-direction: column; }
.stations-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 20px; }
.station { background: #eceff1; border-radius: 12px; border: 3px inset #cfd8dc; height: 120px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 15px; position: relative; }
.station.idle { color: #aaa; font-style: italic; }
.station.cooking { background: #fff3e0; border-color: #ffb74d; }
.station.ready { background: #e8f5e9; border-color: #81c784; cursor: pointer; animation: pulse 1s infinite alternate;}

.progress-bar-bg { width: 100%; height: 15px; background: #ddd; border-radius: 10px; overflow: hidden; margin-top: 15px; }
.progress-bar-fill { height: 100%; background: var(--warm-yellow); width: 0%; transition: width 0.1s linear; }

/* Market Tab */
.market-list { display: flex; flex-direction: column; gap: 15px; }
.market-item { background: white; border-radius: 12px; padding: 20px; display: flex; justify-content: space-between; align-items: center; border: 2px solid rgba(121, 85, 72, 0.2); }
.market-info { display: flex; align-items: center; gap: 15px; }
.market-icon { font-size: 2.5rem; }
.market-price { font-size: 1.5rem; font-weight: bold; display: flex; align-items: center; gap: 10px; min-width: 150px;}
.price-up { color: var(--market-up); }
.price-down { color: var(--market-down); }
.market-actions { display: flex; gap: 10px; }

/* Factory Tab */
.factory-layout { display: flex; gap: 20px; height: 100%; }
.generators-shop { flex: 1; display: flex; flex-direction: column; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; }
.shop-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding-right: 10px; }
.shop-item { background: white; border-radius: 12px; padding: 15px; display: flex; justify-content: space-between; align-items: center; border: 2px solid rgba(121, 85, 72, 0.15); }
.item-icon { font-size: 2rem; margin-right: 15px; }
.item-actions { display: flex; flex-direction: column; gap: 5px; }

.factory-floor { flex: 1.5; background: #eceff1; border-radius: 15px; padding: 15px; border: 4px inset #cfd8dc; display: flex; flex-direction: column; }
.factory-grid { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 10px; overflow-y: auto; }
.factory-node { width: 50px; height: 50px; background: white; border-radius: 10px; display: flex; justify-content: center; align-items: center; font-size: 1.5rem; border: 2px solid #cfd8dc; position: relative; animation: popIn 0.2s; }
.factory-particle { position: absolute; font-size: 1rem; font-weight: bold; color: var(--leaf-green); text-shadow: 1px 1px 0px white; animation: floatUpNode 1s ease-out forwards; pointer-events: none; z-index: 10; }

/* Titles Tab */
.titles-list { display: flex; flex-direction: column; gap: 15px; padding-top: 10px; }
.title-card {
    background: white; border-radius: 12px; padding: 20px; display: flex; justify-content: space-between; align-items: center;
    border: 2px solid rgba(121, 85, 72, 0.2); transition: all 0.2s;
}
.title-card.owned {
    background: #fff8e1; border-color: var(--warm-yellow);
}
.title-card.locked {
    opacity: 0.6; filter: grayscale(1); pointer-events: none;
}
.title-info h4 { margin: 0 0 5px 0; font-size: 1.4rem; color: var(--earth-brown); }
.title-info p { margin: 0; font-size: 0.9rem; color: #777; }
.title-icon { font-size: 2rem; margin-right: 15px; }
.title-main-area { display: flex; align-items: center; }

/* Modal & Animations */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: none; justify-content: center; align-items: center; z-index: 2000; }
.modal-content { background: var(--panel-bg); padding: 40px; border-radius: 20px; border: 4px solid var(--warm-yellow); box-shadow: 0 0 50px rgba(255, 202, 40, 0.4); text-align: center; max-width: 400px; }
.modal-actions { display: flex; gap: 20px; justify-content: center; margin-top: 20px; }
.explosion { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 9999; animation: flash 2s forwards; pointer-events: none; }
@keyframes flash { 0% { opacity: 0; } 10% { opacity: 1; } 100% { opacity: 0; } }
@keyframes floatUpNode { 0% { transform: translateY(0) scale(0.8); opacity: 1; } 100% { transform: translateY(-30px) scale(1.2); opacity: 0; } }
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.1); } }

/* Toasts */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--earth-dark); color: white; padding: 15px 25px; border-radius: 12px; box-shadow: 0 10px 20px rgba(0,0,0,0.3); font-weight: 600; display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s; border-left: 5px solid var(--warm-yellow); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.fade-out { animation: fadeOut 0.5s forwards; }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-20px) scale(0.9); } }
