:root {
    --shop-page-background: rgba(189, 86, 63, 0.21);
    --shop-card-background: rgba(19, 94, 49, 0.38);
    --shop-control-background: rgba(58, 156, 160, 0.65);
    --shop-info-background: rgba(95, 58, 160, 0.38);
    --shop-border-color: rgb(11, 37, 75);
    --text-color: #071d3b;
}

/* Elementy ukrywane przez logikę ekranów. */
.hidden {
    display: none !important;
}

/* Podstawowy układ strony. */
body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: "Tagesschrift", system-ui;
    font-weight: 400;
    font-style: normal;
    background-image: url(res/img/background.png);
    background-repeat: no-repeat;
    background-size: cover;
}

.site-footer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    padding: 6px 12px;
    color: #d7eeee;
    background: rgb(27, 103, 126);
    border-top: 1px solid rgb(11, 37, 75);
    box-shadow: 0 -4px 10px rgba(5, 23, 57, 0.3);
    text-align: center;
    font-size: 12px;
}

.site-footer a {
    color: #e2f2ef;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* Kolor tego kontenera pozostaje bez zmian. */
.main {
    width: 50%;
    height: max-content;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background-color: rgb(27, 103, 126);
    box-shadow: 10px 10px rgb(19, 67, 79);
    border: 1px solid rgb(11, 37, 75);
}

#titleheader {
    margin-top: 0.67em;
    font-family: "New Rocker", system-ui;
    font-weight: 400;
    font-style: normal;
    font-size: 30px;
    text-shadow: 0 2px 5px rgb(47, 172, 255);
}

#titleedition {
    margin-bottom: 20px;
    font-size: 18px;
    text-shadow: 0 2px 5px rgb(47, 172, 255);
}

button,
input {
    font-family: "Tagesschrift", system-ui;
    font-weight: 400;
    font-style: normal;
}

button {
    border: 1px solid var(--shop-border-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 7px 10px;
    background: var(--shop-control-background);
    transition: transform 120ms ease, filter 120ms ease, background-color 120ms ease;
}

button:hover:not(:disabled) {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#main-buttons button,
#main-playerModel button,
#login-screen button,
#login-screen input {
    background: rgba(90, 130, 121, 0.65) !important;
}

/* Ekran logowania. */
#login-screen {
    width: 70%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 3px;
    border: 1px solid black;
    text-align: center;
    background-color: var(--shop-page-background);
    box-shadow: 6px 6px rgb(10, 68, 91), inset 0 0 18px rgba(5, 23, 57, 0.28);
}

#login-screen input {
    background: var(--shop-control-background);
}

/* Menu główne. */
#main-menu {
    width: 80%;
    display: flex;
    gap: 10px;
    align-items: stretch;
}

#main-playerSummary,
#main-playerModel {
    width: 50%;
    box-sizing: border-box;
    border: 1px solid black;
    background: var(--shop-page-background);
    box-shadow: 6px 6px rgb(17, 89, 117), inset 0 0 18px rgba(5, 23, 57, 0.28);
}

#main-playerSummary {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    text-align: left;
    font-weight: 300;
}

#main-playerModel {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 3px;
    text-align: left;
    font-weight: 300;
}

#main-buttons {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

#main-buttons #play-btn,
#main-buttons #options-btn {
    grid-column: 1 / -1;
}

/* Wspólne style ekranu walki i sklepu. */
#battle-screen,
#shop-screen,
#inventory-screen {
    width: 92%;
    box-sizing: border-box;
    padding: 14px;
    border: 1px solid black;
    background: var(--shop-page-background);
    box-shadow: inset 0 0 30px rgba(5, 23, 57, 0.35);
}

.battle-header,
.stat-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.battle-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.55);
}

.battle-header h2,
.combatant h3,
.shop-header h2,
.shop-section h3,
.shop-item h4 {
    margin: 2px 0;
    font-family: "New Rocker", system-ui;
    font-weight: 400;
}

.battle-header h2,
.shop-header h2 {
    font-size: 24px;
}

.eyebrow,
.combatant-label {
    font-size: 11px;
    letter-spacing: 2px;
    opacity: 0.8;
}

#battle-wave {
    padding: 5px 8px;
    border: 1px solid black;
    background: var(--shop-info-background);
}

.battle-arena {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    gap: 10px;
}

.combatant {
    min-width: 0;
    padding: 10px;
    border: 1px solid black;
    background: var(--shop-card-background);
}

.combatant h3 {
    min-height: 42px;
    font-size: 18px;
}

.battle-model,
.enemy-silhouette {
    display: flex;
    height: 220px;
    align-items: center;
    justify-content: center;
    margin: 6px 0 10px;
    border: 1px solid rgba(0, 0, 0, 0.6);
    background: var(--shop-info-background);
}

.battle-model img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
}

.enemy-silhouette {
    color: #142e55;
    font-size: 68px;
    text-shadow: 0 0 12px rgba(47, 172, 255, 0.8);
}

.health-bar {
    height: 12px;
    margin: 5px 0 8px;
    overflow: hidden;
    border: 1px solid black;
    background: rgba(0, 0, 0, 0.4);
}

.health-bar span {
    display: block;
    width: 100%;
    height: 100%;
    background: #35c46a;
    transition: width 180ms ease;
}

.enemy-health-bar span {
    background: #e15b61;
}

.combatant p {
    min-height: 18px;
    margin: 7px 0 0;
    font-size: 12px;
}

.battle-versus {
    display: flex;
    align-items: center;
    color: var(--text-color);
    font-family: "New Rocker", system-ui;
    font-size: 20px;
}

.battle-log,
.shop-message {
    min-height: 18px;
    box-sizing: border-box;
    padding: 9px;
    border: 1px solid black;
    background: var(--shop-info-background);
    text-align: center;
}

.battle-log {
    min-height: 38px;
    margin: 12px 0 8px;
}

.battle-log.success,
.shop-message.success {
    background: rgba(49, 158, 83, 0.4);
}

.battle-log.warning,
.shop-message.warning {
    background: rgba(187, 151, 36, 0.4);
}

.battle-log.danger,
.shop-message.danger {
    background: rgba(179, 48, 58, 0.42);
}

.battle-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.secondary-button {
    width: 100%;
}

/* Sklep. */
.shop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.55);
}

#shop-money,
.shop-current-weapon {
    padding: 7px 9px;
    border: 1px solid black;
    background: var(--shop-info-background);
}

.shop-current-weapon {
    margin-bottom: 12px;
}

.shop-sections {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.shop-section {
    margin-top: 14px;
}

.shop-section h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.shop-items {
    display: grid;
    grid-template-columns: 1fr;
    max-height: 300px;
    gap: 8px;
    overflow-y: auto;
    align-content: start;
    padding: 2px 6px 6px 2px;
    overscroll-behavior: contain;
    scrollbar-color: var(--shop-border-color) rgba(5, 28, 69, 0.28);
}

.shop-item {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 8px;
    border: 1px solid black;
    background: var(--shop-card-background);
}

.shop-item h4 {
    min-height: 38px;
    font-size: 15px;
}

.shop-item p {
    margin: 4px 0;
    font-size: 12px;
}

.shop-item .shop-description {
    min-height: 42px;
    color: var(--text-color);
}

.shop-message {
    margin: 12px 0 8px;
}

/* Ekwipunek. */
.inventory-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.inventory-current,
.inventory-owned {
    min-width: 0;
    margin-top: 14px;
}

.inventory-current h3,
.inventory-owned h3 {
    margin: 2px 0 8px;
    font-family: "New Rocker", system-ui;
    font-size: 18px;
    font-weight: 400;
}

.inventory-current-card {
    min-height: 120px;
    padding: 12px;
    border: 1px solid black;
    background: var(--shop-info-background);
}

.inventory-current-card h4 {
    margin: 0 0 8px;
    font-family: "New Rocker", system-ui;
    font-size: 20px;
    font-weight: 400;
}

.inventory-current-card p {
    margin: 6px 0;
}

.inventory-current-card span {
    font-size: 12px;
    opacity: 0.85;
}

.inventory-item-equipped {
    border-color: #f0d36a;
    box-shadow: inset 0 0 0 1px #f0d36a;
}

.inventory-item-selected {
    outline: 2px solid var(--shop-control-background);
}

.inventory-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Responsywność. */
@media (max-width: 760px) {
    body {
        justify-content: center;
        box-sizing: border-box;
        padding: 12px 12px 44px;
    }

    .main {
        width: min(100%, 620px);
        margin: 0;
        box-sizing: border-box;
    }

    #main-menu,
    #battle-screen,
    #shop-screen,
    #inventory-screen {
        width: 100%;
    }

    #start-screen,
    #login-screen {
        width: 100%;
    }

    #main-menu {
        flex-direction: column;
    }

    #main-playerSummary,
    #main-playerModel {
        width: 100%;
    }

    #main-playerModel img {
        max-width: 100%;
        max-height: 220px;
        object-fit: contain;
    }

    #battle-screen,
    #shop-screen {
        padding: 10px;
    }

    .battle-arena {
        grid-template-columns: 1fr;
    }

    .battle-versus {
        justify-content: center;
        height: 24px;
    }

    .battle-header,
    .shop-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .battle-header h2,
    .shop-header h2 {
        font-size: 22px;
    }

    .shop-sections {
        grid-template-columns: 1fr;
    }

    .inventory-layout {
        grid-template-columns: 1fr;
    }

    .shop-items {
        max-height: 260px;
    }
}

@media (max-width: 520px) {
    body {
        align-items: flex-start;
        padding: 8px 8px 44px;
    }

    .main {
        width: 100%;
        margin: 8px 0 0;
        padding: 8px;
    }

    #titleheader {
        margin-bottom: 8px;
        font-size: 25px;
        text-align: center;
    }

    #titleedition {
        margin-bottom: 14px;
        font-size: 16px;
    }

    #main-menu,
    .battle-arena {
        flex-direction: column;
    }

    #main-buttons {
        grid-template-columns: 1fr 1fr;
    }

    #main-playerSummary,
    #main-playerModel {
        width: 100%;
    }

    .battle-arena {
        grid-template-columns: 1fr;
    }

    .battle-versus {
        justify-content: center;
        height: 24px;
    }

    .battle-actions {
        grid-template-columns: 1fr;
    }

    .inventory-actions {
        grid-template-columns: 1fr;
    }

    button,
    input {
        min-height: 42px;
        box-sizing: border-box;
        font-size: 15px;
    }

    input {
        padding: 8px 10px;
    }

    .stat-line {
        gap: 8px;
    }

    .combatant h3 {
        min-height: 0;
    }

    .shop-items {
        max-height: 230px;
    }

    .site-footer {
        padding: 7px 5px;
        font-size: 10px;
        line-height: 1.35;
    }
}

/* Ekran startowy, modal opcji i ekran śmierci. */
#start-screen {
    width: 70%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    box-sizing: border-box;
    border: 1px solid black;
    background: var(--shop-page-background);
}

.screen-message {
    min-height: 18px;
    margin: 4px 0 0;
    text-align: center;
}

.screen-message.success {
    color: #d6f5dd;
}

.screen-message.warning {
    color: #fff0b2;
}

.screen-message.danger {
    color: #ffd0d0;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.65);
}

.modal-content {
    width: min(100%, 560px);
    box-sizing: border-box;
    padding: 16px;
    border: 1px solid black;
    background: rgb(27, 103, 126);
    box-shadow: 8px 8px rgb(17, 57, 117);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    font-family: "New Rocker", system-ui;
    font-weight: 400;
}

.modal-close {
    width: 36px;
    padding: 6px;
}

#save-code {
    width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
    padding: 8px;
    resize: vertical;
    border: 1px solid black;
    color: var(--control-text-color);
    background: var(--shop-info-background);
}

.modal-actions,
.death-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.battle-death-panel {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid black;
    background: var(--shop-info-background);
    text-align: center;
}

.battle-death-panel h3 {
    margin: 0 0 6px;
    font-family: "New Rocker", system-ui;
    font-weight: 400;
}

.battle-death-panel p {
    margin: 6px 0;
}

.death-actions {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 520px) {
    .modal-actions,
    .death-actions {
        grid-template-columns: 1fr;
    }
}
