:root {
    --primary-color: #5d4037;
    --secondary-color: #3e2723;
    --accent-color: #d84315;
    --text-color: #efebe9;
    --bg-color: #2b1d0e;
    --input-bg: #3e2723;
    --border-color: #795548;
}

body {
    background-color: #2b1d0e;
    background-image: 
        radial-gradient(circle at center, rgba(93, 64, 55, 0.4) 0%, rgba(43, 29, 14, 0.8) 100%),
        url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    background-attachment: fixed;
    color: var(--text-color);
    font-family: 'Old Standard TT', serif;
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 0 0 20px 0; /* Прибираємо відступ зверху, залишаємо тільки знизу */
    box-sizing: border-box;
}

/* Логіка миттєвого входу */
html.is-logged-in #login-screen { display: none !important; }
html.is-logged-in #main-screen { display: flex !important; }

#login-screen {
    justify-content: center;
    padding: 20px; /* Повертаємо відступи для екрана логіна */
}

@media (max-width: 800px) {
    #login-screen {
        justify-content: flex-start;
        padding-top: 10vh; /* Піднімаємо вгору на мобільному */
    }
}

.saloon-box {
    background: var(--primary-color);
    padding: 50px 30px; /* Збільшив відступи для кращого вигляду квадрата */
    border: 5px double var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    text-align: center;
    max-width: 380px; /* Трохи ширше */
    width: calc(100% - 40px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Центруємо контент всередині квадрата */
}

@media (min-width: 801px) {
    .saloon-box {
        aspect-ratio: 1 / 1; /* Квадратне на ПК */
    }
}

#login-error {
    text-shadow: 1px 1px 1px #000;
    color: #fff !important;
}

.login-title {
    font-size: 1.8rem !important; /* Менший заголовок спеціально для логіна */
    margin-bottom: 25px;
    margin-top: 20px;
    font-weight: 700;
}

h1 {
    font-family: 'Rye', cursive;
    font-size: 2.5rem;
    margin: 0; /* Прибираємо зовнішні відступи */
    text-shadow: 3px 3px #000;
    color: #ffcc80;
    letter-spacing: 2px;
}

header {
    width: 100%;
    text-align: center;
    padding: 15px 0; /* Трохи збільшив вертикальні відступи для балансу */
    background: rgba(0,0,0,0.4); /* Трохи темніший фон для контрасту */
    border-bottom: 2px solid #ffcc80; /* Колір як у літер */
    margin-bottom: 25px;
    box-sizing: border-box;
}

input, button {
    padding: 10px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
}

input {
    background: var(--input-bg);
    color: #fff;
    width: calc(100% - 22px);
}

button {
    background: var(--accent-color);
    color: #fff;
    cursor: pointer;
    border: none;
    /* Тінь прибрано */
    transition: all 0.1s;
    text-transform: uppercase;
    padding: 12px 25px 8px 25px; /* Злегка зміщуємо текст вниз */
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    align-self: center;
    min-width: 150px;
}

button:active {
    /* Ефект натискання вниз прибрано, бо немає тіні */
    opacity: 0.8;
}

button:disabled {
    background: #666;
    cursor: not-allowed;
}

.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 1600px;
    width: 100%;
}

@media (max-width: 800px) {
    .container {
        grid-template-columns: 1fr;
    }
    .screen {
        padding: 10px; /* Менші відступи по боках */
    }
    header {
        padding: 5px; /* Компактний хедер */
        margin-bottom: 10px;
    }
    h1 {
        font-size: 1.4rem; /* Значно менший заголовок на мобільних */
        margin-bottom: 5px;
        letter-spacing: 1px;
    }
}

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

h2 {
    font-family: 'Kelly Slab', cursive;
    color: #ffcc80;
    text-align: left;
    text-shadow: 2px 2px #000;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    text-transform: uppercase;
    font-size: 1.8rem;
    letter-spacing: 1px;
}

h2::after {
    content: "";
    height: 1px;
    background: #ffcc80;
    flex: 1;
    box-shadow: 1px 1px 2px #000;
    opacity: 0.8; /* Трохи приглушимо, щоб текст залишався головним */
}

h2::before {
    display: none;
}

/* Склад у 5 ячейки для десктопа */
@media (min-width: 801px) {
    #ingredients-list {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Стиль виділення тексту */
::selection {
    background-color: var(--accent-color);
    color: #fff;
}

input::selection {
    background-color: #ffcc80;
    color: #2b1d0e;
}

.ingredient-item {
    background: linear-gradient(315deg, #1a110a 0%, var(--secondary-color) 100%);
    padding: 10px;
    border: 1px solid #2a1a15;
    border-radius: 4px;
    position: relative;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 1px 1px 6px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.5);
}

.ingredient-item label {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    color: #ffcc80;
    text-align: left;
    margin-bottom: 5px;
    pointer-events: none;
    letter-spacing: 0.5px;
}

.ingredient-item input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    text-align: right;
    font-size: 1.2rem;
    font-weight: bold;
    width: 100%;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield; /* Прибираємо стрілочки у Firefox */
    -webkit-touch-callout: none; /* ВИМИКАЄМО меню Android (Копіювати/Дзвонити) */
    -webkit-user-select: text; /* Але дозволяємо ввід тексту */
    user-select: text;
}

/* Прибираємо стрілочки у Chrome/Safari/Edge */
.ingredient-item input::-webkit-outer-spin-button,
.ingredient-item input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ingredient-item input:focus {
    color: var(--accent-color);
}

.recipe-card {
    background: linear-gradient(315deg, #1a110a 0%, var(--primary-color) 100%);
    padding: 15px;
    border: 2px solid #2a1a15;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 1px 1px 8px rgba(0,0,0,0.4), 0 6px 15px rgba(0,0,0,0.6);
    position: relative; /* Для позиціонування хрестика */
}

/* Прогресбар у стилі кнопки */
.button-progress-container {
    --progress: 0%; /* Керуємо прогресом через змінну */
    padding: 0;
    margin: 10px 0;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    align-self: center;
    min-width: 150px;
    height: 36px; /* Зменшив на 2px для точного збігу з кнопкою */
    /* Основне тіло кнопки: зліва золотисте, справа ДУЖЕ темно-сіре */
    background: linear-gradient(to right, #ffcc80 var(--progress), #1a1a1a var(--progress));
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

/* Динамічна тінь кнопки через псевдоелемент */
/* (Хоча ми її приховали раніше, я залишу правильний колір про всяк випадок) */
.button-progress-container::after {
    display: none; /* Тінь прибрана згідно попереднього запиту */
}

.button-progress-text {
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
    z-index: 2;
    padding-top: 2px; /* Злегка зміщуємо вниз */
}

/* Маленький хрестик у кутку */
.card-cancel-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.3);
    color: #ffcc80;
    border: 1px solid var(--border-color);
    width: 24px; /* Трохи збільшив для кращого вигляду */
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    z-index: 10;
    box-sizing: border-box; /* Гарантуємо ідеальний квадрат */
    padding: 0;
    line-height: 1;
}

.card-cancel-btn:hover {
    background: var(--accent-color);
    color: #fff;
}

.recipe-card h3 {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    color: #ffcc80;
    letter-spacing: 0.5px;
    min-height: 2.5rem; /* Займає 2 строки */
    display: flex;
    align-items: flex-start; /* Вирівнюємо зверху */
    justify-content: flex-start; /* Вирівнюємо зліва як на складі */
    text-align: left;
}

.recipe-card .portions {
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.oven-box {
    background: #1a1a1a;
    padding: 15px;
    border: 3px solid #111;
    border-bottom-color: #333;
    border-right-color: #333;
    border-top-color: #000;
    border-left-color: #000;
    border-radius: 8px;
    margin-bottom: 20px;
    position: relative;
    height: 120px; /* Фіксована висота, щоб не стрибало */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.8);
    box-sizing: border-box;
}

#oven-idle-text, #progress-container {
    position: absolute;
    width: calc(100% - 30px);
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}

#progress-container {
    flex-direction: column;
    align-items: center;
}

#cooking-text {
    margin: 0 0 2px 0;
    font-size: 0.9rem;
    color: #fff;
}

.progress-bar-bg {
    background: #444;
    height: 30px; /* Трохи збільшив висоту для тексту всередині */
    border-radius: 15px;
    overflow: hidden;
    margin: 10px 0;
    width: 250px;
    position: relative;
    border: 2px solid #222;
}

#timer-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none;
    z-index: 10;
    padding-top: 2px; /* Коригування для візуального центру */
}

#progress-bar {
    background: var(--accent-color);
    height: 100%;
    width: 0%;
    transition: width 0.5s;
}

.cancel-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #444;
    padding: 2px 8px;
    font-size: 12px;
    margin: 0;
    box-shadow: none;
    min-width: 0; /* Виправляємо розтягнення */
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(40, 30, 20, 0.4); /* Напівпрозорий коричнево-сірий фон */
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px); /* М'якше розмиття */
    -webkit-backdrop-filter: blur(4px);
}

.modal-box {
    max-width: 300px;
    padding: 30px 20px;
    border: 3px double var(--border-color);
}

.modal-box p {
    color: #ffcc80;
    text-transform: uppercase;
    font-size: 1rem;
    margin-bottom: 10px;
}

.modal-box button {
    min-width: 80px;
}

.cancel-btn:hover {
    background: #666;
}

/* Стилі для модального вікна рецептів */
.recipes-modal-box {
    max-width: 90%;
    width: 1000px;
    height: 80vh;
    padding: 40px;
    background: #e6d4a7 !important; /* Колір старого паперу */
    background-image: url('https://www.transparenttextures.com/patterns/paper.png') !important;
    border: 15px solid #3e2723 !important;
    border-image: url('https://www.transparenttextures.com/patterns/dark-leather.png') 30 round !important;
    color: #3e2723 !important;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden; /* Щоб заголовок не скролився, якщо захочемо, але тут краще весь контент */
}

.recipes-modal-box h2 {
    color: #3e2723 !important;
    text-shadow: none !important;
    border-bottom: 2px double #3e2723;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.recipes-modal-box h2::after {
    display: none;
}

#recipes-modal-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 15px;
    /* Стилізація скроллбару */
}

#recipes-modal-content::-webkit-scrollbar {
    width: 8px;
}

#recipes-modal-content::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

#recipes-modal-content::-webkit-scrollbar-thumb {
    background: #3e2723;
    border-radius: 4px;
}

.recipes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 800px) {
    .recipes-grid {
        grid-template-columns: 1fr;
    }
    .recipes-modal-box {
        width: 95%;
        padding: 20px;
        border-width: 8px !important;
    }
}

.recipe-item {
    border-bottom: 1px solid rgba(62, 39, 35, 0.2);
    padding-bottom: 15px;
}

.recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.recipe-header h2 {
    font-size: 1.2rem !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.recipe-meta {
    font-size: 0.85rem;
    font-weight: bold;
    opacity: 0.7;
}

.ing-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ing-list li {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dotted rgba(62, 39, 35, 0.3);
    font-size: 1.1rem;
}

.ing-list li:last-child {
    border-bottom: none;
}

.ing-list li b {
    color: #8d2b0b;
}
