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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: #f5f0e8;
    color: #2c2c2c;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 740px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 2.5rem;
    color: #1a3a5c;
    letter-spacing: 0.05em;
}

.subtitle {
    color: #6b7280;
    font-style: italic;
    margin-top: 0.25rem;
}

/* Controls */
.controls {
    margin-bottom: 1.5rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

.button-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

#article-input {
    flex: 1;
    padding: 0.7rem 1rem;
    font-size: 1rem;
    border: 2px solid #d1c9b8;
    border-radius: 8px;
    background: white;
    font-family: inherit;
    transition: border-color 0.2s;
    min-width: 0; /* prevent flex overflow */
}

#article-input:focus {
    outline: none;
    border-color: #1a3a5c;
}

button {
    padding: 0.7rem 1.2rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    transform: scale(0.97);
}

#btn-go {
    background: #1a3a5c;
    color: white;
    flex-shrink: 0;
}

#btn-go:hover {
    background: #24506e;
}

#btn-random {
    background: #e8a838;
    color: #2c2c2c;
    white-space: nowrap;
    flex: 1;
}

#btn-random:hover {
    background: #d49a2e;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem 0;
    color: #6b7280;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #d1c9b8;
    border-top-color: #1a3a5c;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Game area */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.game-header h2 {
    font-size: 1.15rem;
    color: #1a3a5c;
    flex: 1 1 100%;
}

.stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat {
    font-size: 0.85rem;
    color: #6b7280;
}

.stat-number {
    font-weight: 700;
    color: #1a3a5c;
    font-size: 1.05rem;
}

/* Text display */
.text-display {
    background: white;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    line-height: 2;
    font-size: 1.05rem;
    border: 1px solid #e5ddd0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.word {
    cursor: default;
    padding: 2px 1px;
    border-radius: 3px;
    transition: background 0.2s, box-shadow 0.2s;
    display: inline;
    -webkit-user-select: none;
    user-select: none;
}

.word.clickable {
    cursor: pointer;
}

.word.clickable:hover {
    background: #fef3c7;
}

.word.corrected {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
    animation: reveal-correction 0.5s ease;
}

@keyframes reveal-correction {
    from { background: #fef3c7; }
    to { background: #d1fae5; }
}

.word.hinted {
    background: #fef3c7;
    box-shadow: 0 0 0 2px #e8a838;
    border-radius: 3px;
    animation: hint-pulse 1.5s ease-in-out 3;
}

@keyframes hint-pulse {
    0%, 100% { box-shadow: 0 0 0 2px #e8a838; }
    50% { box-shadow: 0 0 0 4px #e8a83880; }
}

.word.wrong-guess {
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* Game actions bar */
.game-actions {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    gap: 0.5rem;
}

.btn-hint {
    background: #f3f0ea;
    color: #6b7280;
    border: 2px solid #d1c9b8;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-hint:hover {
    background: #e8e3d9;
    color: #4b5563;
}

.btn-hint:disabled,
.btn-solve:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #d1c9b8;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

.btn-solve {
    background: #f3f0ea;
    color: #6b7280;
    border: 2px solid #d1c9b8;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
}

.btn-solve:hover {
    background: #e8e3d9;
    color: #4b5563;
}

/* Review footer (replaces victory screen) */
.review-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #ecfdf5;
    border-radius: 12px;
    border: 1px solid #a7f3d0;
}

.review-header {
    font-size: 1.8rem;
    font-weight: 700;
    color: #065f46;
    margin-bottom: 0.5rem;
}

.review-stats {
    color: #6b7280;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.btn-play-again {
    background: #e8a838;
    color: #2c2c2c;
    font-size: 1.05rem;
    padding: 0.75rem 2rem;
}

.btn-play-again:hover {
    background: #d49a2e;
}

/* Translation tooltip */
.translation-tooltip {
    position: fixed;
    background: #1a3a5c;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    white-space: nowrap;
    transform: translate(-50%, -100%);
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.translation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a3a5c;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.modal-label {
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.modal-word {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a3a5c;
    margin-bottom: 1rem;
}

#correction-input {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 1.1rem;
    border: 2px solid #d1c9b8;
    border-radius: 8px;
    text-align: center;
    font-family: inherit;
    margin-bottom: 1rem;
}

#correction-input:focus {
    outline: none;
    border-color: #1a3a5c;
}

.modal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.modal-buttons button {
    flex: 1;
    max-width: 140px;
}

.btn-cancel {
    background: #e5e7eb;
    color: #4b5563;
}

.btn-cancel:hover {
    background: #d1d5db;
}

.btn-submit {
    background: #1a3a5c;
    color: white;
}

.btn-submit:hover {
    background: #24506e;
}

.modal-feedback {
    margin-top: 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.modal-feedback.incorrect {
    color: #dc2626;
}

.modal-feedback.not-an-error {
    color: #d97706;
}

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

/* Responsive — tablets */
@media (max-width: 768px) {
    .container {
        padding: 1.25rem 1rem;
    }

    h1 {
        font-size: 2.2rem;
    }

    .text-display {
        padding: 1rem 1.25rem;
        line-height: 1.9;
        font-size: 1rem;
    }
}

/* Responsive — phones */
@media (max-width: 480px) {
    .container {
        padding: 1rem 0.75rem;
    }

    header {
        margin-bottom: 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .input-row {
        flex-direction: column;
    }

    #btn-go {
        width: 100%;
    }

    .button-row {
        flex-direction: column;
    }

    .game-header {
        flex-direction: column;
        gap: 0.3rem;
    }

    .game-header h2 {
        font-size: 1.05rem;
    }

    .stats {
        gap: 0.75rem;
    }

    .stat {
        font-size: 0.8rem;
    }

    .stat-number {
        font-size: 0.95rem;
    }

    .text-display {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        line-height: 1.85;
        border-radius: 8px;
    }

    .word.clickable {
        padding: 3px 2px;
    }

    .modal-content {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .modal-word {
        font-size: 1.3rem;
    }

    #correction-input {
        font-size: 1rem;
        padding: 0.6rem 0.75rem;
    }

    .modal-buttons button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .review-footer {
        padding: 1.25rem;
    }

    .review-header {
        font-size: 1.5rem;
    }

    .btn-play-again {
        width: 100%;
        font-size: 1rem;
        padding: 0.7rem 1.5rem;
    }

    .game-actions {
        margin-top: 0.75rem;
    }

    .btn-hint,
    .btn-solve {
        width: 100%;
        justify-content: center;
    }
}
