:root {
    /* Deep Jewel Tones - Premium Dark Theme */
    --bg-dark: #0f0f0f;
    --bg-card: #1a1a1a;
    --primary: #22d3ee;
    /* Cyan */
    --secondary: #a855f7;
    /* Purple */
    --accent: #f472b6;
    /* Pink */

    --glass: rgba(26, 26, 26, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);

    --text-main: #f0f0f0;
    --text-dim: #a1a1aa;

    /* Heatmap Gradient: Gray -> Emerald -> Cyan -> Bright */
    --level-0: rgba(255, 255, 255, 0.05);
    --level-1: #065f46;
    --level-2: #059669;
    --level-3: #10b981;
    --level-4: #34d399;

    --neon-glow: 0 0 20px rgba(34, 211, 238, 0.3);
    --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a2e 50%, #0f0f0f 100%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Space Grotesk', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle Animated Background */
.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 80%, rgba(34, 211, 238, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
    animation: bgPulse 10s ease-in-out infinite;
}

@keyframes bgPulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: -2;
}



/* Global Entrance Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 0 0 1px var(--glass-border);
    }

    50% {
        box-shadow: 0 8px 32px rgba(0, 243, 255, 0.15), inset 0 0 0 1px rgba(0, 243, 255, 0.2);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    letter-spacing: 2px;
    font-size: 1.5rem;
    background: linear-gradient(90deg, #fff, #8b9bb4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 5px var(--primary));
}

.status-pill {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
}

.dot {
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 10px #00ff88;
}

/* Glass Cards */
.glass-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 2rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: fadeInUp 0.6s ease-out both;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.glass-card:nth-child(1) {
    animation-delay: 0.1s;
}

.glass-card:nth-child(2) {
    animation-delay: 0.2s;
}

.glass-card:nth-child(3) {
    animation-delay: 0.3s;
}

.glass-card:hover {
    transform: translateY(-8px) rotateX(2deg) rotateY(-2deg);
    box-shadow:
        0 20px 40px -15px rgba(0, 0, 0, 0.5),
        0 0 30px -10px rgba(0, 243, 255, 0.3);
    border-color: rgba(0, 243, 255, 0.3);
}

.glass-card:active {
    transform: translateY(-4px) scale(0.98);
}

/* Hero Stat */
.hero-stats {
    margin-bottom: 2rem;
}

.main-stat h2 {
    color: var(--text-dim);
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.timer-display {
    font-family: 'Outfit', sans-serif;
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 1rem;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.timer-display .unit {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 300;
}

.timer-display .divider {
    color: var(--glass-border);
    font-weight: 300;
}

.stat-footer {
    display: flex;
    gap: 1rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Streak Badge */
.streak-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 100, 50, 0.15), rgba(255, 200, 50, 0.1));
    border: 1px solid rgba(255, 150, 50, 0.3);
    border-radius: 50px;
    animation: streakPulse 2s ease-in-out infinite;
}

.streak-icon {
    font-size: 1.5rem;
    animation: fireFlicker 0.5s ease-in-out infinite alternate;
}

#streakCount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ff9500;
    text-shadow: 0 0 10px rgba(255, 150, 50, 0.5);
}

.streak-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes streakPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 150, 50, 0.3);
    }

    50% {
        box-shadow: 0 0 20px 5px rgba(255, 150, 50, 0.2);
    }
}

/* Best Day Badge */
.best-day-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(168, 85, 247, 0.15));
    border: 1px solid rgba(34, 211, 238, 0.3);
    padding: 8px 16px;
    border-radius: 50px;
    margin-top: 10px;
    cursor: default;
}

.best-day-icon {
    font-size: 1.2rem;
}

#bestDayName {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 10px rgba(34, 211, 238, 0.5);
}

.best-day-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Monthly Chart Card */
.monthly-chart {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .monthly-chart {
        grid-column: span 1;
    }
}

/* ====== LANDSCAPE MODE FOR MOBILE ====== */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-stats {
        padding: 10px 0;
    }

    .main-stat {
        padding: 15px;
    }

    .main-timer {
        font-size: 3rem !important;
        margin: 0.5rem 0 !important;
    }

    .stat-tabs {
        padding: 2px;
    }

    .stat-tab {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    .streak-badge,
    .best-day-badge {
        padding: 4px 10px;
        font-size: 0.8rem;
    }

    .streak-icon,
    .best-day-icon {
        font-size: 1rem;
    }

    #streakCount,
    #bestDayName {
        font-size: 1rem;
    }

    .charts-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .chart-card {
        padding: 10px;
    }

    .chart-card h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .heatmap-section {
        padding: 10px;
    }

    footer {
        padding: 0.5rem 0;
        font-size: 0.7rem;
    }
}

@keyframes fireFlicker {
    0% {
        transform: scale(1) rotate(-5deg);
    }

    100% {
        transform: scale(1.1) rotate(5deg);
    }
}

/* Heatmap */
.heatmap-section h3 {
    margin-bottom: 1rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.heatmap-scroller {
    overflow-x: auto;
    padding-bottom: 10px;
    direction: ltr;
    /* Ensure scrolling works LTR even if page is RTL */
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 10px);
    grid-auto-flow: column;
    gap: 3px;
    width: max-content;
    padding: 2px;
}

.heat-box {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--level-0);
    transition: all 0.3s ease;
}

.heat-box:hover {
    transform: scale(1.4);
    z-index: 2;
    box-shadow: 0 0 10px var(--primary);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.heat-box.l1 {
    background: var(--level-1);
    box-shadow: 0 0 5px var(--level-1);
}

.heat-box.l2 {
    background: var(--level-2);
    box-shadow: 0 0 8px var(--level-2);
}

.heat-box.l3 {
    background: var(--level-3);
    box-shadow: 0 0 12px var(--level-3);
}

.heat-box.l4 {
    background: var(--level-4);
    box-shadow: 0 0 15px var(--level-4);
}

.separator {
    color: var(--glass-border);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: var(--text-main);
}

.chart-card {
    overflow: hidden;
    min-width: 0;
}

.chart-card canvas {
    max-width: 100%;
}

/* Heatmap */
.heatmap-section h3 {
    margin-bottom: 1rem;
}

.heatmap-scroller {
    overflow-x: auto;
    padding-bottom: 10px;
}

.heatmap-grid {
    display: grid;
    grid-template-rows: repeat(7, 12px);
    grid-auto-flow: column;
    gap: 4px;
}

.heat-box {
    width: 12px;
    height: 12px;
    background: var(--level-0);
    border-radius: 2px;
    transition: all 0.2s;
}

.heat-box:hover {
    transform: scale(1.3);
    z-index: 2;
    border: 1px solid #fff;
}

.heat-box.l1,
.heat-box.level-1 {
    background: var(--level-1);
    box-shadow: 0 0 5px var(--level-1);
}

.heat-box.l2,
.heat-box.level-2 {
    background: var(--level-2);
    box-shadow: 0 0 8px var(--level-2);
}

.heat-box.l3,
.heat-box.level-3 {
    background: var(--level-3);
    box-shadow: 0 0 10px var(--level-3);
}

.heat-box.l4,
.heat-box.level-4 {
    background: var(--level-4);
    box-shadow: 0 0 15px var(--level-4);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.legend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.legend .heat-box {
    width: 10px;
    height: 10px;
}

/* Modern Tabs & Filters */
.stat-header,
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    /* responsive wrap */
    gap: 10px;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.glass-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 20px;
    font-family: 'Space Grotesk', sans-serif;
    outline: none;
    cursor: pointer;
    color-scheme: dark;
    /* Ensures native calendar is dark mode */
}

.glass-input:hover,
.glass-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

.stat-tabs,
.chart-filters {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 50px;
    display: inline-flex;
    gap: 4px;
}

.stat-tab,
.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: 20px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stat-tab:hover,
.filter-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.stat-tab.active,
.filter-btn.active {
    background: var(--primary);
    color: #000;
    font-weight: 700;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

/* Small adjustment for timer size in the new layout */
.main-timer {
    font-size: 6rem;
    justify-content: center;
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
    margin: 2rem 0;
}

#stat-label {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8rem;
    opacity: 0.7;
    width: 100%;
    text-align: center;
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .timer-display,
    .main-timer {
        font-size: 4rem;
    }

    .stat-header,
    .chart-header {
        flex-direction: column;
        align-items: stretch;
        /* Full width items */
        gap: 1rem;
    }

    .chart-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .chart-filters {
        order: 1;
        /* Filters first */
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .filter-btn {
        padding: 6px 12px;
        /* Smaller touch targets if needed, or keep for tap */
        flex-grow: 1;
        text-align: center;
    }

    #monthPicker {
        order: 2;
        flex-grow: 1;
        width: auto;
    }

    .maximize-btn {
        order: 3;
    }
}

/* Fullscreen Chart Logic (Native API Support) */
/* Fullscreen Charts Grid (Native API Support) */
.charts-grid.fullscreen,
.charts-grid:fullscreen {
    background: #0a0a0a !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 20px !important;
    gap: 30px !important;

    /* Allow scrolling */
    overflow-y: auto !important;

    /* Browser handles sizing/positioning in native mode */
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Ensure children behave well in fullscreen */
.charts-grid:fullscreen .chart-card {
    width: 100% !important;
    flex-shrink: 0 !important;
    /* Reset height to auto to fit content */
    height: auto !important;
    min-height: 400px !important;
}

.charts-grid:fullscreen canvas {
    max-height: 60vh !important;
    width: 100% !important;
}

/* Hide body scroll just in case */
body.fullscreen-active {
    overflow: hidden !important;
}

/* Hide body scroll just in case */
body.fullscreen-active {
    overflow: hidden !important;
}

/* Maximize Button - Premium Glass Style */
.maximize-btn {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: var(--primary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 8px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.maximize-btn:hover {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(168, 85, 247, 0.25));
    border-color: var(--primary);
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.maximize-btn:active {
    transform: scale(0.95);
}

/* Icon Button Base - Fallback */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 5px;
    border-radius: 5px;
}

.icon-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 2rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 1px;
    opacity: 0.6;
    transition: opacity 0.3s;
}

footer:hover {
    opacity: 1;
    color: var(--primary);
}

/* ====== CUSTOM SCROLLBAR ====== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: all 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(255, 255, 255, 0.02);
}

/* ====== LOADING SKELETON ====== */
.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.08),
            transparent);
    animation: shimmerSkeleton 1.5s infinite;
}

@keyframes shimmerSkeleton {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 2rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-chart {
    height: 200px;
    width: 100%;
}

/* ====== SMOOTH SECTION TRANSITIONS ====== */
section,
.glass-card,
.hero-stats,
.charts-grid,
.heatmap-section {
    animation: fadeSlideIn 0.6s ease-out both;
}

.hero-stats {
    animation-delay: 0.1s;
}

.charts-grid {
    animation-delay: 0.3s;
}

.heatmap-section {
    animation-delay: 0.5s;
}

footer {
    animation-delay: 0.7s;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====== PARALLAX BACKGROUND ====== */
.bg-glow {
    transform: translateZ(0);
    will-change: transform;
}

body.parallax-enabled .bg-glow {
    transition: transform 0.1s ease-out;
}

/* ====== TYPING NUMBER EFFECT ====== */
.typing-number {
    font-variant-numeric: tabular-nums;
    display: inline-block;
    min-width: 2ch;
}

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary);
    margin-left: 2px;
    animation: blink 0.7s infinite;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}