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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

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

.controls {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

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

.settings {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-left: auto;
}

.settings label {
    font-weight: 600;
    color: #555;
}

#speedSlider {
    width: 150px;
    cursor: pointer;
}

#voiceSelect {
    padding: 8px 15px;
    border-radius: 8px;
    border: 2px solid #ddd;
    font-size: 0.95em;
    cursor: pointer;
    background: white;
}

.lang-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.lang-buttons span {
    font-weight: 600;
    color: #555;
    margin-right: 5px;
}

.lang-btn {
    padding: 8px 15px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
    font-weight: 600;
}

.lang-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.lang-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 20px;
    transition: color 0.3s;
}

.close:hover {
    color: #667eea;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 2em;
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.topic-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.topic-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.topic-item:active {
    transform: translateY(-2px);
}

.phrases-container {
    padding: 30px;
    min-height: 400px;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1.2em;
}

.phrase-card {
    background: #f8f9fa;
    border-left: 5px solid #667eea;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.phrase-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.phrase-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.korean-section {
    flex: 1;
}

.korean-text {
    font-size: 1.8em;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.pronunciation-text {
    font-size: 1.1em;
    color: #667eea;
    font-style: italic;
    margin-top: 5px;
    font-weight: 500;
}

.play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.play-btn:active {
    transform: scale(0.95);
}

.play-btn.playing {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    animation: pulse 1s infinite;
}

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

.explanation {
    font-size: 1.1em;
    color: #555;
    padding: 10px;
    background: white;
    border-radius: 8px;
    margin-top: 10px;
}

.topic-title {
    font-size: 2em;
    color: #667eea;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 700;
}

.back-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

.back-btn:hover {
    background: #5a6268;
}

.nav-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

.nav-btn:active {
    transform: translateY(0);
}

/* Image Gallery Styles */
.gallery-section {
    padding: 40px 30px;
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
}

.gallery-title {
    font-size: 2em;
    color: #667eea;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 700;
}

.thumbnail-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.thumbnail-btn {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    overflow: hidden;
}

.thumbnail-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.thumbnail-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 5px;
}

/* Image Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

.image-modal-content {
    position: relative;
    margin: auto;
    padding: 20px;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.image-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    transition: color 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
}

.image-close:hover {
    color: #f5576c;
    background: rgba(0, 0, 0, 0.7);
}

.image-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(102, 126, 234, 0.8);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    z-index: 2001;
    transition: background 0.3s, transform 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.image-nav-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: translateY(-50%) scale(1.05);
}

.image-prev {
    left: 20px;
}

.image-next {
    right: 20px;
}

.image-controls {
    margin-top: 20px;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.download-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.6);
}

.image-counter {
    color: white;
    font-size: 1.2em;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border-radius: 20px;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .settings {
        margin-left: 0;
        flex-direction: column;
        align-items: stretch;
    }
    
    .topics-grid {
        grid-template-columns: 1fr;
    }
    
    .korean-text {
        font-size: 1.4em;
    }

    .thumbnail-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }

    .image-nav-btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }

    .image-prev {
        left: 10px;
    }

    .image-next {
        right: 10px;
    }

    .image-close {
        top: 10px;
        right: 10px;
        font-size: 30px;
        width: 40px;
        height: 40px;
    }

    .image-modal-content {
        width: 95%;
        height: 95vh;
        padding: 10px;
    }
}

