@property --glow { syntax: "<number>"; inherits: true; initial-value: 0; }

:root {
  --bg: #09090d;
  --surface: #12121a;
  --surface-2: #1a1a24;
  --line: rgba(255, 255, 255, .08);
  --text: #f4f4f7;
  --muted: #9a9aab;
  --yes: #2ee59d;
  --no: #ff4d6a;
  --hot: #ffb23e;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font: 16px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }

#app {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  max-width: 560px; margin: 0 auto;
  --glow: 0;
  transition: --glow .4s var(--ease-out);
}
#app.dragging { transition: none; }
@media (min-width: 600px) { #app { border-inline: 1px solid var(--line); } }

/* ---------- swipe glow on the screen edges ---------- */
.edge { position: fixed; top: 0; bottom: 0; width: 30%; max-width: 180px; pointer-events: none; z-index: 40; will-change: opacity; }
.edge-yes { right: calc(50% - min(50vw, 280px)); background: linear-gradient(270deg, rgba(46, 229, 157, .55), transparent); opacity: max(0, var(--glow)); }
.edge-no  { left: calc(50% - min(50vw, 280px)); background: linear-gradient(90deg, rgba(255, 77, 106, .55), transparent); opacity: max(0, calc(var(--glow) * -1)); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: max(10px, env(safe-area-inset-top)) 16px 6px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--yes), #19b9ff); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 7px; top: 5px; width: 6px; height: 12px; border: solid #04120c; border-width: 0 3px 3px 0; transform: rotate(40deg); }
.brand-text { font-weight: 600; letter-spacing: -.01em; font-size: 15px; line-height: 1; display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.brand-text b { color: var(--text); font-weight: 800; font-size: 17px; letter-spacing: -.03em; text-transform: uppercase; }
.top-right { display: flex; align-items: center; gap: 6px; }
.progress { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 99px; background: var(--surface); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); transition: background .2s, color .2s, transform .2s var(--spring); }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- views ---------- */
main { position: relative; min-height: 0; overflow: hidden; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity .28s var(--ease-out), transform .38s var(--ease-out), visibility 0s .38s; }
#app[data-view="swipe"] #view-swipe,
#app[data-view="ranks"] #view-ranks { opacity: 1; visibility: visible; transform: none; transition: opacity .28s var(--ease-out), transform .38s var(--ease-out), visibility 0s; }

/* ---------- card stack ---------- */
.stack { position: relative; flex: 1; min-height: 0; margin: 4px 14px 0; --p: 0; touch-action: none; user-select: none; -webkit-user-select: none; perspective: 1200px; }
.card {
  --d: 0; --yes: 0; --no: 0;
  position: absolute; inset: 0; border-radius: 28px; overflow: hidden; background: var(--surface);
  box-shadow: 0 24px 48px -24px rgba(0, 0, 0, .9), 0 0 0 1px var(--line);
  transform: translate3d(0, calc((var(--d) - var(--p)) * 14px), 0) scale(calc(1 - (var(--d) - var(--p)) * .05));
  transform-origin: 50% 100%;
  transition: transform .45s var(--ease-out), opacity .3s;
  will-change: transform; backface-visibility: hidden;
  cursor: grab;
  z-index: calc(10 - var(--d));
}
.card[data-top="1"] { transform: none; transition: transform .5s var(--spring); }
.card:not([data-top="1"]) { pointer-events: none; }
.card[data-d="3"] { opacity: 0; }
.stack.dragging .card { transition: none; }
.card.dragging { cursor: grabbing; transition: none; }
.card.leaving { pointer-events: none; z-index: 20; transition: none; }

.card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--pos, 50% 50%); opacity: 0; transition: opacity .35s; -webkit-user-drag: none; pointer-events: none; background: var(--surface); }
.card-img.loaded { opacity: 1; }
.card::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 250% 100%; animation: shimmer 1.4s linear infinite; }
.card:has(.card-img.loaded)::before { display: none; }
@keyframes shimmer { to { background-position: -150% 0; } }
.card-shade { position: absolute; inset: 0; z-index: 2; background: linear-gradient(180deg, rgba(0, 0, 0, .35) 0%, transparent 22%, transparent 48%, rgba(5, 5, 8, .88) 100%); pointer-events: none; }
.card-info { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 20px 22px 24px; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; padding: 5px 10px; border-radius: 99px; background: rgba(255, 255, 255, .14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); margin-bottom: 10px; }
.card-name { font-size: clamp(28px, 8vw, 42px); line-height: 1.02; font-weight: 800; letter-spacing: -.035em; text-wrap: balance; text-shadow: 0 2px 20px rgba(0, 0, 0, .5); }
.card-desc { margin-top: 8px; font-size: 15px; color: rgba(255, 255, 255, .78); text-wrap: pretty; }

.stamp { position: absolute; z-index: 4; top: 22px; width: 78px; height: 78px; display: grid; place-items: center; border-radius: 50%; border: 4px solid; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none; }
.stamp svg { width: 40px; height: 40px; stroke-width: 2.4; }
.card.dragging .stamp { transition: none; }
.stamp { transition: opacity .25s, transform .25s var(--spring); }
.stamp-yes { left: 22px; color: var(--yes); border-color: var(--yes); background: rgba(6, 40, 28, .5); opacity: var(--yes); transform: rotate(-14deg) scale(calc(.7 + var(--yes) * .4)); }
.stamp-no  { right: 22px; color: var(--no); border-color: var(--no); background: rgba(50, 8, 16, .5); opacity: var(--no); transform: rotate(14deg) scale(calc(.7 + var(--no) * .4)); }

/* ---------- vote result pill ---------- */
.pill { position: absolute; left: 50%; top: 14px; z-index: 30; transform: translate(-50%, -14px) scale(.9); opacity: 0; pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 9px 15px 9px 11px; border-radius: 99px; background: rgba(12, 12, 18, .78); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; white-space: nowrap; transition: transform .45s var(--spring), opacity .25s; }
.pill.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.pill svg { width: 18px; height: 18px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill small { color: var(--muted); font-weight: 500; }

/* ---------- controls ---------- */
.controls { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 14px 16px 16px; }
.ctl { display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 2px solid; position: relative; transition: transform .25s var(--spring), box-shadow .25s, background .2s, opacity .2s; }
.ctl svg { width: 30px; height: 30px; transition: transform .3s var(--spring); }
.ctl-yes, .ctl-no { width: 72px; height: 72px; }
.ctl-yes { color: var(--yes); border-color: rgba(46, 229, 157, .55); box-shadow: 0 8px 28px -10px rgba(46, 229, 157, .55); }
.ctl-no { color: var(--no); border-color: rgba(255, 77, 106, .55); box-shadow: 0 8px 28px -10px rgba(255, 77, 106, .55); }
.ctl-undo { width: 48px; height: 48px; color: var(--hot); border-color: rgba(255, 178, 62, .4); }
.ctl-undo svg { width: 22px; height: 22px; }
.ctl:hover:not(:disabled) { transform: translateY(-2px) scale(1.05); }
.ctl-yes:hover { background: rgba(46, 229, 157, .14); }
.ctl-no:hover { background: rgba(255, 77, 106, .14); }
.ctl:active:not(:disabled) { transform: scale(.88); }
.ctl-yes:active svg { transform: rotate(-14deg) scale(1.15); }
.ctl-no:active svg { transform: rotate(14deg) scale(1.15); }
.ctl:disabled { opacity: .3; cursor: default; }
.ctl:focus-visible, .icon-btn:focus-visible, .tabs button:focus-visible, .tabbar a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (max-height: 640px) { .ctl-yes, .ctl-no { width: 60px; height: 60px; } .controls { padding: 8px 16px 10px; } }

/* ---------- empty / done card ---------- */
.done { display: grid; place-content: center; text-align: center; gap: 14px; padding: 30px; background: radial-gradient(circle at 50% 30%, #1b2a3d, var(--surface) 70%); }
.done::before, .done .card-shade { display: none; }
.done h2 { font-size: 34px; letter-spacing: -.03em; font-weight: 800; }
.done p { color: var(--muted); }
.done-actions { display: grid; gap: 10px; margin-top: 8px; }
.btn { padding: 14px 20px; border-radius: 16px; font-weight: 700; background: var(--surface-2); transition: transform .2s var(--spring), background .2s; }
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--yes); color: #04120c; }

/* ---------- rankings ---------- */
#view-ranks { overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px calc(var(--tabbar-h) + var(--safe-b) + 20px); -webkit-overflow-scrolling: touch; }
.tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; --ti: 0; }
.tabs button { position: relative; z-index: 1; padding: 10px 4px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-radius: 12px; transition: color .25s; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); }
.tab-ind { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 12px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); transform: translateX(calc(var(--ti) * 100%)); transition: transform .4s var(--spring), background .3s; }
.tabs[data-tab="loved"] .tab-ind { background: linear-gradient(135deg, rgba(46, 229, 157, .25), var(--surface-2)); }
.tabs[data-tab="hated"] .tab-ind { background: linear-gradient(135deg, rgba(255, 77, 106, .25), var(--surface-2)); }
.tabs[data-tab="controversial"] .tab-ind { background: linear-gradient(135deg, rgba(255, 178, 62, .25), var(--surface-2)); }
.ranks-note { color: var(--muted); font-size: 13px; padding: 4px 6px 12px; text-wrap: pretty; }

.ranks-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 30px 56px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 14px 10px 8px; border-radius: 18px; background: var(--surface); border: 1px solid transparent; animation: rise .5s var(--ease-out) backwards; animation-delay: calc(min(var(--i), 14) * 35ms); transition: transform .2s var(--spring), border-color .2s, background .2s; }
.row:hover { border-color: var(--line); background: var(--surface-2); }
.row:active { transform: scale(.98); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.row-rank { text-align: center; font-weight: 800; font-size: 17px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.row:nth-child(-n+3) .row-rank { color: var(--accent, var(--text)); font-size: 20px; }
.row-thumb { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--surface-2); }
.row-main { min-width: 0; }
.row-name, .row-cat { display: block; }
.row-name { font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-cat { font-size: 12px; color: var(--muted); }
.bar { display: block; height: 5px; border-radius: 99px; background: var(--no); overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; width: var(--w); background: var(--yes); border-radius: 99px; transform-origin: left; animation: grow .8s var(--ease-out) backwards; animation-delay: calc(min(var(--i), 14) * 35ms + 150ms); }
@keyframes grow { from { transform: scaleX(0); } }
.row-score { text-align: right; font-variant-numeric: tabular-nums; }
.row-score b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; }
.row-score small { font-size: 11.5px; color: var(--muted); }
[data-tab="loved"] .row-score b { color: var(--yes); }
[data-tab="hated"] .row-score b { color: var(--no); }
[data-tab="controversial"] .row-score b { color: var(--hot); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; display: grid; gap: 10px; justify-items: center; }
.empty b { color: var(--text); font-size: 18px; }

/* ---------- tab bar ---------- */
.tabbar { display: grid; grid-template-columns: 1fr 1fr; padding: 6px 12px calc(6px + var(--safe-b)); background: rgba(9, 9, 13, .82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); z-index: 50; }
.tabbar a { display: grid; justify-items: center; gap: 3px; padding: 7px 0; font-size: 11.5px; font-weight: 600; color: var(--muted); border-radius: 14px; transition: color .25s, transform .2s var(--spring); }
.tabbar a:active { transform: scale(.94); }
.tabbar svg { width: 24px; height: 24px; transition: transform .35s var(--spring); }
#app[data-view="swipe"] [data-nav="swipe"], #app[data-view="ranks"] [data-nav="ranks"] { color: var(--text); }
#app[data-view="swipe"] [data-nav="swipe"] svg, #app[data-view="ranks"] [data-nav="ranks"] svg { transform: translateY(-1px) scale(1.12); color: var(--yes); }

/* ---------- bottom sheets ---------- */
.sheet { width: min(100%, 520px); max-width: none; max-height: 90dvh; margin: auto auto 0; padding: 0 0 calc(18px + var(--safe-b)); border: 0; border-radius: 28px 28px 0 0; background: #14141b; color: var(--text); overflow-y: auto; overscroll-behavior: contain; }
.sheet[open] { animation: sheet-in .45s var(--ease-out); }
.sheet.closing { animation: sheet-out .22s ease-in forwards; }
.sheet::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .3s; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-grab { position: sticky; top: 0; z-index: 2; width: 42px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .25); margin: 10px auto; }
.detail-img { display: block; width: calc(100% - 32px); aspect-ratio: 4 / 3; object-fit: cover; margin: 0 16px; border-radius: 20px; background: var(--surface); }
.detail-body { padding: 16px 20px 6px; display: grid; gap: 10px; }
.detail-body h2 { font-size: 28px; letter-spacing: -.03em; line-height: 1.05; font-weight: 800; }
.detail-body p { color: var(--muted); }
.split { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.split i { display: block; height: 100%; }
.split .u { background: var(--yes); } .split .d { background: var(--no); }
.split-legend { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.split-legend .u { color: var(--yes); } .split-legend .d { color: var(--no); }
.credit-line { font-size: 12px; color: var(--muted); }
.credit-line a { text-decoration: underline; text-underline-offset: 2px; }
.credits-head { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 22px; }
.credits-head h2 { font-size: 22px; letter-spacing: -.02em; }
.credits-note { padding: 4px 22px 10px; color: var(--muted); font-size: 13px; }
.credits-list { list-style: none; margin: 0; padding: 0 22px; display: grid; gap: 10px; font-size: 12.5px; color: var(--muted); }
.credits-list b { color: var(--text); font-weight: 600; }
.credits-list a { text-decoration: underline; text-underline-offset: 2px; }

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