:root {
  --bg: #140d2b;
  --bg2: #1d1440;
  --card: #241a4d;
  --card2: #2e2260;
  --line: #3b2f75;
  --text: #f4f0ff;
  --muted: #a99fd0;
  --accent: #ff4f8b;
  --accent2: #7c5cff;
  --ok: #3ddc97;
  --warn: #ffcc33;
  --danger: #ff5a5a;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #3a1f7a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 10; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(20, 13, 43, .88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 22px; letter-spacing: -.5px; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
.gear { color: var(--muted); text-decoration: none; font-size: 22px; padding: 4px 8px; }

.banner {
  background: repeating-linear-gradient(45deg, #ffcc33, #ffcc33 12px, #ffb000 12px, #ffb000 24px);
  color: #2a1a00; font-weight: 800; text-align: center; padding: 8px 16px; font-size: 14px;
}

main { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 4px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 10px 0;
}
.notice { text-align: center; padding: 22px 16px; }
.notice .big { font-size: 40px; display: block; margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700;
  background: var(--card2); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn.danger { background: #4a1a2a; color: #ffb3c2; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: default; }

label.f { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
input.in, select.in {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); font-size: 16px;
}
input.pin { letter-spacing: 10px; font-size: 24px; text-align: center; }
.err { color: #ffb3c2; min-height: 1.4em; margin: 8px 0; font-size: 14px; }

/* Avatares */
.av {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: none;
  border: 2px solid var(--accent2); background: var(--card2);
}
.av-ini { display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); }
.av.sm { width: 40px; height: 40px; font-size: 14px; }

/* Quadro do queridômetro */
.board { display: flex; flex-direction: column; gap: 8px; }
.pcard {
  display: flex; gap: 10px; align-items: center;
  background: linear-gradient(90deg, var(--card2), var(--card));
  border: 1px solid var(--line); border-radius: 999px 16px 16px 999px; padding: 6px 10px 6px 6px;
}
.pcard .body { flex: 1; min-width: 0; }
.pcard .name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0 0 2px 2px; }
.erow { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 1px; }
.ecell { display: flex; flex-direction: column; align-items: center; border-radius: 8px; padding: 2px 0; }
.ecell .e { font-size: 19px; line-height: 1.15; }
.ecell .n { font-size: 13px; font-weight: 800; }
.ecell.zero { opacity: .28; }
.ecell.hl { background: rgba(255, 79, 139, .22); }

.sortbar { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.sortbar button {
  flex: none; border: 1px solid var(--line); background: var(--bg2); border-radius: 999px;
  padding: 6px 10px; font-size: 17px; cursor: pointer;
}
.sortbar button.on { background: var(--accent); border-color: var(--accent); }
.sortbar button.txt { font-size: 14px; font-weight: 700; }

/* Cédula de votação */
.vcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin: 10px 0; }
.vcard.done { border-color: var(--accent2); }
.vhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.vhead .name { font-weight: 700; }
.vhead .pick { font-size: 13px; color: var(--muted); }
.vrow { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.vrow button {
  aspect-ratio: 1; border: 1px solid var(--line); background: var(--bg2); border-radius: 10px;
  font-size: 20px; padding: 0; cursor: pointer; transition: transform .1s;
}
.vcard.done .vrow button { opacity: .35; }
.vcard.done .vrow button.sel { opacity: 1; background: var(--accent); border-color: var(--accent); transform: scale(1.08); }

.sendbar {
  position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 8;
  padding: 10px 16px; background: linear-gradient(transparent, var(--bg) 35%);
}
.sendbar .btn { max-width: 528px; margin: 0 auto; display: flex; }

/* Navegação inferior */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(20, 13, 43, .95); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a { display: flex; flex-direction: column; align-items: center; padding: 8px 0 10px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.nav a span { font-size: 22px; }
.nav a.on { color: var(--text); }

/* Admin */
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.plist .item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.plist .item:first-child { border-top: 0; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--muted); margin-top: 2px; }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.off { color: var(--danger); }
.switch { position: relative; width: 54px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--warn); }
.switch input:checked + span::before { transform: translateX(22px); }
.tv { font-size: 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.tv:first-child { border-top: 0; }
.photo-pick { display: flex; align-items: center; gap: 12px; }
.photo-pick .av { width: 72px; height: 72px; }

dialog {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 528px; margin: 0 auto; background: #000c; border: 1px solid var(--line);
  padding: 12px 14px; border-radius: 12px; text-align: center; font-weight: 600;
}
