:root {
    --bg-primary: #b8cce5;
    --bg-secondary: #a4a4cc;
    --bg-container: #c8d8eb;
    --text-primary: #005050;
    --text-secondary: #285f69;
    --accent: #176b75;
    --accent-strong: #70b8bd;
    --accent-active: #064750;
    --divider: rgba(255, 255, 255, 0.85);
    --shadow: 0 8px 18px rgba(40, 67, 104, 0.18);
    --shadow-hover: 0 12px 24px rgba(40, 67, 104, 0.28);
    --radius: clamp(4px, 0.5vw, 8px);
    --transition: 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-color: var(--accent) transparent;
    scrollbar-width: auto;
}

body {
    min-height: 100vh;
    padding: clamp(1rem, 2vw, 1.5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    font-family: "Poppins", "Segoe UI", sans-serif;
    line-height: 1.6;
}

.header {
    width: min(100%, 680px);
    margin-bottom: clamp(1.25rem, 3vw, 2rem);
    text-align: center;
}

h1 {
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.5rem, 1.5vw, 0.85rem);
    overflow: hidden;
    color: var(--text-primary);
    font-size: clamp(1.5rem, 6vw, 2.25rem);
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
    white-space: normal;
}

.level-badge {
    flex: 0 0 auto;
    min-height: 2rem;
    padding: 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ffffff;
    border-radius: 999px;
    color: #ffffff;
    background-color: var(--bg-secondary);
    box-shadow: 0 3px 8px rgba(40, 67, 104, 0.16);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
}

.level-description {
    min-width: 0;
    padding-bottom: 0.5rem;
    overflow: hidden;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
}

.progress-container {
    width: 100%;
    height: 16px;
    margin-top: 1rem;
    overflow: hidden;
    border: 1px solid var(--divider);
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.62);
    box-shadow: inset 0 1px 3px rgba(40, 67, 104, 0.18);
}

.progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-active), var(--accent));
    box-shadow: 0 0 10px rgba(23, 107, 117, 0.3);
    transition: width var(--transition);
}

.progress-text {
    margin-top: 0.65rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.level-introduction {
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-style: italic;
    font-weight: 600;
}

.container {
    width: min(100%, 960px);
    display: flex;
    justify-content: center;
    gap: clamp(1rem, 5vw, 3rem);
    padding: clamp(1rem, 3vw, 2rem);
    border: 2px solid var(--divider);
    border-radius: var(--radius);
    background-color: rgba(164, 164, 204, 0.72);
    box-shadow: var(--shadow);
}

.column {
    flex: 1;
    min-width: 0;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.word {
    min-height: 4.5rem;
    height: 4.5rem;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    color: var(--text-primary);
    background-color: var(--bg-container);
    box-shadow: var(--shadow);
    cursor: pointer;
    font-weight: 500;
    line-height: 1.35;
    overflow-wrap: anywhere;
    text-align: center;
    user-select: none;
    transition: var(--transition);
}

.word:hover,
.word:focus-visible {
    border-color: var(--accent);
    background-color: #d8e5f3;
    box-shadow: var(--shadow-hover);
    outline: none;
    transform: translateY(-2px);
}

body[data-read-only="true"] .word {
    cursor: default;
}

body[data-read-only="true"] .word:hover {
    border-color: rgba(255, 255, 255, 0.9);
    background-color: var(--bg-container);
    box-shadow: var(--shadow);
    transform: none;
}

.word.selected {
    border-color: var(--accent-strong);
    color: #ffffff;
    background-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(112, 184, 189, 0.35), var(--shadow);
    transform: scale(1.02);
}

button {
    margin-top: 2rem;
    padding: 0.8rem 1.4rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: #ffffff;
    background-color: var(--accent);
    box-shadow: 0 6px 16px rgba(9, 20, 32, 0.25);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    transition: var(--transition);
}

button:hover,
button:focus-visible {
    background-color: var(--accent-strong);
    box-shadow: var(--shadow-hover);
    outline: none;
    transform: translateY(-2px);
}

.removing {
    animation: fadeOutAndCollapse var(--transition) forwards;
}

@keyframes fadeOutAndCollapse {
    0% {
        opacity: 1;
        height: var(--element-height);
        margin-bottom: 0.85rem;
        transform: translateY(0);
    }
    100% {
        height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
        opacity: 0;
        transform: translateY(-10px);
    }
}

@media (max-width: 600px) {
    body {
        padding: 0.75rem;
    }

    .header {
        margin-bottom: 1rem;
    }

    h1 {
        font-size: clamp(1.4rem, 7vw, 1.9rem);
    }

    .container {
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .column {
        gap: 0.6rem;
    }

    .word {
        padding: 0.5rem;
        font-size: 0.95rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
