* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #121213;
    color: #ffffff;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

/* ---- Контейнер ---- */
.game-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

h1 {
    font-size: 2rem;
    letter-spacing: 2px;
    margin: 0 0 16px 0;
    font-weight: 700;
    color: #d7dadc;
}

/* ---- Переключатели длины ---- */
.length-switcher {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}
.len-btn { padding: 8px 12px; font-size: 0.9rem; }
.len-5 { background: #5ca54a; }
.len-6 { background: #8d4e4e; }
.len-7 { background: #4a6fa5; }

/* ---- Сетка ---- */
.grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
    align-items: center;
}

.row {
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

.tile {
    aspect-ratio: 1 / 1;
    background-color: #3a3a3c;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 8vw, 2rem);
    font-weight: bold;
    text-transform: uppercase;
    color: white;
}
.tile.green  { background-color: #538d4e; }
.tile.yellow { background-color: #b59f3b; }
.tile.gray   { background-color: #3a3a3c; }

/* ---- Ввод ---- */
.input-area {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 16px 0;
    flex-wrap: wrap;
}

#guess-input {
    background: #1e1e1f;
    border: 2px solid #3a3a3c;
    color: white;
    font-size: 1.5rem;
    text-align: center;
    padding: 12px;
    width: 180px;
    border-radius: 8px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: lowercase;
}
#guess-input:focus { outline: none; border-color: #818384; }

/* ---- Кнопки ---- */
button {
    background-color: #818384;
    border: none;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    touch-action: manipulation;
}
button:active { transform: scale(0.96); }

#submit-btn      { background-color: #538d4e; width: 40%; }
#surrender-btn   { background-color: #BC8F8F; }
#word-of-day-btn { background-color: #4a6fa5; }
#leaderboard-btn { background-color: #7b5ea7; }
#feedback-btn    { background-color: #3a3a3c; font-size: 0.9rem; padding: 8px 16px; }

.btn-success   { background-color: #538d4e; }
.btn-secondary { background-color: #818384; }

/* ---- Сообщение ---- */
.message {
    background: #1e1e1f;
    margin-top: 16px;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #d7dadc;
}

#rating-status {
    font-size: 0.8rem;
    color: #888;
    margin-top: 8px;
    min-height: 1.2em;
}
#rating-status.tg { color: #b59f3b; }

/* ---- Подвал ---- */
footer {
    font-size: 0.7rem;
    color: #6b6b6e;
    margin-top: 24px;
    margin-bottom: 8px;
}

.feedback-button-container {
    text-align: center;
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* ---- Модальные окна ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-box {
    background: #1e1e1f;
    padding: 24px;
    border-radius: 16px;
    max-width: 420px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}
.modal-box h3 { margin-top: 0; }

.modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    color: #888;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-input {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    background: #3a3a3c;
    border: none;
    color: white;
    border-radius: 6px;
}

.modal-textarea {
    resize: vertical;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-status {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #d7dadc;
}

/* ---- Никнейм ---- */
.modal-nickname {
    border: 2px solid #7b5ea7;
}
.nickname-title { color: #7b5ea7; }
.nickname-desc {
    font-size: 0.85rem;
    color: #aaa;
}

#nickname-input {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    background: #3a3a3c;
    border: 2px solid #555;
    color: white;
    border-radius: 6px;
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 1px;
}
#nickname-input:focus { outline: none; border-color: #7b5ea7; }

#nickname-hint {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 12px;
}
#nickname-error {
    font-size: 0.82rem;
    color: #f87171;
    min-height: 1.2em;
    margin-bottom: 8px;
}

#nickname-submit-btn {
    background-color: #7b5ea7;
    width: 100%;
    font-size: 1.1rem;
}
#nickname-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Победитель ---- */
.winner-title { color: #ffd700; }

/* ---- Рейтинг ---- */
.lb-title { margin-bottom: 4px; }
.lb-desc {
    font-size: 0.78rem;
    color: #666;
    margin-top: 4px;
}
.lb-loading {
    text-align: center;
    color: #666;
    padding: 20px;
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 16px 0 0 0;
}
.lb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    background: #2a2a2c;
    transition: background 0.15s;
}
.lb-item.gold   { background: #3a3010; border-left: 3px solid #ffd700; }
.lb-item.silver { background: #2a2e35; border-left: 3px solid #c0c0c0; }
.lb-item.bronze { background: #2e2218; border-left: 3px solid #cd7f32; }

.lb-rank {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}
.lb-name {
    flex: 1;
    font-size: 0.95rem;
    text-align: left;
    color: #d7dadc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lb-pts {
    font-size: 0.9rem;
    font-weight: 700;
    color: #b59f3b;
    white-space: nowrap;
}
.lb-empty {
    text-align: center;
    color: #666;
    padding: 24px 0;
    font-size: 0.9rem;
}
.lb-note {
    font-size: 0.75rem;
    color: #555;
    margin-top: 12px;
    text-align: center;
}

/* ---- Адаптив ---- */
@media (max-width: 480px) {
    .row { gap: 5px; }
    .tile { font-size: clamp(1rem, 6vw, 1.5rem); }
}
@media (max-width: 450px) {
    .tile { font-size: 1.5rem; }
    #guess-input { width: 140px; font-size: 1.2rem; }
    button { padding: 10px 16px; }
}