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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #F2F1E8 0%, #E8E1D5 100%);
    overflow: hidden;
    padding: 20px;
}

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #F2F1E8 0%, #E8E1D5 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-screen img {
    max-width: 300px;
    max-height: 300px;
    width: 80%;
    height: auto;
    object-fit: contain;
    animation: fadeIn 0.5s ease-in;
}

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

.timer-container {
    position: relative;
    width: 300px;
    height: 300px;
}

.timer-circle {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.time-display {
    font-size: 56px;
    font-weight: bold;
    color: #5B8266;
    z-index: 10;
}

.notches-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.notch {
    position: absolute;
    width: 4px;
    height: 20px;
    background: #A3C585;
    top: 0;
    left: 50%;
    transform-origin: 50% 150px;
    border-radius: 2px;
    transition: opacity 0.3s ease;
}

.notch.hidden {
    opacity: 0;
}

.controls {
    position: absolute;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
}

button {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 25px;
    background: #5B8266;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

button:hover {
    background: #AED9E0;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

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

.input-container {
    width: 100%;
}

.slider-group {
    margin-bottom: 20px;
}

.slider-group label {
    display: block;
    color: #4A5759;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.slider-group label span {
    float: right;
    color: #5B8266;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #E8E5DC;
    outline: none;
    -webkit-appearance: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5B8266;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #AED9E0;
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5B8266;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #AED9E0;
    transform: scale(1.1);
}

.timer-info {
    position: absolute;
    top: -320px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-weight: 700;
    font-size: 20px;
    text-align: center;
    background: #5B8266;
    padding: 10px 24px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.5px;
    min-width: 120px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

#timerIcon {
    width: 300px;
    height: 300px;
    object-fit: contain;
    display: block;
}

#timerLabel {
    display: inline-block;
}

/* Modal backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.modal-backdrop.show {
    display: block;
    opacity: 1;
}

/* Modal dialog */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.modal.show {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #E8E5DC;
}

.modal-header h2 {
    font-size: 24px;
    color: #4A5759;
    margin: 0;
}

/* Modal close button */
.modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    color: #5B8266;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: none;
}

.modal-close:hover {
    background: #AED9E0;
    color: white;
}

/* Modal content */
.modal-content {
    padding: 0;
}

@media (max-width: 480px) {
    body {
        overflow: auto;
        padding: 10px;
        min-height: 100vh;
        align-items: center;
        padding-top: 20px;
        padding-bottom: 60px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 0;
    }

    .splash-screen img {
        max-width: 250px;
        max-height: 250px;
        width: 70%;
    }

    .timer-container {
        width: min(280px, calc(100vw - 60px));
        height: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        position: relative;
    }

    .timer-circle {
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
        width: min(280px, calc(100vw - 60px));
        height: min(280px, calc(100vw - 60px));
        position: relative;
        order: 2;
    }

    .notch {
        transform-origin: 50% calc(min(280px, calc(100vw - 60px)) / 2);
        height: 16px;
    }

    .time-display {
        font-size: clamp(42px, 12vw, 52px);
    }

    .controls {
        position: relative;
        bottom: auto;
        gap: 8px;
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        order: 3;
    }

    button {
        padding: 10px 16px;
        font-size: 14px;
        border-radius: 20px;
        flex: 0 1 auto;
        min-width: 80px;
    }

    .timer-info {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        transform: none;
        font-size: 16px;
        padding: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        min-width: min(280px, calc(100vw - 60px));
        width: min(280px, calc(100vw - 60px));
        height: min(280px, calc(100vw - 60px));
        min-height: min(280px, calc(100vw - 60px));
        z-index: 5;
        order: 1;
        align-items: center;
        justify-content: center;
    }

    #timerIcon {
        width: 100%;
        height: 100%;
        max-width: min(280px, calc(100vw - 60px));
        max-height: min(280px, calc(100vw - 60px));
        object-fit: contain;
    }

    .modal {
        width: 95%;
        padding: 20px;
        max-height: 85vh;
    }

    .modal-header {
        margin-bottom: 15px;
        padding-bottom: 12px;
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .modal-close {
        font-size: 28px;
        width: 36px;
        height: 36px;
    }

    .slider-group {
        margin-bottom: 16px;
    }

    .slider-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }
}

/* iPhone Pro specific (14 Pro, 15 Pro: 393px, Pro Max: 430px) */
@media (max-width: 430px) and (min-width: 375px) {
    body {
        padding-top: 20px;
        padding-bottom: 60px;
    }

    .timer-container {
        width: min(300px, calc(100vw - 80px));
        gap: 20px;
    }

    .timer-circle {
        width: min(300px, calc(100vw - 80px));
        height: min(300px, calc(100vw - 80px));
    }

    .notch {
        transform-origin: 50% calc(min(300px, calc(100vw - 80px)) / 2);
    }

    .time-display {
        font-size: clamp(48px, 13vw, 56px);
    }

    .timer-info {
        width: min(300px, calc(100vw - 80px));
        height: min(300px, calc(100vw - 80px));
        min-height: min(300px, calc(100vw - 80px));
    }

    #timerIcon {
        max-width: min(300px, calc(100vw - 80px));
        max-height: min(300px, calc(100vw - 80px));
    }

    .controls {
        width: min(300px, calc(100vw - 80px));
    }

    button {
        padding: 10px 16px;
        font-size: 13px;
        min-width: 80px;
    }
}

/* Safe area insets for iPhone with notch */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: max(60px, env(safe-area-inset-top));
        padding-bottom: max(100px, env(safe-area-inset-bottom));
    }
}
