/* 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;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
    overflow-x: hidden;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Screen Management */
.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Loading Screen */
#loading-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.loading-content {
    text-align: center;
}

.loading-content h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Login and Register Screens */
#login-screen, #register-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.container h1 {
    color: white;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2.5rem;
}

.form-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.form-container h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.form-container form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-container input,
.form-container select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-container button {
    padding: 0.75rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.form-container button:hover {
    background: #5568d3;
}

.form-switch {
    text-align: center;
    margin-top: 1rem;
    color: #666;
}

.form-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

/* Header */
.header {
    background: #667eea;
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h2 {
    flex: 1;
    text-align: center;
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.progress-info {
    font-size: 0.9rem;
    min-width: 60px;
    text-align: right;
}

/* Tabs */
.tabs {
    display: flex;
    background: white;
    border-bottom: 2px solid #e0e0e0;
}

.tab {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.tab.active {
    border-bottom-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

/* Content Area */
.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Card */
.card {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.character-display,
.word-display {
    text-align: center;
    padding: 2rem 0;
}

.character-display h1,
.word-display h1 {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.grammar-display {
    margin-bottom: 2rem;
}

.grammar-display h2 {
    color: #667eea;
    margin-bottom: 1rem;
}

.grammar-display p {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.dialog-display {
    margin-bottom: 2rem;
}

.dialog-display p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.dialog-display h2 {
    font-size: 1.8rem;
    color: #333;
}

/* Options */
.options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.option-btn {
    padding: 1rem;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.option-btn:hover {
    background: #e8e8e8;
    border-color: #667eea;
}

.option-btn.correct {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.option-btn.incorrect {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Preview Section */
.preview-section {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.preview-section h3 {
    color: #667eea;
    margin-bottom: 1.5rem;
    text-align: center;
}

.preview-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.preview-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: #f5f5f5;
    border-radius: 5px;
    border-left: 4px solid #667eea;
}

.preview-item-word {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.preview-item-translation {
    font-size: 1rem;
    color: #666;
}

.preview-item-explanation {
    font-size: 0.9rem;
    color: #888;
    margin-top: 0.25rem;
}

.start-btn {
    width: 100%;
    padding: 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.start-btn:hover {
    background: #5568d3;
}

/* Progress Bar */
.progress-bar {
    background: #f5f5f5;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.progress-fill {
    height: 20px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: width 0.3s;
    width: 0%;
}

.progress-bar span {
    display: block;
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 600;
    color: #667eea;
}

/* Learning Section */
.learning-section {
    display: block;
}

/* Skip Button */
.skip-btn {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.skip-btn:hover {
    opacity: 1;
}

/* Completion Message */
.completion-message {
    text-align: center;
    padding: 2rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.completion-message h2 {
    color: #4CAF50;
    margin-bottom: 1rem;
}

.completion-message button {
    padding: 1rem 2rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 1rem;
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: left 0.3s;
    z-index: 1001;
}

.side-menu.open {
    left: 0;
}

.menu-header {
    background: #667eea;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.menu-content {
    padding: 1.5rem;
}

.menu-section {
    margin-bottom: 2rem;
}

.menu-section h4 {
    color: #667eea;
    margin-bottom: 1rem;
}

.menu-section button {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.menu-section button:hover {
    background: #e8e8e8;
}

.menu-section p {
    margin-bottom: 0.5rem;
    color: #666;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: #333;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-content input,
.modal-content select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
}

.modal-buttons button {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.modal-buttons button[type="submit"] {
    background: #667eea;
    color: white;
}

.modal-buttons button[type="button"] {
    background: #f5f5f5;
    color: #333;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 1rem 2rem;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 1003;
    animation: slideUp 0.3s;
}

.toast.success {
    background: #4CAF50;
}

.toast.error {
    background: #f44336;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (min-width: 768px) {
    .options {
        grid-template-columns: 1fr 1fr;
    }

    .character-display h1,
    .word-display h1 {
        font-size: 5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    .form-container {
        padding: 1.5rem;
    }

    .character-display h1,
    .word-display h1 {
        font-size: 3rem;
    }
}

/* Audio Controls */
.audio-btn {
    background: #667eea;
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 1rem;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.audio-btn:hover {
    background: #764ba2;
    transform: scale(1.1);
}

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

.audio-btn.playing {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}