:root {
  --bg: #fbf6ef;
  --card: #ffffff;
  --ink: #2c2420;
  --muted: #7a6e66;
  --line: #eadfd3;
  --accent: #c8372d;
  --accent-ink: #fff;
  --green: #1f7a43;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 35, 20, .08);
  --head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --gift-red: #d9433a; --gift-green: #2e9455; --gift-blue: #3b7fd1;
  --gift-gold: #e0a92a; --gift-purple: #8a5cd1; --gift-pink: #e5639f;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--head); font-size: 1.3rem; color: var(--ink); text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 4px; }
.topbar nav a { padding: 8px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.topbar nav a.active { background: #f6e6dc; }
.link-btn { background: none; border: 0; font: inherit; font-weight: 700; color: var(--muted); padding: 8px 10px; cursor: pointer; border-radius: 10px; }
.link-btn:hover { background: #f3ece4; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.loading { text-align: center; color: var(--muted); margin-top: 20vh; }

/* ---- buttons & forms ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; padding: 11px 18px; min-height: 46px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: #b3261e; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.big { font-size: 1.1rem; padding: 14px 24px; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-weight: 700; margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=url], select, textarea {
  width: 100%; font: inherit; padding: 11px 13px; border-radius: 10px; border: 1px solid #d9cbbd; background: #fff; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid #f2b9a5; outline-offset: 1px; }
.checkbox { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.checkbox input { width: 22px; height: 22px; }
.error { color: #b3261e; font-weight: 700; min-height: 1.5em; margin: 10px 0 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

/* ---- login ---- */
.auth-wrap { max-width: 420px; margin: 6vh auto 0; }
.auth-wrap .hero { text-align: center; margin-bottom: 18px; }
.auth-wrap .hero img { width: 84px; height: 84px; }
.auth-wrap .btn { width: 100%; margin-top: 18px; }

/* ---- board list ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }
.boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.board-card { display: block; text-decoration: none; color: inherit; border-radius: var(--radius); overflow: hidden; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s; }
.board-card:hover { transform: translateY(-3px); }
.board-card .thumb { aspect-ratio: 10 / 6; overflow: hidden; }
.board-card .thumb svg { width: 100%; height: 100%; display: block; }
.board-card .info { padding: 12px 16px 16px; }
.board-card h2 { font-size: 1.25rem; margin: 0; }
.pill { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: #f6e6dc; color: #8a3a22; }
.pill.gray { background: #eee; color: #666; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---- board ---- */
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.board-head h1 { margin: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.chip { font: inherit; font-weight: 700; font-size: .95rem; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.chip[aria-pressed=true] { background: var(--ink); color: #fff; border-color: var(--ink); }

.scene {
  position: relative; container-type: inline-size; aspect-ratio: 10 / 7; border-radius: 18px; overflow: hidden;
  box-shadow: 0 6px 24px rgba(40, 20, 10, .18);
}
.scene > svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* gift-shaped sticky note */
.gift {
  --c: var(--gift-red);
  position: absolute; transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
  width: clamp(58px, 10.5cqw, 124px); aspect-ratio: 1 / .95;
  border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--c); border-radius: 8% 8% 6% 6%;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18), 0 8px 18px rgba(0, 0, 0, .25);
  transition: transform .15s, opacity .2s, filter .2s;
  animation: drop .45s cubic-bezier(.3, 1.4, .6, 1) both;
}
.gift::before { /* vertical ribbon */
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 13%; transform: translateX(-50%);
  background: rgba(255, 255, 255, .55);
}
.gift::after { /* lid */
  content: ''; position: absolute; left: -4%; right: -4%; top: 0; height: 22%;
  background: var(--c); filter: brightness(.88); border-radius: 6px; box-shadow: 0 2px 0 rgba(0, 0, 0, .15);
}
.gift .bow {
  position: absolute; left: 50%; top: 0; width: 46%; height: 26%; transform: translate(-50%, -78%); z-index: 2; pointer-events: none;
}
.gift .bow::before, .gift .bow::after {
  content: ''; position: absolute; top: 10%; width: 50%; height: 85%; border: 1.5px solid rgba(0, 0, 0, .15);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: rgba(255, 255, 255, .92);
}
.gift .bow::before { left: 0; transform: rotate(-24deg); }
.gift .bow::after { right: 0; transform: rotate(24deg); }
.gift .tag {
  position: absolute; z-index: 1; left: 9%; right: 9%; top: 28%; bottom: 9%;
  background: #fffdf5; border-radius: 6px; padding: 4% 6%; text-align: center;
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.gift .who { font-family: var(--head); font-weight: 600; font-size: clamp(9px, 1.3cqw, 15px); line-height: 1.1; color: #8a3a22; }
.gift .what {
  font-size: clamp(8px, 1.1cqw, 12px); line-height: 1.2; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.gift .taken {
  position: absolute; z-index: 3; right: -8%; bottom: -8%; background: #fff; color: var(--green); border-radius: 99px;
  font-size: clamp(9px, 1.1cqw, 12px); font-weight: 800; padding: 1px 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.gift:hover, .gift:focus-visible { transform: translate(-50%, -50%) rotate(0deg) scale(1.12); z-index: 10; outline: none; }
.gift.dim { opacity: .25; filter: grayscale(.6); }
.gift.c-red { --c: var(--gift-red); } .gift.c-green { --c: var(--gift-green); } .gift.c-blue { --c: var(--gift-blue); }
.gift.c-gold { --c: var(--gift-gold); } .gift.c-purple { --c: var(--gift-purple); } .gift.c-pink { --c: var(--gift-pink); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -90%) scale(.6); } }

.scene-empty {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%); background: rgba(255, 255, 255, .92);
  padding: 10px 18px; border-radius: 99px; font-weight: 700; text-align: center; box-shadow: var(--shadow); width: max-content; max-width: 90%;
}

/* scene animation */
.twinkle { animation: twinkle 3s ease-in-out infinite; }
.bulb { animation: twinkle 2.2s ease-in-out infinite; }
.flake { animation: fall 9s linear infinite; }
.petals .flake { animation-duration: 12s; }
.flame { animation: flicker .6s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.balloon { animation: bob 4s ease-in-out infinite; }
.sleigh { animation: fly 18s linear infinite; }
.nose { animation: twinkle 1s ease-in-out infinite; }
.pop { animation: pop .6s cubic-bezier(.3, 1.5, .6, 1) both; transform-box: fill-box; transform-origin: 50% 100%; }
.merry { font-family: var(--head); font-weight: 600; animation: twinkle 3s ease-in-out infinite; }
@keyframes fly {
  from { transform: translate(-300px, 190px) scale(.8); }
  50% { transform: translate(500px, 120px) scale(.8); }
  to { transform: translate(1300px, 90px) scale(.8); }
}
@keyframes pop { from { opacity: 0; } }
@keyframes twinkle { 50% { opacity: .3; } }
@keyframes fall { from { transform: translateY(-60px); } to { transform: translateY(720px); } }
@keyframes flicker { to { transform: scale(.85, 1.1); } }
@keyframes bob { 50% { transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .sleigh { transform: translate(560px, 150px) scale(.8); }
}

/* wish lists under the scene */
.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 26px; }
.list h3 { display: flex; align-items: center; gap: 8px; }
.list ul { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px dashed var(--line); }
.list li:first-child { border-top: 0; }
.dot { flex: none; width: 14px; height: 14px; border-radius: 4px; margin-top: 5px; background: var(--c); }
.list .txt { flex: 1; min-width: 0; word-break: break-word; }
.list .txt button { all: unset; cursor: pointer; }
.list .txt button:hover { text-decoration: underline; }
.list .meta { font-size: .85rem; color: var(--muted); }
.list .got { color: var(--green); font-weight: 700; }

/* ---- dialogs ---- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); color: var(--ink);
}
dialog::backdrop { background: rgba(30, 20, 15, .55); }
dialog form, dialog .dlg { padding: 22px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.dlg-head h2 { margin: 0; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.wish-big { font-size: 1.25rem; font-weight: 600; margin: 14px 0; white-space: pre-wrap; word-break: break-word; }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors label { margin: 0; }
.colors input { position: absolute; opacity: 0; pointer-events: none; }
.colors span { display: block; width: 40px; height: 40px; border-radius: 10px; background: var(--c); cursor: pointer; border: 3px solid transparent; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.colors input:checked + span { border-color: var(--ink); }
.colors input:focus-visible + span { outline: 3px solid #f2b9a5; }
.claim-box { background: #f1faf3; border: 1px solid #cde9d5; border-radius: 12px; padding: 12px 14px; margin: 10px 0; }

/* ---- admin ---- */
.admin-grid { display: grid; gap: 22px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td .row { justify-content: flex-end; }
.password-reveal { font-family: ui-monospace, Menlo, monospace; font-size: 1.2rem; background: #fff7d6; border: 1px dashed #e0b94a; padding: 10px 14px; border-radius: 10px; display: inline-block; user-select: all; }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 700; transition: .25s; z-index: 50;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* On small scenes, gifts show just the name; tap one to read the wish. */
@container (max-width: 560px) {
  .gift .what { display: none; }
  .gift .who { font-size: 10px; }
  .gift .tag { padding: 2px; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand { font-size: 1.05rem; white-space: nowrap; gap: 6px; }
  .brand img { width: 24px; height: 24px; }
  .topbar nav { gap: 0; }
  .topbar nav a { padding: 8px; }
  #menu-btn { max-width: 7.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 6px; }
  .scene { border-radius: 12px; }
  .resp-table thead { display: none; }
  .resp-table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .resp-table td { display: block; border: 0; padding: 4px 0; }
  .resp-table td .row { justify-content: flex-start; }
}
