:root {
    --modal-bg-color: transparent; /* Премахваме замъгляването */
    --modal-content-bg: #BCB6B2;
    --settings-label-color: #383838;
    --container-bg-color: #b1aba6;
    --calc-bottom-offset: 0px; /* Отместване за долната част на калкулатора */
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
    background-size: contain;
    background-color: #BFB8B4;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

body.ready {
  opacity: 1;
}

.calculator-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0) + var(--calc-bottom-offset));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    height: auto; /* Динамична височина спрямо съдържанието */
    padding: 10px env(safe-area-inset-left, 0) env(safe-area-inset-bottom, 10px) env(safe-area-inset-right, 0);
    box-sizing: border-box;
    background-color: #BFB8B4;
    z-index: 0;
}

.calculator-img {
    max-height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
    width: auto;
    height: auto;
    max-width: 100%;
    object-fit: contain; /* Запазва съотношението и мащабира умно */
    display: block;
    margin: 0 auto;
}

#currency, #currencyLev {
    position: absolute; /* Абсолютно позициониране спрямо контейнера */
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    color: #d8d9d9;
    z-index: 200; /* Показва валутата над изображението */
    user-select: none; /* Предотвратява селектиране */
}

.statusArea {
    position: fixed;
    background-color: #565749;
    color: white;                   /* светъл текст */
    font-family: 'Arial', sans-serif; /* шрифт Arial */
    font-size: 14px;
    font-weight: bold;
    border: 5px solid #3C3B3B;      /* сив кант */
    border-radius: 4px;
    padding: 2px 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 20px;
    opacity: 0; /* Скрито по подразбиране */
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.5s ease;
    pointer-events: none;
    z-index: 2;
    box-shadow: inset 0 0 4px #535251;  /* вътрешна светлина */
    user-select: none;
    -webkit-user-select: none; /* за Safari */
    touch-action: manipulation;
}

.calculator-display {
    font-family: 'Arial', sans-serif;
    position: absolute;
    color: white;
    display: flex;
    justify-content: flex-end; /* подравняване на текста вдясно */
    align-items: flex-end; /* поставяне на текста долу */
    background: rgba(255,255,255,0);
    border-radius: 5px;
    height: 60px;
    /* Добавяме плавен преход за по-добър ефект */
    transition: background-color 0.3s, box-shadow 0.3s, border-color 0.3s;
    border-bottom: 2px solid transparent; /* Запазва място и избягва "подскачане" на елемента */
}

.calculator-display.active-display {
    background-color: rgba(201, 255, 5, 0.2);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.5);
    border-bottom-color: #C9FF05; /* По-видим цвят за рамката */
}

.layout-settings-grid {
    display: grid;
    grid-template-columns: auto 80px 1fr; /* Label, X input, Y input */
    gap: 8px 5px;      /* 8px вертикално, 2px хоризонтално */
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #a4a4a4;
}

.layout-settings-grid label {
    font-weight: bold;
    color: var(--settings-label-color);
    grid-column: 1;
}

.layout-settings-grid input[type="number"] {
    width: 60px; /* Adjust as needed */
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
}

.settings-section h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Полупрозрачен фон */
    z-index: 1;
    pointer-events: all; /* ← ключово */
    cursor: default; /* принуждава браузъра да отчете повърхност */
}

/* Modal styles */
.modal {
    display: none; /* Hidden by default */
    font-family: 'Arial', sans-serif; /* шрифт Arial */
    position: fixed; /* Stay in place */
    z-index: 10; /* Sit on top, по-висок от statusArea */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: var(--modal-bg-color); /* Black w/ opacity */
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* по подразбиране, но важно */
}

.modal-content {
    background-color: var(--modal-content-bg);
    margin: auto;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 370px;
    position: relative;
    pointer-events: auto;
    z-index: 2;
}

/* Specific background for history modal content to match container */
#historyModal .modal-content {
    background-color: var(--container-bg-color);
    z-index: 9999;
    border: 2px solid #ccc; /* Светъл кант */
    pointer-events: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: var(--settings-label-color); /* Използваме същата променлива като за етикетите */
}

#historyList {
    max-height: 500px; /* Максимална височина на списъка */
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid #eee;
    border-radius: 5px;
}

#historyList li {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    font-size: 1.1em;
    color: #555;
    background-color:rgb(193, 193, 194); /* По-светъл нюанс на сивото за нечетни редове */
}

#historyList li:last-child {
    border-bottom: none;
}

#historyList li:nth-child(even) {
    background-color:rgb(209, 211, 212); /* Малко по-тъмен нюанс на сивото за четни редове */
}

.action-button {
    background-color: #383838;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-grow: 1;
    user-select: none;
    -webkit-user-select: none; /* за Safari */
    touch-action: manipulation;
}

.overlay-marker:hover {
  outline: 3px solid lime;
}

.help-modal-content {
    max-width: 600px;
    margin: auto;
    padding: 16px;
    background: #aca6a2;
    border-radius: 8px;
    font-family: sans-serif;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    position: relative;
}

.help-modal-header {
    position: relative;
    padding-right: 32px;
}

.help-close-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #666;
}

.help-modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.help-modal-table {
    width: 100%;
    /* премахва удвояване на рамката */
    border-collapse: collapse;
    border: 1px solid #000;
}

.help-modal-table tr {
    border-bottom: 1px solid #000;
}

.help-modal-table td {
    border: none;
    padding: 6px;
    vertical-align: middle;
}

.help-modal-table td:nth-child(2) {
    border-left: 1px solid #000;
}

/* Първа колона: ляво подравнена и вертикално центрирана */
.help-key-combo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-align: left;
    min-width: 80px;
}

/* Подредба на съдържанието вътре */
.help-top-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.help-bottom-row {
    font-size: 12px;
    margin-top: 2px;
    color: #555;
    text-align: left;
}

.help-key-combo kbd {
    padding: 2px 6px;
    background: #eee;
    border-radius: 4px;
    font-size: 13px;
}

.help-key-img {
    display: block;
}

/* Втора колона */
.help-key-desc {
    vertical-align: middle;
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
}

/*.help-separator {
    margin: 8px 0;
    border: none;
    border-top: 1px solid #ccc;
}*/

.help-modal-footer {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.help-action-button {
    font-size: 13px;
    padding: 5px 10px;
    background-color: #0078d4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none; /* за Safari */
    touch-action: manipulation;
}

/* Адаптивност за мобилни устройства */
@media (max-width: 480px) {
    .help-modal-content {
        padding: 12px;
        font-size: 13px;
    }

    .help-key-combo {
        min-width: 60px;
    }

    .help-key-desc {
        font-size: 12px;
    }

    .help-close-button {
        font-size: 18px;
        top: 6px;
        right: 6px;
    }
}
