:root {
  --cream: #f6eedd;
  --cream-dim: rgba(246, 238, 221, 0.72);
  --red: #c0272f;
  --red-deep: #8e1b2c;
  --gold: #e8bc55;
  --green: #1f5f3a;
  --panel: rgba(12, 18, 36, 0.78);
  --panel-border: rgba(232, 188, 85, 0.28);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1228;
  color: var(--cream);
  font-family: 'Nunito', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#scene:active { cursor: grabbing; }

button { font: inherit; color: inherit; }

/* Header */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: max(16px, env(safe-area-inset-top)) 16px 0;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.topbar h1 {
  margin: 0;
  font-family: 'Mountains of Christmas', cursive;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 1.05;
  color: var(--cream);
  letter-spacing: 0.01em;
}
.subtitle {
  margin: 2px 0 0;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.8rem;
}
.subtitle:empty { display: none; }
.countdown {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(12, 18, 36, 0.5);
  border: 1px solid var(--panel-border);
  font-size: 0.9rem;
  color: var(--cream-dim);
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.countdown strong { color: var(--cream); font-weight: 800; }
.countdown:empty { display: none; }

/* Panels */
.card, .list-panel, .list-toggle, .tooltip {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

.list-toggle {
  position: fixed;
  left: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  z-index: 3;
}
.list-toggle:hover { border-color: var(--gold); }

/* Detail card */
.card {
  position: fixed;
  z-index: 4;
  right: 24px;
  top: 50%;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px 22px 22px;
  border-radius: var(--radius);
  opacity: 0;
  transform: translate(20px, -50%);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.card.open { opacity: 1; transform: translate(0, -50%); }
.card-close { position: absolute; top: 14px; right: 14px; }
.card-priority {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-height: 1em;
}
.card-name {
  margin: 6px 40px 12px 0;
  font-size: 1.45rem;
  line-height: 1.2;
}
.card-image {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
}
.card-image[hidden] { display: none; }
.card-note { margin: 0 0 8px; color: var(--cream-dim); line-height: 1.5; }
.card-note:empty, .card-price:empty { display: none; }
.card-price { margin: 0 0 14px; font-weight: 800; color: var(--gold); }
.card-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.buy-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
  transition: background 0.15s, transform 0.15s;
}
.buy-link::after { content: '↗'; opacity: 0.8; }
.buy-link:hover { background: #d8343c; transform: translateY(-1px); }
.buy-link:focus-visible, .row-main:focus-visible, .list-toggle:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.muted { color: var(--cream-dim); margin: 0; font-size: 0.92rem; }

/* List panel */
.list-panel {
  position: fixed;
  z-index: 5;
  top: 16px;
  bottom: 16px;
  left: 16px;
  width: min(380px, calc(100vw - 32px));
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.list-panel[hidden] { display: none; }
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 10px 22px;
}
.list-head h2 {
  margin: 0;
  font-family: 'Mountains of Christmas', cursive;
  font-size: 2rem;
}
.gift-list {
  list-style: none;
  margin: 0;
  padding: 0 14px 18px;
  overflow-y: auto;
}
.gift-row {
  padding: 12px;
  border-radius: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.gift-row:hover { background: rgba(255, 255, 255, 0.04); }
.row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex: none;
  background: var(--c);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.row-name { font-weight: 700; font-size: 1.02rem; flex: 1; }
.row-tag {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag-high { background: rgba(232, 188, 85, 0.18); color: var(--gold); }
.tag-low { background: rgba(255, 255, 255, 0.08); color: var(--cream-dim); }
.row-note, .row-price { margin: 6px 0 0 26px; color: var(--cream-dim); font-size: 0.92rem; line-height: 1.45; }
.row-price { color: var(--gold); font-weight: 700; }
.row-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0 26px; }
.row-links .buy-link { padding: 6px 11px; font-size: 0.84rem; }
.empty { padding: 20px 12px; color: var(--cream-dim); }

/* Tooltip, hint, loading */
.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 6;
  padding: 7px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  pointer-events: none;
  white-space: nowrap;
}
.tooltip[hidden] { display: none; }

.hint {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(12, 18, 36, 0.5);
  color: var(--cream-dim);
  font-size: 0.88rem;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.6s;
}
.hint.gone { opacity: 0; }

.loading {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: radial-gradient(ellipse at center, #1a2547, #070c1c);
  font-family: 'Mountains of Christmas', cursive;
  font-size: 1.8rem;
  transition: opacity 0.8s;
}
.loading.gone { opacity: 0; pointer-events: none; }
.loading.error span { font-family: 'Nunito', sans-serif; font-size: 1rem; max-width: 460px; line-height: 1.5; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; }

/* Without WebGL the list is the whole page. */
.no-webgl #scene, .no-webgl .list-toggle { display: none; }
.no-webgl .list-panel { top: 150px; left: 50%; transform: translateX(-50%); }
.no-webgl .list-head .icon-btn { display: none; }

/* Star easter egg */
.hohoho {
  position: fixed;
  z-index: 6;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff8e8;
  color: #9b1b24;
  font-family: 'Mountains of Christmas', cursive;
  font-size: 1.7rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35), 0 0 30px rgba(255, 210, 120, 0.6);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) scale(0.6);
}
.hohoho span { display: inline-block; }
.hohoho.show { animation: hohoho-in 0.45s ease-out forwards; }
.hohoho.show.hide { animation: hohoho-out 0.6s ease-in forwards; }
.hohoho .swap { animation: hohoho-swap 0.4s ease-out; }
@keyframes hohoho-in {
  0% { opacity: 0; transform: translate(-50%, -60%) scale(0.6); }
  65% { opacity: 1; transform: translate(-50%, -150%) scale(1.08); }
  100% { opacity: 1; transform: translate(-50%, -150%) scale(1); }
}
@keyframes hohoho-out {
  from { opacity: 1; transform: translate(-50%, -150%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -200%) scale(0.95); }
}
@keyframes hohoho-swap {
  0% { opacity: 0; transform: scale(0.7); }
  60% { opacity: 1; transform: scale(1.12); }
  100% { transform: scale(1); }
}

@media (max-width: 720px) {
  .card {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    max-height: 48vh;
    transform: translateY(24px);
  }
  .card.open { transform: translateY(0); }
  .card-image { max-height: 120px; }
  .list-panel { top: 12px; bottom: 12px; left: 12px; width: calc(100vw - 24px); }
  .hint { bottom: 76px; font-size: 0.8rem; }
  .countdown { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .hint, .loading { transition: none; }
}
