/* 363 Challenge Series · estilos base (negro, blanco y verde lima del tablero físico) */
:root {
  --black: #0a0a0a;
  --ink: #141414;
  --ink-2: #1d1d1d;
  --ink-3: #2a2a2a;
  --line: #333;
  --white: #ffffff;
  --paper: #eef0ea;
  --muted: #a3a3a3;
  --lime: #B9E402;
  --lime-deep: #a9d000;
  --lime-ink: #111a00;
  --danger: #ff5c5c;
  --warn: #ffb020;
  --ok: #c8f31d;
  --radius: 14px;
  --font-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--black);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--lime); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Marca ---------- */
.brand { text-align: center; line-height: 1; user-select: none; }
.brand-logo { display: block; width: 168px; max-width: 60%; height: auto; margin: 0 auto; }
.brand-site { display: table; margin: 6px auto 0; background: var(--lime); color: var(--lime-ink); font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; padding: 2px 12px; transform: skewX(-12deg); }
.brand-challenge { margin: 10px auto 0; border: 3px solid var(--lime); border-radius: 12px; padding: 6px 18px 4px; display: inline-flex; flex-direction: column; align-items: center; transform: skewX(-10deg); }
.brand-challenge span { font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 1.9rem; letter-spacing: 0.01em; }
.brand-challenge small { font-family: var(--font-display); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.6em; margin-top: 2px; }

/* ---------- Estructura app ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(10,10,10,0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .logo { font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 1.5rem; letter-spacing: -0.03em; text-decoration: none; color: var(--white); }
.topbar .logo img { display: block; height: 30px; width: auto; }
.topbar .title { flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar nav { display: flex; gap: 6px; }
main { max-width: 960px; margin: 0 auto; padding: 16px 16px 120px; }
h1, h2, h3 { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.01em; margin: 0 0 10px; line-height: 1.05; }
h1 { font-size: 1.9rem; font-style: italic; font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 700; margin-top: 22px; }
h3 { font-size: 1.1rem; font-weight: 700; }

/* ---------- Controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-2); color: var(--white); font-weight: 600; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover { border-color: #555; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: 1.1rem; letter-spacing: 0.02em; }
.btn-primary:hover { background: #d6ff3a; }
.btn-xl { width: 100%; min-height: 64px; font-size: 1.5rem; border-radius: 16px; font-style: italic; }
.btn-ghost { background: transparent; }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: 0.85rem; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label.field { display: block; margin: 12px 0; }
label.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink); color: var(--white); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(200,243,29,0.18); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--ink); margin: 12px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--lime); flex: none; margin-top: 2px; }
.mark-input { font-family: var(--font-display); font-size: 2.6rem !important; font-weight: 800; text-align: center; letter-spacing: 0.04em; min-height: 76px !important; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.error-text { color: var(--danger); font-size: 0.9rem; margin-top: 6px; }

/* ---------- Tarjetas y listas ---------- */
.card { background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--lime); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; border: 1px solid var(--line); color: var(--muted); }
.badge-open { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.badge-closed { color: var(--white); }
.badge-warn { border-color: var(--warn); color: var(--warn); }
.badge-danger { border-color: var(--danger); color: var(--danger); }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 8px 0 14px; scrollbar-width: none; }
.tab { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; text-decoration: none; }
.tab.active { background: var(--white); color: var(--black); border-color: var(--white); }

/* ---------- Tabla de clasificación (personal) ---------- */
.lb { width: 100%; border-collapse: collapse; }
.lb th { text-align: left; font-size: 0.75rem; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.lb td { padding: 10px 8px; border-bottom: 1px solid var(--ink-3); vertical-align: middle; }
.lb tr.clickable { cursor: pointer; }
.lb tr.clickable:hover td { background: var(--ink-2); }
.lb .pos { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; width: 42px; color: var(--lime); }
.lb .mark { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; text-align: right; white-space: nowrap; }
.lb .who b { display: block; }
.lb .who small { color: var(--muted); }
.lb tr.void td { color: var(--muted); text-decoration: line-through; }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.summary .card { padding: 12px; }
.summary .label { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; }
.summary .value { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; }
.summary .sub { font-size: 0.8rem; color: var(--muted); }

/* ---------- Hoja de registro ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 40; display: flex; justify-content: center; align-items: flex-end; }
.sheet { width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto; background: var(--ink); border: 1px solid var(--line); border-bottom: none; border-radius: 20px 20px 0 0; padding: 16px 16px 28px; animation: up 0.18s ease-out; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-style: italic; }
.result-list { list-style: none; margin: 10px 0; padding: 0; }
.result-list li + li { margin-top: 8px; }
.person-btn { width: 100%; text-align: left; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink-2); cursor: pointer; }
.person-btn:hover, .person-btn:focus { border-color: var(--lime); outline: none; }
.person-btn .who { flex: 1; min-width: 0; }
.person-btn .who b { display: block; font-size: 1.05rem; }
.person-btn .who small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-person { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--ink-2); border: 1px solid var(--lime); }
.selected-person .who { flex: 1; }
.matches { border: 1px solid var(--warn); border-radius: 12px; padding: 12px; margin: 12px 0; background: rgba(255,176,32,0.06); }
.matches h3 { color: var(--warn); font-size: 1rem; }

/* ---------- Estado de confirmación ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin: 10px 0; font-weight: 600; }
.banner-ok { background: rgba(200,243,29,0.12); border: 1px solid var(--lime); color: var(--lime); }
.banner-warn { background: rgba(255,176,32,0.1); border: 1px solid var(--warn); color: var(--warn); }
.banner-error { background: rgba(255,92,92,0.1); border: 1px solid var(--danger); color: var(--danger); }
.banner .icon { font-size: 1.2rem; line-height: 1.2; }
.banner small { display: block; font-weight: 400; color: var(--white); opacity: 0.85; }
.pending-list { list-style: none; padding: 0; margin: 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.live-dot.live { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.live-dot.reconnecting { background: var(--warn); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); background-color: #161c05; box-shadow: 0 8px 30px rgba(0,0,0,0.6); }
.toast.banner-error { background-color: #2a1010; }
.toast.banner-warn { background-color: #2a1f08; }

/* ---------- Login ---------- */
.login { max-width: 420px; margin: 0 auto; padding: 40px 16px; }
.login .brand { margin-bottom: 28px; }
.demo-accounts { margin-top: 22px; }
.demo-accounts button { width: 100%; justify-content: space-between; margin-top: 8px; }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--ink-3); vertical-align: top; }
.admin-table th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.chip input { accent-color: var(--lime); }
.table-wrap { overflow-x: auto; }
details > summary { cursor: pointer; color: var(--muted); }

/* ---------- Reglas del reto ---------- */
.rules { display: grid; gap: 10px; }
.rule-item { border-left: 3px solid var(--lime); padding: 2px 0 2px 12px; }
.rule-label { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; color: var(--lime); letter-spacing: 0.03em; }
.rule-value { font-size: 0.95rem; }
.rule-value ul { margin: 4px 0 0; padding-left: 18px; }
.rules-compact .rule-value { font-size: 0.88rem; }
details.rules-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--ink-2); margin: 10px 0; }
details.rules-box > summary { color: var(--lime); font-weight: 700; }
details.rules-box[open] > summary { margin-bottom: 10px; }
fieldset.rules-form { border: 2px solid var(--lime); border-radius: 14px; padding: 6px 14px 12px; margin: 14px 0; }
fieldset.rules-form legend { font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; color: var(--lime); padding: 0 6px; font-size: 1.1rem; }
.usage { display: inline-flex; gap: 6px; align-items: center; }
.photo-row { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.photo-preview { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: var(--ink-3); display: flex; align-items: center; justify-content: center; flex: none; border: 2px solid var(--line); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.consent-icons { font-size: 0.8rem; letter-spacing: 1px; }
.person-thumb { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.qr-box { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; }
.qr-box svg, .qr-box img { display: block; width: 100%; height: auto; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: fixed; inset: 0; background: #fff; color: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
}
