:root {
  --paper: #f3efe6;
  --paper-2: #ebe5d8;
  --card: #fbf9f4;
  --ink: #1d1c1a;
  --ink-2: #4a4740;
  --muted: #7a756b;
  --rule: #d6cfc0;
  --accent: #b8321c;
  --marker: #f1dd6b;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --paper: #181715;
  --paper-2: #211f1c;
  --card: #1e1d1a;
  --ink: #ece6d8;
  --ink-2: #c4bdae;
  --muted: #8d877b;
  --rule: #34312b;
  --accent: #e0573c;
  --marker: rgba(241, 221, 107, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s, color 0.25s;
}

/* faint paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--marker);
  color: var(--ink);
}

.container {
  width: min(1080px, 100% - 2.5rem);
  margin-inline: auto;
}

.mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
}

/* ---------- Top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--rule);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.who__mark {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s;
}

.who__mark:active {
  transform: scale(0.92);
}

.who__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.who__text strong {
  font-weight: 600;
  font-size: 0.92rem;
}

.who__text small {
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--ink-2);
}

.theme-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.theme-btn:hover {
  border-color: var(--ink);
}

[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon {
  display: none;
}

/* ---------- Masthead ---------- */
.masthead {
  padding: 3.5rem 0 3rem;
}

.masthead__meta {
  margin: 0 0 1.5rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
}

.masthead__meta span + span::before {
  content: "/";
  margin: 0 0.7rem;
  color: var(--rule);
}

#countdownPill {
  color: var(--accent);
}

.masthead__title {
  margin: 0;
  max-width: 14ch;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.8rem, 7.5vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
}

.masthead__title em {
  font-style: italic;
  color: var(--accent);
}

.masthead__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 3rem;
  margin-top: 2.75rem;
  padding-top: 2rem;
  border-top: 1px solid var(--ink);
}

.letter__hi {
  margin: 0 0 0.6rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.6rem;
  line-height: 1.2;
}

.letter__body {
  margin: 0;
  max-width: 54ch;
  color: var(--ink-2);
}

.letter__sign {
  margin: 1.25rem 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--muted);
}

.letter__sign span {
  color: var(--ink);
}

.notes {
  padding-left: 1.75rem;
  border-left: 1px solid var(--rule);
}

.notes__label {
  margin: 0 0 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--muted);
}

.notes__list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--ink-2);
}

.notes__list li {
  position: relative;
  padding-left: 1.1rem;
}

.notes__list li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.notes__facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
}

.notes__facts dt {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.7rem;
}

.notes__facts dd {
  margin: 0.1rem 0 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.2;
}

.draw-btn {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  text-decoration-color: var(--accent);
}

.draw-btn:hover span {
  display: inline-block;
  transform: translateX(3px);
}

.draw-btn span {
  transition: transform 0.15s;
}

.draw-btn:disabled {
  color: var(--muted);
  cursor: wait;
}

/* ---------- List ---------- */
.list {
  padding-bottom: 4rem;
}

.list__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ink);
  color: var(--muted);
  text-transform: uppercase;
}

.wish-card {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 2.25rem;
  padding: 2.75rem 0;
  border-bottom: 1px solid var(--rule);
  transition: background-color 0.12s;
}

.wish-card.is-roulette {
  background: var(--marker);
}

.wish-card__num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 3.2rem;
  line-height: 0.9;
  color: var(--muted);
}

.wish-card.is-picked .wish-card__num {
  color: var(--accent);
}

.wish-card__media {
  position: relative;
  margin: 0;
  padding: 10px 10px 34px;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 var(--rule), 0 10px 24px -18px rgba(0, 0, 0, 0.35);
  align-self: start;
  cursor: zoom-in;
  transform: rotate(-0.8deg);
  transition: transform 0.25s ease;
}

.wish-card:nth-child(even) .wish-card__media {
  transform: rotate(0.7deg);
}

.wish-card__media:hover {
  transform: rotate(0deg);
}

/* bit of tape */
.wish-card__media::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 84px;
  height: 22px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(225, 214, 180, 0.7);
  border-left: 1px dashed rgba(0, 0, 0, 0.06);
  border-right: 1px dashed rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .wish-card__media::before {
  background: rgba(200, 190, 160, 0.25);
}

.wish-card__media img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--paper-2);
}

.wish-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.wish-card__cat {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.wish-card__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 2.6vw, 2.05rem);
  line-height: 1.08;
  cursor: pointer;
}

.wish-card__title:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.wish-card__sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.95rem;
}

.specs {
  margin: 0.25rem 0 0;
  border-top: 1px dashed var(--rule);
}

.specs > div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 0.9rem;
}

.specs dt {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  padding-top: 0.12rem;
}

.specs dd {
  margin: 0;
}

.specs s {
  margin-left: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.wish-card__note {
  margin: 0;
  padding-left: 0.9rem;
  border-left: 2px solid var(--accent);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.12rem;
  line-height: 1.4;
  color: var(--ink-2);
}

.why-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.why-toggle {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--muted);
  text-decoration: underline dotted;
  text-underline-offset: 4px;
}

.why-toggle:hover {
  color: var(--ink);
}

.why-box {
  margin: 0;
  padding: 0.85rem 1rem;
  background: var(--paper-2);
  font-size: 0.9rem;
  color: var(--ink-2);
}

.why-box[hidden] {
  display: none;
}

/* ---------- Buy links ---------- */
.buy {
  margin-top: 0.5rem;
}

.buy__label {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

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

.ecom-links {
  display: grid;
  border-top: 1px solid var(--ink);
}

.ecom-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.25rem;
  border-bottom: 1px solid var(--ink);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, padding 0.15s;
}

.ecom-btn:hover {
  background: var(--ink);
  color: var(--paper);
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.ecom-btn__dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  background: var(--ink);
}

.ecom-btn--tokopedia .ecom-btn__dot {
  background: #03ac0e;
}

.ecom-btn--shopee .ecom-btn__dot {
  background: #ee4d2d;
}

.ecom-btn--tiktok .ecom-btn__dot {
  background: linear-gradient(135deg, #25f4ee 50%, #fe2c55 50%);
}

.ecom-btn__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.ecom-btn__tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.ecom-btn:hover .ecom-btn__tag {
  color: inherit;
  opacity: 0.7;
}

.ecom-btn__arrow {
  font-size: 0.95rem;
}

.ecom-btn__name + .ecom-btn__arrow {
  margin-left: auto;
}

/* ---------- Stamp ---------- */
.stamp {
  position: absolute;
  top: 1.75rem;
  right: 0;
  padding: 0.3rem 0.75rem;
  border: 2px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  transform: rotate(-7deg) scale(1.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.wish-card.is-picked .stamp {
  opacity: 0.9;
  transform: rotate(-7deg) scale(1);
}

/* ---------- Footer ---------- */
.footer {
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
}

.footer p {
  margin: 0;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(20, 18, 15, 0.55);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(820px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.18);
}

.modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 34px;
  height: 34px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--paper);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  border-color: var(--ink);
}

.modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 2rem;
  align-items: start;
}

.modal-media {
  margin: 0;
  padding: 10px 10px 30px;
  background: var(--card);
  border: 1px solid var(--rule);
}

.modal-media img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.modal-info {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-right: 1.5rem;
}

.modal-info .wish-card__title {
  cursor: default;
}

.modal-info .wish-card__title:hover {
  text-decoration: none;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 80;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.7rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.8rem;
}

/* ---------- Hidden terminal ---------- */
.terminal-modal {
  width: min(620px, 100%);
  background: #141311;
  color: #ddd6c7;
  border: 1px solid #3a372f;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.35);
  font-family: var(--mono);
}

.terminal-close {
  background: transparent;
  border-color: #3a372f;
  color: #ddd6c7;
}

.terminal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  padding: 0 2.5rem 0.9rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px dashed #3a372f;
}

.terminal-dots {
  display: inline-flex;
  gap: 0.35rem;
}

.terminal-dots i {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3a372f;
}

.terminal-title {
  font-size: 0.86rem;
  color: #e3b341;
}

.terminal-badge {
  margin-left: auto;
  font-size: 0.68rem;
  color: #8d877b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.terminal-prompt {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #a39d90;
}

.clue-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.clue-card {
  width: 100%;
  padding: 0.75rem 0.9rem;
  text-align: left;
  font-family: inherit;
  background: transparent;
  border: 1px solid #2e2b25;
  color: #ddd6c7;
  cursor: pointer;
}

.clue-card:hover {
  border-color: #e3b341;
}

.clue-card__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.7rem;
  color: #e3b341;
}

.clue-card__body {
  font-size: 0.8rem;
  line-height: 1.5;
}

.clue-card:not(.is-unlocked) .clue-card__body {
  filter: blur(4px);
  opacity: 0.55;
  user-select: none;
}

.terminal-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.terminal-input-wrap {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #3a372f;
  background: #0f0e0d;
}

.terminal-input-wrap:focus-within {
  border-color: #e3b341;
}

.terminal-prefix {
  font-size: 0.78rem;
  color: #8fbf7a;
  white-space: nowrap;
}

.terminal-input-wrap input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: #f1ebdd;
  font-family: inherit;
  font-size: 0.82rem;
}

.terminal-submit {
  padding: 0.65rem 1rem;
  border: 1px solid #e3b341;
  background: transparent;
  color: #e3b341;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.terminal-submit:hover {
  background: #e3b341;
  color: #141311;
}

.terminal-output {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.8rem;
  line-height: 1.5;
}

.terminal-output.is-success {
  border: 1px solid #5d7d50;
  color: #a8d293;
}

.terminal-output.is-error {
  border: 1px solid #7a3a2e;
  color: #ec9a87;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .masthead__grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .notes {
    padding-left: 0;
    padding-top: 1.5rem;
    border-left: none;
    border-top: 1px solid var(--rule);
  }

  .wish-card {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 1.25rem 1.25rem;
  }

  .wish-card__num {
    font-size: 2.4rem;
  }

  .wish-card__media,
  .wish-card__body {
    grid-column: 2;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .modal-info {
    padding-right: 0;
  }
}

@media (max-width: 560px) {
  .container {
    width: min(1080px, 100% - 1.75rem);
  }

  .masthead {
    padding-top: 2.5rem;
  }

  .wish-card {
    grid-template-columns: 1fr;
  }

  .wish-card__media,
  .wish-card__body {
    grid-column: 1;
  }

  .wish-card__num {
    font-size: 2rem;
  }

  .stamp {
    top: 2.5rem;
  }

  .modal {
    padding: 1.5rem 1.25rem;
  }

  .hide-sm {
    display: none;
  }
}

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