:root {
  --bg: #fafaf8;
  --card: #ffffff;
  --surface: #ffffff;
  --soft: #f4efe3;
  --soft-line: #e3d6bb;
  --media: #ecebe6;
  --thumb: #e7e5de;
  --ok-bg: #eef7f1;
  --bad-bg: #fbefed;
  --btn-bg: var(--ink);
  --btn-ink: #ffffff;
  --top-bg: rgba(250, 250, 248, .92);
  --nav-bg: rgba(255, 255, 255, .94);
  --ink: #141414;
  --mute: #77746e;
  --line: #e6e3dc;
  --accent: #8a6d3b;
  --ok: #2f7d4f;
  --bad: #b3402f;
  --r: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }
.muted { color: var(--mute); }
.err { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 14px; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 11px; color: var(--accent); margin: 0 0 6px; }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; margin: 0 0 8px; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 22px; }

/* topo */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: var(--top-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 19px; line-height: 1.1; }
.brand small { display: block; font-family: inherit; color: var(--mute); font-size: 12px; letter-spacing: .04em; margin-top: 3px; }
.pill { font-size: 13px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--mute); max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 560px; margin: 0 auto; padding: 18px; }

/* navegação */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: flex-end;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: var(--nav-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; max-width: 90px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--mute); text-decoration: none; font-size: 11px; padding: 4px 0;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.active { color: var(--ink); }
.tabs a.shoot {
  flex: none; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%;
  background: var(--btn-bg); color: var(--btn-ink); justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
}
.tabs a.shoot svg { width: 26px; height: 26px; }

/* botões e campos */
.btn {
  appearance: none; border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font: inherit; font-weight: 500; padding: 13px 18px; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
input[type=text], input:not([type]), select, textarea {
  width: 100%; font: inherit; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
label.field { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--mute); }

/* início / feed */
.hero { padding: 6px 0 20px; }
.hero p { margin: 0; color: var(--mute); max-width: 36ch; }
.feed { display: flex; flex-direction: column; gap: 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.card .meta { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 10px; font-size: 14px; }
.card .meta span { color: var(--mute); font-size: 12px; }
.card .media { display: block; width: 100%; padding: 0; border: 0; background: var(--media); position: relative; cursor: pointer; min-height: 120px; }
.card .media img { display: block; width: 100%; height: auto; }
.card .media .ph { aspect-ratio: 4 / 3; background: #1d1d1d; }
.card .play {
  position: absolute; inset: 0; margin: auto; width: 58px; height: 58px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); display: grid; place-items: center;
}
.card .play::after { content: ""; border-left: 16px solid #fff; border-top: 10px solid transparent; border-bottom: 10px solid transparent; margin-left: 4px; }
.card .foot { padding: 10px 14px 14px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.card .foot .tag { align-self: flex-start; font-size: 12px; color: var(--accent); border: 1px solid var(--soft-line); border-radius: 999px; padding: 2px 10px; }
.card .foot .del { align-self: flex-end; background: none; border: 0; color: var(--mute); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; }
.empty { text-align: center; color: var(--mute); padding: 56px 12px; border: 1px dashed var(--line); border-radius: var(--r); }
.empty .btn { margin-top: 16px; }
.sentinel { height: 1px; }

/* câmera / envio */
.choices { display: grid; gap: 12px; margin: 18px 0; }
.choices label.btn { cursor: pointer; }
.choices label.btn.primary { padding: 18px; font-size: 17px; }
.choices input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.banner { background: var(--soft); border: 1px solid var(--soft-line); border-radius: 12px; padding: 12px 14px; font-size: 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.banner button { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.queue { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.qrow { display: flex; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.qrow .th { width: 56px; height: 56px; border-radius: 8px; background: var(--thumb) center / cover no-repeat; flex: none; }
.qrow .tx { flex: 1; min-width: 0; font-size: 13px; }
.qrow .tx b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow .tx span { color: var(--mute); }
.qrow.error .tx span { color: var(--bad); }
.qrow.done .tx span { color: var(--ok); }
.bar { height: 4px; background: var(--line); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--btn-bg); transition: width .15s; }
.success { text-align: center; padding: 34px 10px; }
.success h2 { font-size: 26px; }

/* desafios */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.item { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.item .n { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; color: var(--mute); }
.item.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 500; }
.item .t span { font-size: 13px; color: var(--mute); }
.score { display: flex; gap: 10px; margin: 14px 0 6px; }
.score > div { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.score b { display: block; font-family: var(--serif); font-size: 26px; font-weight: 400; }
.score span { font-size: 12px; color: var(--mute); }

/* quiz */
.progress { display: flex; gap: 5px; margin: 6px 0 22px; }
.progress i { flex: 1; height: 3px; border-radius: 3px; background: var(--line); }
.progress i.on { background: var(--btn-bg); }
.qtext { font-family: var(--serif); font-size: 26px; line-height: 1.2; margin: 0 0 20px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { text-align: left; font: inherit; padding: 15px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink); }
.opt:disabled { cursor: default; }
.opt.ok { border-color: var(--ok); background: var(--ok-bg); }
.opt.bad { border-color: var(--bad); background: var(--bad-bg); }
.feedback { margin: 18px 0; font-size: 15px; }
.feedback b.ok { color: var(--ok); }
.feedback b.bad { color: var(--bad); }

/* ranking */
.rank { display: flex; flex-direction: column; margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.rank .row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.rank .row:last-child { border-bottom: 0; }
.rank .row.me { background: var(--soft); }
.rank .pos { width: 24px; font-family: var(--serif); font-size: 20px; color: var(--mute); }
.rank .row:nth-child(-n+3) .pos { color: var(--accent); }
.rank .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .who small { display: block; color: var(--mute); font-size: 12px; }
.rank .pts { font-weight: 600; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(10, 10, 10, .96); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 78vh; border-radius: 6px; background: #000; }
.lightbox .cap { color: #fff; margin-top: 14px; text-align: center; font-size: 14px; max-width: 520px; }
.lightbox .cap small { display: block; color: #aaa; margin-top: 4px; }
.lightbox .x { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; background: rgba(255, 255, 255, .14); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer; }

/* entrada */
.gate { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: grid; place-items: center; padding: 22px; overflow: auto; }
.gate-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.gate-card .muted { margin: 0 0 6px; }

.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--btn-bg); color: var(--btn-ink); padding: 11px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 90; max-width: 88vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ======================= TEMAS =======================
   O tema do evento vem do painel e é aplicado em <html data-theme="...">.
   Elegante é o padrão (variáveis do :root acima). */

/* Festa Gamer: escuro com neon */
[data-theme="festa"] {
  --bg: #0b0d17; --card: #141829; --surface: #141829; --ink: #e9ecff; --mute: #8b93bd; --line: #262c4d;
  --accent: #35f2c2; --ok: #35f2c2; --bad: #ff5c7a;
  --soft: #1a2040; --soft-line: #2f3a73; --media: #0f1222; --thumb: #1a2040; --ok-bg: #10302c; --bad-bg: #3a1621;
  --btn-bg: #35f2c2; --btn-ink: #06130f; --top-bg: rgba(11, 13, 23, .9); --nav-bg: rgba(15, 18, 34, .94);
  --r: 10px; --serif: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
[data-theme="festa"] h1, [data-theme="festa"] .brand { text-transform: uppercase; letter-spacing: .04em; }
[data-theme="festa"] h1 { font-size: 26px; }
[data-theme="festa"] .eyebrow { color: #b57cff; }
[data-theme="festa"] .btn.primary { box-shadow: 0 0 18px rgba(53, 242, 194, .3); }
[data-theme="festa"] .tabs a.active { color: var(--accent); }
[data-theme="festa"] .tabs a.shoot { box-shadow: 0 0 22px rgba(53, 242, 194, .55); }
[data-theme="festa"] .rank .row:nth-child(-n+3) .pos, [data-theme="festa"] .card .foot .tag { color: var(--accent); }
[data-theme="festa"] .card .media .ph { background: #0f1222; }
[data-theme="festa"] .score b { color: var(--accent); }

/* Colorido: alegre, para infantil, 15 anos, formaturas e chás */
[data-theme="colorido"] {
  --bg: #fff7ec; --card: #ffffff; --surface: #ffffff; --ink: #2a1f4d; --mute: #7a6f99; --line: #f0dfc6;
  --accent: #ff4f8b; --ok: #1f9d6b; --bad: #d6334f;
  --soft: #ffe9c7; --soft-line: #ffd28a; --media: #f6e7d0; --thumb: #f1dec2; --ok-bg: #e6f7ef; --bad-bg: #fde8ec;
  --btn-bg: #6b3bff; --btn-ink: #ffffff; --top-bg: rgba(255, 247, 236, .92); --nav-bg: rgba(255, 255, 255, .95);
  --r: 20px; --serif: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
[data-theme="colorido"] h1, [data-theme="colorido"] h2 { font-weight: 800; letter-spacing: -.02em; }
[data-theme="colorido"] .btn { border-radius: 999px; }
[data-theme="colorido"] .btn:not(.primary) { border-color: var(--btn-bg); color: var(--btn-bg); }
[data-theme="colorido"] .eyebrow { color: #6b3bff; }
[data-theme="colorido"] .tabs a.active { color: #6b3bff; }
[data-theme="colorido"] .opt, [data-theme="colorido"] .item, [data-theme="colorido"] .qrow { border-radius: 18px; }
[data-theme="festa"] .item.done .n { color: #06130f; }

/* estados de tela cheia (evento encerrado / não encontrado) */
.notice { max-width: 420px; margin: 18vh auto 0; text-align: center; padding: 0 22px; }
.notice h1 { margin-bottom: 10px; }
