:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-border: rgba(255, 255, 255, 0.1);
    --accent-1: #3b82f6;
    --accent-2: #8b5cf6;
}

body.theme-ocean {
    --bg-color: #082f49;
    --card-bg: rgba(12, 74, 110, 0.6);
    --accent-1: #0ea5e9;
    --accent-2: #2dd4bf;
}

body.theme-sunset {
    --bg-color: #450a0a;
    --card-bg: rgba(127, 29, 29, 0.6);
    --accent-1: #f97316;
    --accent-2: #f43f5e;
}

body.theme-forest {
    --bg-color: #052e16;
    --card-bg: rgba(6, 78, 59, 0.6);
    --accent-1: #22c55e;
    --accent-2: #10b981;
}

body.theme-cyberpunk {
    --bg-color: #09090b;
    --card-bg: rgba(24, 24, 27, 0.6);
    --accent-1: #06b6d4;
    --accent-2: #ec4899;
}

body.theme-sakura {
    --bg-color: #2e1026;
    --card-bg: rgba(74, 20, 56, 0.6);
    --accent-1: #f472b6;
    --accent-2: #fb7185;
}

body.theme-stealth {
    --bg-color: #000000;
    --card-bg: rgba(20, 20, 20, 0.6);
    --accent-1: #94a3b8;
    --accent-2: #ffffff;
}

body.theme-royal {
    --bg-color: #1e1b4b;
    --card-bg: rgba(49, 46, 129, 0.6);
    --accent-1: #fbbf24;
    --accent-2: #d97706;
}

body.theme-aurora {
    --bg-color: #020617;
    --card-bg: rgba(15, 23, 42, 0.6);
    --accent-1: #a855f7;
    --accent-2: #10b981;
}

body.theme-arctic {
    --bg-color: #0b1320;
    --card-bg: rgba(21, 40, 60, 0.6);
    --accent-1: #38bdf8;
    --accent-2: #cffafe;
}

body.theme-synthwave {
    --bg-color: #17002e;
    --card-bg: rgba(45, 10, 75, 0.6);
    --accent-1: #f472b6;
    --accent-2: #22d3ee;
}

body.theme-terminal {
    --bg-color: #050505;
    --card-bg: rgba(0, 25, 5, 0.6);
    --accent-1: #22c55e;
    --accent-2: #86efac;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 14px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    border: 4px solid var(--bg-color);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

html {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) var(--bg-color);
    overscroll-behavior-y: none;
    /* Prevents rubber-band bounce on mobile */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    /* Fallback */
    min-height: 100dvh;
    /* Dynamic viewport height for mobile */
    display: flex;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

.background-blobs {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    animation: float 10s infinite ease-in-out alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background-color: var(--accent-1);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background-color: var(--accent-2);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes float {
    0% {
        transform: translateY(0) scale(1);
    }

    100% {
        transform: translateY(30px) scale(1.1);
    }
}

.container {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 800px;
    height: fit-content;
    margin: 4rem auto;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
    position: relative;
}

.header-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
}

.header-top h1 {
    grid-column: 2;
    text-align: center;
    margin: 0;
    white-space: nowrap;
}

.top-right-actions {
    grid-column: 3;
    justify-self: end;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#customize-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: opacity 0.3s, transform 0.2s;
    opacity: 0.7;
    margin-right: 1rem;
}

#customize-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.share-btn {
    background: var(--accent-1);
    color: #ffffff;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin-left: 1rem;
}

#share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

.settings-panel {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    text-align: left;
    backdrop-filter: blur(10px);
}

.settings-panel h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.theme-selector {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
}

.theme-selector:focus {
    border-color: var(--accent-1);
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.settings-options label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.settings-options input[type="checkbox"] {
    accent-color: var(--accent-1);
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

#sortable-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.section-header-wrapper .section-title {
    margin: 0;
}

.drag-handle {
    position: absolute;
    left: 0;
    cursor: grab;
    font-size: 1.5rem;
    color: var(--text-secondary);
    padding: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    user-select: none;
}

body.edit-mode .drag-handle {
    opacity: 0.5;
    pointer-events: auto;
}

.drag-handle:hover {
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}



/* SortableJS styles */
.sortable-ghost {
    opacity: 0.4;
}

.sortable-drag {
    background: rgba(30, 41, 59, 0.9) !important;
    backdrop-filter: blur(30px) !important;
    border: 1px solid var(--accent-1) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5) !important;
    z-index: 100 !important;
    border-radius: 16px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.input-section label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-section input[type="date"],
.input-section input[type="datetime-local"] {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    font-size: 1.25rem;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
    width: 100%;
    max-width: 350px;
    color-scheme: dark;
}

.input-section input[type="date"]:focus,
.input-section input[type="datetime-local"]:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.date-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 400;
}

.exact-age-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.exact-age-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    display: flex;
    flex-wrap: wrap;
    overflow: hidden;
}

.age-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 100px;
    padding: 1.5rem;
    position: relative;
    transition: background 0.3s ease;
}

.age-segment:hover {
    background: rgba(255, 255, 255, 0.02);
}

.age-segment:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: var(--card-border);
}

.age-segment .value {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    font-variant-numeric: tabular-nums;
}

.age-segment .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.countdown-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.countdown-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.countdown-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1rem;
}

.countdown-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.countdown-segment .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-2);
    font-variant-numeric: tabular-nums;
}

.countdown-segment .label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.progress-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
    width: 0%;
    border-radius: 4px;
    transition: width 1s linear;
}



.totals-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.totals-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.total-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 500px;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--card-border);
    transition: background 0.3s ease;
}

.total-item:last-child {
    border-bottom: none;
}

.total-item:hover {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

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

.total-item .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-1);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* Birth Details Section */
.birth-details-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.birth-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.detail-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.3s ease, background 0.3s ease;
}

.detail-card:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-5px);
}

.detail-card .label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.detail-card .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-1);
}

/* Responsiveness */
@media (max-width: 600px) {
    .container {
        padding: 2rem 1.5rem;
    }

    .header-top {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .header-top h1 {
        grid-column: 1;
    }

    .top-right-actions {
        grid-column: 1;
        justify-self: center;
    }

    .age-segment .value {
        font-size: 1.75rem;
    }

    .age-segment {
        min-width: 33.33%;
        padding: 1rem;
        border-right: 1px solid var(--card-border);
        border-bottom: 1px solid var(--card-border);
    }

    .age-segment::after {
        display: none !important;
    }

    .age-segment:nth-child(3n) {
        border-right: none;
    }

    .age-segment:nth-child(n+4) {
        border-bottom: none;
    }
}

/* Precision Toggles */
body.hide-time-hours .time-hours,
body.hide-time-minutes .time-minutes,
body.hide-time-seconds .time-seconds {
    display: none !important;
}

@media (max-width: 425px) {
    .container {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .header-top h1 {
        width: fit-content;
        margin-inline: auto;
        white-space: nowrap;
    }
}