:root {
  --bg: #fafafa;
  --fg: #0a0a0a;
  --muted: rgba(10, 10, 10, 0.55);
  --faint: rgba(10, 10, 10, 0.38);
  --line: rgba(10, 10, 10, 0.12);
  --accent: #fb923c;
  --accent-deep: #c2570b;
  --card: #ffffff;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  --cw: 260px;
  --ch: 312px;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, Menlo, monospace;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

html { overflow-x: hidden; }

body {
  font-family: var(--sans);
  color: var(--fg);
  background: radial-gradient(ellipse at center, rgba(251, 146, 60, 0.1) 0%, rgba(251, 146, 60, 0.04) 40%, var(--bg) 80%) no-repeat fixed, var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 56px 20px 80px;
}

h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.05; margin-top: 18px; }
h2 { font-size: 22px; line-height: 1.2; }
p { margin: 0; }

.mono { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.2em; font-size: 10px; color: var(--muted); }
.label { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.2em; font-size: 10px; color: var(--muted); }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.hint { color: var(--faint); font-size: 12px; margin: 6px 0 14px; }

.hero { text-align: center; margin-bottom: 28px; }
.eyebrow { display: flex; align-items: center; justify-content: center; gap: 12px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.22em; font-size: 10px; color: var(--muted); }
.rule { width: 40px; height: 1px; background: rgba(10, 10, 10, 0.25); }
.lede { margin: 14px auto 0; max-width: 460px; font-size: 14px; line-height: 1.6; color: var(--muted); }

/* Deck */
.deck-section { margin-top: 8px; overflow-x: clip; }
.deck {
  position: relative;
  width: 100%;
  height: calc(var(--ch) + 60px);
  perspective: 1200px;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
  outline: none;
}
.deck:active { cursor: grabbing; }

.card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cw);
  height: var(--ch);
  margin-left: calc(var(--cw) / -2);
  margin-top: calc(var(--ch) / -2);
  border-radius: 24px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  will-change: transform, opacity;
  backface-visibility: hidden;
}
.deck.dragging .card { transition: none; }

.card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.card .shade { position: absolute; inset: 0; background: #000; opacity: 0.22; transition: opacity 0.4s ease; pointer-events: none; }
.card.is-active .shade { opacity: 0; }
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.22), inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  pointer-events: none;
}
.card.is-active { outline: 2.5px solid var(--accent); outline-offset: -2.5px; }

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  min-width: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
  display: none;
}
.card.picked .badge { display: block; }

.deck-controls { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 4px; }
.counter { min-width: 72px; text-align: center; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.icon-btn:hover { background: rgba(10, 10, 10, 0.05); border-color: rgba(10, 10, 10, 0.25); }

/* Detail */
.detail { text-align: center; margin: 30px auto 0; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.detail .meta { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.price { font-family: var(--serif); font-size: 26px; }
.actions { display: flex; align-items: center; justify-content: center; gap: 22px; margin-top: 6px; flex-wrap: wrap; }

.pill {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 11px 24px;
  border-radius: 999px;
  border: 0;
  background: var(--fg);
  color: var(--bg);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.pill:hover { opacity: 0.9; }
.pill:active { transform: scale(0.97); }
.pill:disabled { opacity: 0.35; cursor: not-allowed; }
.pill.secondary { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.pill.wide { width: 100%; margin-top: 10px; }

.ghost-link { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.ghost-link:hover { color: var(--fg); }

/* Ballot */
.ballot {
  max-width: 560px;
  margin: 56px auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.slot {
  border: 1px dashed rgba(10, 10, 10, 0.2);
  border-radius: 14px;
  padding: 10px 12px;
  min-height: 62px;
  text-align: left;
  background: transparent;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
}
.slot .label { display: block; margin-bottom: 4px; }
.slot .slot-name { font-size: 13px; line-height: 1.35; color: var(--faint); }
.slot.filled { border: 1px solid var(--accent); background: #fff7f0; }
.slot.filled .slot-name { color: var(--fg); }
.slot.filled .label { color: var(--accent-deep); }

.field { display: grid; gap: 8px; margin-top: 4px; }
.field input {
  font: inherit;
  font-size: 15px;
  padding: 10px 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  outline: none;
  transition: border-color 0.3s;
}
.field input:focus { border-bottom-color: var(--fg); }

#message { min-height: 1.3em; margin-top: 12px; font-size: 13px; text-align: center; }
#message.error { color: #b3261e; }
#message.ok { color: #1e7b34; }

/* Results */
.results { max-width: 560px; margin: 56px auto 0; }
.results .label { display: block; margin-bottom: 14px; }
.results ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.result { display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 14px; align-items: center; }
.result img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: #fff; box-shadow: var(--shadow); }
.result-name { font-size: 14px; font-weight: 500; line-height: 1.3; }
.result-score { font-family: var(--mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { grid-column: 2 / -1; height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.5s ease; }

@media (max-width: 640px) {
  :root { --cw: 214px; --ch: 258px; }
  main { padding-top: 40px; }
  .deck { height: calc(var(--ch) + 40px); }
  .ballot { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .bar > span { transition: none; }
}
