:root {
    --bg: #f4f7f4;
    --surface: #ffffff;
    --text: #1f2a1f;
    --muted: #4f5d52;
    --border: #c7d2c8;
    --accent: #1d6a47;
    --accent-strong: #145335;
    --error: #b42318;
    --radius: 12px;
    --shadow: 0 10px 24px rgba(17, 38, 23, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    color: var(--text);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    line-height: 1.45;
}

#cardsApp {
    max-width: 42rem;
    margin: 0 auto;
    padding: 1rem;
}

h1,
h2,
p {
    margin: 0;
    margin-bottom: 1rem;
}

h1 {
    margin-bottom: 0.9rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.2;
}

.pageHeader {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.pageHeader h1 {
    margin-bottom: 0;
}

.addCardIconLink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-size: 1.65rem;
    line-height: 1;
    text-decoration: none;
    flex: 0 0 auto;
}

.addCardIconLink:hover,
.addCardIconLink:focus-visible {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #fff;
}

h2 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

a {
    color: var(--accent);
    font-weight: 600;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

a:hover,
a:focus-visible {
    color: var(--accent-strong);
}

#cardsList {
    margin: 1rem 0 1rem 0;
    padding: 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

#cardsList li {
    min-width: 0;
}

#cardsList a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    height: 100%;
    min-height: 8rem;
    aspect-ratio: 1 / 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fbf8;
    text-decoration: none;
}

.cardsListStoreImage {
    max-width: 72%;
    max-height: 50%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.cardsListStoreName {
    color: var(--text);
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

#cardsList a:focus-visible,
#cardsList a:hover {
    border-color: var(--accent);
    background: #eef7f1;
}

#addCardForm {
    margin-top: 0.9rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

label {
    display: block;
    margin-top: 0.75rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

label:first-child {
    margin-top: 0;
}

input,
button {
    width: 100%;
    font: inherit;
    border-radius: 10px;
}

input[type="text"],
input[type="file"] {
    border: 1px solid var(--border);
    background: #fff;
    padding: 0.7rem 0.75rem;
}

input[type="file"] {
    padding: 0.55rem;
}

#shopSuggestions {
    margin: 0.45rem 0 0;
    padding: 0.25rem;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(17, 38, 23, 0.1);
}

.shopSuggestionItem + .shopSuggestionItem {
    margin-top: 0.2rem;
}

.shopSuggestionButton {
    display: block;
    width: 100%;
    margin-top: 0;
    padding: 0.65rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    text-align: left;
}

.shopSuggestionButton:hover,
.shopSuggestionButton:focus-visible,
.shopSuggestionButton.isActive {
    border-color: #b7c8ba;
    background: #edf5ef;
    color: var(--text);
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(29, 106, 71, 0.25);
    outline-offset: 2px;
}

button {
    margin-top: 1rem;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

button:hover,
button:focus-visible {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

button.dangerButton {
    border-color: var(--error);
    background: var(--error);
}

button.dangerButton:hover,
button.dangerButton:focus-visible {
    background: #911d12;
    border-color: #911d12;
}

a.button {
    display: inline-block;
    width: auto;
    margin-top: 1rem;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--accent);
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

a.button:hover,
a.button:focus-visible {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #fff;
}

#formError {
    min-height: 1.2rem;
    margin-top: 0.75rem;
    color: var(--error);
    font-weight: 600;
}

#viewCardImage {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 1rem;

}

#backToCardsLink {
    display: inline-block;
    margin-top: 0.2rem;
}

.wtfToggleContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.wtfToggle {
    width: auto;
    margin-top: 1rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    cursor: pointer;
}

.wtfToggle:hover,
.wtfToggle:focus-visible {
    color: var(--accent-strong);
}

.modalBackdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 24, 18, 0.62);
}

.wtfModal {
    position: relative;
    width: min(100%, 36rem);
    max-height: min(88dvh, 48rem);
    overflow: auto;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 14px 36px rgba(15, 24, 18, 0.3);
}

.wtfModal h1 {
    padding-right: 2rem;
}

.deleteModalActions {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.modalCloseButton {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 1.25rem;
    line-height: 1;
}

.modalCloseButton:hover,
.modalCloseButton:focus-visible {
    background: #f4f7f4;
    border-color: var(--accent);
}

@media (min-width: 600px) {
    #cardsApp {
        padding: 1.5rem;
    }

    .addCardIconLink {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.8rem;
    }

    section,
    #addCardForm {
        padding: 1.25rem;
    }

    #cardsList {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
        gap: 0.7rem;
    }

    #cardsList li + li {
        margin-top: 0;
    }

    .deleteModalActions {
        grid-template-columns: 1fr 1fr;
    }
}