:root {
    color-scheme: dark;

    /* Colors */
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-color: #2dd4bf;
    --accent-hover: #14b8a6;
    --box-past: #334155;
    --box-current: #f59e0b;
    --box-future: #0f172a;
    --border-color: #334155;

    /* Typography */
    --font-heading: 'Lora', serif;
    --font-body: 'Inter', sans-serif;

    /* Fluid Spacing (scales with viewport) */
    --space-xs: clamp(0.25rem, 1vw, 0.5rem);
    --space-sm: clamp(0.5rem, 2vw, 1rem);
    --space-md: clamp(1rem, 3vw, 1.5rem);
    --space-lg: clamp(1.5rem, 4vw, 2.5rem);
    --space-xl: clamp(2rem, 5vw, 4rem);

    /* Fluid Typography */
    --text-xs: clamp(0.6rem, 1.5vw, 0.75rem);
    --text-sm: clamp(0.75rem, 2vw, 0.9rem);
    --text-base: clamp(0.9rem, 2.5vw, 1rem);
    --text-lg: clamp(1rem, 3vw, 1.2rem);
    --text-xl: clamp(1.25rem, 4vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 5vw, 2rem);
    --text-3xl: clamp(2rem, 6vw, 3rem);

    /* Grid sizing */
    --week-box-size: clamp(0.5rem, 1.5vw, 0.875rem);
    --week-gap: clamp(0.125rem, 0.5vw, 0.1875rem);

    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
}

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

body {
    font-family: var(--font-body);
    background:
        linear-gradient(to bottom, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.7)),
        url("./assets/zen_background.png");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: var(--space-md);
}

.container {
    width: 100%;
    max-width: 75rem;
    /* 1200px equivalent */
    margin: 0 auto;
    padding: 0 var(--space-sm);
}

/* Header */
header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

h1 {
    font-family: var(--font-heading);
    font-size: var(--text-3xl);
    font-weight: 400;
    background: linear-gradient(to right, #f1f5f9, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-style: italic;
    font-size: var(--text-lg);
    opacity: 0.8;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    justify-content: center;
    align-items: flex-start;
    background-color: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(0.5rem);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 0.25rem 0.375rem -0.0625rem rgba(0, 0, 0, 0.1);
    margin-bottom: var(--space-lg);
    max-width: 50rem;
    margin-left: auto;
    margin-right: auto;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: center;
    flex: 1 1 auto;
    min-width: 8rem;
}

label {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    color: #e2e8f0;
}

/* Inputs */
input {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.6) !important;
    color: white !important;
    font-size: var(--text-base);
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 12rem;
}

input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.125rem rgba(45, 212, 191, 0.2);
}

/* Date Input */
.date-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232dd4bf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.8;
    cursor: pointer;
    transition: opacity 0.2s;
}

/* Number Input with +/- Buttons */
.custom-number-input {
    display: flex;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    gap: var(--space-xs);
}

.custom-number-input input {
    border: none;
    background: transparent !important;
    text-align: center;
    width: 3.75rem;
    padding: var(--space-xs);
    margin: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.custom-number-input input::-webkit-outer-spin-button,
.custom-number-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* +/- Buttons */
.pm-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--text-xl);
    font-weight: 400;
    line-height: 1;
}

.pm-btn:hover {
    background: rgba(45, 212, 191, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 0.5rem rgba(45, 212, 191, 0.2);
}

.pm-btn:active {
    transform: scale(0.95);
}

/* Buttons */
button {
    padding: var(--space-sm) var(--space-md);
    background-color: var(--accent-color);
    color: #0f172a;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--text-base);
    cursor: pointer;
    transition: all 0.2s;
}

button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-0.0625rem);
    box-shadow: 0 0.25rem 0.75rem rgba(45, 212, 191, 0.2);
}

button:active {
    transform: translateY(0);
}

.secondary-btn {
    background-color: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.secondary-btn:hover {
    background-color: rgba(45, 212, 191, 0.1);
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-family: var(--font-heading);
}

.week-box-legend {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: var(--radius-sm);
}

/* Stats Section */
.stats {
    margin-bottom: var(--space-lg);
    color: #cbd5e1;
    font-size: var(--text-lg);
    max-width: 56.25rem;
    margin-left: auto;
    margin-right: auto;
}

.stats-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.stat-box {
    background: var(--card-bg);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex: 1 1 15rem;
    max-width: 20rem;
    text-align: center;
    box-shadow: 0 0.25rem 0.375rem -0.0625rem rgba(0, 0, 0, 0.1);
}

.stat-box h4 {
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-style: italic;
    margin-bottom: var(--space-sm);
}

.time-display {
    font-family: 'Courier New', Courier, monospace;
    font-size: var(--text-base);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
    font-variant-numeric: tabular-nums;
}

.time-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.time-val {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--accent-color);
}

.stat-box.left .time-val {
    color: var(--box-current);
}

.time-label {
    font-size: var(--text-xs);
    color: #64748b;
    margin-top: 0.25rem;
    font-family: var(--font-body);
}

/* Lifeline Progress Bar */
.lifeline-container {
    margin-top: var(--space-lg);
    width: 100%;
}

.lifeline-bar {
    height: 0.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: 100%;
}

.lifeline-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--box-past), var(--accent-color));
    border-radius: var(--radius-sm);
    transition: width 1s ease-in-out;
    box-shadow: 0 0 0.625rem rgba(45, 212, 191, 0.2);
}

.lifeline-labels {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-style: italic;
}

.summary-sentences {
    width: 100%;
    text-align: center;
    margin-bottom: var(--space-sm);
    font-size: var(--text-lg);
    color: var(--text-color);
    font-family: var(--font-heading);
}

.summary-sentences strong {
    color: var(--accent-color);
    font-weight: 600;
}

/* Chart Wrapper */
.chart-wrapper {
    display: flex;
    gap: var(--space-sm);
    background-color: var(--card-bg);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    box-shadow: 0 1.25rem 1.5625rem -0.3125rem rgba(0, 0, 0, 0.1);
    align-items: flex-start;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: var(--space-xl);
    overflow-x: auto;
}

/* Y-Axis (Years) */
.y-axis {
    display: flex;
    flex-direction: column;
    gap: var(--week-gap);
    text-align: right;
    font-size: var(--text-xs);
    color: var(--text-muted);
    /* Match the x-axis height + margin */
    padding-top: calc(var(--text-xs) + var(--space-xs) + var(--space-xs));
    min-width: 2.5rem;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-body);
    opacity: 0.6;
    flex-shrink: 0;
}

.y-axis span {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: var(--week-box-size);
    line-height: 1;
}

/* Calendar Container */
.calendar-container {
    display: flex;
    flex-direction: column;
    min-width: max-content;
    padding: var(--space-xs);
}

/* X-Axis (Weeks) */
.x-axis {
    display: grid;
    grid-template-columns: repeat(53, var(--week-box-size));
    gap: var(--week-gap);
    margin-bottom: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-align: center;
    opacity: 0.6;
    height: var(--text-xs);
    line-height: 1;
}

.x-axis span {
    display: block;
}

/* Life Grid */
.life-grid {
    display: flex;
    flex-direction: column;
    gap: var(--week-gap);
}

.year-row {
    display: grid;
    grid-template-columns: repeat(53, var(--week-box-size));
    gap: var(--week-gap);
}

.life-grid .week-box {
    width: var(--week-box-size);
    height: var(--week-box-size);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    cursor: pointer;
}

/* Week Box States */
.past {
    background-color: var(--box-past);
    opacity: 0.7;
}

.pre-birth,
.post-death {
    background-color: transparent;
    border: 1px solid #1e293b;
    opacity: 0.3;
}

.current {
    background-color: var(--box-current);
    box-shadow: 0 0 0.625rem var(--box-current);
    z-index: 2;
    animation: breathe 4s ease-in-out infinite;
    border-radius: 50%;
}

@keyframes breathe {

    0%,
    100% {
        opacity: 0.8;
        box-shadow: 0 0 0.3125rem var(--box-current);
    }

    50% {
        opacity: 1;
        box-shadow: 0 0 0.9375rem var(--box-current);
    }
}

.future {
    background-color: var(--box-future);
    border: 1px solid #334155;
    opacity: 0.5;
}

/* Hover effect - disabled on touch */
@media (hover: hover) {
    .life-grid .week-box:hover {
        transform: scale(1.5);
        z-index: 10;
        box-shadow: 0 0 0.625rem rgba(0, 0, 0, 0.5);
    }
}

/* Tooltip */
.tooltip {
    position: fixed;
    display: none;
    background-color: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--accent-color);
    color: white;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 0.625rem 0.9375rem -0.1875rem rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    backdrop-filter: blur(0.25rem);
    font-family: var(--font-heading);
}

/* Donation Section */
.donation-section {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-bottom: var(--space-lg);
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.donation-section:hover {
    opacity: 1;
}

.donation-card {
    background: var(--card-bg);
    padding: var(--space-md);
    text-align: center;
    max-width: 17.5rem;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 0.25rem 0.375rem -0.0625rem rgba(0, 0, 0, 0.1);
}

.donation-card h3 {
    color: var(--text-color);
    margin-bottom: var(--space-xs);
    font-size: var(--text-sm);
    font-weight: 600;
}

.donation-card p {
    color: #94a3b8;
    font-size: var(--text-xs);
    margin-bottom: var(--space-sm);
    line-height: 1.4;
}

.revolut-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    color: #64748b;
    text-decoration: none;
    border-radius: 99rem;
    font-weight: 500;
    font-size: var(--text-xs);
    transition: all 0.2s;
    border: 1px solid #334155;
}

.revolut-btn:hover {
    background: #0f172a;
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.crypto-note {
    font-size: var(--text-xs) !important;
    margin-top: var(--space-xs);
    margin-bottom: 0 !important;
    opacity: 0.5;
    font-style: italic;
}

/* Feedback Message */
.feedback-message {
    width: 100%;
    text-align: center;
    color: #f59e0b;
    font-size: var(--text-sm);
    margin-top: var(--space-xs);
    min-height: 1.5em;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-family: var(--font-heading);
    font-style: italic;
}

.feedback-message.visible {
    opacity: 1;
}

/* ============================================
   MOBILE TOUCH SUPPORT
   ============================================ */

@media (pointer: coarse) {

    /* Touch devices: larger tap targets */
    .life-grid .week-box {
        min-width: 0.75rem;
        min-height: 0.75rem;
    }

    /* Tooltip at bottom for touch */
    .tooltip {
        position: fixed;
        bottom: 1.25rem;
        left: 50% !important;
        top: auto !important;
        transform: translateX(-50%);
        max-width: 90vw;
        text-align: center;
    }
}