/* ========================================
   Brew Bloom - Premium UI/UX Design
   Material Design 3 + Organic Aesthetics
   ======================================== */

:root {
    /* Core Colors */
    --primary: #5D4037;
    --primary-light: #8B6B61;
    --primary-dark: #3E2723;
    
    --accent: #FF6B35;
    --accent-light: #FF8A5C;
    --accent-glow: rgba(255, 107, 53, 0.4);
    
    /* Nature Colors */
    --leaf-1: #2D5A27;
    --leaf-2: #4A7C42;
    --leaf-3: #6B9B5E;
    --leaf-4: #8FBC8F;
    
    --trunk-1: #3E2723;
    --trunk-2: #5D4037;
    --trunk-3: #795548;
    
    --cherry-ripe: #C41E3A;
    --cherry-unripe: #E8A849;
    --flower-white: #FFF8F0;
    
    --pot-1: #D2691E;
    --pot-2: #A0522D;
    --pot-3: #8B4513;
    
    /* Surface */
    --surface: #FDF8F3;
    --surface-dim: #F5EDE5;
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-border: rgba(93, 64, 55, 0.08);
    
    /* Text */
    --text-primary: #2D2017;
    --text-secondary: #6B5B4F;
    --text-hint: #9E8E82;
    
    /* Effects */
    --shadow-soft: 0 2px 12px rgba(93, 64, 55, 0.08);
    --shadow-medium: 0 4px 20px rgba(93, 64, 55, 0.12);
    --shadow-strong: 0 8px 32px rgba(93, 64, 55, 0.16);
    --shadow-glow: 0 0 40px var(--accent-glow);
    
    /* Timing */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* Spacing */
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Outfit', 'Noto Sans JP', system-ui, sans-serif;
    background: var(--surface);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    touch-action: manipulation;
}

/* ==========================================
   BACKGROUND
   ========================================== */
.background {
    position: fixed;
    inset: 0;
    z-index: -1;
    transition: background 1.5s ease;
}

.background.morning {
    background: linear-gradient(165deg, 
        #87CEEB 0%, 
        #B4E4F5 25%,
        #FFF8E7 60%,
        var(--surface) 100%
    );
}

.background.afternoon {
    background: linear-gradient(165deg, 
        #5BA3D9 0%, 
        #87CEEB 30%,
        #FFF5E1 65%,
        var(--surface) 100%
    );
}

.background.evening {
    background: linear-gradient(165deg, 
        #E67E4D 0%, 
        #F4A460 25%,
        #FFECD2 60%,
        var(--surface) 100%
    );
}

.background.night {
    background: linear-gradient(165deg, 
        #1A1A2E 0%, 
        #2D3A5C 30%,
        #4A5568 60%,
        #2D2017 100%
    );
}

body.night-mode {
    --text-primary: #F5EDE5;
    --text-secondary: #C4B8AD;
    --card-bg: rgba(45, 32, 23, 0.9);
}

/* ==========================================
   APP CONTAINER
   ========================================== */
.app {
    max-width: 440px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 16px;
    padding-bottom: calc(20px + var(--safe-bottom));
    position: relative;
}

/* ==========================================
   HEADER
   ========================================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.375rem;
    font-weight: 700;
}

.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.logo-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--card-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    color: var(--text-secondary);
    box-shadow: var(--shadow-soft);
}

.icon-btn:active {
    transform: scale(0.92);
}

/* ==========================================
   MENU MODAL
   ========================================== */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    padding: 20px;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-card {
    background: var(--surface);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    max-width: 320px;
    box-shadow: var(--shadow-strong);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s var(--ease-bounce);
}

.menu-overlay.active .menu-card {
    transform: scale(1) translateY(0);
}

.menu-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--text-primary);
    transition: background 0.15s;
    font-family: inherit;
}

.menu-item:active {
    background: var(--surface-dim);
}

.menu-item .material-icons-round {
    color: var(--text-secondary);
    font-size: 22px;
}

.menu-item.danger {
    color: #C41E3A;
}

.menu-item.danger .material-icons-round {
    color: #C41E3A;
}

.menu-close {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    border: none;
    background: var(--surface-dim);
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: inherit;
    transition: all 0.15s;
}

.menu-close:active {
    background: var(--primary);
    color: white;
}

/* ==========================================
   MAIN TREE AREA
   ========================================== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    position: relative;
}

.tree-scene {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tree-scene svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 8px 24px rgba(45, 90, 39, 0.15));
}

/* Tree Animation Classes */
.tree-scene.pulse svg {
    animation: tree-pulse 0.6s var(--ease-bounce);
}

@keyframes tree-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* ==========================================
   GROWTH INFO
   ========================================== */
.growth-info {
    width: 100%;
    max-width: 280px;
    margin-top: 20px;
}

.growth-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.stage-icon {
    font-size: 1.25rem;
}

.stage-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-container {
    position: relative;
}

.progress-bar {
    height: 8px;
    background: var(--surface-dim);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--leaf-2) 0%, var(--leaf-3) 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s var(--ease-out);
    position: relative;
}

.progress-glow {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--leaf-3);
    border-radius: 50%;
    filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s;
}

.progress-fill:not([style*="width: 0"]) ~ .progress-glow {
    opacity: 0.6;
}

.progress-text {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-text span:first-child {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-separator {
    opacity: 0.5;
}

.progress-unit {
    margin-left: 2px;
}

/* ==========================================
   STATS ROW
   ========================================== */
.stats-row {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.stat-card {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s var(--ease-out);
}

.stat-card:active {
    transform: scale(0.97);
}

.stat-card.featured {
    background: linear-gradient(135deg, rgba(74, 124, 66, 0.1) 0%, rgba(143, 188, 143, 0.1) 100%);
    border-color: rgba(74, 124, 66, 0.2);
}

.stat-icon-wrap {
    width: 36px;
    height: 36px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.25rem;
}

.stat-icon-wrap.sun { background: rgba(255, 193, 7, 0.15); }
.stat-icon-wrap.tree { background: rgba(74, 124, 66, 0.15); }
.stat-icon-wrap.trophy { background: rgba(255, 152, 0, 0.15); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-hint);
    margin-top: 2px;
}

/* ==========================================
   ACTION AREA
   ========================================== */
.action-area {
    margin-top: auto;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Coffee Button - Hero Element */
.coffee-btn {
    position: relative;
    width: 100%;
    max-width: 280px;
    height: 72px;
    border: none;
    border-radius: 36px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.15s var(--ease-out);
}

.coffee-btn:active {
    transform: scale(0.96);
}

.coffee-btn-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    border-radius: 36px;
}

.coffee-btn-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    color: white;
}

.coffee-icon {
    font-size: 1.75rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.coffee-label {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.coffee-btn-ring {
    position: absolute;
    inset: -4px;
    border: 3px solid var(--accent);
    border-radius: 40px;
    opacity: 0;
    animation: ring-pulse 2s ease-out infinite;
}

@keyframes ring-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.08); opacity: 0; }
}

.coffee-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.hint-text {
    margin-top: 12px;
    font-size: 0.8125rem;
    color: var(--text-hint);
    text-align: center;
}

/* Harvest Button */
.harvest-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
    height: 56px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--cherry-ripe) 0%, #E91E63 100%);
    color: white;
    border: none;
    border-radius: 28px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(196, 30, 58, 0.3);
    animation: harvest-glow 2s ease-in-out infinite;
}

.harvest-btn.visible {
    display: flex;
}

@keyframes harvest-glow {
    0%, 100% { box-shadow: 0 4px 20px rgba(196, 30, 58, 0.3); }
    50% { box-shadow: 0 4px 30px rgba(196, 30, 58, 0.5); }
}

.harvest-btn:active {
    transform: scale(0.96);
}

/* ==========================================
   FEEDBACK TOAST
   ========================================== */
.feedback-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    background: var(--primary);
    color: white;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: var(--shadow-strong);
    opacity: 0;
    pointer-events: none;
    z-index: 500;
}

.feedback-toast.show {
    animation: toast-pop 1s var(--ease-bounce) forwards;
}

@keyframes toast-pop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    40% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(0.9); opacity: 0; }
}

.feedback-icon {
    font-size: 1.25rem;
}

/* ==========================================
   CELEBRATION MODAL
   ========================================== */
.celebration-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    padding: 20px;
}

.celebration-overlay.active {
    opacity: 1;
    visibility: visible;
}

.celebration-card {
    background: var(--surface);
    border-radius: 28px;
    padding: 32px 28px;
    width: 100%;
    max-width: 320px;
    text-align: center;
    box-shadow: var(--shadow-strong);
    transform: scale(0.9) translateY(30px);
    transition: transform 0.4s var(--ease-bounce);
    position: relative;
    overflow: hidden;
}

.celebration-overlay.active .celebration-card {
    transform: scale(1) translateY(0);
}

.confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}

.celebration-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: bounce 0.8s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.celebration-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.celebration-message {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
}

.celebration-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--leaf-2) 0%, var(--leaf-3) 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74, 124, 66, 0.3);
    transition: transform 0.15s;
}

.celebration-btn:active {
    transform: scale(0.96);
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 380px) {
    .app {
        padding: 12px;
    }
    
    .tree-scene {
        max-width: 240px;
    }
    
    .coffee-btn {
        height: 64px;
    }
    
    .stat-card {
        padding: 12px 8px;
    }
}

@media (min-height: 800px) {
    .main {
        min-height: 340px;
    }
    
    .tree-scene {
        max-width: 320px;
    }
}

@media (min-width: 768px) {
    .app {
        padding: 24px;
    }
    
    .tree-scene {
        max-width: 360px;
    }
    
    .coffee-btn {
        max-width: 320px;
        height: 76px;
    }
}
