:root {
    color-scheme: light;
    --page-bg: #fff8ee;
    --surface: #ffffff;
    --text: #292621;
    --muted: #746e64;
    --line: #e1dbd0;
    --accent: #a24b67;
    --free: #fffdf8;
    --reserved: #f1eee8;
    --shared-free: #edf5f8;
    --shared-reserved: #dcefe9;
    --mine: #e2f2df;
    --warning: #fff0c4;
    --error: #f8d7d7;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 280px;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 8% 4%, rgb(255 219 144 / 35%) 0 55px, transparent 56px),
        radial-gradient(circle at 92% 8%, rgb(234 181 200 / 28%) 0 70px, transparent 71px),
        var(--page-bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }
button:focus-visible { outline: 3px solid #386ca6; outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell {
    width: min(100%, 720px);
    margin: 0 auto;
    padding: max(20px, env(safe-area-inset-top)) 14px max(44px, env(safe-area-inset-bottom));
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 8vw, 2.6rem); line-height: 1.05; }

.current-guest { flex: 0 0 auto; text-align: right; }
.current-guest-name {
    display: block;
    max-width: 150px;
    padding: 7px 10px;
    border-radius: 11px;
    font-weight: 800;
    line-height: 1.2;
}

.change-guest {
    min-height: 38px;
    padding: 4px 8px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 0.88rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.section-heading h2 { margin-bottom: 5px; font-size: 1.35rem; }
.section-heading p {
    margin-bottom: 15px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.gift-list { display: grid; gap: 11px; }

.gift-card {
    display: block;
    width: 100%;
    min-height: 92px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--free);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    box-shadow: 0 2px 7px rgb(57 45 28 / 6%);
    touch-action: manipulation;
}

.gift-card.shared-gift { border-color: #bdd4dc; background: var(--shared-free); }
.gift-card.is-reserved:not(.shared-gift) { background: var(--reserved); }
.gift-card.shared-gift.is-reserved { border-color: #9bc8ba; background: var(--shared-reserved); }
.gift-card.is-mine { border-color: #91c789; background: var(--mine); }
.gift-card:disabled:not(.is-busy) { cursor: default; opacity: 0.72; }
.gift-card.is-busy { cursor: wait; opacity: 0.62; }
.gift-card:active:not(:disabled) { transform: scale(0.992); }

.gift-name { display: block; font-size: 1.08rem; font-weight: 800; line-height: 1.25; }
.shared-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgb(255 255 255 / 70%);
    color: #396c75;
    font-size: 0.75rem;
    font-weight: 750;
}

.reservation-status, .own-status, .join-status {
    display: block;
    margin-top: 9px;
    font-size: 0.88rem;
    line-height: 1.35;
}
.reservation-status { color: var(--muted); }
.own-status { color: #286822; font-weight: 800; }
.join-status { color: #45665f; font-weight: 650; }

.empty-list, .loading {
    padding: 24px 14px;
    border: 1px dashed var(--line);
    border-radius: 14px;
    color: var(--muted);
    text-align: center;
}

.message {
    position: sticky;
    z-index: 5;
    top: 8px;
    margin: 0 0 14px;
    padding: 11px 13px;
    border: 1px solid rgb(0 0 0 / 9%);
    border-radius: 11px;
    font-size: 0.9rem;
    box-shadow: 0 3px 14px rgb(0 0 0 / 10%);
}
.message-error { background: var(--error); }
.message-warning { background: var(--warning); }

.guest-screen {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: grid;
    place-items: center;
    overflow-y: auto;
    padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
    background: rgb(255 248 238 / 97%);
}

.guest-card { width: min(100%, 520px); }
.guest-card h2 { margin-bottom: 20px; font-size: clamp(2rem, 10vw, 3rem); }
.guest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }

.guest-choice {
    min-height: 76px;
    padding: 13px 8px;
    border: 1px solid rgb(0 0 0 / 8%);
    border-radius: 15px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    cursor: pointer;
    box-shadow: 0 2px 7px rgb(0 0 0 / 6%);
    touch-action: manipulation;
}
.guest-choice:active { transform: scale(0.98); }

/* Двенадцать стабильных цветов. Номер задаётся в data/guests.json. */
.guest-color-1  { background-color: #dcecf8; }
.guest-color-2  { background-color: #f7dfd7; }
.guest-color-3  { background-color: #e4e0f6; }
.guest-color-4  { background-color: #ddefd9; }
.guest-color-5  { background-color: #f7ebc8; }
.guest-color-6  { background-color: #dcefed; }
.guest-color-7  { background-color: #f4dce8; }
.guest-color-8  { background-color: #e7edd2; }
.guest-color-9  { background-color: #e1e7f5; }
.guest-color-10 { background-color: #f5e0c9; }
.guest-color-11 { background-color: #d8eee4; }
.guest-color-12 { background-color: #eee0d7; }

@media (min-width: 620px) {
    .app-shell { padding-right: 24px; padding-left: 24px; }
    .gift-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; }
}
