/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --success: #4caf50;
    --error: #f44336;
    --warning: #ff9800;
    --background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text: #333;
    --text-light: #666;
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.1);
}

body {
    font-family: Arial, sans-serif;
    background: var(--background);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    max-width: 600px;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

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

/* Container */
.container {
    background: var(--white);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow);
}

/* Typography */
.title {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    font-size: clamp(2rem, 5vw, 3rem);
    color: var(--primary);
    text-align: center;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 30px;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.select-input {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-input:hover:not(:disabled) {
    border-color: var(--primary);
}

.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.select-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Buttons */
.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    min-width: 44px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

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

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

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--secondary);
}

.btn-success {
    background: var(--success);
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-audio {
    background: var(--secondary);
    color: white;
    flex: 1;
    margin: 5px;
}

.btn-hint {
    background: #e3f2fd;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 10px 15px;
    margin: 5px;
    font-size: 0.9rem;
    flex: 1 1 calc(50% - 10px);
}

.btn-hint:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.score, .progress {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
}

/* Audio Controls */
.audio-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

/* Input Area */
.input-area {
    margin-bottom: 20px;
}

.word-input {
    width: 100%;
    padding: 20px;
    font-size: 1.5rem;
    text-align: center;
    border: 3px solid var(--primary);
    border-radius: 15px;
    transition: all 0.3s ease;
}

.word-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Hint Buttons */
.hint-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

/* Hint Display */
.hint-display {
    background: #f5f5f5;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    min-height: 50px;
    color: var(--text);
    line-height: 1.6;
}

.hint-display:empty {
    display: none;
}

.hint-display strong {
    color: var(--primary);
    display: block;
    margin-bottom: 5px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Feedback */
.feedback {
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    animation: slideIn 0.3s ease-out;
}

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

.feedback.correct {
    background: #e8f5e9;
    color: var(--success);
    border: 2px solid var(--success);
}

.feedback.incorrect {
    background: #ffebee;
    color: var(--error);
    border: 2px solid var(--error);
}

/* Results Screen */
.results-summary {
    text-align: center;
    margin-bottom: 30px;
}

.star-rating {
    font-size: 3rem;
    margin: 20px 0;
}

.final-score {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    margin: 20px 0;
}

.encouragement {
    font-size: 1.3rem;
    color: var(--text);
    margin: 20px 0;
    font-style: italic;
}

.missed-words {
    background: #fff3e0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.missed-words h3 {
    color: var(--warning);
    margin-bottom: 15px;
}

.missed-words ul {
    list-style: none;
    padding: 0;
}

.missed-words li {
    padding: 10px;
    margin: 5px 0;
    background: white;
    border-radius: 5px;
    border-left: 4px solid var(--warning);
}

.missed-words:empty {
    display: none;
}

/* Responsive Design */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 1rem;
    }

    .word-input {
        font-size: 1.2rem;
        padding: 15px;
    }

    .hint-buttons {
        gap: 5px;
    }

    .btn-hint {
        flex: 1 1 100%;
        margin: 3px 0;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
}

/* ============================================
   Request Form Styles
   ============================================ */

/* Request Page Header */
.request-header {
    text-align: center;
    margin-bottom: 20px;
}

.back-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: bold;
    margin-top: 10px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.back-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--secondary);
}

/* Rate Limit Info */
.rate-limit-info {
    background: #e3f2fd;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 25px;
    text-align: center;
    border: 2px solid transparent;
}

.rate-limit-info .rate-limit-text {
    font-weight: bold;
    color: var(--primary);
    display: block;
}

.rate-limit-info .rate-limit-detail {
    font-size: 0.9rem;
    color: var(--text-light);
}

.rate-limit-info .rate-limit-loading {
    color: var(--text-light);
    font-style: italic;
}

.rate-limit-info .rate-limit-error {
    color: var(--error);
}

.rate-limit-info.warning {
    background: #fff3e0;
    border-color: var(--warning);
}

.rate-limit-info.warning .rate-limit-text {
    color: var(--warning);
}

.rate-limit-info.exceeded {
    background: #ffebee;
    border-color: var(--error);
}

.rate-limit-info.exceeded .rate-limit-text {
    color: var(--error);
}

/* Request Form */
.request-form {
    margin-bottom: 20px;
}

/* Form Row (for side-by-side fields) */
.form-row {
    display: flex;
    gap: 15px;
}

.form-group-half {
    flex: 1;
}

/* Text Input Styles */
.text-input,
.textarea-input {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
}

.text-input:hover:not(:disabled),
.textarea-input:hover:not(:disabled) {
    border-color: var(--primary);
}

.text-input:focus,
.textarea-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.textarea-input {
    resize: vertical;
    min-height: 120px;
}

/* Field Help Text */
.field-help {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* Field Error */
.field-error {
    display: block;
    font-size: 0.85rem;
    color: var(--error);
    margin-top: 5px;
    min-height: 1.2em;
}

.form-group.has-error .text-input,
.form-group.has-error .textarea-input,
.form-group.has-error .select-input {
    border-color: var(--error);
    background: #fff8f8;
}

/* Word Count Display */
.word-count {
    font-size: 0.85rem;
    margin-top: 5px;
    min-height: 1.2em;
    color: var(--text-light);
}

.word-count.count-valid {
    color: var(--success);
}

.word-count.count-warning {
    color: var(--warning);
}

.word-count.count-error {
    color: var(--error);
}

/* Submit Button */
.btn-submit {
    margin-top: 20px;
}

.btn-submit:disabled {
    background: #ccc;
}

/* Success Panel */
.success-panel {
    text-align: center;
    padding: 20px;
}

.success-panel.hidden {
    display: none;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    margin: 0 auto 20px;
}

.success-panel h2 {
    color: var(--success);
    margin-bottom: 10px;
}

.success-panel p {
    color: var(--text);
    margin-bottom: 20px;
}

.success-details {
    background: #e8f5e9;
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
    text-align: left;
}

.success-details p {
    margin: 8px 0;
}

.success-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.success-actions .btn {
    flex: 1;
    min-width: 150px;
    max-width: 200px;
}

.btn-secondary {
    background: #e0e0e0;
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background: #d0d0d0;
}

/* Error Panel */
.error-panel {
    text-align: center;
    padding: 20px;
}

.error-panel.hidden {
    display: none;
}

.error-icon {
    width: 80px;
    height: 80px;
    background: var(--error);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    margin: 0 auto 20px;
}

.error-panel h2 {
    color: var(--error);
    margin-bottom: 10px;
}

.error-panel p {
    color: var(--text);
    margin-bottom: 20px;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Add List Link for main page */
.add-list-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: bold;
    padding: 10px 20px;
    border: 2px solid var(--primary);
    border-radius: 25px;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.add-list-link:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Responsive adjustments for request form */
@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .success-actions {
        flex-direction: column;
    }

    .success-actions .btn {
        max-width: none;
    }
}
