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

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f5f3f0;
    font-family: system-ui, 'Segoe UI', Roboto, sans-serif;
    padding: 1.5rem;
}

/* ----- Общий контейнер (как .trainer) ----- */
#content, .trainer-container {
    width: 100%;
    max-width: 900px;
    background: #ffffff;
    border-radius: 2.5rem;
    padding: 2rem 1.8rem 2.5rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    margin: 0 auto;
}

/* ----- Заголовки h1-h3 ----- */
h1, h2, h3, .page-title {
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    font-weight: 500;
    color: #2c3e50;
    text-align: center;
    margin-bottom: 1.8rem;
    border-bottom: 2px solid #eae7e3;
    padding-bottom: 0.75rem;
}

h3 {
    font-size: 90px;
    border-bottom: none;
    margin-bottom: 10px;
    color: #3d5166;
}

/* ----- Кнопки (общий стиль) ----- */
input[type="button"], button, .btn {
    display: inline-block;
    background: linear-gradient(145deg, #f6f4f0, #e8e3dc);
    border: none;
    border-radius: 1.2rem;
    padding: 0.6rem 1.8rem;
    font-size: 96px;
    font-weight: 600;
    color: #1e2b37;
    box-shadow: 0 3px 0 #cbc3b8, 0 4px 10px rgb(0 0 0 / 4%);
    cursor: pointer;
    transition: all 0.1s ease;
    text-decoration: none;
    font-family: inherit;
    margin: 25px;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 0 rgb(255 255 255 / 50%);
}

input[type="button"]:hover, button:hover, .btn:hover {
    transform: scale(1.02);
    background: #eae5dd;
    box-shadow: 0 3px 0 #b9b0a4, 0 6px 14px rgba(0, 0, 0, 0.06);
}

input[type="button"]:active, button:active, .btn:active {
    transform: scale(0.94);
    box-shadow: 0 1px 0 #b9b0a4;
    background: #ddd7cd;
}

/* ----- Поля ввода (текстовые) ----- */
input[type="text"], input[type="number"], .example {
    background: #f8f7f5;
    border: 2px solid #e0dbd4;
    border-radius: 1rem;
    padding: 1rem;
    font-size: 65px;
    font-family: inherit;
    color: #1e2b37;
    transition: border-color 0.2s ease;
    text-align: center;
    width: 215px;
}

input[type="text"]:focus, input[type="number"]:focus, .example:focus {
    outline: none;
    border-color: #8a9aa8;
    box-shadow: 0 0 0 3px rgba(90, 122, 154, 0.15);
}

/* ----- Таблицы (общие стили) ----- */
table {
    border-collapse: separate;
    border-spacing: 0.5rem;
    margin: 1.2rem auto;
    width: 90%;
    max-width: 700px;
    table-layout: fixed;
}

table td, table th {
    background: #f0ede8;
    border-radius: 1.2rem;
    padding: 0.8rem;
    text-align: center;
    font-size: clamp(1.2rem, 4vw, 2.6rem);
    font-weight: 600;
    color: #1e2b37;
    box-shadow: 0 2px 0 #cbc3b8, 0 4px 8px rgba(0, 0, 0, 0.03);
    transition: all 0.1s ease;
    border: none;
    aspect-ratio: 1 / 1;
    width: 33.333%;
}

/* ----- Специфичные стили для memory.html ----- */
#manage {
    text-align: center;
    padding: 0.5rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

#manage span {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 500;
    color: #2c3e50;
}

#manage input[type="text"] {
    width: 80px;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    text-align: center;
    margin: 0 0.5rem;
}

#info {
    text-align: center;
    font-size: clamp(1rem, 2vw, 1.4rem);
    margin: 0.8rem auto;
    padding: 0.8rem;
    background: #f8f7f5;
    border-radius: 1.5rem;
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
}

#info #search {
    color: #339933;
    font-weight: 700;
}

#info #errors {
    color: #cc3333;
    font-weight: 700;
}

#info #nextLvl, #info #currLvl {
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    padding: 0.3rem 1.2rem;
    margin: 0 0.3rem;
}

/* Поле memory — ячейки */
#fieldsTable {
    margin: 0.8rem auto;
    touch-action: manipulation;
    width: 90%;
    max-width: 650px;
}

#fieldsTable tr td {
    border: none;
    padding: 0;
    aspect-ratio: 1 / 1;
    width: 33.333%;
    border-radius: 1.2rem;
    background: #e8e3dc;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.15s ease;
}

#fieldsTable tr td.black {
    background: #2c4a7a;
    box-shadow: 0 3px 0 #1a2f4f, 0 4px 12px rgba(0, 0, 0, 0.15);
}

#fieldsTable tr td.valid {
    background: #339933;
    box-shadow: 0 3px 0 #1f6b1f, 0 4px 12px rgba(0, 0, 0, 0.12);
}

#fieldsTable tr td.invalid {
    background: #999999;
    box-shadow: 0 3px 0 #6b6b6b, 0 4px 12px rgba(0, 0, 0, 0.08);
}

#fieldsTable tr td:hover:not(.black):not(.valid):not(.invalid) {
    transform: scale(1.03);
    background: #ddd7cd;
}

/* ----- Стили для attention.html ----- */
#tableItem {
    margin: 1rem auto;
    width: 90%;
    max-width: 650px;
    border-collapse: separate;
    border-spacing: 1rem;
}

#tableItem td {
    border: none;
    border-radius: 1.2rem;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 700;
    text-align: center;
    width: 116px;
    padding: 30px 0;
    aspect-ratio: 1 / 1;
    background: #e8e3dc;
    box-shadow: 0 2px 0 #cbc3b8, 0 4px 8px rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition: all 0.1s ease;
    color: #1e2b37;
}

#tableItem td:hover {
    transform: scale(1.03);
    background: #ddd7cd;
}

#progres, #result {
    font-size: clamp(1rem, 2vw, 1.6rem);
    font-weight: 500;
    text-align: center;
    margin: 0.5rem 0;
    padding: 0.5rem;
    color: #2c3e50;
}

#progres {
    color: #2c4a7a;
}

#errors {
    color: #cc3333;
    font-weight: 700;
}

#time {
    color: #2c3e50;
    font-weight: 500;
}

#result {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    background: #f8f7f5;
    border-radius: 1.5rem;
    padding: 0.8rem 1.5rem;
    margin-top: 0.8rem;
}

/* ----- Стили для count.html ----- */
#countForm {
    width: 100%;
    margin: 0 auto;
}

.countItem {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem 1rem;
    background: #f8f7f5;
    border-radius: 1.5rem;
    padding: 0.6rem 1.2rem;
    margin: 0.5rem auto;
    width: 100%;
}

.countItem span {
    font-weight: 600;
    color: #1e2b37;
    font-size:90px;
}

.countItem .example:focus {
    border-color: #8a9aa8;
}

.countItem #show0, .countItem #show1, .countItem #show2,
.countItem #show3, .countItem #show4, .countItem #show5,
.countItem #show6, .countItem #show7, .countItem #show8,
.countItem #show9 {
    font-weight: 700;
    min-width: 40px;
}

/* Кнопка "Завершить" */
#send {
    font-size: 90px;
    padding: 0.6rem 2.5rem;
    margin: 0.5rem 0;
}

#result {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1.5rem 2.5rem;
    background: #f8f7f5;
    border-radius: 1.5rem;
    padding: 0.8rem 1.5rem;
    margin-top: 0.8rem;
}

#correct {
    color: #339933;
    font-weight: 700;
}

/* ----- Адаптивность (резина) ----- */
@media (max-width: 600px) {
    body {
        padding: 0.8rem;
    }
    
    #content, .trainer-container {
        padding: 1rem 0.8rem 1.5rem;
        border-radius: 1.8rem;
    }
    
    table, #fieldsTable, #tableItem {
        border-spacing: 0.3rem;
        width: 95%;
    }
    
    table td, #fieldsTable tr td, #tableItem td {
        border-radius: 0.9rem;
        font-size: clamp(1.2rem, 4vw, 2rem);
        padding: 0.3rem;
    }
    
    .countItem {
        padding: 0.4rem 0.6rem;
        gap: 0.3rem;
        font-size: clamp(1rem, 2.5vw, 1.4rem);
        border-radius: 1rem;
    }
    
    .countItem .example {
        width: 80px;
        font-size: clamp(1rem, 2vw, 1.4rem);
    }
    
    input[type="button"], button, .btn {
        padding: 0.4rem 1rem;
        font-size: clamp(0.8rem, 1.5vw, 1rem);
        border-radius: 0.9rem;
    }
    
    #manage input[type="text"] {
        width: 60px;
        font-size: clamp(1rem, 2vw, 1.4rem);
    }
    
    #info {
        font-size: clamp(0.8rem, 1.5vw, 1rem);
        padding: 0.5rem;
    }
    
    #result {
        padding: 0.5rem 1rem;
        gap: 0.8rem;
        font-size: clamp(0.8rem, 1.5vw, 1rem);
    }
    
    #progres, #result {
        font-size: clamp(0.9rem, 1.8vw, 1.2rem);
    }
}

@media (max-width: 400px) {
    table, #fieldsTable, #tableItem {
        border-spacing: 0.2rem;
        width: 98%;
    }
    
    table td, #fieldsTable tr td, #tableItem td {
        border-radius: 0.6rem;
        font-size: clamp(0.9rem, 3vw, 1.4rem);
        padding: 0.2rem;
    }
    
    .countItem .example {
        width: 60px;
        font-size: clamp(0.8rem, 2vw, 1.2rem);
    }
    
    #manage {
        flex-direction: column;
        gap: 0.3rem;
    }
}

/* ----- Общие утилиты ----- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none; }