@font-face { font-family: 'Ultra'; src: url('/fonts/ultra.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }

:root {
  --night: #1B1950;
  --night-2: #25226B;
  --night-3: #312E86;
  --line: #4B47A8;
  --marigold: #F2A20C;
  --marigold-2: #FFC24B;
  --rosa: #E4007C;
  --jade: #0F9B8E;
  --cielo: #5BC0EB;
  --paper: #F8EBCF;
  --paper-2: #EEDBB2;
  --ink: #2A1533;
  --text: #FFF3D6;
  --muted: #B9B5E6;
  --danger: #FF5C5C;
  --display: 'Ultra', 'Rockwell Extra Bold', 'Georgia', serif;
  --ui: 'Bricolage', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-sm: 8px; --r-md: 14px; --r-lg: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  background-image:
    radial-gradient(120% 60% at 50% -10%, rgba(242, 162, 12, .22), transparent 60%),
    radial-gradient(80% 50% at 100% 110%, rgba(228, 0, 124, .16), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--marigold-2); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cards ---------- */
.card {
  container-type: inline-size;
  aspect-ratio: 5 / 7;
  position: relative;
  border-radius: 6%/4.3%;
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--ink), 0 3px 0 2px rgba(0, 0, 0, .35);
  overflow: hidden;
  user-select: none;
}
.card-face {
  position: absolute; inset: 4.5%;
  border: max(1.5px, 1.4cqi) solid var(--ink);
  border-radius: 3%;
  display: grid; grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .45), transparent 55%),
    repeating-linear-gradient(135deg, transparent 0 3px, rgba(42, 21, 51, .025) 3px 4px),
    var(--paper);
}
.card-num {
  font-family: var(--display); font-size: 11cqi; line-height: 1;
  padding: 4cqi 0 0 5cqi; color: var(--ink);
}
.card-art {
  width: 100%; height: 100%; display: block; align-self: center;
  filter: drop-shadow(1.6cqi 1.2cqi 0 rgba(228, 0, 124, .32));
}
.card-name {
  font-family: var(--display); color: var(--ink);
  font-size: var(--fs, 11.5cqi); line-height: 1.05; text-align: center;
  min-height: 13cqi; display: flex; align-items: center; justify-content: center;
  padding: 0 3cqi 5cqi; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -.01em;
}
.card-sub { display: block; text-align: center; font-size: 7.5cqi; color: #6B4E5E; padding-bottom: 4cqi; margin-top: -3cqi; font-weight: 600; }

/* The memorable moment: a freshly pulled print sliding into register. */
@keyframes pull {
  0% { transform: translate(60%, -8%) rotate(14deg) scale(.9); opacity: 0; }
  55% { transform: translate(-3%, 0) rotate(-3deg) scale(1.03); opacity: 1; }
  100% { transform: none; }
}
@keyframes register {
  0% { filter: drop-shadow(7cqi 5cqi 0 rgba(228, 0, 124, .9)); }
  60% { filter: drop-shadow(-1.5cqi -1cqi 0 rgba(228, 0, 124, .6)); }
  100% { filter: drop-shadow(1.6cqi 1.2cqi 0 rgba(228, 0, 124, .32)); }
}
.card.pulled { animation: pull .7s cubic-bezier(.2, .9, .25, 1.1) both; }
.card.pulled .card-art { animation: register .9s .25s cubic-bezier(.3, .8, .3, 1) both; }

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 0 20px;
  border-radius: 999px; border: 2px solid var(--ink);
  background: var(--paper); color: var(--ink);
  font-weight: 700; font-size: 1rem;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--marigold); }
.btn.hot { background: var(--rosa); color: #fff; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); box-shadow: none; }
.btn.ghost:active { transform: none; background: var(--night-3); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: .9rem; box-shadow: 0 3px 0 var(--ink); }
.btn.block { width: 100%; }
.iconbtn {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1.5px solid var(--line); background: var(--night-2);
  color: var(--text); padding: 0;
}
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn.on { background: var(--jade); border-color: var(--jade); }
.iconbtn.live { background: var(--rosa); border-color: var(--rosa); }

.field { display: grid; gap: 6px; }
.field > span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.input {
  height: 52px; border-radius: var(--r-md); border: 2px solid var(--line);
  background: var(--night-2); padding: 0 16px; font-size: 1.1rem; color: var(--text); width: 100%;
}
.input:focus { border-color: var(--marigold); outline: none; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: transparent; font-size: .92rem; font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.seg button:disabled { opacity: .55; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.switch input { appearance: none; width: 48px; height: 28px; border-radius: 99px; background: var(--night-3); border: 1.5px solid var(--line); position: relative; flex: none; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked { background: var(--jade); border-color: var(--jade); }
.switch input:checked::after { transform: translateX(20px); background: #fff; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.stepper button { width: 38px; height: 36px; border: 0; background: transparent; font-size: 1.2rem; font-weight: 700; }
.stepper output { min-width: 34px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.mini { display: inline-grid; grid-template-columns: repeat(4, 1fr); gap: 1.5px; width: 22px; height: 22px; flex: none; }
.mini i { background: rgba(255, 255, 255, .16); border-radius: 1.5px; }
.mini i.on { background: var(--marigold); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center;
  font-weight: 800; font-size: .85rem; color: var(--ink); border: 2px solid var(--ink); flex: none; letter-spacing: -.03em; overflow: hidden;
}

/* ---------- Bottom sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; background: rgba(10, 8, 40, .55); animation: fade .18s; }
.sheet {
  background: var(--night-2); border-top: 2px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  max-height: 88dvh; overflow: auto; overscroll-behavior: contain;
  padding: 10px 18px calc(24px + var(--safe-b));
  animation: rise .26s cubic-bezier(.2, .9, .3, 1);
  width: 100%; max-width: 640px; margin: 0 auto;
}
.sheet::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; margin: 4px 0 12px; }
.sheet h3 { font-size: 1rem; margin: 22px 0 8px; color: var(--marigold-2); }
@keyframes rise { from { transform: translateY(40%); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%);
  z-index: 80; background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  border-radius: 999px; padding: 10px 18px; font-weight: 700; box-shadow: 0 4px 0 var(--ink);
  animation: drop .25s cubic-bezier(.2, .9, .3, 1.2); max-width: calc(100vw - 32px); text-align: center;
}
@keyframes drop { from { transform: translate(-50%, -30px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
