* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
}

body {
    background-color: #f0f8ff;
    padding: 20px;
    padding-bottom: 80px; /* Increased space for the footer */
    touch-action: pan-x pan-y; /* Allow scrolling but prevent zooming */
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #4b0082;
    text-align: center;
    margin-bottom: 30px;
    font-size: 3rem;
}

h2, h3 {
    color: #4b0082;
    margin: 15px 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-bottom: 30px;
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
}

.control-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.day-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 10px 0;
    flex-wrap: wrap;
}

.day-btn {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    border: 2px solid #7b68ee;
    background-color: white;
    color: #4b0082;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    margin: 4px;
    touch-action: manipulation; /* Prevent double-tap zoom */
}

.day-emoji {
    font-size: 24px;
    margin-bottom: 4px;
}

.day-name {
    font-size: 14px;
}

.day-btn:hover {
    background-color: #e6e6fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.day-btn.active {
    background-color: #7b68ee;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.number-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="number"] {
    width: 80px;
    text-align: center;
    -moz-appearance: textfield;
    padding: 8px;
    font-size: 20px;
    border: 2px solid #7b68ee;
    border-radius: 5px;
    background-color: white;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.adjust-btn {
    width: 40px;
    height: 40px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #7b68ee;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s;
    touch-action: manipulation; /* Prevent double-tap zoom */
    padding: 0;
    line-height: 1;
}

.adjust-btn:hover {
    background-color: #6a5acd;
}

.footer-config {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 8px 5px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.ai-credit {
    font-size: 12px;
    color: #666;
    text-align: center;
    padding: 0 5px;
}

.ai-credit a {
    color: #7b68ee;
    text-decoration: none;
    transition: color 0.3s;
}

.ai-credit a:hover {
    color: #6a5acd;
    text-decoration: underline;
}

.config-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.config-label {
    font-size: 14px;
    font-weight: bold;
    color: #4b0082;
}

.toggle-container {
    display: flex;
    border-radius: 5px;
    overflow: hidden;
    border: 2px solid #7b68ee;
}

.toggle-btn {
    padding: 5px 8px;
    background-color: white;
    color: #4b0082;
    border: none;
    border-radius: 0;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation; /* Prevent double-tap zoom */
}

.toggle-btn:hover {
    background-color: #e6e6fa;
}

.toggle-btn.active {
    background-color: #7b68ee;
    color: white;
}

button {
    padding: 10px 20px;
    background-color: #7b68ee;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 18px;
    cursor: pointer;
    align-self: center;
    transition: background-color 0.3s;
    touch-action: manipulation; /* Prevent double-tap zoom */
}

button:hover {
    background-color: #6a5acd;
}

.result-container {
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    font-size: 2rem;
}

.start-day-icon, .target-day-icon {
    font-size: 2.5rem;
}

.result-text {
    font-size: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    border-left: 5px solid #7b68ee;
}

.weeks-visualization {
    margin-top: 20px;
}

.week-row {
    display: flex;
    margin-bottom: 15px;
    align-items: center;
}

.week-label {
    width: 40px;
    font-weight: bold;
    color: #4b0082;
    margin-right: 15px;
    text-align: center;
}

.day {
    flex: 1;
    text-align: center;
    padding: 10px 5px;
    margin: 0 4px;
    border-radius: 8px;
    font-weight: bold;
    background-color: #e6e6fa;
}

.day.current {
    background-color: #ffd700;
}

.day.in-range {
    background-color: #b19cd9;
}

.day.target {
    background-color: #ff69b4;
    color: white;
}

.day-label {
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 5px;
}

.day-number {
    font-size: 18px;
}

@media (max-width: 600px) {
    body {
        padding: 15px 10px;
    }

    .control-group {
        flex-direction: column;
        align-items: center;
    }

    .controls {
        padding: 15px 10px;
        gap: 15px;
        margin-bottom: 20px;
    }

    .day-selector {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        margin: 5px 0;
    }

    .day-btn {
        width: 45px;
        height: 45px;
        margin: 2px;
        padding: 2px;
        border-width: 1px;
    }

    .day-emoji {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .day-name {
        font-size: 10px;
    }

    .container {
        padding: 15px 10px;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }

    .result-container {
        padding: 12px 5px;
        border-radius: 8px;
    }

    .result-icon {
        margin-bottom: 20px;
        gap: 15px;
    }

    .config-option {
        flex-direction: row;
        gap: 5px;
    }

    .ai-credit {
        font-size: 10px;
        width: 100%;
        order: 2;
        margin-top: 5px;
    }

    .week-row {
        flex-wrap: nowrap;
        margin-bottom: 8px;
    }

    .week-label {
        width: 20px;
        margin-right: 5px;
        font-size: 12px;
    }

    .day {
        padding: 5px 2px;
        margin: 0 1px;
        min-width: 0;
    }

    .day-label {
        font-size: 10px;
        gap: 0;
        margin-bottom: 2px;
    }

    .day-label span {
        display: none;
    }

    .day-number {
        font-size: 12px;
    }

    .number-input-group {
        gap: 8px;
    }

    input[type="number"] {
        width: 60px;
        font-size: 18px;
        padding: 6px;
    }

    .adjust-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        line-height: 1;
    }

    h1 {
        margin-bottom: 20px;
        font-size: 2.5rem;
    }
}

/* iPhone-specific adjustments */
@media (max-width: 414px) {
    body {
        padding: 10px 5px;
        padding-bottom: 90px; /* Increase padding to accommodate the footer */
    }

    .container {
        padding: 12px 8px;
    }

    .controls {
        padding: 12px 8px;
        gap: 12px;
        margin-bottom: 15px;
    }

    .result-container {
        padding: 10px 5px;
    }

    .result-icon {
        margin-bottom: 15px;
        gap: 10px;
        font-size: 1.8rem;
    }

    .start-day-icon, .target-day-icon {
        font-size: 2rem;
    }

    .day-btn {
        width: 40px;
        height: 40px;
    }

    .day-emoji {
        font-size: 16px;
        margin-bottom: 1px;
    }

    .day-name {
        font-size: 9px;
    }

    .footer-config {
        padding: 6px 4px;
    }

    .config-label {
        font-size: 12px;
    }

    .toggle-btn {
        padding: 4px 6px;
        font-size: 11px;
    }

    .ai-credit {
        font-size: 9px;
    }

    .week-label {
        width: 16px;
        margin-right: 3px;
        font-size: 10px;
    }

    .day {
        padding: 3px 1px;
        border-radius: 4px;
    }

    .day-label {
        font-size: 8px;
    }

    .day-number {
        font-size: 10px;
    }

    .number-input-group {
        gap: 6px;
    }

    input[type="number"] {
        width: 50px;
        font-size: 16px;
        padding: 5px;
    }

    .adjust-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
        padding: 0;
        line-height: 1;
    }

    h1 {
        margin-bottom: 15px;
        font-size: 2.2rem;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    body {
        padding: 8px 4px;
        padding-bottom: 100px;
    }

    .container {
        padding: 10px 5px;
    }

    .controls {
        padding: 10px 5px;
        gap: 10px;
        margin-bottom: 12px;
    }

    .result-container {
        padding: 8px 4px;
    }

    .day-btn {
        width: 36px;
        height: 36px;
        margin: 1px;
    }

    .day-emoji {
        font-size: 14px;
    }

    .day-name {
        font-size: 8px;
    }

    .footer-config {
        padding: 5px 2px;
    }

    .config-option {
        gap: 3px;
    }

    .config-label {
        font-size: 11px;
    }

    .toggle-btn {
        padding: 3px 5px;
        font-size: 10px;
    }

    .week-label {
        width: 12px;
        margin-right: 2px;
    }

    .day-label {
        font-size: 7px;
    }

    h1 {
        margin-bottom: 12px;
        font-size: 2rem;
    }

    .adjust-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
        padding: 0;
        line-height: 1;
    }
}
