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

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 26px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin-top: 28px;
}

h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.input-group {
    margin-bottom: 34px;
}

.letters-mode {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.letters-chooser .hint {
    margin-bottom: 8px;
}

.mode-btn {
    flex: 1;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: #fff;
}

.mode-btn:focus {
    outline: none;
    border-color: #764ba2;
}

.letters-chooser.hidden {
    display: none;
}

label {
    display: block;
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 8px;
    font-weight: 600;
}

input[type="text"] {
    width: 100%;
    padding: 15px;
    font-size: 1.5rem;
    border: 3px solid #667eea;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    border-color: #764ba2;
}

.hint {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 6px;
}

.template-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
}

.template-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.template-box {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid #667eea;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
    text-transform: uppercase;
}

.template-box:focus {
    border-color: #764ba2;
}

.multiplier-btn {
    width: 50px;
    height: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.multiplier-btn:hover {
    border-color: #667eea;
    background: #f5f5ff;
}

.multiplier-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.multiplier-btn.off {
    border-color: #cfcfcf;
    background: #ededed;
    color: #777;
}

.template-column.off .template-box {
    border-color: #cfcfcf;
    background: repeating-linear-gradient(45deg,
            #f4f4f4,
            #f4f4f4 6px,
            #ededed 6px,
            #ededed 12px);
    color: #999;
}

.template-column.off .template-box:focus {
    border-color: #cfcfcf;
}

.results {
    margin-top: 8px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 10px;
    font-weight: 600;
}

.toggle-scores {
    font-weight: normal;
    color: #667eea;
    text-decoration: none;
    cursor: pointer;
}

.toggle-scores:hover {
    color: #764ba2;
    text-decoration: underline;
}

.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.word {
    background: #f0f0f0;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 500;
    color: #333;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.word.common {
    border-color: #ff9800;
}

.word:hover {
    background: #667eea;
    color: white;
    border-color: #764ba2;
    transform: translateY(-2px);
}

.word-text {
    margin-bottom: 4px;
}

.word-score {
    font-size: 0.9rem;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s, max-height 0.3s;
    color: #666;
}

.word.show-score .word-score {
    opacity: 1;
    max-height: 30px;
}

.word:hover .word-score {
    color: white;
}

.bonus-score {
    color: #ff9800;
}

.word:hover .bonus-score {
    color: #ffd54f;
}

.wildcard-question {
    color: #555;
}

.wildcard-star {
    color: #c41e3a;
}

.word:hover .wildcard-question,
.word:hover .wildcard-star {
    color: white;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    color: #999;
    font-size: 1.1rem;
    padding: 16px 12px;
}

.footer-text {
    max-width: 600px;
    width: 100%;
    margin-top: 34px;
    padding: 0 18px 36px 18px;
    text-align: center;
}

.footer-text p {
    color: #ffffff;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    padding-bottom: 0.9rem;
}

.footer-text a {
    color: #ffd54f;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 213, 79, 0.3);
    transition: all 0.2s;
}

.footer-text a:hover {
    color: #ffeb3b;
}

.highlight-orange {
    color: #ff9800;
    font-weight: 600;
}

@media (max-width: 480px) {
    body {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
        margin-bottom: 18px;
    }

    .container {
        padding: 18px;
        margin-top: 10px;
    }

    .input-group {
        margin-bottom: 30px;
    }

    label {
        font-size: 1.1rem;
        margin-bottom: 7px;
    }

    .results-header {
        font-size: 1.1rem;
    }

    .hint {
        font-size: 0.88rem;
    }

    .letters-mode {
        gap: 6px;
        margin-bottom: 8px;
    }

    .mode-btn {
        padding: 9px 10px;
        font-size: 0.9rem;
        border-radius: 9px;
    }

    input[type="text"] {
        font-size: 1.3rem;
    }

    .template-container {
        gap: 7px;
        margin-bottom: 8px;
    }

    .template-box {
        width: 46px;
        height: 46px;
    }

    .multiplier-btn {
        width: 46px;
        height: 28px;
    }

    .words-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    .word {
        font-size: 1rem;
        padding: 10px;
    }

    .footer-text {
        margin-top: 28px;
        padding: 0 14px 28px 14px;
    }
}