* {
    box-sizing: border-box;
    user-select: none;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 0 auto;
}

.game-area {
    background: rgba(22, 33, 62, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 24px;
    padding: 16px;
    flex: 2;
    min-width: 280px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

/* Кнопка смены имени (крестик) */
.change-name-btn_x {
    background: none;
    border: none;
    color: #e94560;
    font-size: 14px;          /* маленький размер */
    cursor: pointer;
    padding: 0 4px;
    margin-left: 6px;
    font-weight: bold;
    transition: transform 0.1s ease, color 0.2s;
    line-height: 1;
    display: inline-block;
}
.change-name-btn_x:hover {
    transform: scale(1.3);
    color: #ff5a77;
}
.change-name-btn_x:active {
    transform: scale(0.9);
}


.sidebar {
    background: rgba(22, 33, 62, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 24px;
    padding: 16px;
    flex: 1;
    min-width: 220px;
    color: #f0f0f0;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

h1, h2 {
    margin: 0 0 8px 0;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #fff, #e94560);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

.grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(0,0,0,0.2);
    padding: 12px;
    border-radius: 20px;
    margin-bottom: 0px;
}

.row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.cell {
    width: 48px;
    height: 48px;
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid #e94560;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    text-transform: uppercase;
    color: #fff;
    transition: all 0.1s ease;
    box-shadow: 0 3px 0 rgba(0,0,0,0.3);
}

.cell.correct {
    background: #4caf50;
    border-color: #66bb6a;
    box-shadow: 0 0 6px #4caf50;
}
.cell.present {
    background: #ffc107;
    border-color: #ffca28;
    color: #1a1a2e;
    box-shadow: 0 0 6px #ffc107;
}
.cell.absent {
    background: #3a3a4a;
    border-color: #4a4a5a;
    box-shadow: none;
}

.keyboard {
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 20px;
    margin: 12px 0;
}
.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}
.key {
    background: #1e2a3e;
    border: none;
    color: white;
    font-size: 14px;
    font-weight: bold;
    padding: 8px 6px;
    border-radius: 10px;
    min-width: 36px;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.05s linear;
    box-shadow: 0 2px 0 #0a0e14;
    flex-shrink: 0;
}
.key:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #0a0e14;
}
.key.correct { background: #4caf50; box-shadow: 0 2px 0 #2e6b2e; }
.key.present { background: #ffc107; color: #1a1a2e; box-shadow: 0 2px 0 #b97f00; }
.key.absent { background: #737373;; box-shadow: 0 2px 0 #1f1f2a; }

/* Мобильная адаптация клавиатуры */
@media (max-width: 700px) {
    .keyboard { padding: 6px; }
    .keyboard-row { gap: 4px; }
    .key { font-size: 12px; padding: 6px 2px; min-width: 0; flex: 1 1 auto; box-shadow: 0 1px 0 #0a0e14; }
    .key:active { transform: translateY(1px); box-shadow: none; }
}
@media (max-width: 550px) {
    .key { font-size: 10px; padding: 5px 1px; }
}

.controls {
    display: flex;
    gap: 12px;
    margin-top: 0px;
    justify-content: center;
    flex-wrap: wrap;
}
input, button {
    padding: 8px 14px;
    border-radius: 40px;
    border: none;
    font-size: 14px;
    font-weight: 600;
}
#wordInput {
    background: #0f172a;
    color: white;
    text-align: center;
    width: 300px;
    text-transform: uppercase;
    border: 1px solid #e94560;
}
button {
    background: #e94560;
    color: white;
    cursor: pointer;
    box-shadow: 0 3px 0 #8e2a3c;
}
button:hover {
    background: #ff5a77;
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #8e2a3c;
}
button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #8e2a3c;
}
button:disabled {
    opacity: 0.6;
    transform: none;
    cursor: not-allowed;
}

.timer {
    font-size: 16px;
    font-weight: bold;
    /*background: rgba(0,0,0,0.5);*/
    display: inline-block;
    padding: 4px 12px;
    /*border-radius: 30px;*/
    margin-bottom: 16px;
    /*backdrop-filter: blur(4px);*/
    text-align: center;
    width: auto;
    color: #404040;
}

.message {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    padding: 6px;
    border-radius: 24px;
    margin-top: 12px;
    text-align: center;
    font-size: 13px;
    color: #19ff00;
}

.name-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.name-form.hidden { display: none; }
.player-name-display {
    background: rgba(0,0,0,0.5);
    padding: 6px 12px;
    border-radius: 30px;
    margin-bottom: 16px;
    text-align: center;
    font-weight: bold;
    font-size: 15px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    overflow: hidden;
}
.leaderboard-table th, .leaderboard-table td {
    padding: 6px 6px;
    text-align: left;
    border-bottom: 1px solid #3a6ea5;
}
.leaderboard-table th {
    background: #e94560;
    color: white;
}

.my-result {
    margin-top: 16px;
    font-size: 13px;
    background: rgba(233, 69, 96, 0.2);
    padding: 8px;
    border-radius: 20px;
    text-align: center;
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.75);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
.modal-content {
    background: linear-gradient(145deg, #1e2a47, #0f172a);
    color: white;
    margin: auto;
    padding: 20px 24px;
    border-radius: 32px;
    width: 90%;
    max-width: 480px;
    position: relative;
    animation: fadeInUp 0.2s ease;
    box-shadow: 0 20px 30px rgba(0,0,0,0.5);
}

pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.close {
    color: #ccc;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 12px;
}
.close:hover { color: #e94560; }
.modal-content ul { text-align: left; line-height: 1.5; margin-top: 16px; padding-left: 20px; }
.modal-content li { margin: 8px 0; }
.modal-content h2 { margin-top: 0; }

.close-code {
    color: #ccc;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 12px;
}
.close-code:hover { color: #e94560; }

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #e94560;
    color: white;
    padding: 8px 20px;
    border-radius: 40px;
    font-weight: bold;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    font-size: 14px;
}
.toast.show { opacity: 1; }

/* Адаптация для экранов до 900px (ноутбуки) */
@media (max-width: 900px) {
    .cell {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }
    .row {
        gap: 5px;
    }
    .key {
        font-size: 13px;
        padding: 6px 4px;
        min-width: 32px;
    }
    .controls {
        gap: 10px;
    }
    #wordInput {
        width: 110px;
        font-size: 13px;
        padding: 6px 10px;
    }
    button {
        padding: 6px 12px;
        font-size: 13px;
    }
    h1 { font-size: 1.4rem; }
    .timer { font-size: 14px; }
}

@media (max-width: 600px) {
    .cell {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
    .row {
        gap: 4px;
    }
    .game-area, .sidebar {
        padding: 12px;
    }
}