:root {
  --bg: #fbfaf7;
  --fg: #222;
  --muted: #666;
  --accent: #5b3cc4;
  --ok: #1d7a3a;
  --bad: #b3261e;
  --border: #ddd;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 2rem;
  min-height: 9rem;
  padding: 1rem 1.5rem;
  color: #fff;
  background: #3b2616 url("/assets/safari-banner.svg") center bottom / cover no-repeat;
}
.site-header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: .04em;
  text-shadow: 0 2px 4px #000a;
}
.site-header nav { display: flex; flex-wrap: wrap; gap: .6rem; align-self: center; }
.site-header nav a {
  padding: .45rem 1.1rem;
  border-radius: 999px;
  border: 2px solid #f6e7c1;
  background: #f6e7c1;
  color: #3b2616;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 6px #0007;
  transition: transform .1s, background .1s;
}
.site-header nav a:hover { background: #fff; transform: translateY(-1px); }
.site-header nav a:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.site-header nav a[aria-current="page"] { background: var(--accent); border-color: #fff; color: #fff; }
.site-header .balance { margin: 0 0 0 auto; background: #0005; padding: .3rem .7rem; border-radius: 999px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 1.5rem;
  max-width: 64rem;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}
@media (max-width: 720px) { .layout { grid-template-columns: 1fr; } }

form { display: grid; gap: .4rem; max-width: 28rem; }
label { font-weight: 600; margin-top: .6rem; }
input, select, button { font: inherit; padding: .5rem; border: 1px solid var(--border); border-radius: .4rem; }
button { margin-top: 1rem; background: var(--accent); color: #fff; border: none; cursor: pointer; }
button:disabled { opacity: .6; cursor: progress; }

.preview { max-width: 100%; max-height: 16rem; object-fit: contain; border-radius: .4rem; margin-top: .4rem; }
.photo-drop { display: grid; gap: .4rem; padding: .75rem; border: 2px dashed var(--border); border-radius: .5rem; background: #fff; transition: background .15s, border-color .15s; }
.photo-drop.dragover { border-color: var(--accent); background: #efeafd; }
.errors { color: var(--bad); white-space: pre-line; }

.payout-goals { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; }
.payout-goals li { padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 999px; background: #fff; font-weight: 700; white-space: nowrap; }

.result { margin-top: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: .5rem; background: #fff; }
.result-summary { font-size: 1.25rem; font-weight: 700; margin-top: 0; }
.result.ok { border-color: var(--ok); }
.result.rejected { border-color: var(--bad); }
.result.bonus { background: #fff8e1; }

.wallet { border: 1px solid var(--border); border-radius: .5rem; padding: 1rem; background: #fff; align-self: start; }
.wallet h2 { margin-top: 0; }
.history { padding-left: 1.2rem; margin: 0; max-height: 24rem; overflow: auto; }
.history li { margin-bottom: .5rem; }
.history .entry { display: flex; gap: .5rem; align-items: flex-start; }
.history .entry-text { flex: 1; min-width: 0; }
.history .amount { font-weight: 700; }
.history .earn .amount { color: var(--ok); }
.history .spend .amount { color: var(--bad); }
.history time { display: block; color: var(--muted); font-size: .8rem; }

.mini-photo {
  flex: none;
  margin: 0;
  padding: 0;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: .3rem;
  background: #eee;
  overflow: hidden;
  cursor: zoom-in;
}
.mini-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-peek {
  position: fixed;
  z-index: 20;
  max-width: 128px;
  max-height: 128px;
  border: 3px solid #fff;
  border-radius: .4rem;
  box-shadow: 0 4px 16px #0005;
  pointer-events: none;
}

.intro { margin-bottom: 1.5rem; padding: 1rem 1.25rem; background: #fff7e8; border: 1px solid #ecd9b0; border-left: 4px solid #c8792a; border-radius: .5rem; }
.intro p { margin: 0 0 .75rem; line-height: 1.5; }
.intro summary { cursor: pointer; font-weight: 700; }
.intro .suggestions { margin: 0 0 .75rem; padding-left: 0; list-style: none; line-height: 1.8; }
.intro .suggestions li { display: flex; align-items: center; gap: .5rem; }

.swatch { display: inline-block; flex: none; width: 1rem; height: 1rem; border-radius: 50%; border: 1px solid #0003; background: transparent; vertical-align: middle; }
.swatch[data-color=""] { border-style: dashed; }
.swatch[data-color="red"] { background: #e53935; }
.swatch[data-color="orange"] { background: #fb8c00; }
.swatch[data-color="yellow"] { background: #fdd835; }
.swatch[data-color="green"] { background: #43a047; }
.swatch[data-color="blue"] { background: #1e88e5; }
.swatch[data-color="indigo"] { background: #3949ab; }
.swatch[data-color="violet"] { background: #8e44ad; }

.color-picker { position: relative; }
.color-button { display: flex; align-items: center; gap: .5rem; width: 100%; margin-top: 0; background: #fff; color: inherit; border: 1px solid var(--border); text-align: left; }
.color-button::after { content: "▾"; margin-left: auto; }
.color-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.color-list { position: absolute; z-index: 10; left: 0; right: 0; margin: .25rem 0 0; padding: .25rem 0; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: .4rem; box-shadow: 0 6px 18px #0002; }
.color-list [role="option"] { display: flex; align-items: center; gap: .5rem; padding: .4rem .75rem; cursor: pointer; }
.color-list [role="option"]:hover, .color-list .active { background: #efeafd; }
.color-list [aria-selected="true"] { font-weight: 700; }
.intro[open] summary { margin-bottom: .75rem; }
.intro summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.hint { margin: 0; color: var(--muted); font-size: .9rem; }

.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--border); text-align: right; }
.danger-outline { margin: 0; background: transparent; color: var(--bad); border: 1px solid var(--bad); font-size: .85rem; padding: .35rem .7rem; }
.danger-outline:hover { background: #fdecea; }

dialog { max-width: 26rem; border: none; border-radius: .6rem; padding: 1.5rem; box-shadow: 0 10px 40px #0006; }
dialog::backdrop { background: #0008; }
dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .75rem; }
.dialog-actions button { margin-top: .5rem; }
.star-dialog { text-align: center; background: linear-gradient(#fffbea, #fff1b8); border: 3px solid #f2b705; }
.star-dialog h2 { color: #8a5a00; font-size: 1.6rem; margin: .5rem 0; }
.star-dialog .dialog-actions { justify-content: center; }
.star-burst { font-size: 4rem; line-height: 1; animation: star-pop .6s ease-out both; }
@keyframes star-pop { 0% { transform: scale(0) rotate(-180deg); } 70% { transform: scale(1.3) rotate(15deg); } 100% { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .star-burst { animation: none; } }
button.secondary { background: #eee; color: var(--fg); border: 1px solid var(--border); }
button.danger { background: var(--bad); }

.not-found { max-width: 32rem; margin: 4rem auto; text-align: center; }


.store-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 1.25rem; align-items: start; }
@media (max-width: 960px) { .store-layout { grid-template-columns: 1fr; } }
.store-form { max-width: none; }
.catalog { border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .75rem; margin: 0; background: #fff; }
.catalog legend { font-weight: 600; padding: 0 .3rem; }
.catalog-list { display: grid; gap: .25rem; }
.catalog-item { display: flex; align-items: center; gap: .6rem; margin: 0; padding: .45rem .5rem; border-radius: .4rem; font-weight: 400; cursor: pointer; }
.catalog-item:hover { background: #f4f1ea; }
.catalog-item:has(input:checked) { background: #efe9fb; outline: 1px solid var(--accent); }
.catalog-item .item-name { flex: 1; }
.catalog-item .item-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.gold-star { color: #e0a800; text-shadow: 0 0 2px #a07000; font-size: 1.1rem; }

.order-preview { display: grid; gap: .2rem; margin: 1rem 0 0; padding: .75rem 1rem; background: #fff; border: 1px solid var(--border); border-radius: .5rem; }
.order-preview div { display: flex; justify-content: space-between; }
.order-preview dt { color: var(--muted); }
.order-preview dd { margin: 0; font-variant-numeric: tabular-nums; }
.order-preview .total { font-weight: 700; border-top: 1px solid var(--border); padding-top: .25rem; }
.order-preview .total dt { color: var(--fg); }
.store-status { color: var(--ok); margin: 0; }

.purchase-ledger { border: 1px solid var(--border); border-radius: .5rem; padding: 1rem; background: #fffdf6; }
.purchase-ledger h3 { margin-top: 0; }
.purchases { list-style: none; margin: 0; padding: 0; max-height: 28rem; overflow: auto; display: grid; gap: .6rem; }
.purchases li { font-size: .9rem; line-height: 1.35; }
.purchases time { display: block; color: var(--muted); font-size: .8rem; }

.reward { margin: 0 0 1.5rem; padding: 1rem; text-align: center; background: #120f2a; color: #fff; border-radius: .6rem; }
.reward img { max-width: 100%; height: auto; border-radius: .4rem; }
.reward figcaption { margin-top: .5rem; }

.fireworks { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 40; pointer-events: none; }
.celebration {
  position: fixed; z-index: 41; left: 50%; top: 40%; transform: translate(-50%, -50%);
  padding: 1.25rem 2rem; text-align: center; border-radius: .75rem;
  background: #120f2aee; color: #fff; box-shadow: 0 10px 40px #0008; pointer-events: none;
}
.celebration p { margin: .25rem 0; }
.celebration p:first-child { font-size: 1.5rem; font-weight: 800; }

.password-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  flex-basis: 100%; justify-content: flex-end; max-width: none;
}
.password-form label { margin: 0; color: #fff; background: #0006; padding: .3rem .7rem; border-radius: 999px; }
.password-form input { width: 13rem; max-width: 100%; padding: .4rem .6rem; }
.password-form button { margin: 0; padding: .4rem .9rem; }
.password-note { flex-basis: 100%; text-align: right; font-size: .9rem; color: #fff; text-shadow: 0 1px 2px #000; }
.password-note:empty { display: none; }
.password-note.error { color: #ffd2cc; }

[hidden] { display: none !important; }
