@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

.witchy-container {
    font-family: 'Courier Prime', monospace;
    max-width: 800px;
    margin: 20px auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-color: #2E0854;
    /* Deep Purple fallback */
    color: #E6E6FA;
    /* Lavender */
    position: relative;
    aspect-ratio: 4/3;
    min-height: 500px;
}

.witchy-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Header */
.witchy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(to bottom, rgba(46, 8, 84, 0.8), transparent);
}

.witchy-level-badge {
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.level-text {
    font-size: 0.9em;
    color: #FFD700;
    /* Gold */
}

.xp-bar-container {
    width: 100px;
    height: 6px;
    background: #444;
    border-radius: 3px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: #9370DB;
    /* Medium Purple / Lavender */
    transition: width 0.3s ease;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: rotate(20deg);
}

/* Main Content */
.witchy-main {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Move content to top */
    padding-top: 20px;
}

.witch-area {
    position: absolute;
    bottom: 160px;
    /* Move up to clear the task list (~150px high) */
    /* Center horizontal, but maybe offset slightly */
    transform: translateX(-50%);
    left: 50%;
    z-index: 1;
    pointer-events: none;
}

#witch-sprite {
    height: 250px;
    /* Adjust based on image scale */
    width: auto;
    image-rendering: pixelated;
    transition: opacity 0.3s;
}

/* Timer Display */
.timer-display {
    z-index: 2;
    position: absolute;
    top: 20px;
    right: 40px;
    text-align: center;
    background: rgba(46, 8, 84, 0.85);
    /* Semi-transparent purple box */
    padding: 20px;
    border-radius: 100%;
    /* Circle? Or just rounded box? Design used circle */
    width: 180px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px solid #FFD700;
}

#timer-text {
    font-size: 2.5em;
    font-weight: bold;
    color: #FFF;
    text-shadow: 0 0 10px #9370DB;
}

.phase-label {
    font-size: 0.9em;
    color: #50C878;
    /* Emerald */
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timer-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.witchy-btn {
    font-family: 'Courier Prime', monospace;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    text-transform: uppercase;
}

.witchy-btn.primary {
    background-color: #50C878;
    color: #2E0854;
}

.witchy-btn.primary:hover {
    background-color: #40A868;
    transform: scale(1.05);
}

.witchy-btn.secondary {
    background-color: transparent;
    border: 1px solid #E6E6FA;
    color: #E6E6FA;
}

.witchy-btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Task List */
.witchy-tasks {
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    margin: 10px;
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 3;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.task-header h3 {
    margin: 0;
    font-size: 1em;
    color: #FFD700;
}

.small-btn {
    background: #50C878;
    border: none;
    color: #2E0854;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-weight: bold;
}

#task-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0;
    margin: 0;
}

#task-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 10px;
    border-radius: 4px;
}

#task-list li.completed span {
    text-decoration: line-through;
    opacity: 0.5;
}

.delete-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #FF5555;
    cursor: pointer;
}

/* Modal */
.witchy-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.witchy-modal.hidden {
    display: none;
}

.modal-content {
    background: #2E0854;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #FFD700;
    width: 80%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-content label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
}

.modal-content input[type="number"] {
    width: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #777;
    color: white;
    padding: 4px;
    border-radius: 4px;
}

.modal-actions {
    margin-top: 10px;
    text-align: center;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: #50C878;
}

input:focus+.slider {
    box-shadow: 0 0 1px #50C878;
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Task Input Modal */
.task-text-input {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #777;
    color: white;
    border-radius: 4px;
    font-family: 'Courier Prime', monospace;
    font-size: 1em;
    box-sizing: border-box;
}

.task-text-input:focus {
    outline: none;
    border-color: #FFD700;
    box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

.task-text-input::placeholder {
    color: #888;
}

.task-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Toast Notification */
.witchy-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: linear-gradient(135deg, #4B0082, #2E0854);
    color: #FFD700;
    padding: 20px 30px;
    border-radius: 12px;
    border: 2px solid #FFD700;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.witchy-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Mobile Responsiveness */

/* Tablet and small desktop */
@media (max-width: 800px) {
    .witchy-container {
        margin: 10px;
        border-radius: 8px;
    }
}

/* Mobile devices */
@media (max-width: 600px) {
    .witchy-container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        min-height: 100dvh; /* Dynamic viewport height for mobile browsers */
        aspect-ratio: auto;
    }

    .witchy-bg {
        min-height: 100vh;
        min-height: 100dvh;
    }

    .witchy-main {
        min-height: 400px;
    }

    .witchy-header {
        padding: 10px 15px;
    }

    .witchy-level-badge {
        padding: 4px 8px;
    }

    .level-text {
        font-size: 0.8em;
    }

    .xp-bar-container {
        width: 80px;
        height: 5px;
    }

    .icon-btn {
        font-size: 1.3em;
        padding: 5px;
    }

    .timer-display {
        width: 120px;
        height: 120px;
        padding: 10px;
        right: 10px;
        top: 10px;
    }

    #timer-text {
        font-size: 1.6em;
    }

    .phase-label {
        font-size: 0.7em;
        letter-spacing: 0.5px;
    }

    .timer-controls {
        gap: 5px;
        margin-top: 8px;
    }

    .witchy-btn {
        padding: 6px 10px;
        font-size: 0.75em;
        /* Ensure touch-friendly minimum size */
        min-height: 32px;
        min-width: 44px;
    }

    .witch-area {
        bottom: 140px;
    }

    #witch-sprite {
        height: 180px;
    }

    .witchy-tasks {
        padding: 10px;
        margin: 8px;
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-height: 130px;
    }

    .task-header {
        padding-bottom: 4px;
        margin-bottom: 8px;
    }

    .task-header h3 {
        font-size: 0.9em;
    }

    .small-btn {
        width: 28px;
        height: 28px;
        font-size: 1.1em;
    }

    #task-list li {
        padding: 6px 8px;
        gap: 8px;
        font-size: 0.9em;
    }

    .delete-btn {
        font-size: 1.2em;
        padding: 4px 8px;
    }

    .modal-content {
        width: 90%;
        max-width: none;
        padding: 15px;
    }

    .modal-content h3 {
        font-size: 1.1em;
        margin-bottom: 5px;
    }

    .modal-content label {
        font-size: 0.85em;
    }

    .witchy-toast {
        width: 85%;
        padding: 15px 20px;
        font-size: 1em;
    }

    .task-text-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

/* Very small screens (iPhone SE, older devices) */
@media (max-width: 380px) {
    .witchy-header {
        padding: 8px 10px;
    }

    .timer-display {
        width: 100px;
        height: 100px;
        padding: 8px;
        right: 8px;
        top: 8px;
    }

    #timer-text {
        font-size: 1.4em;
    }

    .phase-label {
        font-size: 0.65em;
    }

    .timer-controls {
        gap: 4px;
    }

    .witchy-btn {
        padding: 5px 8px;
        font-size: 0.7em;
    }

    .witch-area {
        bottom: 130px;
    }

    #witch-sprite {
        height: 150px;
    }

    .witchy-tasks {
        max-height: 110px;
        padding: 8px;
    }

    #task-list li {
        font-size: 0.85em;
        padding: 5px 6px;
    }

    .witchy-toast {
        font-size: 0.9em;
        padding: 12px 15px;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .witchy-container {
        min-height: 100vh;
        aspect-ratio: auto;
    }

    .witchy-bg {
        min-height: 100vh;
    }

    .witchy-main {
        min-height: 300px;
    }

    .timer-display {
        width: 100px;
        height: 100px;
        top: 5px;
        right: 10px;
    }

    #timer-text {
        font-size: 1.3em;
    }

    .phase-label {
        font-size: 0.6em;
        margin-top: 2px;
    }

    .timer-controls {
        margin-top: 5px;
    }

    .witch-area {
        bottom: 80px;
        left: 30%;
    }

    #witch-sprite {
        height: 120px;
    }

    .witchy-tasks {
        max-height: 80px;
        bottom: 5px;
        left: 5px;
        right: 5px;
    }

    .witchy-header {
        padding: 5px 10px;
    }
}

/* Touch device enhancements */
@media (hover: none) and (pointer: coarse) {
    .witchy-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .small-btn {
        width: 36px;
        height: 36px;
    }

    .delete-btn {
        padding: 8px 12px;
    }

    .icon-btn {
        padding: 8px;
    }

    /* Disable hover effects on touch */
    .witchy-btn.primary:hover {
        transform: none;
    }

    .icon-btn:hover {
        transform: none;
    }

    /* Add active states instead */
    .witchy-btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }

    .icon-btn:active {
        transform: rotate(20deg);
    }
}
