/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    height: 100dvh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px 28px;
    max-width: 600px;
    width: 100%;
    height: 100%;
    max-height: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2c3e50, #3498db);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

h1 {
    font-size: 2em;
    margin: 0;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    line-height: 1.2;
}

.subtitle {
    color: #666;
    margin-bottom: 10px;
    font-size: 0.95em;
}

/* ===== HEADER ROW ===== */
.header-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.header-row h1 {
    text-align: center;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: flex-end;
    order: -1;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(52, 152, 219, 0.4);
    background: white;
    color: #3498db;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    flex: 0 0 auto;
    padding: 0;
    min-width: unset;
    box-shadow: none;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: #3498db;
    color: white;
    transform: none;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.lang-toggle {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(52, 152, 219, 0.3);
}

.lang-btn {
    flex: 0 0 auto;
    min-width: unset;
    padding: 6px 14px;
    font-size: 0.9em;
    font-weight: 700;
    border: none;
    border-radius: 0;
    background: white;
    color: #3498db;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
}

.lang-btn:hover {
    background: rgba(52, 152, 219, 0.1);
    transform: none;
    box-shadow: none;
}

.lang-btn.active {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-box {
    background: white;
    border-radius: 20px;
    padding: 36px 32px 28px;
    max-width: 480px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: fadeIn 0.3s ease-out;
}

.modal-box h2 {
    font-size: 1.6em;
    margin-bottom: 18px;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-box p {
    color: #444;
    font-size: 1em;
    line-height: 1.5;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.3em;
    color: #999;
    cursor: pointer;
    flex: 0 0 auto;
    min-width: unset;
    padding: 4px 8px;
    box-shadow: none;
    line-height: 1;
    border-radius: 6px;
}

.modal-close:hover {
    background: rgba(0,0,0,0.06);
    color: #333;
    transform: none;
    box-shadow: none;
}

.example-box {
    background: linear-gradient(135deg, rgba(52,152,219,0.08), rgba(44,62,80,0.05));
    border: 2px dashed rgba(52, 152, 219, 0.35);
    border-radius: 14px;
    padding: 18px 22px;
    margin: 18px 0;
    text-align: center;
}

.example-box p {
    margin: 4px 0;
}

.hidden {
    display: none !important;
}

.game-info {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    background: rgba(52, 152, 219, 0.1);
    padding: 10px 16px;
    border-radius: 12px;
    border: 2px solid rgba(52, 152, 219, 0.2);
    flex-shrink: 0;
}

.timer {
    font-size: 1.2em;
    font-weight: bold;
    color: #3498db;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    position: relative;
    animation: pulse 2s infinite;
}

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


.elements-container {
    flex: 1;
    min-height: 0;
    margin: 6px 0;
    padding: 10px 12px;
    background: rgba(52, 152, 219, 0.05);
    border-radius: 15px;
    border: 2px dashed rgba(52, 152, 219, 0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

/* Hint button and popup styles removed for cleaner interface */

.elements {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
    margin-bottom: 0;
    line-height: 1.3;
}

.element-tag {
    display: inline-block;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 12px 22px;
    margin: 6px;
    border-radius: 10px;
    font-size: 1.05em;
    font-weight: 600;
    box-shadow: 0 3px 6px rgba(44, 62, 80, 0.3);
    transform: translateY(0);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.element-tag:nth-child(2n) {
    background: linear-gradient(135deg, #3498db, #2980b9);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.element-tag:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.input-container {
    position: relative;
    margin: 8px 0;
}

input[type="text"] {
    width: 100%;
    font-size: 1.15em;
    padding: 12px 20px;
    border: 3px solid rgba(52, 152, 219, 0.3);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
    font-weight: 500;
}

input[type="text"]:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
    background: white;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

button, .button {
    flex: 1;
    min-width: 100px;
    font-size: 1em;
    padding: 11px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    color: white;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.primary-button {
    background: linear-gradient(135deg, #3498db, #2980b9);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.5);
    background: linear-gradient(135deg, #2980b9, #1f6692);
}

.secondary-button {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    box-shadow: 0 6px 20px rgba(44, 62, 80, 0.4);
}

.secondary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(44, 62, 80, 0.5);
    background: linear-gradient(135deg, #1a252f, #2c3e50);
}

.tertiary-button {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.4);
}

.tertiary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(149, 165, 166, 0.5);
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
}

/* Result page styles */
.message {
    font-size: 1.5em;
    margin: 16px 0;
    padding: 18px;
    border-radius: 15px;
    font-weight: 600;
}

.correct {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
    border: 2px solid rgba(39, 174, 96, 0.3);
}

.incorrect {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    border: 2px solid rgba(231, 76, 60, 0.3);
}

/* Practice page styles */
.practice-container {
    background: rgba(52, 152, 219, 0.05);
    padding: 25px;
    border-radius: 15px;
    margin: 20px 0;
    border: 2px solid rgba(52, 152, 219, 0.1);
}

.element-display {
    font-size: 2.2em;
    font-weight: bold;
    color: #2c3e50;
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 3px solid #3498db;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(52, 152, 219, 0.2);
    border-radius: 5px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border-radius: 5px;
    transition: width 0.5s ease;
}

.feedback {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    border: 2px solid rgba(231, 76, 60, 0.3);
    font-weight: 600;
}

/* ===== SECTION LAYOUT ===== */
#game-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#result-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#practice-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* .hidden overrides display via !important */

/* Mobile responsiveness */
@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    .container {
        padding: 16px 16px 12px;
        border-radius: 16px;
    }

    h1 {
        font-size: 1.4em;
    }

    .subtitle {
        font-size: 0.85em;
        margin-bottom: 6px;
    }

    .header-row {
        margin-bottom: 4px;
    }

    .elements {
        font-size: 1.4em;
    }

    .element-tag {
        font-size: 0.92em;
        padding: 10px 16px;
        margin: 4px;
    }

    .game-info {
        padding: 8px 12px;
        margin-bottom: 6px;
    }

    .timer {
        font-size: 1em;
    }

    .button-group {
        gap: 6px;
        margin-top: 6px;
    }

    button, .button {
        font-size: 0.9em;
        padding: 10px 12px;
        min-width: auto;
    }

    input[type="text"] {
        font-size: 1.05em;
        padding: 10px 14px;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

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

.bounce-in {
    animation: bounceIn 0.8s ease-out;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}