:root {
  --bg: #120d0b;
  --surface: #1c1513;
  --surface-hi: #261d1a;
  --line: #3a2d28;
  --text: #f4ebe6;
  --muted: #b9a79f;
  --accent: #e8b48a;
  --accent-ink: #2b1a10;
  --owned: #8fd19e;
  --radius: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -200px, #2a1c15 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: 'Poppins', system-ui, sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* Frames are not meant to be saved: no selection, no drag, no long-press menu on images. */
canvas, .tile { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.brand-name b { color: var(--accent); font-weight: 600; }

.who {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}
.who b { color: var(--text); font-weight: 500; }
@media (max-width: 480px) { .who .lbl { display: none; } }

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 16px 40px; }

.state { text-align: center; max-width: 520px; margin: 12vh auto 0; }
.state h1 { font-size: 1.6rem; margin: 0 0 8px; }
.state p { color: var(--muted); margin: 0 0 20px; }

.steps {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px 16px 40px;
  margin: 0;
}
.steps li { margin: 6px 0; }

.spinner {
  width: 36px; height: 36px; margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.intro { margin: 4px 4px 20px; }
.intro h1 { font-size: 1.5rem; margin: 0 0 4px; }
.intro p { color: var(--muted); margin: 0; }
.intro .thanks {
  margin-top: 12px; padding: 10px 14px; border-radius: 14px;
  color: #10240f; background: var(--owned); font-weight: 500;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-out), background 160ms var(--ease-out);
}
.tile:hover { background: var(--surface-hi); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tile:active { transform: scale(0.97); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tile canvas { width: 100%; max-width: 132px; aspect-ratio: 1; }
.tile .name { font-size: 0.9rem; font-weight: 500; text-align: center; }
.tile .meta { font-size: 0.8rem; color: var(--muted); }
.tile .badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 0.7rem; font-weight: 600;
  color: #10240f; background: var(--owned);
  padding: 2px 8px; border-radius: 999px;
}

dialog {
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / 0.65); }
dialog[open] .sheet { animation: rise 220ms var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

.sheet {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  text-align: center;
}
.close {
  position: absolute; top: 10px; right: 12px;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--surface-hi); color: var(--muted);
  font-size: 1.3rem; cursor: pointer;
}
.stage {
  margin: 8px auto 12px;
  width: min(260px, 70vw);
  aspect-ratio: 1;
}
.stage canvas { width: 100%; height: 100%; }
.sheet h2 { margin: 0; font-size: 1.25rem; }
.price { margin: 4px 0 0; color: var(--accent); font-weight: 600; }
.owned { margin: 6px 0 0; color: var(--owned); font-size: 0.9rem; }
.buy {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.buy:disabled { opacity: 0.45; cursor: not-allowed; }
.note { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }

.claim { margin-top: 14px; text-align: left; border-top: 1px solid var(--line); padding-top: 12px; }
.claim summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; font-weight: 500; text-align: center; list-style: none; }
.claim summary::-webkit-details-marker { display: none; }
.claim-help { margin: 8px 0; font-size: 0.8rem; color: var(--muted); text-align: center; }
.claim-row { display: flex; gap: 8px; }
.claim-row input {
  flex: 1; min-width: 0;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 0.95rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.claim-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.claim-go {
  padding: 10px 16px; border: none; border-radius: 12px;
  background: var(--surface-hi); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.claim-go:disabled { opacity: 0.5; cursor: progress; }
.claim-msg { margin: 8px 0 0; min-height: 1.2em; font-size: 0.85rem; color: var(--owned); text-align: center; }
.claim-msg.error { color: #f28b82; }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0 16px max(20px, env(safe-area-inset-bottom)); }

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