:root {
  --bg: #0b1020;
  --panel: #151b30;
  --panel-2: #1c2440;
  --line: #2a3354;
  --text: #eef1f8;
  --muted: #98a2c0;
  --up: #22c55e;
  --down: #ef4444;
  --accent: #3b82f6;
  --bar: calc(64px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.2px; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg-btn { padding: 7px 13px; border-radius: 999px; font-size: 14px; color: var(--muted); }
.seg-btn.is-active { background: var(--accent); color: #fff; font-weight: 600; }

/* ---------- intro ---------- */
.intro { padding: 14px 14px 2px; max-width: 760px; }
.intro h1 { font-size: 20px; margin: 0 0 8px; }
.intro p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.intro p.muted { color: var(--muted); }
.intro strong { color: var(--text); }

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 12px calc(var(--bar) + 20px);
  align-items: start;
}
@media (min-width: 760px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.card.voted-up { border-color: var(--up); box-shadow: 0 0 0 1px var(--up) inset; }
.card.voted-down { border-color: var(--down); box-shadow: 0 0 0 1px var(--down) inset; opacity: 0.72; }

.thumb {
  position: relative;
  background: #fff;
  display: block; width: 100%;
  padding: 0; border: 0;
}
.thumb img {
  width: 100%; height: auto; aspect-ratio: 4 / 3;
  object-fit: contain; display: block;
}
.badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 15px; line-height: 1;
  background: rgba(0,0,0,0.65); border-radius: 999px; padding: 5px 7px;
}
.card-name {
  font-size: 13px; color: var(--muted);
  padding: 7px 10px 0; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; }
.vote {
  padding: 11px 0; border-radius: 11px; font-size: 19px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.vote.on-up { background: var(--up); border-color: var(--up); }
.vote.on-down { background: var(--down); border-color: var(--down); }

/* ---------- one-at-a-time ---------- */
.one { padding: 10px 12px calc(var(--bar) + 12px); }
.one-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.ghost { color: var(--muted); font-size: 14px; padding: 6px 2px; }
.ghost.small { font-size: 13px; }

.stage { position: relative; }
.one-card {
  background: #fff; border-radius: 18px; overflow: hidden;
  touch-action: pan-y;
  transition: transform 0.12s ease-out;
}
.one-card img {
  width: 100%; height: min(58vh, 62vw + 120px);
  object-fit: contain; display: block; background: #fff;
}
.one-name {
  text-align: center; color: #0b1020; font-weight: 600;
  padding: 6px 10px 10px; font-size: 15px;
}
.one-state {
  position: absolute; top: 10px; left: 10px;
  font-size: 22px; line-height: 1;
  background: rgba(0,0,0,0.6); border-radius: 999px; padding: 6px 9px;
}
.one-state:empty { display: none; }

.edge {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 3; font-size: 30px; line-height: 1;
  width: 42px; height: 58px; border-radius: 12px;
  background: rgba(11,16,32,0.55); color: #fff;
}
.edge-left { left: 6px; }
.edge-right { right: 6px; }

.one-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.act {
  padding: 16px 0; border-radius: 14px; font-size: 24px;
  background: var(--panel); border: 1px solid var(--line);
}
.act.skip { font-size: 16px; color: var(--muted); }
.act.up:active, .act.up.flash { background: var(--up); }
.act.down:active, .act.down.flash { background: var(--down); }

/* ---------- bottom bar ---------- */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11,16,32,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tally { display: flex; align-items: center; gap: 8px; }
.pill {
  font-size: 14px; font-variant-numeric: tabular-nums;
  padding: 7px 10px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
}
.pill.done { font-weight: 700; }
.pill.up.done { background: rgba(34,197,94,0.22); border-color: var(--up); }
.pill.down.done { background: rgba(239,68,68,0.22); border-color: var(--down); }
.submit {
  padding: 13px 22px; border-radius: 13px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.submit:disabled { background: #2a3354; color: #6b769b; cursor: not-allowed; }

/* ---------- done overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 9, 20, 0.92); padding: 24px;
}
.done-card { text-align: center; max-width: 340px; }
.done-emoji { font-size: 48px; }
.done-card h2 { margin: 8px 0; }
.done-card p { color: var(--muted); margin: 0 0 20px; }
