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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 50%, #a5d6a7 100%);
    min-height: 100vh;
    overflow: hidden;
}

.header {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #2e7d32;
    font-size: 2em;
    margin-bottom: 10px;
}

.countdown-display {
    margin: 15px 0;
    padding: 15px 30px;
    background: linear-gradient(135deg, #2e7d32 0%, #43a047 100%);
    border-radius: 15px;
    display: inline-block;
}

#countdown-timer {
    font-size: 1.8em;
    font-weight: 700;
    color: white;
    text-align: center;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.info {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    font-size: 0.95em;
    color: #666;
}

.info > div {
    padding: 5px 15px;
    background: rgba(46, 125, 50, 0.1);
    border-radius: 20px;
}

.canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#baby-canvas {
    width: 100%;
    height: 100%;
    pointer-events: auto;
    cursor: pointer;
}

.controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
    min-width: 400px;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slider-container label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #2e7d32;
}

#timeline-slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #a5d6a7;
    outline: none;
    -webkit-appearance: none;
}

#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2e7d32;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#timeline-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2e7d32;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#reset-button {
    padding: 10px 20px;
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

#reset-button:hover {
    background: #1b5e20;
}

.milestone-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
    width: 300px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.milestone-panel h2 {
    color: #2e7d32;
    font-size: 1.3em;
    margin-bottom: 15px;
    text-align: center;
    flex-shrink: 0;
}

#debug-info {
    flex-shrink: 0;
}

#milestones-container {
    overflow-y: scroll;
    flex: 1;
    min-height: 0;
    padding-right: 5px;
}

/* Force scrollbar to always be visible */
#milestones-container::-webkit-scrollbar {
    width: 16px;
    background: #e8f5e9;
}

#milestones-container::-webkit-scrollbar-track {
    background: #c8e6c9;
    border-left: 1px solid #a5d6a7;
}

#milestones-container::-webkit-scrollbar-thumb {
    background: #43a047;
    border: 3px solid #c8e6c9;
    border-radius: 8px;
}

#milestones-container::-webkit-scrollbar-thumb:hover {
    background: #2e7d32;
}

/* Firefox */
#milestones-container {
    scrollbar-width: auto;
    scrollbar-color: #43a047 #c8e6c9;
}

.milestone {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(46, 125, 50, 0.05);
    transition: background 0.3s;
}

.milestone.completed {
    background: rgba(46, 125, 50, 0.15);
}

.milestone-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #2e7d32;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.milestone.completed .milestone-checkbox {
    background: #2e7d32;
}

.milestone.completed .milestone-checkbox::after {
    content: '✓';
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.milestone-text {
    flex: 1;
    font-size: 0.9em;
    line-height: 1.4;
}

.milestone.completed .milestone-text {
    color: #666;
}

.milestone-week {
    font-size: 0.75em;
    color: #888;
    font-weight: 600;
    margin-bottom: 3px;
}

.instructions {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9em;
    color: #666;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Narrow screens (portrait orientation or narrow windows) */
@media (max-width: 900px), (max-aspect-ratio: 1/1) {
    .milestone-panel {
        position: fixed;
        right: auto;
        left: 50%;
        top: auto;
        bottom: 100px;
        transform: translateX(-50%);
        width: calc(100% - 40px);
        max-width: 600px;
        max-height: 35vh;
        padding: 15px;
        border-radius: 15px;
    }

    .milestone-panel h2 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    .milestone {
        padding: 8px;
        margin-bottom: 6px;
    }

    .milestone-text {
        font-size: 0.85em;
    }

    .controls {
        bottom: 10px;
        min-width: calc(100% - 40px);
        max-width: 600px;
        padding: 15px 20px;
    }
}

/* Tablet size adjustments */
@media (max-width: 1024px) and (min-aspect-ratio: 1/1) {
    .milestone-panel {
        width: 280px;
        padding: 15px;
    }

    .milestone-panel h2 {
        font-size: 1.1em;
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .header {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.4em;
        margin-bottom: 8px;
    }

    #countdown-timer {
        font-size: 1.2em;
    }

    .countdown-display {
        padding: 8px 16px;
        margin: 10px 0;
    }

    .info {
        font-size: 0.8em;
        gap: 8px;
    }

    .info > div {
        padding: 4px 12px;
    }

    .milestone-panel {
        bottom: 80px;
        max-height: 25vh;
        width: calc(100% - 30px);
        padding: 10px;
    }

    .milestone-panel h2 {
        font-size: 0.95em;
        margin-bottom: 8px;
    }

    #debug-info {
        font-size: 0.65em !important;
        padding: 4px !important;
        margin-bottom: 6px !important;
    }

    .controls {
        bottom: 8px;
        padding: 10px 12px;
        min-width: calc(100% - 30px);
    }

    .slider-container {
        gap: 6px;
    }

    .slider-container label {
        font-size: 0.9em;
    }

    #reset-button {
        padding: 8px 16px;
        font-size: 0.9em;
    }
}

/* Controls buttons row */
.controls-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#calibrate-button {
    padding: 10px 20px;
    background: #fff;
    color: #2e7d32;
    border: 2px solid #2e7d32;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

#calibrate-button:hover {
    background: #e8f5e9;
}

#calibrate-button.calibrated {
    background: #e8f5e9;
    border-color: #43a047;
}

#calibrate-button.calibrated #calibration-status::before {
    content: '✓ ';
}

/* Calibration Modal */
.calibration-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.calibration-modal.active {
    display: flex;
}

.calibration-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    max-width: 90%;
    width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.calibration-content h2 {
    color: #2e7d32;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.calibration-content p {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.calibration-visual {
    margin: 30px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.calibration-bar {
    height: 54px;
    background: linear-gradient(135deg, #2e7d32 0%, #43a047 100%);
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.3);
    transition: width 0.1s ease-out;
}

.calibration-label {
    font-size: 0.85em;
    color: #888;
}

.calibration-slider-container {
    margin: 25px 0;
}

.calibration-slider-container input[type="range"] {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: #e8f5e9;
    outline: none;
    -webkit-appearance: none;
}

.calibration-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2e7d32;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.calibration-slider-container input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2e7d32;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

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

.calibration-btn {
    padding: 12px 30px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1em;
}

.calibration-btn.primary {
    background: #2e7d32;
    color: white;
    border: none;
}

.calibration-btn.primary:hover {
    background: #1b5e20;
}

.calibration-btn.secondary {
    background: white;
    color: #666;
    border: 2px solid #ddd;
}

.calibration-btn.secondary:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

/* Mobile adjustments for calibration */
@media (max-width: 600px) {
    .controls-buttons {
        flex-direction: column;
        gap: 8px;
    }

    #calibrate-button {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    .calibration-content {
        padding: 20px;
        margin: 15px;
    }

    .calibration-content h2 {
        font-size: 1.2em;
    }

    .calibration-content p {
        font-size: 0.9em;
    }

    .calibration-bar {
        height: 45px;
    }

    .calibration-btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }
}
