* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --berry-pink: #ff6b9d;
    --berry-accent: #ff4081;
    --bg-light: #f0f0ff;
    --bg-dark: #1a1a2e;
    --card-light: #ffffff;
    --card-dark: #252540;
    --text-light: #1f2937;
    --text-dark: #f3f4f6;
    --green: #10b981;
    --orange: #f59e0b;
    --red: #ef4444;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg-light);
    color: var(--text-light);
    min-height: 100vh;
}

.app {
    min-height: 100vh;
    background: linear-gradient(180deg, #6366f1 0%, #8b5cf6 100%);
}

.app.berry-mode {
    background: linear-gradient(180deg, #6366f1 0%, #8b5cf6 50%, #ff6b9d 100%);
}

.app.dark {
    --bg-light: #1a1a2e;
    --card-light: #252540;
    --text-light: #f3f4f6;
}

.header {
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-main {
    flex: 1;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.25rem;
}

.berry-icon {
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
    display: inline-block;
}

.berry-icon:hover {
    transform: scale(1.2);
}

.berry-icon.bouncing {
    animation: berryBounce 0.6s ease;
}

@keyframes berryBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-15px) scale(1.1); }
    50% { transform: translateY(-5px) scale(1.05); }
    75% { transform: translateY(-10px) scale(1.08); }
}

.app-tagline {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.currency-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-size: 0.9rem;
}

.currency-dropdown {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
}

.currency-dropdown option {
    background: var(--primary-dark);
    color: white;
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.main {
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.hero-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
    position: relative;
}

.hero-label {
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.berry-mode .hero-label {
    color: var(--berry-pink);
}

.hero-amount {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--text-light);
    margin: 0.5rem 0;
}

.hero-quote {
    color: #6b7280;
    font-size: 1rem;
    margin-bottom: 1rem;
    min-height: 1.5em;
}

.blame-berry-btn {
    background: linear-gradient(135deg, var(--berry-pink), var(--berry-accent));
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.blame-berry-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

.milestone-section {
    background: #f3f4f6;
    border-radius: 12px;
    padding: 1rem;
    margin-top: 0.5rem;
}

.milestone-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #4b5563;
    margin-bottom: 0.5rem;
}

.milestone-bar {
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: visible;
    position: relative;
}

.milestone-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 6px;
    transition: width 0.3s ease;
}

.berry-mode .milestone-progress {
    background: linear-gradient(90deg, var(--berry-pink), var(--berry-accent));
}

.milestone-berry {
    position: absolute;
    top: -8px;
    transform: translateX(-50%);
    font-size: 1.2rem;
    transition: left 0.3s ease;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-purple { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.stat-blue { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.stat-orange { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.stat-green { background: linear-gradient(135deg, #d1fae5, #a7f3d0); }

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-light);
}

.stat-berry {
    font-size: 0.9rem;
}

.stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 1rem;
    text-align: center;
}

.section-title-white {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    text-align: center;
}

.quick-add-section {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.quick-add-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.quick-add-btn {
    background: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.quick-add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.berry-mode .quick-add-btn:hover {
    background: linear-gradient(135deg, #fff0f5, #ffe4ec);
}

.add-custom-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.add-custom-btn:hover {
    transform: translateY(-2px);
}

.habits-section {
    margin-bottom: 1.5rem;
}

.habits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.habit-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    position: relative;
}

.berry-quip-toast {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--berry-pink);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 10;
    animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15%, 85% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.habit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.habit-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.habit-emoji {
    font-size: 1.5rem;
}

.habit-title h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.habit-actions {
    display: flex;
    gap: 0.5rem;
}

.habit-actions button {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.habit-actions button:hover {
    opacity: 1;
}

.habit-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.habit-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
}

.habit-value {
    padding: 0.5rem;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 0.9rem;
}

.savings-display {
    text-align: center;
    margin-bottom: 1rem;
}

.savings-label {
    display: block;
    color: var(--green);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.savings-amount {
    font-size: 2rem;
    font-weight: 800;
    color: var(--green);
}

.time-display {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.time-unit {
    text-align: center;
}

.time-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.time-label {
    font-size: 0.75rem;
    color: #6b7280;
}

.time-divider {
    width: 1px;
    background: #e5e7eb;
}

.reset-btn {
    display: block;
    margin: 1rem auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.investment-section {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.section-subtitle {
    text-align: center;
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.investment-inputs {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.investment-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
}

.input-hint {
    font-size: 0.75rem;
    color: #9ca3af;
}

.wasted-card {
    background: linear-gradient(135deg, #fef3c7, #fed7aa);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
}

.wasted-label {
    display: block;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 0.25rem;
}

.wasted-amount {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: #ea580c;
}

.wasted-subtitle {
    font-size: 0.85rem;
    color: #92400e;
}

.investment-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.investment-card {
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    color: white;
    transition: transform 0.2s;
}

.investment-card:hover {
    transform: scale(1.02);
}

.inv-emoji {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.inv-name {
    display: block;
    font-size: 0.75rem;
    opacity: 0.9;
}

.inv-amount {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.berry-comment {
    text-align: center;
    color: var(--berry-pink);
    font-style: italic;
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(255, 107, 157, 0.1);
    border-radius: 8px;
}

.btc-chart-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.btc-chart-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-light);
    text-align: center;
    margin-bottom: 0.25rem;
}

.btc-chart-subtitle {
    font-size: 0.85rem;
    color: #6b7280;
    text-align: center;
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 250px;
    margin-bottom: 1rem;
}

.btc-chart {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.chart-tooltip {
    position: absolute;
    top: 10px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 10;
    min-width: 150px;
}

.tooltip-date {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #a5b4fc;
}

.tooltip-row {
    margin-bottom: 0.25rem;
}

.tooltip-pl {
    margin-top: 0.5rem;
    font-weight: 600;
}

.tooltip-pl.positive { color: #10b981; }
.tooltip-pl.negative { color: #ef4444; }

.btc-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .btc-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.btc-stat {
    text-align: center;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 8px;
}

.btc-stat-label {
    display: block;
    font-size: 0.7rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.btc-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-light);
}

.btc-stat-value.gain {
    color: var(--green);
}

.future-section {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.future-section h2 {
    color: #065f46;
    margin-bottom: 0.5rem;
}

.future-section p {
    color: #047857;
    line-height: 1.6;
}

.future-tagline {
    font-weight: 600;
    margin-top: 1rem !important;
}

.footer {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.8);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-heart {
    display: inline;
}

.footer a {
    color: white;
    font-weight: 600;
}

.berry-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.berry-toggle input {
    display: none;
}

.toggle-slider {
    width: 48px;
    height: 24px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider::after {
    content: '🍓';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: left 0.3s;
}

.berry-toggle input:checked + .toggle-slider {
    background: var(--berry-pink);
}

.berry-toggle input:checked + .toggle-slider::after {
    left: 26px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.modal-inputs {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
}

.emoji-input {
    max-width: 80px;
}

.modal-actions {
    display: flex;
    gap: 1rem;
}

.modal-cancel {
    flex: 1;
    padding: 0.75rem;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
}

.modal-add {
    flex: 1;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* Berry Character Overlay */
.berry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.berry-character {
    text-align: center;
    animation: berryPopIn 0.4s ease;
}

@keyframes berryPopIn {
    0% { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.berry-emoji {
    font-size: 6rem;
    display: block;
    margin-bottom: 1rem;
}

.berry-emoji.dancing {
    animation: berryDance 1s ease-in-out infinite;
}

@keyframes berryDance {
    0%, 100% { transform: rotate(-5deg) translateY(0); }
    25% { transform: rotate(5deg) translateY(-10px); }
    50% { transform: rotate(-5deg) translateY(0); }
    75% { transform: rotate(5deg) translateY(-5px); }
}

.berry-speech-bubble {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 300px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.berry-speech-bubble::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 15px solid white;
}

.berry-speech-bubble p {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.berry-close-btn {
    background: linear-gradient(135deg, var(--berry-pink), var(--berry-accent));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.berry-close-btn:hover {
    transform: scale(1.05);
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1000;
}

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

.confetti-particle.berry-confetti {
    font-size: 1.5rem;
    width: auto;
    height: auto;
    background: transparent !important;
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Dark mode overrides */
.app.dark .hero-card,
.app.dark .stat-card,
.app.dark .habit-card,
.app.dark .investment-section,
.app.dark .modal {
    background: var(--card-dark);
    color: var(--text-dark);
}

.app.dark .quick-add-btn {
    background: var(--card-dark);
    color: var(--text-dark);
}

.app.dark .habit-input,
.app.dark .investment-input,
.app.dark .modal-input {
    background: #1a1a2e;
    border-color: #3f3f5a;
    color: var(--text-dark);
}

.app.dark .habit-value {
    background: #1a1a2e;
}

.app.dark .milestone-section {
    background: #1a1a2e;
}

.app.dark .time-divider,
.app.dark .habit-inputs + .savings-display {
    border-color: #3f3f5a;
}

.app.dark .btc-stat {
    background: #1a1a2e;
}

.app.dark .section-title-white,
.app.dark .btc-chart-title {
    color: var(--text-dark);
}

@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-controls {
        justify-content: space-between;
    }
    
    .hero-amount {
        font-size: 2.5rem;
    }
    
    .habit-inputs {
        grid-template-columns: 1fr;
    }
    
    .investment-grid {
        grid-template-columns: 1fr;
    }
    
    .berry-emoji {
        font-size: 4rem;
    }
}