* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Atkinson Hyperlegible', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: background 0.3s;
}

/* Theme backgrounds */
body.light { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
}

body.dark { 
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%); 
}

body.sepia { 
    background: linear-gradient(135deg, #d4a373 0%, #b8860b 100%); 
}

.container {
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    padding: 40px;
    transition: background 0.3s, color 0.3s;
}

.light .container { 
    background: white; 
    color: #333; 
}

.dark .container { 
    background: #3a3a3a; 
    color: #e0e0e0; 
}

.sepia .container { 
    background: #f4ecd8; 
    color: #5a4a3a; 
}

h1 {
    margin-bottom: 30px;
    text-align: center;
    font-size: 2.5em;
    transition: color 0.3s;
}

.light h1 { color: #667eea; }
.dark h1 { color: #a0a0a0; }
.sepia h1 { color: #8b6914; }

.input-section {
    margin-bottom: 30px;
}

textarea {
    width: 100%;
    padding: 15px;
    border-radius: 10px;
    font-size: 16px;
    resize: vertical;
    min-height: 150px;
    transition: all 0.3s;
    border: 2px solid;
}

.light textarea { 
    background: white; 
    color: #333; 
    border-color: #e0e0e0; 
}

.dark textarea { 
    background: #2a2a2a; 
    color: #e0e0e0; 
    border-color: #555; 
}

.sepia textarea { 
    background: #faf6ed; 
    color: #5a4a3a; 
    border-color: #d4a373; 
}

textarea:focus { 
    outline: none; 
}

.light textarea:focus { border-color: #667eea; }
.dark textarea:focus { border-color: #888; }
.sepia textarea:focus { border-color: #8b6914; }

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

label { 
    font-weight: 600; 
}

input[type="range"] { 
    width: 150px; 
}

.wpm-display {
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
    transition: all 0.3s;
}

.light .wpm-display { 
    background: #f0f0f0; 
    color: #667eea; 
}

.dark .wpm-display { 
    background: #2a2a2a; 
    color: #c0c0c0; 
}

.sepia .wpm-display { 
    background: #e8dcc0; 
    color: #8b6914; 
}

button {
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.light button { 
    background: #667eea; 
    color: white; 
}

.dark button { 
    background: #666; 
    color: #fff; 
}

.sepia button { 
    background: #8b6914; 
    color: #f4ecd8; 
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.light button:hover:not(:disabled) { 
    background: #764ba2; 
}

.dark button:hover:not(:disabled) { 
    background: #888; 
}

.sepia button:hover:not(:disabled) { 
    background: #a67c1a; 
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.theme-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.theme-btn {
    padding: 8px 20px;
    font-size: 14px;
}

.reader-display {
    border-radius: 15px;
    padding: 60px 40px;
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    transition: background 0.3s;
}

.light .reader-display { 
    background: #f8f9fa; 
}

.dark .reader-display { 
    background: #2a2a2a; 
}

.sepia .reader-display { 
    background: #faf6ed; 
}

.word {
    font-size: 3em;
    font-weight: 700;
    letter-spacing: 2px;
    font-family: 'Atkinson Hyperlegible', sans-serif;
}

.word-char {
    transition: color 0.05s;
}

.light .word-char.highlight { 
    color: #ff4757; 
}

.dark .word-char.highlight { 
    color: #ff4757; 
}

.sepia .word-char.highlight { 
    color: #d63031; 
}

.progress {
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    transition: background 0.3s;
}

.light .progress { 
    background: #e0e0e0; 
}

.dark .progress { 
    background: #2a2a2a; 
}

.sepia .progress { 
    background: #e8dcc0; 
}

.progress-bar {
    height: 100%;
    width: 0%;
    transition: width 0.1s linear, background 0.3s;
}

.light .progress-bar { 
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); 
}

.dark .progress-bar { 
    background: linear-gradient(90deg, #666 0%, #888 100%); 
}

.sepia .progress-bar { 
    background: linear-gradient(90deg, #8b6914 0%, #a67c1a 100%); 
}

.stats {
    text-align: center;
    font-size: 14px;
    transition: color 0.3s;
}

.light .stats { 
    color: #666; 
}

.dark .stats { 
    color: #b0b0b0; 
}

.sepia .stats { 
    color: #7a6a5a; 
}

.placeholder {
    font-size: 1.2em;
    transition: color 0.3s;
}

.light .placeholder { 
    color: #999; 
}

.dark .placeholder { 
    color: #7a7a7a; 
}

.sepia .placeholder { 
    color: #9a8a7a; 
}

.ad-container {
    margin-top: 30px;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    transition: all 0.3s;
}

.light .ad-container { 
    background: #f0f0f0; 
    border: 1px solid #e0e0e0; 
}

.dark .ad-container { 
    background: #2a2a2a; 
    border: 1px solid #444; 
}

.sepia .ad-container { 
    background: #e8dcc0; 
    border: 1px solid #d4a373; 
}

.ad-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.ad-content {
    font-size: 14px;
    line-height: 1.6;
}

/* Reading mode - focus view */
body.reading-mode .container > *:not(.controls):not(.reader-display) {
    position: relative;
    pointer-events: none;
    opacity: 0.15;
}

body.reading-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1;
    pointer-events: none;
}

body.reading-mode .container {
    position: relative;
    z-index: 2;
}

body.reading-mode .container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    z-index: 1;
}

body.reading-mode .controls,
body.reading-mode .reader-display {
    position: relative;
    z-index: 3;
}

body.reading-mode .progress,
body.reading-mode .stats {
    position: relative;
    z-index: 3;
    opacity: 1 !important;
}

.keyboard-shortcuts {
    margin-top: 20px;
    padding: 15px;
    text-align: center;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

body.reading-mode .keyboard-shortcuts {
    position: relative;
    z-index: 3;
    opacity: 1 !important;
}