:root {
  --bg: #000;
  --panel: #0b0b0b;
  --panel-2: #141414;
  --line: #262626;
  --line-strong: #3d3d3d;
  --text: #fff;
  --muted: #8c8c8c;
  --invert-bg: #fff;
  --invert-text: #000;
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}

h2, h3 { margin: 0; letter-spacing: -0.01em; }
a { color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s ease, background .15s ease, color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line-strong); }
.btn-primary { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); font-weight: 700; }
.btn-primary:hover { background: #d9d9d9; border-color: #d9d9d9; }
.btn-primary:disabled:hover { background: var(--invert-bg); border-color: var(--invert-bg); }
.btn-wallet.connected { font-family: var(--mono); font-size: .9rem; }
.btn-wallet.connected::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text);
}
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
.icon-btn:hover { color: var(--text); }

/* ---------- Banner ---------- */
.banner {
  --green: #39ff14;
  overflow: hidden;
  background: #000;
  border-bottom: 1px solid #1d4d12;
  box-shadow: inset 0 -12px 24px -18px rgba(57, 255, 20, .45);
  color: var(--green);
  font-family: var(--mono);
  font-weight: 700;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 11px 0;
}
.banner-track { display: flex; width: max-content; animation: marquee 40s linear infinite; }
.banner:hover .banner-track { animation-play-state: paused; }
.banner-group { display: flex; align-items: center; flex: none; }
.banner span { white-space: nowrap; padding: 0 22px; text-shadow: 0 0 6px rgba(57, 255, 20, .75), 0 0 18px rgba(57, 255, 20, .35); }
.banner b { color: #fff; text-shadow: 0 0 8px rgba(255, 255, 255, .8); }
.banner i { font-style: normal; opacity: .55; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .banner-track { animation: none; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px;
  background: rgba(0, 0, 0, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--text);
  box-shadow: inset 0 0 0 5px var(--text), inset 0 0 0 7px var(--bg);
}
.brand-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.03em; }

/* ---------- Layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px; }

.status {
  display: grid;
  grid-template-columns: auto 1.4fr 1fr auto auto;
  align-items: center; gap: 16px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.status-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.value { font-size: 1.6rem; font-weight: 700; }
.value small { font-size: .9rem; color: var(--muted); font-weight: 500; }
#timer.urgent { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; width: 0; background: var(--text); transition: width .25s linear; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; margin-top: 24px; }
.section-head { margin-bottom: 16px; }
.section-head p { margin: 4px 0 0; }

/* ---------- Entries ---------- */
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.card.leader {
  grid-column: 1 / -1;
  flex-direction: row;
  border: 2px solid var(--text);
}
.card.leader .card-img { width: 55%; aspect-ratio: auto; min-height: 280px; }
.card.leader .card-body { justify-content: center; padding: 24px; }
.card.leader .caption { font-size: 1.3rem; }
.card.mine { border-style: dashed; border-color: var(--line-strong); }
.card.leader.mine { border-style: solid; border-color: var(--text); }

.card-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--panel-2); }
.rank {
  position: absolute; top: 10px; left: 10px;
  font-family: var(--mono); font-weight: 700; font-size: .85rem;
  padding: 4px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .75); color: var(--text);
}
.card.leader .rank { background: var(--invert-bg); color: var(--invert-text); }
.card-body { display: flex; flex-direction: column; gap: 10px; padding: 14px; flex: 1; }
.leader-tag { align-self: flex-start; font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.caption { margin: 0; font-weight: 500; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: .8rem; color: var(--muted); }
.meta .addr { font-family: var(--mono); }
.tag {
  font-size: .65rem; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line-strong); color: var(--muted);
}
.tag.you { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }
.votes { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; }
.votes small { color: var(--muted); font-weight: 500; font-size: .75rem; }
.vote-btn.voted { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }

.empty { padding: 48px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty p { margin: 4px 0; }

/* ---------- Sidebar ---------- */
.side { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel h3 { font-size: 1rem; margin-bottom: 12px; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: .92rem; color: #c8c8c8; }
.steps b { color: var(--text); }
.winners { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.winner {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: center;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.winner:last-child { border-bottom: 0; padding-bottom: 0; }
.winner img { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; }
.winner-top { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; }
.winner-amt { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.winner-amt a { text-decoration: none; }
.winner-amt a:hover { text-decoration: underline; }
.winner-cap { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Modals ---------- */
.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
}
.modal::backdrop { background: rgba(0, 0, 0, .75); backdrop-filter: blur(3px); }
.modal-inner { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal p { margin: 0; }

.qr {
  align-self: center;
  width: min(280px, 100%); aspect-ratio: 1;
  background: #fff; border-radius: 12px; padding: 12px;
  display: grid; place-items: center;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr.expired { opacity: .15; }
.capture-status {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: .9rem;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--text); animation: blink 1.2s steps(2, start) infinite; }
.dot.ok { background: var(--text); }
.wallet-options { display: flex; gap: 8px; }
.wallet-options .btn { flex: 1; }

.result { text-align: center; align-items: center; }
.result img { width: 100%; border-radius: 10px; aspect-ratio: 4 / 3; object-fit: cover; }
.result h3 { font-size: 1.4rem; }
.result .big { font-family: var(--mono); font-size: 2rem; font-weight: 700; }
.result .tx { font-family: var(--mono); font-size: .75rem; color: var(--muted); word-break: break-all; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; bottom: 16px; right: 16px; z-index: 50;
  display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px);
}
.toast {
  padding: 10px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  font-size: .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  animation: pop .2s ease;
}
.toast.good { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.toast.bad { border-color: var(--text); }

/* ---------- Phone capture page ---------- */
.capture-page { max-width: 520px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.capture-page h1 { margin: 8px 0 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.viewfinder {
  position: relative; aspect-ratio: 3 / 4;
  background: var(--panel-2); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
}
.viewfinder video, .viewfinder img { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder-msg {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 24px; text-align: center; color: var(--muted);
}
.shutter {
  align-self: center;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--text); border: 0;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--text);
  cursor: pointer;
}
.shutter:active { transform: scale(.94); }
.shutter:disabled { opacity: .3; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
.field input {
  padding: 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
  font: inherit; font-size: 1rem;
}
.field input:focus { outline: none; border-color: var(--text); }
.notice { padding: 14px; border: 1px solid var(--line-strong); border-radius: 10px; }
.notice.ok { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.notice p { margin: 0; }
.notice p + p { margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-cta { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .wrap { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .value { font-size: 1.3rem; }
  .card.leader { flex-direction: column; }
  .card.leader .card-img { width: 100%; min-height: 0; aspect-ratio: 4 / 3; }
  .card.leader .card-body { padding: 14px; }
}
