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

:root {
    --primary-dark: #0F2027;
    --primary-mid: #203A43;
    --primary-light: #2C5364;
    --water-cyan: #00D4FF;
    --water-blue: #0077B6;
    --white: #ffffff;
    --white-70: rgba(255, 255, 255, 0.7);
    --white-20: rgba(255, 255, 255, 0.2);
    --success: #4CAF50;
    --warning: #FFC107;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'Kanit', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary-mid), var(--primary-light));
    overflow: hidden;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s, transform 0.3s;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
}

/* ==================
   Login Screen
================== */
.login-screen {
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

.login-content {
    text-align: center;
    max-width: 320px;
}

.login-header {
    margin-bottom: 40px;
}

.login-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.login-header h1 {
    font-size: 2.5rem;
    color: var(--white);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--white-70);
    font-size: 1.1rem;
}

.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: 600;
    color: #333;
    background: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.google-login-btn:active {
    transform: scale(0.98);
}

.google-icon {
    width: 24px;
    height: 24px;
}

.login-note {
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--white-70);
}

.skip-login-btn {
    display: block;
    width: 100%;
    margin-top: 15px;
    padding: 14px 24px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--white-70);
    background: transparent;
    border: 1px solid var(--white-20);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.skip-login-btn:hover {
    background: var(--white-20);
    color: var(--white);
}

/* ==================
   Top Navigation
================== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    padding-top: max(15px, env(safe-area-inset-top));
}

.nav-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--white-20);
    border-radius: 12px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: background 0.2s;
}

.nav-btn:active {
    background: var(--white-70);
}

.nav-title {
    color: var(--white);
    font-size: 1.2rem;
}

.spacer {
    width: 44px;
}

.user-info {
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--water-cyan);
}

/* ==================
   Body Animation (Mask)
   ================== */
.body-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    max-height: 45%;
    position: relative;
    margin-top: 20px;
}

.body-mask-wrapper {
    position: relative;
    width: 200px;
    /* Base width */
    height: 450px;
    /* Base height */
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 200/450;

    /* The Mask */
    -webkit-mask-image: url('body_mask.png');
    mask-image: url('body_mask.png');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;

    /* Outline effect using background */
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.5);
    /* Optional: explicit border for the box if needed, or rely on outline img */
    /* Actually better: Use the outline image as a background overlay */
}

/* Background Outline Image (Optional - if we want strict outline) */
.body-outline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('body_outline.png') center/contain no-repeat;
    pointer-events: none;
    z-index: 10;
    opacity: 0.8;
}

/* The Water */
.water-fill-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Will clip */
    background: transparent;
    z-index: 1;
    display: flex;
    align-items: flex-end;
}

.water-liquid {
    width: 100%;
    height: 0%;
    /* Dynamic */
    background: linear-gradient(180deg, #00D4FF 0%, #0077B6 100%);
    position: relative;
    transition: height 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Wave Animation */
.water-liquid::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 200%;
    height: 20px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120" preserveAspectRatio="none"><path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".5" fill="%2300D4FF"/></svg>') repeat-x;
    background-size: 50% 100%;
    animation: wave 10s linear infinite;
    opacity: 0.9;
}

@keyframes wave {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* Undo Button */
.undo-btn {
    position: absolute;
    right: 20px;
    top: -50px;
    /* Position relative to Add Button or similar */
    background: rgba(255, 255, 255, 0.1);
    color: var(--white-70);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.undo-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}


/* ==================
   Progress Display
================== */
.progress-display {
    text-align: center;
    padding: 0 20px;
}

.intake-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1;
    text-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
    transition: transform 0.3s ease;
}

.intake-value.bump {
    transform: scale(1.1);
}

.intake-goal {
    font-size: 1.2rem;
    color: var(--white-70);
    margin-top: 8px;
}

.progress-bar {
    width: 100%;
    max-width: 280px;
    height: 10px;
    background: var(--white-20);
    border-radius: 5px;
    margin: 16px auto 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--water-cyan), var(--water-blue));
    border-radius: 5px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================
   Button
================== */
.button-container {
    padding: 30px 20px;
    display: flex;
    justify-content: center;
}

.add-water-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 40px;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--primary-dark);
    background: linear-gradient(180deg, var(--white), #E0F7FA);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.4);
    transition: all 0.2s ease;
}

.add-water-btn:active {
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(0, 212, 255, 0.3);
}

.water-icon {
    font-size: 1.6rem;
}

/* ==================
   Goal Status
================== */
.goal-status {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
    min-height: 40px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
}

.goal-status.visible {
    opacity: 1;
    transform: scale(1);
}

/* ==================
   Calendar Screen
================== */
.calendar-screen {
    background: linear-gradient(180deg, var(--primary-dark), var(--primary-mid));
    overflow-y: auto;
}

.calendar-container {
    padding: 20px;
}

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

.month-title {
    color: var(--white);
    font-size: 1.3rem;
    font-weight: 600;
}

.month-nav {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--white-20);
    color: var(--white);
    font-size: 1.5rem;
    border-radius: 10px;
    cursor: pointer;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    color: var(--white-70);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--white-20);
    color: var(--white);
    font-size: 0.95rem;
    position: relative;
}

.calendar-day.empty {
    background: transparent;
}

.calendar-day.today {
    border: 2px solid var(--water-cyan);
}

.calendar-day.completed {
    background: linear-gradient(135deg, var(--water-cyan), var(--water-blue));
}

.calendar-day.partial {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.3), rgba(0, 119, 182, 0.3));
}

.day-intake {
    font-size: 0.6rem;
    opacity: 0.8;
    margin-top: 2px;
}

/* ==================
   Stats
================== */
.stats-container {
    padding: 20px;
}

.stats-container h3 {
    color: var(--white);
    margin-bottom: 15px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--white-20);
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--water-cyan);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--white-70);
    margin-top: 4px;
}

/* ==================
   Confetti
================== */
#confettiCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* ==================
   Responsive
================== */
@media (max-height: 700px) {
    .body-container {
        max-height: 40%;
    }

    .intake-value {
        font-size: 3rem;
    }

    .button-container {
        padding: 20px;
    }
}

@media (min-width: 768px) {

    .main-screen,
    .calendar-screen {
        max-width: 500px;
        margin: 0 auto;
    }
}

/* ==================
   New Features Styles
   ================== */

/* Skip Login Button */
button.skip-login-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    padding: 10px 20px;
    border-radius: 20px;
    margin-top: 15px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

button.skip-login-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: white;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: #1e3c4a;
    padding: 25px;
    border-radius: 20px;
    width: 100%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-content.large-modal {
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
}

.modal h3 {
    margin-bottom: 10px;
    color: var(--water-color);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-confirm {
    background: var(--water-cyan);
    color: #000;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-danger {
    background: #ff4b4b;
    color: white;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #ff4b4b;
    color: #ff4b4b;
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    margin-top: 20px;
    cursor: pointer;
}

.input-text {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    text-align: center;
    font-size: 1.1rem;
}

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

.modal-date {
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
}

.close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 2rem;
    cursor: pointer;
}

.detail-summary {
    display: flex;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.detail-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--water-cyan);
}

.chart-container {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    height: 250px;
    position: relative;
}

.logs-list {
    max-height: 200px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.log-time {
    color: rgba(255, 255, 255, 0.7);
}

.log-amount {
    color: var(--water-cyan);
    font-weight: bold;
}

/* Calendar Status Colors */
.day.status-excellent {
    background: rgba(76, 175, 80, 0.3);
    border: 1px solid #4CAF50;
}

.day.status-good {
    background: rgba(255, 235, 59, 0.2);
    border: 1px solid #FFEB3B;
}

.day.status-warning {
    background: rgba(255, 152, 0, 0.2);
    border: 1px solid #FF9800;
}

.day.status-critical {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid #F44336;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}