:root {
    --red: #b3202a;
    --red-dark: #8f1821;
    --green: #1f4d36;
    --gold: #c9a24a;
    --ink: #22302a;
    --muted: #66736c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: #fff url('ssbg.jpg') center / cover no-repeat fixed;
}

[hidden] { display: none !important; }

.card {
    position: relative;
    z-index: 1; /* above the snow canvas */
    width: 100%;
    max-width: 440px;
    padding: 36px 28px 32px;
    text-align: center;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(201, 162, 74, 0.45);
    border-radius: 28px;
    box-shadow: 0 20px 50px -20px rgba(31, 77, 54, 0.35), 0 2px 6px rgba(0, 0, 0, 0.05);
}

.eyebrow {
    margin: 0 0 14px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--gold);
}

h1 {
    margin: 0 0 8px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 8vw, 2.6rem);
    line-height: 1.15;
    color: var(--green);
}

#subtitle {
    margin: 0 0 26px;
    color: var(--muted);
    line-height: 1.45;
}

form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

input {
    width: 100%;
    padding: 14px;
    font-size: 1.8rem;
    text-align: center;
    letter-spacing: 0.5em;
    text-indent: 0.5em; /* re-centres text offset by trailing letter-spacing */
    color: var(--ink);
    background: #fff;
    border: 2px solid #e3e8e5;
    border-radius: 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(31, 77, 54, 0.15);
}

button {
    padding: 16px 24px;
    font: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(180deg, var(--red), var(--red-dark));
    border: none;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 8px 18px -8px rgba(179, 32, 42, 0.7);
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px -8px rgba(179, 32, 42, 0.8);
}

button:active:not(:disabled) { transform: translateY(1px); }

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

#error {
    margin-top: 14px;
    color: var(--red-dark);
    font-weight: 500;
}

#recipientContainer {
    display: none;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px dashed rgba(201, 162, 74, 0.7);
}

#recipientContainer.show {
    display: block;
    animation: rise 0.6s ease both;
}

.label {
    margin: 0 0 6px;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

#selectedRecipient {
    min-height: 1.2em;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.4rem, 12vw, 3.4rem);
    font-weight: 700;
    line-height: 1.2;
    color: var(--red);
    overflow-wrap: anywhere;
}

#selectedRecipient.shuffling {
    color: var(--green);
    opacity: 0.55;
    filter: blur(1.5px);
}

#selectedRecipient:not(.shuffling) {
    animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

#note {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@keyframes pop {
    from { transform: scale(0.85); }
    to   { transform: scale(1); }
}

@media (max-width: 480px) {
    .card { padding: 30px 20px 26px; border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
