/* ========== RESET & BASE ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; font-family: 'Inter', sans-serif; background: #e2e8f0; display: flex; justify-content: center; align-items: center; }
h1, h2, h3, h4, h5 { font-family: 'TAN Nimbus', serif; }

#app { width: 100vw; max-width: 414px; height: 100vh; position: relative; overflow: hidden; background: #f0f4f8; box-shadow: 0 0 30px rgba(0,0,0,0.15); }
@media (min-width: 415px) {
  #app { height: 90vh; max-height: 896px; border-radius: 40px; border: 8px solid #fff; }
}
.screen { position: absolute; inset: 0; display: none; flex-direction: column; overflow-y: auto; padding-bottom: 80px; }
.screen.active { display: flex; }
.screen.no-nav { padding-bottom: 0; }

/* ========== GRADIENTS (from wireframes) ========== */
.bg-blue { background: linear-gradient(180deg, #7BC3FF 0%, #B8DFFF 50%, #E8E8E8 100%); }
.bg-purple { background: linear-gradient(180deg, #C98FD6 0%, #E0BAE8 50%, #EEE 100%); }
.bg-green { background: linear-gradient(180deg, #7ED89B 0%, #B8EECA 50%, #EEE 100%); }
.bg-yellow { background: linear-gradient(180deg, #F2D857 0%, #F5E8A0 50%, #EEE 100%); }
.bg-teal { background: linear-gradient(180deg, #5BBFBA 0%, #A8DDD9 50%, #EEE 100%); }

/* ========== COMMON ELEMENTS ========== */
.screen-inner { width: 100%; max-width: 420px; margin: 0 auto; padding: 24px 20px; flex: 1; display: flex; flex-direction: column; }
.screen-title { font-size: 26px; text-align: center; color: #333; margin-bottom: 16px; }
.screen-subtitle { font-size: 14px; color: #666; text-align: center; margin-bottom: 20px; }

/* ========== TOP HEADER BAR (for main screens) ========== */
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; margin-bottom: 8px; }
.top-bar .user-info { display: flex; align-items: center; gap: 8px; }
.top-bar .user-avatar { width: 32px; height: 32px; border-radius: 50%; background: #ddd; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.top-bar .user-name { font-family: 'TAN Nimbus', serif; color: #6B5CFF; font-size: 16px; }
.top-bar .points-badge { background: #A8E6A3; color: #333; font-weight: 700; font-size: 13px; padding: 4px 12px; border-radius: 20px; }

/* ========== FORM ELEMENTS ========== */
.form-group { margin-bottom: 16px; }
.form-label { font-family: 'TAN Nimbus', serif; font-size: 15px; color: #333; margin-bottom: 6px; display: block; }
.form-input { width: 100%; padding: 12px 14px; border: 2px solid #ccc; border-radius: 12px; font-size: 14px; font-family: 'Inter', sans-serif; background: #fff; transition: border-color 0.2s; }
.form-input:focus { outline: none; border-color: #7BC3FF; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
select.form-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23999' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
textarea.form-input { resize: vertical; min-height: 70px; }

/* ========== BUTTONS ========== */
.btn { padding: 14px 28px; border: none; border-radius: 25px; font-family: 'TAN Nimbus', serif; font-size: 16px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: linear-gradient(135deg, #7BC3FF, #5BA8E6); color: #fff; box-shadow: 0 4px 15px rgba(91,168,230,0.3); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(91,168,230,0.4); }
.btn-green { background: linear-gradient(135deg, #7ED89B, #5BBF7A); color: #fff; box-shadow: 0 4px 15px rgba(91,191,122,0.3); }
.btn-purple { background: linear-gradient(135deg, #C98FD6, #A86CB8); color: #fff; box-shadow: 0 4px 15px rgba(168,108,184,0.3); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-outline { background: transparent; border: 2px solid #7BC3FF; color: #7BC3FF; }

.link-btn { background: none; border: none; color: #7BC3FF; font-size: 13px; cursor: pointer; text-decoration: underline; font-family: 'Inter', sans-serif; }

/* ========== CARDS ========== */
.card { background: rgba(255,255,255,0.85); backdrop-filter: blur(10px); border-radius: 16px; padding: 16px; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }

/* ========== TAGS / CHIPS ========== */
.tag-group { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; border: 2px solid #ddd; background: #fff; color: #555; transition: all 0.2s; }
.tag.active { background: #7BC3FF; color: #fff; border-color: #7BC3FF; }

/* ========== MISSION / CHECKLIST ========== */
.mission-item { display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,0.85); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; border-left: 4px solid #7ED89B; }
.mission-item.completed { border-left-color: #5BBF7A; }
.mission-item .mission-text { font-size: 14px; font-weight: 500; color: #333; }
.mission-check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #ccc; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; flex-shrink: 0; }
.mission-check.checked { background: #5BBF7A; border-color: #5BBF7A; color: #fff; }

/* ========== MOOD GRID ========== */
.mood-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.mood-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; background: rgba(255,255,255,0.7); border-radius: 16px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; }
.mood-card:hover, .mood-card.selected { border-color: #C98FD6; background: rgba(201,143,214,0.15); transform: scale(1.05); }
.mood-card .mood-emoji { font-size: 36px; }
.mood-card .mood-label { font-size: 12px; font-weight: 600; color: #555; }

/* ========== BOTTOM NAV ========== */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; display: flex; justify-content: space-around; align-items: center; padding: 8px 0 12px; box-shadow: 0 -2px 15px rgba(0,0,0,0.08); border-radius: 20px 20px 0 0; z-index: 100; }
.bottom-nav.hidden { display: none; }
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: #999; font-size: 10px; cursor: pointer; padding: 4px 8px; transition: color 0.2s; font-family: 'Inter', sans-serif; font-weight: 600; }
.nav-btn.active { color: #7BC3FF; }
.nav-btn svg { width: 22px; height: 22px; }

/* ========== LEADERBOARD ========== */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 20px 0; }
.podium-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.podium-item.first { order: 2; }
.podium-item.second { order: 1; }
.podium-item.third { order: 3; }
.podium-avatar { width: 60px; height: 60px; border-radius: 50%; border: 3px solid #F2D857; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 32px; background: #fef3c7; }
.podium-item.first .podium-avatar { width: 80px; height: 80px; border-color: #F2D857; }
.podium-item.second .podium-avatar { border-color: #C0C0C0; }
.podium-item.third .podium-avatar { border-color: #CD7F32; }
.podium-rank { font-family: 'TAN Nimbus', serif; font-size: 18px; color: #F2D857; }
.podium-name { font-weight: 700; font-size: 13px; color: #333; }
.podium-streak { font-size: 11px; color: #888; }

.leaderboard-row { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.85); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.leaderboard-row .rank { font-family: 'TAN Nimbus', serif; font-size: 16px; color: #888; width: 24px; }
.leaderboard-row .lb-avatar { width: 36px; height: 36px; border-radius: 50%; background: #eee; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.leaderboard-row .lb-name { flex: 1; font-weight: 600; font-size: 14px; }
.leaderboard-row .lb-tag { font-size: 11px; color: #7BC3FF; font-weight: 700; background: #E8F4FF; padding: 2px 8px; border-radius: 10px; }

/* ========== SHOP CARDS ========== */
.shop-section { margin-bottom: 20px; }
.shop-section-title { font-family: 'TAN Nimbus', cursive; font-size: 18px; color: #333; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.shop-card { display: flex; gap: 12px; background: rgba(255,255,255,0.85); border-radius: 14px; padding: 12px; margin-bottom: 10px; align-items: center; }
.shop-card-img { width: 80px; height: 80px; border-radius: 10px; background: #f0e6d3; display: flex; align-items: center; justify-content: center; font-size: 36px; flex-shrink: 0; }
.shop-card-info { flex: 1; }
.shop-card-info h4 { font-family: 'TAN Nimbus', cursive; font-size: 15px; color: #333; }
.shop-card-info p { font-size: 11px; color: #888; margin: 4px 0 8px; }
.btn-redeem { padding: 6px 16px; border: none; border-radius: 15px; background: linear-gradient(135deg, #F2D857, #E6C84D); color: #333; font-weight: 700; font-size: 12px; cursor: pointer; }

/* ========== AVATAR CUSTOMIZER ========== */
.avatar-display { width: 160px; height: 200px; margin: 0 auto 16px; background: rgba(255,255,255,0.5); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 100px; }
.avatar-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.avatar-tab { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; border: 2px solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.3); color: #555; }
.avatar-tab.active { background: #fff; border-color: #C98FD6; color: #C98FD6; }
.avatar-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.avatar-option { background: rgba(255,255,255,0.7); border-radius: 14px; padding: 12px; text-align: center; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; }
.avatar-option:hover, .avatar-option.selected { border-color: #C98FD6; }
.avatar-option .avatar-thumb { font-size: 50px; margin-bottom: 4px; }
.avatar-option .avatar-name { font-size: 11px; font-weight: 600; color: #555; }

/* ========== FOOD SCAN ========== */
.upload-box { border: 2px dashed #ccc; border-radius: 16px; padding: 30px; text-align: center; cursor: pointer; background: rgba(255,255,255,0.7); margin-bottom: 20px; transition: border-color 0.2s; }
.upload-box:hover { border-color: #7ED89B; }
.upload-box .upload-icon { font-size: 48px; margin-bottom: 8px; }
.upload-box p { font-size: 13px; color: #888; }
.nutrition-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.nutrition-row .form-input { flex: 1; }
.nutrition-row .unit { font-size: 13px; color: #888; font-weight: 600; min-width: 40px; }

/* ========== PROFILE SECTION ========== */
.profile-section { text-align: center; margin-bottom: 20px; }
.profile-avatar-large { width: 100px; height: 100px; border-radius: 50%; margin: 0 auto 8px; border: 3px solid #C98FD6; display: flex; align-items: center; justify-content: center; font-size: 56px; background: #f3e8f7; position: relative; }
.profile-avatar-large .heart-badge { position: absolute; bottom: 0; right: 0; width: 24px; height: 24px; background: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.profile-name { font-family: 'TAN Nimbus', cursive; font-size: 20px; color: #333; }
.profile-streak { font-size: 13px; color: #888; margin: 2px 0 8px; }

/* ========== HORIZONTAL SCROLL ========== */
.h-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll-item { flex-shrink: 0; width: 80px; height: 80px; border-radius: 12px; background: #f0e6d3; display: flex; align-items: center; justify-content: center; font-size: 36px; }

/* ========== ANIMATIONS ========== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.screen.active .screen-inner { animation: fadeIn 0.3s ease-out; }
