:root {
    /* Light Theme */
    --bg-color: #f0f2f5;
    --text-color: #1a1a1a;
    --card-bg: rgba(255, 255, 255, 0.8);
    --primary-color: #4CAF50;
    --primary-hover: #45a049;
    --secondary-text: #666;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    --modal-bg: rgba(255, 255, 255, 0.95);
    --border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --card-bg: rgba(30, 30, 30, 0.8);
    --primary-color: #66bb6a;
    --primary-hover: #81c784;
    --secondary-text: #aaa;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    --modal-bg: rgba(18, 18, 18, 0.95);
    --border-color: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

header {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    z-index: 10;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    color: var(--text-color);
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn img {
    display: block;
}

.icon-btn:hover {
    background-color: var(--border-color);
}

.icon-btn svg {
    fill: currentColor;
}

.streak-container {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--card-bg);
    padding: 5px 15px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 15px;
}

.streak-icon {
    font-size: 1.2rem;
}

.streak-count {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-color);
}

.streak-label {
    font-size: 0.9rem;
    color: var(--secondary-text);
    font-weight: 500;
}

.hidden {
    display: none;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-bottom: 60px;
}

.counter-container {
    text-align: center;
    margin-bottom: 40px;
}

.count-display {
    font-size: 8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
}

.goal-display {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 600;
}

.goal-display.completed {
    color: #ffd700;
    /* Gold for completion */
}

.label {
    font-size: 1.2rem;
    color: var(--secondary-text);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Big Increment Button */
#increment-btn {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    box-shadow: 0 10px 25px rgba(76, 175, 80, 0.3);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s, box-shadow 0.1s;

    /* Text Styling */
    color: white;
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#increment-btn:active {
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.2);
}

/* Ripple Effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    background-color: rgba(255, 255, 255, 0.4);
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

#reset-btn {
    margin-top: 40px;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--secondary-text);
    padding: 10px 20px;
    border-radius: 20px;
    font-family: inherit;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

#reset-btn:hover {
    background-color: var(--border-color);
    color: var(--text-color);
    border-color: var(--text-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Bottom sheet on mobile */
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--modal-bg);
    width: 100%;
    max-width: 600px;
    height: 100%;
    /* Full height */
    border-radius: 0;
    /* No radius for full screen feel on mobile */
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
}

.modal.show .modal-content {
    transform: translateY(0);
}

.history-chart-container {
    height: 250px;
    /* Fixed height for chart */
    margin-bottom: 20px;
    flex-shrink: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--secondary-text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 10px;
    position: relative;
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -11px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
}

.history-list {
    flex: 1;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

.history-date {
    font-weight: 500;
}

.history-count {
    font-weight: 700;
    color: var(--primary-color);
}

@media (min-width: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content {
        height: auto;
        max-height: 80%;
        border-radius: 20px;
    }
}

/* Goal Modal Styles */
.goal-options {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.goal-option-btn {
    padding: 15px;
    border: 1px solid var(--border-color);
    background: none;
    border-radius: 10px;
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.goal-option-btn:hover {
    background-color: var(--border-color);
}

.custom-goal-input {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#custom-goal {
    flex: 1;
    padding: 15px;
    border: 1px solid var(--border-color);
    background: none;
    border-radius: 10px;
    color: var(--text-color);
    font-size: 1rem;
    color-scheme: light dark;
    /* Fixes spin button theme */
}

#set-custom-goal {
    padding: 0 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

#clear-goal {
    grid-column: 1 / -1;
    margin-top: 10px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    color: #ff5252;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#clear-goal:hover {
    background-color: rgba(255, 82, 82, 0.1);
    border-color: #ff5252;
}

/* Completion Animation */
@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(76, 175, 80, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.completed-pulse {
    animation: pulse-green 1.5s infinite;
    background-color: #4CAF50 !important;
    /* Ensure green */
}