:root {
    --zoom-min-size: min(50px, 10vw);
    --zoom-max-size: min(300px, 60vw);
    --primary-color: #4299e1;
    --primary-light: rgba(66, 153, 225, 0.2);
    --primary-medium: rgba(66, 153, 225, 0.5);
    --success-color: #2e7d32;
    --success-light: #e8f5e9;
    --text-dark: #2d3748;
    --text-medium: #4a5568;
    --text-light: #718096;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.15);
}

/* Main App Styles */
.eye-exercises-app {
    padding: 1rem;
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
    padding-bottom: 2rem;
}

/* Exercise Selector */
.exercise-selector h2 {
    font-size: 2rem;
    color: #5a67d8;
    margin-bottom: 1.5rem;
    text-align: center;
}

.exercise-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.exercise-card {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.exercise-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.1);
}

.exercise-name {
    font-size: 1.2rem;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.exercise-type {
    padding: 0.25rem 0.75rem;
    border-radius: 5px;
    font-size: 0.9rem;
    background: #c6f6d5;
    color: #276749;
    font-weight: 600;
    margin-bottom: .75rem;
}

.exercise-desc {
    color: #718096;
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 500;
}

/* Exercise Interface */
.exercise-interface {
    text-align: center;
    background: var(--bg-light);
    border-radius: 20px;
    box-shadow: 0 20px 40px var(--shadow-medium);
    border: 3px solid var(--border-color);
    padding: 1rem;
}

[hidden] {
    display: none !important;
}

.exercise-visual {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Main Animation Container */
.exercise-animation {
    position: relative;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Animation Area */
.animation-container {
    width: 100%;
    height: 350px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    overflow: hidden;
}

/* Instruction & Timer Area */
.instruction-timer-area {
    height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    background: rgba(247, 250, 252, 0.9);
}

.exercise-instruction {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-dark);
    min-height: 2.5rem;
    padding: 0 1rem;
    padding-top: 1rem;
    text-align: center;
}

.exercise-timer {
    font-size: 2.8rem;
    font-weight: 300;
    color: var(--text-medium);
    padding-bottom: 2rem;
    font-variant-numeric: tabular-nums;
}

/* General Instruction Layout */
.instruction-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    box-sizing: border-box;
    overflow: auto;
}

.instruction-image {
    justify-content: center;
    align-items: center;
    min-width: 300px;
}

.instruction-image img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    border-radius: 15px;
}

.instruction-content {
    flex: 1;
    text-align: left;
    background: #f8f9fa;
    overflow-y: auto;
    max-height: 350px;
}

.instruction-content h3 {
    font-size: 1.6rem;
    color: var(--success-color);
    margin-bottom: 1.2rem;
    text-align: center;
}

.instructions-list {
    margin-bottom: 1.5rem;
}

.instruction-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
    padding: 0.8rem;
    background: var(--bg-white);
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: var(--bg-white);
    border-radius: 50%;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.step-text {
    font-size: 1rem;
    color: var(--text-medium);
    line-height: 1.5;
}

/* Voice Controls */
.voice-control {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
}

.voice-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-medium);
    user-select: none;
    justify-content: center;
}

.voice-toggle input {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.voice-toggle input:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkmark:after {
    content: '✓';
    color: var(--bg-white);
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.voice-toggle input:checked+.checkmark:after {
    opacity: 1;
}

.voice-toggle:hover .checkmark {
    border-color: #4299e1;
}

/* Volume Control */
.volume-control {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
}

.volume-control.visible {
    display: flex;
}

.volume-control label {
    font-size: 0.95rem;
    color: var(--text-medium);
    font-weight: 500;
    white-space: nowrap;
}

.volume-slider {
    width: 120px;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--bg-white);
    box-shadow: 0 2px 4px var(--shadow-light);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--bg-white);
    box-shadow: 0 2px 4px var(--shadow-light);
}

#volumeValue {
    font-size: 0.9rem;
    color: var(--text-light);
    min-width: 40px;
    text-align: center;
}

/* Hide elements when needed */
.exercise-animation:has(.instruction-layout) .animation-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.exercise-animation:has(.instruction-layout) .instruction-timer-area,
.exercise-animation:has(.instruction-layout) .exercise-instruction,
.exercise-animation:has(.instruction-layout) .exercise-timer {
    display: none !important;
}

/* Session Controls */
.session-controls-group {
    margin: 1.5rem 0;
    text-align: center;
}

.control-row {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.control-item label {
    font-weight: 500;
    color: var(--text-medium);
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Select Styles */
.select-wrapper {
    position: relative;
    display: inline-block;
    min-width: 180px;
}

.styled-select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-white);
    font-size: 1rem;
    color: var(--text-medium);
    cursor: pointer;
    appearance: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

.styled-select:hover,
.styled-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.select-arrow {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-light);
    font-size: 0.8rem;
}

/* Hide session controls when exercise is running */
.session-controls-group.running {
    display: none;
}

/* Exercise Controls */
.exercise-controls {
    max-width: 500px;
    margin: 0 auto 2rem;
}

.control-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.btn.primary {
    background: #667eea;
    color: var(--bg-white);
}

.btn.primary:hover:not(:disabled),
.btn.primary:focus:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--border-color);
    color: var(--text-medium);
}

.btn.secondary:hover:not(:disabled),
.btn.secondary:focus:not(:disabled) {
    background: #cbd5e0;
}

.btn.outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn.outline:hover,
.btn.outline:focus {
    background: #667eea;
    color: var(--bg-white);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.back-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 1rem;
    padding: 0.5rem;
}

.back-btn:hover,
.back-btn:focus {
    text-decoration: underline;
    outline: none;
}

/* Completion Overlay */
.completion-message {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.completion-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Animation Elements */
.figure-eight-path {
    position: absolute;
    width: 90%;
    height: 70%;
    pointer-events: none;
    box-sizing: border-box;
    opacity: 0.3;
}

.figure-eight-dot {
    position: absolute;
    width: 25px;
    height: 25px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 0 0 6px var(--primary-light), 0 4px 15px var(--primary-medium);
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: left 0.1s linear, top 0.1s linear;
}

.directional-dot {
    position: absolute;
    width: 25px;
    height: 25px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 0 0 8px var(--primary-light), 0 8px 25px var(--primary-medium);
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: all 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.zooming-circle-css {
    position: absolute;
    border-radius: 50%;
    background: transparent;
    border: 3px solid var(--primary-color);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: zoomBreath 6s ease-in-out infinite;
    box-shadow: 0 0 20px var(--primary-light);
}

.center-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

@keyframes zoomBreath {
    0%, 100% {
        width: var(--zoom-min-size);
        height: var(--zoom-min-size);
        opacity: 0.8;
    }
    50% {
        width: var(--zoom-max-size);
        height: var(--zoom-max-size);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .exercise-selector h2 {
        font-size: 1.5rem;
    }

    .instruction-layout {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1rem;
    }

    .instruction-image {
        min-width: 100%;
        max-width: 300px;
    }

    .instruction-image img {
        max-height: 250px;
    }

    .instruction-content {
        width: 100%;
        max-height: none;
        text-align: center;
        padding: 1.2rem;
    }

    .instruction-content h3 {
        font-size: 1.4rem;
    }

    .instruction-step {
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 0.5rem;
    }

    .animation-container {
        height: 300px;
    }

    .instruction-timer-area {
        height: 150px;
    }

    .exercise-instruction {
        font-size: 1.3rem;
    }

    .exercise-timer {
        font-size: 2.3rem;
    }

    .completion-message {
        font-size: 2rem;
    }

    .completion-subtitle {
        font-size: 1.1rem;
    }

    .control-row {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }

    .control-item {
        width: 100%;
        max-width: 250px;
    }

    .select-wrapper {
        min-width: 100%;
    }

    .volume-control {
        flex-direction: column;
        gap: 0.5rem;
    }

    .volume-slider {
        width: 150px;
    }

    .figure-eight-dot,
    .directional-dot {
        width: 20px;
        height: 20px;
    }

    .figure-eight-path {
        width: 85%;
        height: 65%;
    }

    :root {
        --zoom-min-size: min(40px, 12vw);
        --zoom-max-size: min(250px, 70vw);
    }
}

@media (max-width: 480px) {
    .instruction-layout {
        padding: 0.8rem;
    }

    .instruction-content {
        padding: 1rem;
    }

    .instruction-content h3 {
        font-size: 1.3rem;
    }

    .instruction-step {
        padding: 0.7rem;
    }

    .control-buttons {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
        min-width: auto;
    }

    .step-text {
        font-size: 0.95rem;
    }

    .voice-toggle {
        font-size: 0.95rem;
    }

    .animation-container {
        height: 250px;
    }

    .instruction-timer-area {
        height: 120px;
    }

    .exercise-instruction {
        font-size: 1.1rem;
        padding-top: .3rem;
    }

    .exercise-timer {
        font-size: 1.5rem;
        padding-bottom: 0.5rem;
        padding-top: 0.5rem;
    }

    .completion-message {
        font-size: 1.5rem;
    }

    .completion-subtitle {
        font-size: 1rem;
    }

    .figure-eight-dot,
    .directional-dot {
        width: 15px;
        height: 15px;
    }

    .figure-eight-path {
        width: 80%;
        height: 60%;
    }

    :root {
        --zoom-min-size: min(30px, 15vw);
        --zoom-max-size: min(200px, 80vw);
    }
}

/* Tablet and larger */
@media (min-width: 600px) {
    .exercise-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop and larger */
@media (min-width: 900px) {
    .exercise-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}