/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* Waiting Screen */
.waiting-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.waiting-content {
    text-align: center;
    color: white;
    padding: 40px;
}

.clock-icon {
    font-size: 6em;
    margin-bottom: 20px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.waiting-content h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    font-weight: 700;
}

.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.2em;
    margin-bottom: 10px;
    opacity: 0.9;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #fbbf24;
    display: inline-block;
    animation: blink 1.5s ease-in-out infinite;
}

.status-dot.connected {
    background-color: #22c55e;
    animation: none;
}

.status-dot.disconnected {
    background-color: #ef4444;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.enable-sound-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.enable-sound-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.enable-sound-btn.enabled {
    background: #22c55e;
    color: white;
}

.enable-sound-btn.hidden {
    display: none;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.8;
}

/* Alert Overlay */
.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.alert-overlay.hidden {
    display: none;
}

.alert-content {
    text-align: center;
    padding: 40px;
    width: 100%;
    max-width: 900px;
}

.alert-title {
    font-size: 4em;
    color: white;
    margin-bottom: 20px;
    font-weight: 900;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.alert-question {
    font-size: 2.5em;
    color: white;
    margin-bottom: 50px;
    font-weight: 700;
    opacity: 0.95;
}

/* Button Grid */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.response-button {
    background: white;
    border: none;
    border-radius: 20px;
    padding: 50px 30px;
    font-size: 1.5em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.response-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.response-button:active {
    transform: translateY(-2px);
}

.response-button .emoji {
    font-size: 3em;
}

.response-button.deep-work {
    border-left: 10px solid #22c55e;
    color: #22c55e;
}

.response-button.deep-work:hover {
    background: #f0fdf4;
}

.response-button.shallow-work {
    border-left: 10px solid #eab308;
    color: #ca8a04;
}

.response-button.shallow-work:hover {
    background: #fefce8;
}

.response-button.time-wasted {
    border-left: 10px solid #ef4444;
    color: #dc2626;
}

.response-button.time-wasted:hover {
    background: #fef2f2;
}

/* Success Message */
.success-message {
    font-size: 3em;
    color: white;
    font-weight: 900;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.success-message.hidden {
    display: none;
}

.checkmark {
    color: #22c55e;
    font-size: 1.2em;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .waiting-content h1 {
        font-size: 2em;
    }

    .clock-icon {
        font-size: 4em;
    }

    .alert-title {
        font-size: 2.5em;
    }

    .alert-question {
        font-size: 1.8em;
        margin-bottom: 30px;
    }

    .button-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .response-button {
        padding: 40px 20px;
        font-size: 1.3em;
    }

    .response-button .emoji {
        font-size: 2.5em;
    }

    .success-message {
        font-size: 2em;
    }
}

/* Ensure full screen on mobile browsers */
@media (max-width: 768px) {
    body {
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* Compact shared to-do list on the alert waiting screen */
.waiting-screen {
    flex-direction: column;
    overflow-y: auto;
    padding: 30px 20px;
}

.waiting-content {
    padding: 20px 40px;
}

.alert-todo-panel {
    width: min(700px, 100%);
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    padding: 18px;
    color: #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.alert-todo-panel h2 {
    margin-bottom: 12px;
    font-size: 1.25rem;
}

.alert-todo-form {
    display: flex;
    gap: 8px;
}

.alert-todo-priority,
.alert-task-priority {
    min-height: 44px;
    padding: 7px 9px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    background: white;
    color: #374151;
    font: inherit;
    font-weight: 600;
}

.alert-todo-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font: inherit;
}

.alert-todo-input:focus {
    outline: 2px solid rgba(102, 126, 234, 0.25);
    border-color: #667eea;
}

.alert-todo-add,
.alert-todo-action {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.alert-todo-add {
    padding: 10px 16px;
    background: #667eea;
    color: white;
}

.alert-todo-message {
    min-height: 18px;
    margin: 7px 0;
    color: #666;
    font-size: 0.85rem;
}

.alert-todo-message.error {
    color: #dc2626;
}

.alert-todo-list {
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
}

.alert-todo-item {
    --task-accent: #94a3b8;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    margin-bottom: 6px;
    border: 1px solid #e5e7eb;
    border-left: 5px solid var(--task-accent);
    border-radius: 8px;
    background: #f3f4f6;
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.alert-todo-item.priority-high { --task-accent: #ef4444; }
.alert-todo-item.priority-medium { --task-accent: #eab308; }
.alert-todo-item.priority-low { --task-accent: #60a5fa; }
.alert-todo-item:focus-within { background: white; border-color: var(--task-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--task-accent) 22%, transparent); }

@media (hover: hover) {
    .alert-todo-item:hover {
        background: white;
        border-color: var(--task-accent);
        box-shadow: 0 9px 24px color-mix(in srgb, var(--task-accent) 24%, transparent);
        transform: translateY(-2px);
    }
}

.alert-todo-item.task-arrived { animation: task-arrival-glow 0.8s ease-out; }

@keyframes task-arrival-glow {
    0% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--task-accent) 32%, transparent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.alert-todo-completed-divider {
    margin: 14px 0 7px;
    padding: 7px 4px;
    border-top: 1px solid #d1d5db;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.alert-todo-checkbox {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    accent-color: #667eea;
}

.alert-todo-text {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.alert-todo-item.completed .alert-todo-text {
    color: #888;
    text-decoration: line-through;
}

.alert-todo-actions {
    display: flex;
    gap: 6px;
}

.alert-todo-action {
    padding: 6px 8px;
    background: #e5e7eb;
    color: #374151;
}

.alert-todo-action.delete {
    background: #fee2e2;
    color: #b91c1c;
}

.alert-todo-action:active,
.alert-todo-add:active {
    transform: scale(0.97);
}

.alert-todo-empty {
    padding: 10px;
    color: #666;
    text-align: center;
}

@media (max-width: 600px) {
    .waiting-screen {
        justify-content: flex-start;
        padding: 16px 12px;
    }

    .waiting-content {
        padding: 12px;
    }

    .alert-todo-panel {
        padding: 14px;
    }

    .alert-todo-form {
        flex-direction: column;
    }

    .alert-todo-add {
        width: 100%;
    }

    .alert-todo-priority {
        width: 100%;
    }

    .alert-todo-item {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .alert-todo-text {
        flex-basis: calc(100% - 27px);
    }

    .alert-todo-actions {
        width: 100%;
        padding-left: 27px;
    }
}

/* Fast, accessible alert runtime feedback */
.alert-runtime {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 14px 0;
}

.runtime-chip {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: white;
    font-size: 0.85rem;
}

.runtime-chip.warning { background: #fef3c7; color: #92400e; }
.runtime-chip.success { background: #dcfce7; color: #166534; }

.volume-control {
    display: grid;
    grid-template-columns: auto minmax(120px, 220px) auto;
    justify-content: center;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 0.9rem;
    margin: 12px 0;
}

.volume-control input { accent-color: white; }

.response-save-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    margin: 10px auto;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.94);
    color: #374151;
    max-width: 520px;
}

.response-save-status.success { color: #166534; }
.response-save-status.error { color: #b91c1c; }
.response-save-status.hidden, .retry-response-btn.hidden { display: none; }

.retry-response-btn {
    min-height: 40px;
    padding: 8px 14px;
    border: 0;
    border-radius: 8px;
    background: #b91c1c;
    color: white;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.response-button,
.enable-sound-btn,
.alert-todo-add,
.alert-todo-action,
.retry-response-btn {
    min-height: 44px;
}

.response-button:focus-visible,
.enable-sound-btn:focus-visible,
.alert-todo-input:focus-visible,
.alert-todo-priority:focus-visible,
.alert-task-priority:focus-visible,
.alert-todo-add:focus-visible,
.alert-todo-action:focus-visible,
.retry-response-btn:focus-visible,
#alarm-volume:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 3px;
}

.response-button.is-pressed {
    transform: scale(0.97);
    filter: brightness(0.96);
}

.response-button:disabled { cursor: not-allowed; opacity: 0.65; }

.response-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 10020;
    width: min(680px, calc(100% - 40px));
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 18px;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 22px;
    color: #172033;
    background: #eff6ff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
    overflow: hidden;
    transform: translate(-50%, -50%);
}

.response-feedback.hidden { display: none; }
.response-feedback-deep_work { background: #dcfce7; border-color: #86efac; }
.response-feedback-shallow_work { background: #fef3c7; border-color: #fcd34d; }
.response-feedback-time_wasted { background: #dbeafe; border-color: #93c5fd; }
.response-feedback-task_completed {
    top: auto;
    right: 18px;
    bottom: 18px;
    left: auto;
    width: min(380px, calc(100% - 36px));
    gap: 10px;
    padding: 16px;
    border-radius: 14px;
    transform: none;
}
.response-feedback-task_completed .response-feedback-icon { font-size: 2rem; }
.response-feedback-task_completed .response-feedback-copy strong { margin-bottom: 3px; font-size: 1.05rem; }
.response-feedback-task_completed .response-feedback-copy p { font-size: 0.9rem; line-height: 1.4; }
.response-feedback-icon { font-size: 3.5rem; line-height: 1; }
.response-feedback-copy strong { display: block; margin-bottom: 8px; font-size: 1.55rem; }
.response-feedback-copy p { margin: 0; color: #334155; font-size: 1.15rem; line-height: 1.55; }

.response-feedback-close {
    min-width: 44px;
    min-height: 44px;
    margin: -10px -10px 0 0;
    border: 0;
    border-radius: 10px;
    color: #334155;
    background: transparent;
    font: inherit;
    font-size: 1.5rem;
    cursor: pointer;
}

.response-feedback-close:hover { background: rgba(255, 255, 255, 0.65); }
.response-feedback-close:focus-visible { outline: 3px solid #4f46e5; outline-offset: 2px; }
.response-feedback-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.response-confetti-piece {
    --confetti-x: 50%;
    --confetti-delay: 0ms;
    --confetti-color: #22c55e;
    position: absolute;
    top: -12px;
    left: var(--confetti-x);
    width: 8px;
    height: 14px;
    border-radius: 2px;
    background: var(--confetti-color);
    animation: response-confetti-fall 1.3s var(--confetti-delay) ease-in forwards;
}

@keyframes response-confetti-fall {
    to { transform: translate3d(18px, 150px, 0) rotate(540deg); opacity: 0; }
}

@media (max-width: 600px) {
    .alert-runtime { gap: 6px; }
    .runtime-chip { font-size: 0.78rem; }
    .volume-control { grid-template-columns: 1fr auto; }
    .volume-control input { grid-column: 1 / -1; width: 100%; }
    .response-feedback { width: calc(100% - 24px); gap: 12px; padding: 24px 18px; }
    .response-feedback-icon { font-size: 2.75rem; }
    .response-feedback-copy strong { font-size: 1.3rem; }
    .response-feedback-copy p { font-size: 1rem; }
    .response-feedback-task_completed {
        top: auto;
        right: 12px;
        bottom: 12px;
        left: auto;
        width: calc(100% - 24px);
        gap: 9px;
        padding: 14px;
        transform: none;
    }
    .response-feedback-task_completed .response-feedback-icon { font-size: 1.8rem; }
    .response-feedback-task_completed .response-feedback-copy strong { font-size: 1rem; }
    .response-feedback-task_completed .response-feedback-copy p { font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.interval-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px auto;
    color: white;
}

.interval-control select,
.interval-control input,
.interval-control button {
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    font: inherit;
}

.interval-control button {
    background: white;
    color: #5b5fc7;
    font-weight: 700;
    cursor: pointer;
}

.interval-control .hidden { display: none; }
#interval-message { flex-basis: 100%; min-height: 20px; font-size: 0.85rem; }

@media (max-width: 600px) {
    .interval-control label { flex-basis: 100%; }
    .interval-control select, .interval-control input, .interval-control button { flex: 1; }
}
