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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
    position: relative;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    position: relative;
}

.dark-mode-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.dark-mode-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

header h1 {
    font-size: 2.8rem;
    font-weight: 800;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.2);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
    color: white;
}

.info-text {
    font-size: 0.9rem;
    opacity: 0.9;
    font-style: italic;
    margin-top: 10px;
}

.stats-bar {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 12px 20px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.speed-indicator {
    background: rgba(255, 255, 255, 0.25);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#stats-display {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-continue {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-continue:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.controls {
    background: white;
    border-radius: 16px;
    padding: 35px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 30px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 150px;
}

.control-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.control-group select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.control-group select option:disabled {
    color: #999;
    font-style: italic;
}

.control-group select:hover {
    border-color: #667eea;
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #e8e8e8;
    border-color: #d0d0d0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.reader-container {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    padding: 80px 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.reader-container.focus-mode {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 0;
    margin: 0;
    z-index: 10000;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

.reader-container.focus-mode .mobile-controls-top,
.reader-container.focus-mode .progress-info {
    display: none !important;
}

.reader-container.focus-mode .word-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.reader-container.focus-mode .word {
    font-size: 5rem;
    padding: 40px 50px;
}

.focus-mode-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.focus-mode-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.1);
}

.reader-container.focus-mode .focus-mode-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(102, 126, 234, 0.5);
}

.reader-container.focus-mode .focus-mode-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.mobile-controls-top {
    display: none;
    width: 100%;
    padding: 15px 20px;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-mobile {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 48px;
}

.btn-mobile:first-child {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-mobile:first-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-mobile:last-child {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
}

.btn-mobile:last-child:hover {
    background: #e8e8e8;
    border-color: #d0d0d0;
}

.reader-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.word-display {
    position: relative;
    width: 100%;
    max-width: 800px;
    text-align: center;
    margin-bottom: 40px;
    padding: 0 20px;
    box-sizing: border-box;
}

.word {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 4rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    display: inline-block;
    min-height: 150px;
    padding: 30px 40px;
    position: relative;
    z-index: 2;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    animation: fadeInWord 0.15s ease-in;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

@keyframes fadeInWord {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#word .red-letter,
.word .red-letter,
.red-letter {
    color: #ff0000 !important;
    font-weight: 800 !important;
    text-shadow: 0 0 15px rgba(255, 0, 0, 0.8), 0 0 30px rgba(255, 0, 0, 0.4) !important;
    font-size: 1.1em !important;
    position: relative;
    display: inline-block;
    background: transparent;
}

.progress-info {
    color: #555;
    font-size: 1.1rem;
    font-weight: 500;
    margin-top: 30px;
    padding: 15px 25px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    min-width: 250px;
    text-align: center;
}

#current-location {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1rem;
}

#progress-text {
    color: #666;
    font-size: 0.95rem;
}

.progress-bar-container {
    width: 100%;
    max-width: 600px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.attribution {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.attribution p {
    margin: 0;
}

.attribution a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.attribution a:hover {
    color: white;
    text-decoration: underline;
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .controls {
    background: #2d2d44;
    border-color: rgba(102, 126, 234, 0.2);
    color: #e0e0e0;
}

body.dark-mode .control-group label {
    color: #d0d0d0;
}

body.dark-mode .control-group select {
    background: #3d3d54;
    border-color: #4d4d64;
    color: #e0e0e0;
}

body.dark-mode .control-group select:hover {
    border-color: #667eea;
}

body.dark-mode .reader-container {
    background: linear-gradient(135deg, #2d2d44 0%, #1f1f2e 100%);
    border-color: rgba(102, 126, 234, 0.2);
}

body.dark-mode .word {
    color: #e0e0e0;
}

body.dark-mode .progress-info {
    background: #3d3d54;
    color: #d0d0d0;
}

body.dark-mode #current-location {
    color: #8b9aff;
}

body.dark-mode .btn-secondary {
    background: #3d3d54;
    color: #e0e0e0;
    border-color: #4d4d64;
}

body.dark-mode .btn-secondary:hover {
    background: #4d4d64;
    border-color: #5d5d74;
}

/* Celebration Animation */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.celebration.show {
    opacity: 1;
}

.celebration-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 60px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
    color: white;
    transform: scale(0.8);
    animation: celebrationPop 0.6s ease forwards;
}

@keyframes celebrationPop {
    0% {
        transform: scale(0.8) translateY(20px);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) translateY(-10px);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.celebration-icon {
    font-size: 4rem;
    margin-bottom: 10px;
    animation: celebrationBounce 0.6s ease 0.2s;
}

@keyframes celebrationBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

.celebration-text {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.celebration-subtext {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Smooth Transitions */
.reader-container {
    transition: opacity 0.5s ease;
}

/* Better Mobile Touch Targets */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }
    
    .container {
        max-width: 100%;
    }
    
    header {
        margin-bottom: 20px;
        padding: 0 5px;
    }
    
    header h1 {
        font-size: 1.75rem;
        margin-bottom: 8px;
        line-height: 1.2;
    }
    
    .header-top {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 0 5px;
    }
    
    .dark-mode-btn {
        position: static;
        transform: none;
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
        flex-shrink: 0;
    }
    
    .stats-bar {
        flex-direction: row;
        align-items: center;
        padding: 8px 12px;
        margin-top: 10px;
        font-size: 0.85rem;
        gap: 8px;
    }
    
    .header-actions {
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .speed-indicator {
        font-size: 0.85rem;
        padding: 6px 10px;
    }
    
    .btn-continue {
        min-height: 40px;
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .controls {
        flex-direction: column;
        padding: 15px;
        margin-bottom: 15px;
        gap: 12px;
        border-radius: 12px;
    }
    
    .control-group {
        width: 100%;
        margin-bottom: 0;
    }
    
    .control-group label {
        font-size: 0.9rem;
        margin-bottom: 6px;
        display: block;
    }
    
    .control-group select {
        min-height: 48px;
        font-size: 1rem;
        padding: 12px 14px;
        width: 100%;
    }
    
    .btn-primary, .btn-secondary {
        min-height: 52px;
        padding: 14px 24px;
        font-size: 1.05rem;
        font-weight: 600;
        width: 100%;
    }
    
    .reader-container {
        padding: 15px 10px;
        min-height: auto;
        border-radius: 12px;
        margin: 0;
    }
    
    .mobile-controls-top {
        display: flex;
        gap: 10px;
        padding: 0 5px 15px 5px;
        margin-bottom: 10px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .btn-mobile {
        flex: 1;
        min-height: 48px;
        font-size: 1rem;
        font-weight: 600;
        border-radius: 10px;
    }
    
    .word-display {
        padding: 0 8px;
        margin-bottom: 20px;
        min-height: 140px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .word {
        font-size: 3rem;
        padding: 15px 10px;
        min-height: auto;
        max-width: 100%;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        line-height: 1.3;
        letter-spacing: 0.02em;
    }
    
    /* Hide desktop controls when reading on mobile */
    .reader-container ~ .controls {
        display: none !important;
    }
    
    .progress-info {
        padding: 12px 14px;
        font-size: 0.9rem;
        min-width: auto;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin-top: 10px;
        border-radius: 10px;
    }
    
    #current-location {
        font-size: 0.85rem;
        margin-bottom: 6px;
        font-weight: 600;
    }
    
    #progress-text {
        font-size: 0.85rem;
        color: #666;
    }
    
    .progress-bar-container {
        margin-top: 8px;
        height: 5px;
    }
    
    .attribution {
        font-size: 0.75rem;
        margin-top: 20px;
        padding: 12px;
        text-align: center;
    }
    
    /* Hide header stats when reading on mobile to save space */
    .reader-container.active ~ header .stats-bar {
        display: none !important;
    }
    
    /* Better spacing for header when reading */
    .reader-container.active ~ header {
        margin-bottom: 10px;
    }
    
    /* Optimize word display for different font sizes on mobile */
    .word[style*="font-size: 3.5rem"] {
        font-size: 2.8rem !important;
    }
    
    .word[style*="font-size: 4rem"] {
        font-size: 3.2rem !important;
    }
    
    .word[style*="font-size: 4.5rem"] {
        font-size: 3.6rem !important;
    }
    
    .word[style*="font-size: 5rem"] {
        font-size: 4rem !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .word {
        font-size: 2.5rem;
        padding: 12px 8px;
    }
    
    .word-display {
        min-height: 120px;
    }
    
    .controls {
        padding: 12px;
    }
    
    .reader-container {
        padding: 12px 8px;
    }
    
    .mobile-controls-top {
        padding: 0 3px 12px 3px;
        margin-bottom: 8px;
    }
}
