:root {
    --spruce: #12261c;
    --needle: #1e4d38;
    --berry: #7c2434;
    --button: #8e2436;
    --button-hover: #a52b40;
    --paper: #f4ebd8;
    --ink: #1a1612;
    --brass: #e4c56a;
    --ring: #c6a15b;
    --quiet: #5c4636;
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Nunito, "Segoe UI", sans-serif;
    font-size: 1.0625rem;
    line-height: 1.5;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 12%, #fff 0 2px, transparent 2.4px),
        radial-gradient(circle at 22% 28%, rgba(255, 255, 255, 0.9) 0 1.4px, transparent 2px),
        radial-gradient(circle at 78% 16%, #fff 0 2.2px, transparent 2.8px),
        radial-gradient(circle at 90% 40%, rgba(255, 255, 255, 0.75) 0 1.2px, transparent 1.8px),
        radial-gradient(circle at 14% 70%, rgba(255, 255, 255, 0.8) 0 1.6px, transparent 2.2px),
        linear-gradient(180deg, #f4f8ff 0%, #f7f1e6 42%, #e5f2ea 100%);
}

.sheet {
    width: min(100% - 32px, 40rem);
    margin: 0 auto;
    padding: 22px 0 72px;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
}

.tree {
    width: 52px;
    height: 66px;
}

.sheet.hall { width: min(100% - 28px, 48rem); }

.mark {
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
}

.mark:hover { color: var(--brass); }

main { margin-top: 36px; }

h1 {
    margin: 0 0 12px;
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-weight: 500;
    font-size: clamp(2rem, 5vw, 3.15rem);
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.ceremony main,
.ceremony h1,
.ceremony .lead { text-align: center; }

.lead {
    max-width: 38ch;
    margin: 0 0 22px;
    color: var(--quiet);
    font-size: 1.125rem;
}

.ceremony .lead { margin-inline: auto; }

.note {
    margin: 0 0 18px;
    padding: 12px 14px;
    background: var(--paper);
    color: var(--ink);
}

.ceremony .note { text-align: left; }

.note.bad {
    background: var(--button);
    color: #fff8ec;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
}

.pin {
    display: block;
    width: min(100%, 16rem);
    height: 4.6rem;
    margin: 0 auto 16px;
    border: 0;
    background: var(--paper);
    color: var(--ink);
    font: 700 2.4rem/1 Nunito, "Segoe UI", sans-serif;
    letter-spacing: 0.28em;
    text-indent: 0.28em;
    text-align: center;
}

.pin.short {
    width: min(100%, 8.5rem);
    letter-spacing: 0.42em;
    text-indent: 0.42em;
}

.add { margin: 8px 0 8px; }

.add-row {
    display: flex;
    gap: 8px;
}

.add input {
    flex: 1;
    min-width: 0;
    height: 3.25rem;
    padding: 0 12px;
    border: 0;
    background: var(--paper);
    color: var(--ink);
    font: 1.05rem/1 Nunito, "Segoe UI", sans-serif;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--brass);
    outline-offset: 3px;
}

input:-webkit-autofill {
    -webkit-text-fill-color: var(--ink);
    box-shadow: 0 0 0 1000px var(--paper) inset;
}

.btn,
.text-btn,
.mark,
a {
    cursor: pointer;
}

.btn {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 3.25rem;
    padding: 0 22px;
    border: 0;
    border-radius: 14px;
    background: var(--button);
    color: #fff8ec;
    font: 700 1.05rem/1 Nunito, "Segoe UI", sans-serif;
    text-decoration: none;
}

.btn:hover { background: var(--button-hover); }

.btn-block {
    width: min(100%, 16rem);
    margin-inline: auto;
}

.wide {
    width: 100%;
    margin-top: 8px;
}

.text-btn {
    appearance: none;
    min-height: 2.75rem;
    padding: 0 8px;
    border: 0;
    background: none;
    color: var(--quiet);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.text-btn:hover,
.quiet-link a:hover { color: var(--brass); }

.quiet-link { margin-top: 28px; }

.quiet-link a {
    color: var(--quiet);
    text-underline-offset: 0.2em;
}

.people {
    list-style: none;
    margin: 28px 0;
    padding: 0;
}

.board {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 26px 14px;
    margin: 28px 0 0;
    padding: 26px 0 0;
    background-image:
        radial-gradient(circle at 5px 5px, #a52b40 3.2px, transparent 3.6px),
        radial-gradient(circle at 17px 5px, #245c40 3.4px, transparent 3.8px),
        linear-gradient(#c6a15b, #c6a15b);
    background-size: 24px 12px, 24px 12px, 100% 2px;
    background-repeat: repeat-x, repeat-x, no-repeat;
    background-position: top left, top left, 0 5px;
}

.board li {
    position: relative;
    padding-top: 18px;
}

.board li::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 18px;
    background: #a52b40;
}

.board form { height: 100%; }

.tag {
    appearance: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 5.5rem;
    padding: 0 8px 18px;
    border: 0;
    border-bottom: 4px solid var(--brass);
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 8px 0 rgba(141, 42, 34, 0.18);
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-size: clamp(1.2rem, 2.2vw, 1.65rem);
    font-weight: 500;
    line-height: 1.05;
    text-wrap: balance;
    cursor: pointer;
}

.tag::before {
    content: "";
    width: 12px;
    height: 16px;
    margin-bottom: 10px;
    border-radius: 0 0 2px 2px;
    background: var(--button);
}

.tag:hover { background: #fff8ea; }

.slip {
    width: min(100%, 16rem);
    margin: 4px auto 18px;
    padding: 18px 12px 22px;
    background:
        linear-gradient(var(--button), var(--button)) top / 100% 16px no-repeat,
        var(--paper);
    color: var(--ink);
    text-align: center;
    box-shadow: 5px 6px 0 #0c1812;
}

.slip::before {
    content: "✶";
    display: block;
    margin: -8px 0 12px;
    color: var(--brass);
    font-size: 1rem;
    line-height: 1;
}

.pin-show {
    margin: 0;
    color: var(--ink);
    font-family: Nunito, "Segoe UI", sans-serif;
    font-weight: 700;
    font-size: clamp(3.4rem, 14vw, 5.2rem);
    letter-spacing: 0.14em;
    text-indent: 0.14em;
    line-height: 1;
    user-select: all;
}

.people li {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px 16px;
    align-items: center;
    padding: 16px 0;
    border-top: 1px solid rgba(198, 161, 91, 0.5);
}

.people li:last-child { border-bottom: 1px solid rgba(198, 161, 91, 0.5); }

.name {
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-weight: 500;
    font-size: 1.7rem;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.code {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    user-select: all;
}

.status {
    color: var(--quiet);
    font-size: 0.98rem;
}

.row-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.row-actions form { display: inline; }

.check {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 2.75rem;
    margin-top: 18px;
}

.check input {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--berry);
}

.organizer-code {
    margin-top: 36px;
    color: var(--quiet);
}

.organizer-code strong {
    color: var(--paper);
    letter-spacing: 0.14em;
}

.stage {
    position: relative;
    width: min(92vw, 26rem);
    margin: 22px auto 18px;
}

.pointer {
    position: absolute;
    z-index: 4;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-right: 12px solid transparent;
    border-left: 12px solid transparent;
    border-top: 22px solid var(--brass);
    filter: drop-shadow(0 2px 0 var(--spruce));
}

.wheel { position: relative; }

.wheel-rotor {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    box-shadow:
        inset 0 0 0 8px var(--ring),
        inset 0 0 0 12px var(--spruce),
        0 16px 36px rgba(0, 0, 0, 0.35);
    transition: transform 4.2s cubic-bezier(0.12, 0.55, 0.05, 1);
}

.wheel-name {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5.6rem;
    margin-top: -0.55em;
    margin-left: -2.8rem;
    color: var(--paper);
    font-size: var(--name-size, 16px);
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    overflow-wrap: anywhere;
    transform: rotate(var(--a)) translateY(calc(var(--size, 26rem) * -0.34));
}

.stage { --size: min(92vw, 26rem); }

.hub {
    position: absolute;
    z-index: 2;
    top: 29%;
    left: 29%;
    display: grid;
    width: 42%;
    height: 42%;
    place-items: center;
    padding: 10px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--paper);
    color: var(--ink);
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-weight: 500;
    font-size: clamp(1.05rem, 3vw, 1.5rem);
    line-height: 1.05;
    text-align: center;
    overflow-wrap: anywhere;
}

.result { margin-top: 8px; }

.result-name {
    margin: 8px 0 22px;
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-size: clamp(3.2rem, 12vw, 6rem);
    font-weight: 500;
    letter-spacing: -0.035em;
    line-height: 0.92;
    overflow-wrap: anywhere;
}

.mine,
.their-wishes {
    width: min(100%, 32rem);
    margin: 18px auto 0;
    padding: 16px 18px 18px;
    border: 3px solid #e0b15a;
    border-radius: 18px;
    background: #fffaf3;
    text-align: left;
}

.mine h2,
.their-wishes h2 {
    margin: 0 0 8px;
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-size: 1.45rem;
    font-weight: 600;
}

.wish-list {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}

.wish-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid rgba(198, 161, 91, 0.45);
}

.edit-wish {
    display: flex;
    flex: 1 1 16rem;
    gap: 8px;
    min-width: 0;
}

.edit-wish input {
    flex: 1;
    min-width: 0;
    height: 3.25rem;
    padding: 0 14px;
    border: 3px solid #e0b15a;
    border-radius: 14px;
    background: #fffaf3;
    color: var(--ink);
    font: 600 1.05rem/1 Nunito, "Segoe UI", sans-serif;
}

.edit-wish .btn { width: auto; }

.wish-list li span { overflow-wrap: anywhere; }

.wish-list form { margin: 0; }

.add-wish {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}

.req {
    color: var(--berry);
    font-size: 0.85rem;
    font-weight: 700;
}

.wish-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 8px 0 0;
}

.add-wish textarea {
    width: 100%;
    min-height: 12rem;
    padding: 14px 16px;
    border: 3px solid #e0b15a;
    border-radius: 18px;
    background: #fffaf3;
    color: var(--ink);
    font: 600 1.15rem/1.45 Nunito, "Segoe UI", sans-serif;
    resize: vertical;
}

.add-wish .btn { width: 100%; }

.logout {
    clear: both;
    margin-top: 28px;
}

.logout .btn-block { width: min(100%, 32rem); }

.later {
    display: block;
    width: min(100%, 32rem);
    margin: 4px auto 0;
    text-align: center;
}

@media (max-width: 640px) {
    .wish-list li { flex-wrap: wrap; }
    .edit-wish { flex-basis: 100%; }
}

.go-wheel { margin-top: 18px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.print-only { display: none; }

.btn,
.text-btn,
.mark {
    transition: background-color 180ms ease, color 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .text-btn,
    .mark,
    .wheel-rotor { transition: none; }
}

@media print {
    body { background: white; color: black; }
    .noprint,
    .status,
    .row-actions,
    .note,
    .lead,
    .quiet-link { display: none !important; }
    .mark,
    .name,
    .code,
    h1 { color: black; }
    .people li { border-color: black; break-inside: avoid; }
}

@media (max-width: 720px) {
    .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
    .sheet { padding-top: 32px; }
    main { margin-top: 48px; }
}

.who {
    margin: 22px 0 10px;
    font-size: 1.35rem;
    font-weight: 600;
}

.cottage {
    position: relative;
    width: min(100%, 36rem);
    margin: 8px auto 64px;
}

.cottage.is-locked .window {
    pointer-events: none;
    cursor: default;
}

.cottage.is-locked .window:hover { transform: none; }

.roof {
    position: relative;
    height: 86px;
    margin: 0 6px -2px;
    background: #c4313a;
    clip-path: polygon(0 100%, 50% 0, 100% 100%);
}

.roof::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 0;
    height: 16px;
    background: radial-gradient(circle at 10px 16px, #fff 10px, transparent 11px) left center / 20px 16px repeat-x;
}

.chimney {
    position: absolute;
    top: 22px;
    right: 18%;
    z-index: 2;
    width: 22px;
    height: 36px;
    background: #8d3b32;
    border-radius: 3px 3px 0 0;
}

.chimney::after {
    content: "";
    position: absolute;
    top: -7px;
    left: -4px;
    width: 30px;
    height: 8px;
    background: #6e2e28;
    border-radius: 2px;
}

.facade {
    background: #fffaf3;
    border: 4px solid #e0b15a;
    border-top: 0;
    border-radius: 0 0 22px 22px;
    padding: 16px 14px 20px;
}

.step {
    position: relative;
    width: 46%;
    height: 14px;
    margin: 0 auto 18px;
    background: #d7c4a2;
    border-radius: 0 0 10px 10px;
}

.step::before,
.step::after {
    content: "";
    position: absolute;
    bottom: -38px;
    width: 34px;
    height: 30px;
    border-radius: 4px 4px 6px 6px;
    background:
        linear-gradient(#e4c56a, #e4c56a) center 0 / 16px 8px no-repeat,
        linear-gradient(#e4c56a, #e4c56a) center / 6px 100% no-repeat,
        #8e2436;
}

.step::before { left: -6px; height: 26px; }
.step::after {
    right: -10px;
    width: 40px;
    background:
        linear-gradient(#fffaf3, #fffaf3) center 0 / 18px 8px no-repeat,
        linear-gradient(#fffaf3, #fffaf3) center / 6px 100% no-repeat,
        #1e4d38;
}

.windows {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    perspective: 900px;
}

.window {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 5.4rem;
    padding: 0;
    border: 0;
    border-radius: 1rem 1rem 0.35rem 0.35rem;
    background: #163828;
    color: #fffaf3;
    font: 700 1.45rem/1 Fredoka, "Trebuchet MS", sans-serif;
    box-shadow: inset 0 0 0 7px #c4313a, 0 7px 0 #8d2a22;
    cursor: pointer;
}

.window.is-shut,
.window.is-taken,
.window.is-mine {
    cursor: default;
}

.window.is-taken { opacity: 0.72; }

.shutter {
    position: absolute;
    inset: 7px;
    border-radius: 0.55rem 0.55rem 0.2rem 0.2rem;
    background: linear-gradient(90deg, #f6e7b4 50%, #e4c56a 50%);
    transform-origin: left center;
    transition: transform 700ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.num {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: #fffaf3;
    color: #7a2430;
    box-shadow: 0 2px 0 rgba(90, 32, 24, 0.18);
}

.window:hover:not(:disabled) { transform: translateY(-3px); }

.window:focus-visible {
    outline: 3px solid var(--brass);
    outline-offset: 3px;
}

.window.is-opening .shutter { transform: perspective(500px) rotateY(-76deg); }

.window.is-mine {
    overflow: hidden;
    background: #fffaf3;
    opacity: 1;
}

.window.is-mine .shutter {
    transform: translateX(-105%);
    opacity: 0;
}

.who-name {
    position: relative;
    z-index: 2;
    display: none;
    max-width: 100%;
    padding: 0 8px;
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-size: clamp(1.2rem, 2.6vw, 1.65rem);
    font-weight: 700;
    line-height: 1.05;
    color: #7a2430;
    text-align: center;
    text-wrap: balance;
    overflow-wrap: anywhere;
}

.window.is-mine .num {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.78rem;
}

.window.is-mine .who-name { display: block; }

@media (prefers-reduced-motion: no-preference) {
    .window.is-mine .who-name { animation: name-out 520ms cubic-bezier(0.2, 0.8, 0.2, 1); }
}

@keyframes name-out {
    from { transform: translateY(10px) scale(0.82); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.gift { margin: 8px 0 18px; text-align: center; }

.gift-kicker {
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.gift-name {
    margin: 4px 0 8px;
    font-family: Fredoka, "Trebuchet MS", sans-serif;
    font-size: clamp(2.4rem, 8vw, 4.2rem);
    font-weight: 700;
    line-height: 1.05;
    color: var(--berry);
}

.restart { margin: 22px 0 8px; }

.restart summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--berry);
}

.restart form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: end;
    margin-top: 10px;
}

@media (max-width: 640px) {
    .windows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

body::before {
    content: "";
    position: fixed;
    inset: -20px 0 auto;
    height: 140%;
    pointer-events: none;
    background-image:
        radial-gradient(circle, #fff 1.3px, transparent 1.6px),
        radial-gradient(circle, rgba(255, 255, 255, 0.85) 1px, transparent 1.4px);
    background-size: 120px 160px, 80px 110px;
    background-position: 0 0, 40px 20px;
    opacity: 0.85;
}

@media (prefers-reduced-motion: no-preference) {
    body::before { animation: snow 16s linear infinite; }
}

@keyframes snow {
    to { background-position: 0 160px, 40px 130px; }
}

@media (prefers-reduced-motion: reduce) {
    .window,
    .shutter { transition: none; }
    .window:hover:not(:disabled) { transform: none; }
    body::before,
    .window.is-mine .who-name { animation: none; }
}
