:root {
    --primary-color: #FF9A00;
    --primary-hover: #E68A00;
    --bg-color: #FDF9F1;
    --card-bg: #FFFFFF;
    --text-main: #333333;
    --text-muted: #666666;
    --border-color: #EEEEEE;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.12);
    --border-radius: 20px;
    --success: #4CAF50;
    --danger: #F44336;
}

body.dark-mode {
    --bg-color: #121212;
    --card-bg: #1E1E1E;
    --text-main: #FDFDFD;
    --text-muted: #AAAAAA;
    --border-color: #333333;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Nunito', sans-serif; transition: background-color 0.3s ease, color 0.3s ease; }

body { background-color: var(--bg-color); color: var(--text-main); display: flex; flex-direction: column; min-height: 100vh; }

/* AUTH OVERLAY */
.auth-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); z-index: 2000; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.auth-card { width: 90%; max-width: 400px; padding: 40px 30px; }
.error-text { color: var(--danger); font-size: 0.9rem; font-weight: bold; margin-top: 10px; text-align: center;}

/* NAVBAR */
.navbar { position: sticky; top: 0; background: var(--card-bg); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.05); z-index: 1000; }
.nav-brand { font-size: 1.5rem; font-weight: 800; color: var(--primary-color); }
.nav-links { display: flex; gap: 10px; }
.nav-btn { background: transparent; border: none; color: var(--text-main); font-size: 1rem; font-weight: 600; padding: 8px 12px; border-radius: 10px; cursor: pointer; transition: all 0.2s; }
.nav-btn:hover { background: var(--border-color); }
.nav-btn.active { background: var(--primary-color); color: white; }
.theme-btn { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; }
.mobile-menu-btn { display: none; font-size: 1.8rem; cursor: pointer; }

/* MAIN & VIEWS */
.container { flex: 1; max-width: 1200px; margin: 0 auto; padding: 20px; width: 100%; }
.view { display: none; animation: fadeIn 0.4s ease; }
.view.active { display: block; }
.section-title { text-align: center; margin-bottom: 20px; font-size: 2rem; }

/* CARDS & LAYOUT */
.card { background: var(--card-bg); border-radius: var(--border-radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.hidden { display: none !important; }

/* STATUS BAR */
.status-bar { display: flex; justify-content: space-between; flex-wrap: wrap; background: var(--card-bg); padding: 15px 20px; border-radius: var(--border-radius); box-shadow: var(--shadow); margin-bottom: 20px; font-weight: 700; }
.status-item span { color: var(--primary-color); }

/* ==== 3D TAMAGOTCHI PET STYLES ==== */
.pet-card { display: flex; flex-direction: column; align-items: center; }
.pet-canvas-wrapper { width: 100%; max-width: 500px; height: 300px; background: rgba(0, 0, 0, 0.05); border-radius: var(--border-radius); overflow: hidden; position: relative; margin-bottom: 15px; cursor: grab; }
.pet-canvas-wrapper:active { cursor: grabbing; }
.dark-mode .pet-canvas-wrapper { background: rgba(255, 255, 255, 0.05); }

.pet-stats { width: 100%; max-width: 500px; display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; align-items: center; gap: 15px; font-size: 0.95rem; font-weight: 700; }
.stat-row span { width: 70px; text-align: right; }
.bar-bg { flex: 1; height: 16px; background: var(--border-color); border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; transition: width 0.4s ease, background-color 0.4s ease; border-radius: 8px; }

.pet-controls { display: flex; gap: 10px; justify-content: center; width: 100%; max-width: 500px; flex-wrap: wrap; }
.pet-action-btn { flex: 1; min-width: 100px; border: 2px solid var(--border-color); font-weight: bold; }
/* =================================== */

/* BUTTONS & INPUTS */
.primary-btn { display: block; width: 100%; padding: 15px; background: var(--primary-color); color: white; border: none; border-radius: 12px; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: transform 0.1s, background 0.2s; box-shadow: 0 4px 15px rgba(255, 154, 0, 0.3); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:hover { background: var(--primary-hover); }
.primary-btn:disabled { background: var(--border-color); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }

.icon-btn { background: var(--border-color); border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #E0E0E0; }
.dark-mode .icon-btn:hover { background: #444; }

input[type="text"], input[type="password"], select { width: 100%; padding: 12px; border: 2px solid var(--border-color); border-radius: 10px; background: var(--card-bg); color: var(--text-main); font-size: 1rem; font-family: 'Nunito', sans-serif; outline: none; }
input[type="text"]:focus, input[type="password"]:focus, select:focus { border-color: var(--primary-color); }

/* INNER TABS (Progress & Profile) */
.inner-tabs-nav { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.tab-btn, .lb-tab { padding: 8px 16px; border: none; border-radius: 20px; background: var(--border-color); color: var(--text-main); cursor: pointer; font-weight: 600; transition: 0.2s; }
.tab-btn.active, .lb-tab.active { background: var(--primary-color); color: white; }
.tab-pane { display: none; animation: fadeIn 0.3s ease; }
.tab-pane.active { display: block; }

/* FORTUNE & CHEST */
.main-fortune-card { text-align: center; padding: 30px 20px; }
.cookie-container { display: flex; align-items: center; justify-content: center; }
.cookie-img { font-size: 5rem; cursor: pointer; animation: bounce 2s infinite; }
.cookie-img.crack { animation: shakeCrack 0.5s forwards; }

.chest-img { display: inline-block; transition: transform 0.2s; }
.chest-img:hover { transform: scale(1.1); }
.chest-img.shake { animation: wiggle 0.4s ease-in-out; }
.chest-img.open { filter: grayscale(1); opacity: 0.5; }

.fortune-text { background: #FFF9E6; color: #333; padding: 20px; border-radius: 10px; border-left: 5px solid var(--primary-color); font-size: 1.2rem; font-style: italic; position: relative; box-shadow: 0 4px 10px rgba(0,0,0,0.05); width: 100%; }
.dark-mode .fortune-text { background: #2A2A2A; color: #FFF; border-left-color: var(--primary-color); }
.fortune-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 15px; }
.timer { color: var(--text-muted); margin-top: 15px; font-weight: 600; font-size: 0.9rem;}

/* PROGRESS BAR */
.progress-bar-container { width: 100%; height: 12px; background: var(--border-color); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.progress-bar { height: 100%; background: var(--primary-color); transition: width 0.5s ease; }

/* LISTS */
.scroll-list { list-style: none; max-height: 250px; overflow-y: auto; padding-right: 10px; text-align: left;}
.scroll-list li { padding: 12px; border-bottom: 1px solid var(--border-color); font-size: 0.95rem; }
.scroll-list li:last-child { border-bottom: none; }
.big-list { max-height: 400px; }

/* WHEEL OF FORTUNE */
.wheel-container { position: relative; width: 250px; height: 250px; margin: 0 auto 30px; }
.wheel { width: 100%; height: 100%; border-radius: 50%; border: 5px solid var(--primary-color); position: relative; overflow: hidden; transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99); box-shadow: 0 0 15px rgba(0,0,0,0.1); }
.wheel::after { content: ''; position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; background: var(--card-bg); border: 4px solid var(--primary-color); border-radius: 50%; transform: translate(-50%, -50%); z-index: 5; }
.wheel-text { position: absolute; top: 50%; left: 50%; width: 50%; height: 20px; margin-top: -10px; transform-origin: 0% 50%; display: flex; align-items: center; justify-content: flex-start; padding-left: 30px; padding-right: 5px; font-size: 0.75rem; font-weight: 800; color: #fff; text-shadow: 1px 1px 4px rgba(0,0,0,0.8); box-sizing: border-box; white-space: nowrap; pointer-events: none; z-index: 2; }
.wheel-pointer { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 2rem; color: #E53935; z-index: 10; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }

/* CARDS GAME */
.cards-container { display: flex; justify-content: center; gap: 15px; margin: 20px 0 30px; }
.flip-card { background-color: transparent; width: 80px; height: 120px; perspective: 1000px; cursor: pointer; }
.flip-card-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.6s; transform-style: preserve-3d; }
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 10px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.flip-card-front { background-color: var(--primary-color); color: white; font-size: 2rem; border: 2px solid #FFF; }
.flip-card-back { background-color: #FFF; color: var(--primary-color); transform: rotateY(180deg); font-size: 1.5rem; font-weight: bold; border: 2px solid var(--primary-color); }
.dark-mode .flip-card-back { background-color: var(--card-bg); }

/* GRID LAYOUTS */
.badges-grid, .grid-shop, .grid-collection { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; text-align: center; }
.badge-item, .shop-item, .collection-item { background: var(--card-bg); border: 2px solid var(--border-color); border-radius: 15px; padding: 15px; box-shadow: var(--shadow); opacity: 0.5; filter: grayscale(1); transition: all 0.3s; }
.badge-item.unlocked, .collection-item { opacity: 1; filter: grayscale(0); border-color: var(--primary-color); }
.shop-item { opacity: 1; filter: grayscale(0); border-color: var(--border-color); }
.badge-icon, .shop-icon { font-size: 2.5rem; margin-bottom: 10px; }
.shop-item button { margin-top: 10px; padding: 8px; font-size: 0.9rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; }
.stat-box { background: var(--bg-color); padding: 15px; border-radius: 10px; text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--primary-color); }

/* CALENDAR */
.calendar-card { max-width: 600px; margin: 0 auto; }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: bold; margin-bottom: 10px; color: var(--text-muted); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: var(--bg-color); border-radius: 50%; font-weight: 600; }
.cal-day.has-fortune { background: var(--primary-color); color: white; box-shadow: 0 2px 8px rgba(255, 154, 0, 0.4); }
.cal-day.empty { background: transparent; }

/* LEADERBOARD */
.table-responsive { overflow-x: auto; }
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th, .leaderboard-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border-color); }
.leaderboard-table tr:nth-child(1) td { font-weight: bold; color: gold; font-size: 1.1rem; }
.leaderboard-table tr:nth-child(2) td { font-weight: bold; color: silver; }
.leaderboard-table tr:nth-child(3) td { font-weight: bold; color: #cd7f32; }

/* TOAST */
#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #333; color: #fff; padding: 12px 24px; border-radius: 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards; font-weight: 600; text-align: center;}
.dark-mode .toast { background: #FFF; color: #333; }

/* FOOTER */
footer { text-align: center; padding: 20px; color: var(--text-muted); font-size: 0.9rem; margin-top: auto; }

/* ANIMATIONS */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes shakeCrack { 0% { transform: rotate(0deg); } 25% { transform: rotate(15deg) scale(1.1); } 50% { transform: rotate(-15deg) scale(1.1); } 75% { transform: rotate(10deg) scale(1.1); opacity: 0.5;} 100% { transform: rotate(0deg) scale(0); opacity: 0; display: none; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-10deg) scale(1.1); } 50% { transform: rotate(10deg) scale(1.1); } 75% { transform: rotate(-10deg) scale(1.1); } }

/* RESPONSIVE */
@media (max-width: 768px) {
    .nav-links { display: none; position: absolute; top: 60px; left: 0; width: 100%; background: var(--card-bg); flex-direction: column; padding: 10px; box-shadow: 0 10px 15px rgba(0,0,0,0.1); }
    .nav-links.show { display: flex; }
    .mobile-menu-btn { display: block; }
    .grid-2 { grid-template-columns: 1fr; } 
    .status-bar { justify-content: center; gap: 15px; }
}