:root {
  --bg: #0e0c14;
  --card: #1c1828;
  --card-edge: rgba(255, 255, 255, 0.1);
  --text: #ffffff;
  --muted: #b9b3c9;
  --accent: #ffc400;
  --accent-ink: #14110a;
  --gap: clamp(10px, 1.6vmin, 20px);
  --display: "Avenir Next Condensed", "Avenir Next", "Helvetica Neue", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  padding: max(env(safe-area-inset-top), 16px) max(env(safe-area-inset-right), 16px)
           max(env(safe-area-inset-bottom), 28px) max(env(safe-area-inset-left), 16px);
}

.screen { height: 100%; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

/* ---------- messages (loading, thanks, closed) ---------- */
.screen-message { align-items: center; justify-content: center; text-align: center; gap: 24px; padding: 0 5vw; }
.big-message { font-size: clamp(36px, 6vmin, 72px); font-weight: 800; line-height: 1.1; margin: 0; overflow-wrap: anywhere; }
.closed-event { font-size: clamp(20px, 3vmin, 32px); color: var(--muted); margin: 0; font-weight: 600; }
.thanks-check {
  width: clamp(120px, 22vmin, 220px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-size: clamp(72px, 14vmin, 140px); font-weight: 900; line-height: 1;
  animation: pop 0.35s cubic-bezier(.2, 1.6, .4, 1);
}
#thanks-name { color: var(--accent); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- ballot ---------- */
.ballot-header { text-align: center; padding-bottom: var(--gap); }
.event-name { margin: 0; font-size: clamp(28px, 4.6vmin, 52px); font-weight: 800; line-height: 1.05; overflow-wrap: anywhere; }
.instruction { margin: 4px 0 0; font-size: clamp(16px, 2.2vmin, 24px); color: var(--accent); font-weight: 600; letter-spacing: 0.02em; }

.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr));
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 2px solid var(--card-edge);
  border-radius: 22px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: center;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.08s ease;
}
.card:active, .card.pressed { transform: scale(0.97); border-color: var(--accent); }
.card-photo { flex: 1; min-height: 0; width: 100%; object-fit: cover; display: block; background: #000; }
.card-text { padding: 12px 14px 14px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.card.no-photo .card-text { flex: 1; padding: 18px; }
.card-name {
  font-size: var(--name-size, 28px); font-weight: 800; line-height: 1.05;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
}
.card.no-photo .card-name { font-size: calc(var(--name-size, 28px) * 1.35); -webkit-line-clamp: 3; }
.card-tagline {
  font-size: var(--tag-size, 16px); color: var(--muted); font-weight: 500; line-height: 1.2;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.card-tagline:empty { display: none; }

/* ---------- confirm ---------- */
#screen-confirm { align-items: center; justify-content: center; gap: clamp(24px, 5vmin, 56px); text-align: center; }
.confirm-band { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 0; max-width: 90vw; }
.confirm-photo {
  width: clamp(200px, 40vmin, 420px); aspect-ratio: 1; object-fit: cover;
  border-radius: 28px; border: 3px solid var(--accent); margin-bottom: 12px; flex-shrink: 1; min-height: 0;
}
.confirm-photo[hidden] { display: none; }
.confirm-label { margin: 0; color: var(--accent); font-size: clamp(20px, 3vmin, 30px); font-weight: 700; }
.confirm-name { margin: 0; font-size: clamp(48px, 9vmin, 110px); font-weight: 800; line-height: 1; overflow-wrap: anywhere; }
.confirm-tagline { margin: 0; color: var(--muted); font-size: clamp(18px, 2.8vmin, 30px); }
.confirm-tagline:empty { display: none; }
.confirm-actions { display: flex; gap: clamp(16px, 3vmin, 32px); }

.btn {
  font: inherit; font-weight: 800; font-size: clamp(28px, 4.4vmin, 44px);
  min-width: clamp(200px, 26vmin, 300px); min-height: clamp(90px, 12vmin, 130px);
  border-radius: 24px; border: 3px solid transparent; cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.96); }
.btn-vote { background: var(--accent); color: var(--accent-ink); }
.btn-back { background: transparent; color: var(--text); border-color: rgba(255, 255, 255, 0.45); }

.timeout-bar {
  position: fixed; left: 0; bottom: 0; height: 6px; width: 100%;
  background: rgba(255, 196, 0, 0.5); transform-origin: left;
}
.timeout-bar.running { animation: shrink var(--timeout, 20s) linear forwards; }
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- status line & warnings ---------- */
.status {
  position: fixed; right: max(env(safe-area-inset-right), 12px); bottom: max(env(safe-area-inset-bottom), 6px);
  font: 12px/1.2 ui-monospace, Menlo, monospace; color: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}
.status.pending { color: var(--accent); }
.key-warning {
  position: fixed; left: 50%; top: max(env(safe-area-inset-top), 8px); transform: translateX(-50%);
  margin: 0; padding: 10px 18px; border-radius: 12px;
  background: #b3261e; color: #fff; font: 600 16px/1.2 system-ui, sans-serif;
}
.key-warning[hidden] { display: none; }
