:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #efebe1;
  --text: #1f2421;
  --muted: #6b6f68;
  --border: #ddd6c7;
  --brand: #1e5b3f;        /* tapete */
  --brand-ink: #ffffff;
  --accent: #b3261e;       /* copas */
  --gold: #b88a1b;         /* oros */
  --ok-bg: #e3f1e6;  --ok: #1e5b3f;
  --info-bg: #e7eef8; --info: #28518a;
  --warn-bg: #fbf0d6; --warn: #7a5a07;
  --err-bg: #f9e2df; --err: #9b231c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --surface: #1d2320; --surface-2: #252c28;
    --text: #e9ece8; --muted: #9aa39c; --border: #323a35;
    --brand: #2f7d57; --accent: #e0645b; --gold: #d9ad45;
    --ok-bg: #1d3327; --ok: #8fd3a8;
    --info-bg: #1d2a3b; --info: #9cc0f0;
    --warn-bg: #3a2f14; --warn: #f0cf7a;
    --err-bg: #3d1f1c; --err: #f3a39c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
@media (prefers-color-scheme: dark) { a { color: var(--ok); } }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- cabecera y navegación ---------- */
.topbar {
  background: var(--brand); color: var(--brand-ink);
  padding: .7rem 16px; position: sticky; top: 0; z-index: 10;
}
.topbar .title { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.topbar .title span { color: #f3d27a; }
.nav {
  display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none;
  margin: .5rem -16px -.7rem; padding: 0 12px;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: rgba(255,255,255,.85); text-decoration: none; white-space: nowrap;
  padding: .55rem .7rem; font-size: .95rem; border-bottom: 3px solid transparent;
}
.nav a.active { color: #fff; border-bottom-color: #f3d27a; font-weight: 600; }
.nav.admin { background: rgba(0,0,0,.18); }

main { max-width: 860px; margin: 0 auto; padding: 16px 16px 48px; }

/* ---------- bloques ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card.highlight { border: 2px solid var(--brand); }
.grid { display: grid; gap: 10px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.stack > * + * { margin-top: .6rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.info { background: var(--info-bg); color: var(--info); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem;
  font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.playing { background: var(--info-bg); color: var(--info); }
.badge.queued { background: var(--warn-bg); color: var(--warn); }
.badge.finished { background: var(--ok-bg); color: var(--ok); }
.badge.conflict { background: var(--err-bg); color: var(--err); }
.badge.table { background: var(--brand); color: #fff; }

/* ---------- formularios ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: .6rem 0 .25rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=url], input[type=date], input[type=time], textarea, select {
  width: 100%; font: inherit; padding: .65rem .75rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
textarea { min-height: 8rem; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; padding: .65rem 1rem; min-height: 44px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { min-height: 34px; padding: .35rem .7rem; font-size: .88rem; }
.btn.block { width: 100%; }
.inline { display: inline; }
.search { display: flex; gap: .5rem; margin-bottom: 12px; }
.search input { flex: 1; }

/* ---------- partidas ---------- */
.match { display: block; color: inherit; text-decoration: none; }
.match .head { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; font-size: .85rem; color: var(--muted); }
.side { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .3rem 0; }
.side + .side { border-top: 1px dashed var(--border); }
.side .who { min-width: 0; }
.side .who b { display: block; overflow-wrap: anywhere; }
.side .who small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.side .score { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1.5ch; text-align: right; }
.side.won b { color: var(--brand); }
@media (prefers-color-scheme: dark) { .side.won b { color: var(--ok); } }
.side.won .score { color: var(--gold); }
.side.lost { opacity: .6; }
.bye { color: var(--muted); font-style: italic; }

.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.tabs a {
  white-space: nowrap; text-decoration: none; padding: .45rem .8rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text); background: var(--surface); font-size: .9rem;
}
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs a small { opacity: .75; }

/* ---------- mesa grande (vista pareja) ---------- */
.big-table { text-align: center; padding: 12px 0 4px; }
.big-table .n { font-size: 3.5rem; font-weight: 800; line-height: 1; color: var(--brand); }
@media (prefers-color-scheme: dark) { .big-table .n { color: var(--ok); } }
.big-table .l { text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; color: var(--muted); }
.vs { text-align: center; margin: .6rem 0; }
.vs .rival { font-size: 1.25rem; font-weight: 700; }
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: .6rem; }
.results button { min-height: 64px; font-size: 1.05rem; }
.results .win { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.results .loss { background: var(--err-bg); color: var(--err); border-color: transparent; }
.results button.selected { outline: 3px solid var(--text); }

/* ---------- mesas ---------- */
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tbl { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: .85rem; min-height: 78px; }
.tbl .n { font-weight: 800; font-size: 1.1rem; }
.tbl.free { opacity: .55; border-style: dashed; }
.tbl.busy { border-left: 4px solid var(--brand); }
.tbl .p { overflow-wrap: anywhere; line-height: 1.25; }
.tbl .p + .p { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); }

/* ---------- tabla admin ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

.champion {
  text-align: center; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, #f7e7b4, #e9c661); color: #3d2d00; margin-bottom: 12px;
}
.champion .t { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; }
.champion .n { font-size: 1.5rem; font-weight: 800; }

.danger-zone { border-color: var(--accent); }
details summary { cursor: pointer; font-weight: 600; }

/* ---------- hoja de QR imprimible ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.qr-card { background: #fff; color: #000; border: 1px dashed #999; border-radius: 8px; padding: 10px; text-align: center; break-inside: avoid; }
.qr-card svg { width: 100%; height: auto; max-width: 160px; }
.qr-card .name { font-weight: 700; margin-top: 4px; }
.qr-card .players { font-size: .75rem; color: #444; }
.qr-card .hint { font-size: .65rem; color: #666; margin-top: 4px; word-break: break-all; }
@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .qr-grid { grid-template-columns: repeat(4, 1fr); }
}
a.stat { color: inherit; text-decoration: none; }

/* ---------- código de pareja ---------- */
.code {
  font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 1.1em;
  letter-spacing: .08em; background: var(--surface-2); padding: .1rem .45rem; border-radius: 6px;
}
.code-form input {
  font-family: ui-monospace, Consolas, monospace; font-size: 1.5rem; text-align: center;
  letter-spacing: .15em; text-transform: uppercase; margin-bottom: 10px;
}
.qr-card .qr-code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 1.25rem; letter-spacing: .1em; }

/* ---------- portada ---------- */
.hero {
  position: relative; color: #fff; text-align: center;
  min-height: 78vh; min-height: 78svh; display: flex; align-items: center; justify-content: center;
  padding: 48px 16px 40px;
  background: radial-gradient(ellipse at top, #2f7d57, #123826 70%) center / cover no-repeat;
}
.hero.has-img { background-size: cover; background-position: 40% center; }  /* monasterio a la izquierda del centro */
.hero::before {  /* oscurece la foto para que el texto se lea siempre */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.25) 0%, rgba(0,0,0,.45) 55%, rgba(0,0,0,.72) 100%);
}
.hero-inner { position: relative; max-width: 680px; width: 100%; }
.hero-logo { max-width: 140px; max-height: 140px; margin-bottom: 12px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.4)); }
.hero h1 {
  font-size: clamp(2rem, 8vw, 3.4rem); line-height: 1.05; margin: 0 0 .6rem;
  text-shadow: 0 2px 16px rgba(0,0,0,.45); letter-spacing: -.01em;
}
.hero-sub { font-size: 1.1rem; opacity: .95; margin: 0 0 .8rem; }
.hero-date { font-size: 1.15rem; font-weight: 700; color: #f3d27a; margin: .2rem 0; }
.hero-place { margin: .1rem 0 0; opacity: .92; }
.countdown { display: flex; justify-content: center; gap: 8px; margin: 20px 0 4px; }
.countdown[hidden] { display: none; }
.countdown div {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 12px;
  min-width: 68px; padding: 8px 6px; backdrop-filter: blur(4px);
}
.countdown b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.countdown span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.hero-cta { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 24px; }
.btn.big { font-size: 1.1rem; padding: .9rem 1.6rem; min-width: 260px; min-height: 54px; }
.btn.ghost { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.55); color: #fff; min-width: 260px; }
.hero .btn.primary { background: #f3d27a; border-color: #f3d27a; color: #2b2100; }
.pill { display: inline-block; padding: .45rem 1rem; border-radius: 999px; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.4); font-weight: 600; }
.hero-champion { background: rgba(0,0,0,.35); border: 1px solid #f3d27a; border-radius: 14px; padding: 12px 18px; }
.hero-champion span { display: block; color: #f3d27a; text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; }
.hero-champion b { font-size: 1.3rem; }

.landing { max-width: 720px; margin: 0 auto; }
.landing h2 { margin-top: 0; }
.rules ul { padding-left: 1.2rem; margin: .4rem 0 .8rem; }
.rules li + li { margin-top: .25rem; }
/* Pie común: Instagram y logos. Grupos (Organiza / Patrocinadores) uno al lado del otro;
   si no caben, bajan de línea. Los logos van sobre blanco para verse también en modo oscuro. */
.site-footer {
  max-width: 860px; margin: 8px auto 0; padding: 16px 16px 32px; text-align: center;
  border-top: 1px solid var(--border);
}
.social { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 8px; }
.social a { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; padding: 6px 4px; }
.logo-groups { display: flex; justify-content: center; align-items: flex-start; }
.logo-group { flex: 0 1 auto; min-width: 0; padding: 0 16px; }
.logo-group + .logo-group { border-left: 1px solid var(--border); }
.logo-group h3 {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  margin: 10px 0 8px;
}
.logos { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.logos img {
  height: 56px; width: auto; max-width: 140px; object-fit: contain;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px;
}
.logos.org img { height: 64px; max-width: 160px; }
@media (max-width: 480px) {
  .logo-group { padding: 0 10px; }
  .logos img { height: 46px; max-width: 110px; padding: 4px; }
  .logos.org img { height: 54px; max-width: 130px; }
}
.site-footer > p { margin: 16px 0 0; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
label.check input { width: 20px; height: 20px; }
