:root {
  --amarillo: #FFE53B;
  --verde: #2e9c12;
  --verde-2: #26860f;
  --verde-osc: #1c6b0c;
  --texto: #1b2a14;
  --muted: #5f6d54;
  --card: #ffffff;
  --card-2: #f4f7ef;
  --linea: #e2e8d8;
  --gold-deep: #d8a300;
  --danger: #d33a3f;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(20, 60, 10, .16);
  --shadow-sm: 0 3px 10px rgba(20, 60, 10, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Poppins', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: linear-gradient(147deg, #FFE53B 0%, #2e9c12 74%) fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid rgba(0,0,0,.06);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--texto); }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  font-weight: 900; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--amarillo), var(--verde));
  color: #143a08;
  box-shadow: var(--shadow-sm);
}
.brand-text { font-weight: 800; font-size: 1.08rem; }
.brand-logo { height: 44px; width: auto; display: block; }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: var(--verde-osc); text-decoration: none; font-weight: 700; }
.topnav a:hover { text-decoration: underline; }
.linklike { background: none; border: none; color: var(--verde-osc); font-weight: 700; cursor: pointer; padding: 0; font-size: 1rem; }
.linklike:hover { text-decoration: underline; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 32px;
  width: 100%; max-width: 380px; text-align: center; }
.login-brand { margin-bottom: 14px; }
.login-brand .brand-mark { width: 54px; height: 54px; font-size: 1.3rem; margin: 0 auto; }
.login-logo { display: block; margin: 0 auto 8px; width: 170px; max-width: 75%; height: auto; }
.login-card h1 { margin: 6px 0 2px; font-size: 1.5rem; }
.login-card form { margin-top: 16px; }

/* Layout */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 26px 20px 80px; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 6px 0 6px; font-size: 1.8rem; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.28); }
.page-head .muted { color: rgba(255,255,255,.92); text-shadow: 0 1px 4px rgba(0,0,0,.25); }
.back { color: #fff; text-decoration: none; font-size: .92rem; font-weight: 600; opacity: .95; text-shadow: 0 1px 4px rgba(0,0,0,.25); }
.back:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--linea);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-title { margin: 0 0 14px; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.card-sub { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--linea); }
.card-sub h3 { margin: 0 0 8px; font-size: 1rem; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }

/* Forms */
input, button, select, textarea { font: inherit; }
input[type="text"], input[type="number"], input[type="password"], textarea {
  background: #fff; border: 1px solid var(--linea); color: var(--texto);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--verde); outline-offset: 1px; border-color: var(--verde); }
textarea { resize: vertical; }

.row-form { display: flex; gap: 10px; margin-bottom: 6px; }
.row-form input { flex: 1; }

.rules-form { display: grid; gap: 12px; }
.rules-form label { display: grid; gap: 6px; font-size: .92rem; }
.rules-form label span { color: var(--muted); font-weight: 600; }
.rules-form label input { max-width: 150px; }

/* Buttons */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
  font-weight: 800; cursor: pointer; text-decoration: none; display: inline-block;
  background: var(--card-2); color: var(--texto); border-color: var(--linea);
}
.btn:hover { filter: brightness(.99); box-shadow: var(--shadow-sm); }
.btn-primary { background: linear-gradient(135deg, var(--verde), var(--verde-2)); color: #fff; border: none; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-soft { background: var(--card-2); color: var(--muted); border: 1px dashed var(--linea); }
.btn-soft:disabled { cursor: not-allowed; opacity: .7; }
.btn-mini { padding: 6px 10px; font-size: .82rem; }
.btn-danger-ghost { background: #fff; border: 1px solid #efc9ca; color: var(--danger); }
.btn-danger-ghost:hover { background: #fdeeee; }

/* Grid de competencias */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.comp-card {
  display: block; text-decoration: none; color: var(--texto);
  background: var(--card); border: 1px solid var(--linea); border-radius: var(--radius);
  padding: 18px; transition: transform .12s ease, box-shadow .12s ease; box-shadow: var(--shadow-sm);
}
.comp-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.comp-card-top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.comp-card h3 { margin: 0 0 10px; font-size: 1.08rem; }
.comp-stats { display: flex; gap: 14px; font-size: .92rem; margin-bottom: 6px; }
.comp-rules { font-size: .82rem; }

/* Estado pills */
.estado { font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.estado-configuracion { background: #fff4c9; color: var(--gold-deep); }
.estado-en_curso { background: #d9f4dd; color: var(--verde-2); }
.estado-finalizada { background: #eceff2; color: #6b7784; }

.count-pill { background: var(--card-2); color: var(--muted); border-radius: 999px; padding: 2px 10px; font-size: .8rem; }

/* Categorías */
.cat-list { list-style: none; margin: 6px 0 14px; padding: 0; display: grid; gap: 6px; }
.cat-list li { display: flex; justify-content: space-between; background: var(--card-2);
  border: 1px solid var(--linea); border-radius: 8px; padding: 7px 12px; font-size: .92rem; }
.cat-list em { font-style: normal; color: var(--verde-2); font-weight: 800; }

/* Lista de equipos */
.team-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.team-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card-2); border: 1px solid var(--linea); border-radius: 10px; padding: 8px 10px; }
.team-list li.eliminado { opacity: .55; }
.team-name-form { flex: 1; }
.team-name-form input { border-color: transparent; background: transparent; font-weight: 600; }
.team-name-form input:hover { border-color: var(--linea); background: #fff; }
.team-actions { display: flex; align-items: center; gap: 8px; }
.badge { font-size: .72rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-vivo { background: #d9f4dd; color: var(--verde-2); }
.badge-out { background: #fbe3e3; color: var(--danger); }

/* Alerts */
.alert { border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-weight: 600; box-shadow: var(--shadow-sm); }
.alert-ok { background: #e4f7e6; border: 1px solid #b6e6bd; color: #1c6b0c; }
.alert-warn { background: #fff6d8; border: 1px solid #f0dd9a; color: #8a6d00; }
.alert-error { background: #fbe3e3; border: 1px solid #f0bcbd; color: #a12327; }

/* Importar */
.upload-form { display: grid; gap: 14px; }
.filedrop { display: block; border: 2px dashed var(--verde); border-radius: 14px; padding: 26px;
  text-align: center; cursor: pointer; background: var(--card-2); }
.filedrop:hover { background: #eef5e6; }
.filedrop input { display: block; margin: 0 auto 10px; }
.filedrop-text { color: var(--verde-osc); font-weight: 700; }
.formato-ej { background: #12210a; color: #d7f7c4; border-radius: 10px; padding: 14px 16px;
  overflow-x: auto; font-size: .85rem; line-height: 1.5; }

/* Preview de importación */
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px; background: rgba(255,255,255,.9); padding: 12px 14px;
  border-radius: 12px; box-shadow: var(--shadow-sm); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card-2); border: 1px solid var(--linea); border-radius: 999px;
  padding: 4px 11px; font-size: .82rem; font-weight: 600; }
.chip em { font-style: normal; color: var(--verde-2); font-weight: 800; }
.preview-actions { display: flex; gap: 8px; }

.cat-block { background: var(--card); border: 1px solid var(--linea); border-radius: 12px;
  margin-bottom: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.cat-block > summary { cursor: pointer; padding: 14px 16px; font-weight: 800; display: flex;
  justify-content: space-between; align-items: center; list-style: none; }
.cat-block > summary::-webkit-details-marker { display: none; }
.cat-block > summary em { font-style: normal; color: var(--muted); font-weight: 600; font-size: .88rem; }
.cat-block[open] > summary { border-bottom: 1px solid var(--linea); background: var(--card-2); }
.cat-body { padding: 12px 16px; display: grid; gap: 10px; }

.preg-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: start;
  padding: 10px; border: 1px solid var(--linea); border-radius: 10px; background: #fff; }
.preg-row.row-off { opacity: .45; background: #faf2f2; }
.preg-num { color: var(--muted); font-weight: 800; font-size: .82rem; padding-top: 8px; }
.preg-fields { display: grid; gap: 6px; }
.ta-preg { font-weight: 600; }
.ta-resp { color: #234718; background: #f7fbf3; }
.preg-del { display: flex; align-items: center; gap: 4px; font-size: .78rem; color: var(--muted);
  white-space: nowrap; padding-top: 6px; }

.sticky-save { position: sticky; bottom: 0; margin-top: 16px; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; flex-wrap: wrap; background: rgba(255,255,255,.96); border: 1px solid var(--linea);
  border-radius: 12px; padding: 12px 16px; box-shadow: 0 -6px 20px rgba(20,60,10,.15); }
.sticky-save .btn { }

/* Vacío */
.empty { text-align: center; color: #fff; padding: 50px 20px; text-shadow: 0 1px 6px rgba(0,0,0,.25); }
.empty h1 { font-size: 3rem; margin: 0 0 8px; }
.empty a { margin-top: 10px; }

/* Botón jugar */
.btn-jugar { font-size: 1.05rem; }

/* Editor de preguntas */
.cat-edit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cat-edit-list li { display: flex; align-items: center; gap: 12px; background: var(--card-2);
  border: 1px solid var(--linea); border-radius: 10px; padding: 10px 14px; }
.cat-edit-name { font-weight: 700; color: var(--texto); text-decoration: none; flex: 1; }
.cat-edit-name:hover { color: var(--verde-2); }
.cat-edit-list li .muted { font-size: .85rem; }

.preg-form { display: grid; gap: 10px; }
.preg-form label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); font-weight: 600; }
.preg-form input, .preg-form textarea { color: var(--texto); }

.preg-edit-list { display: grid; gap: 12px; max-height: 70vh; overflow-y: auto; padding-right: 4px; }
.preg-edit { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start;
  background: var(--card-2); border: 1px solid var(--linea); border-radius: 10px; padding: 10px; }
.preg-edit.usada { opacity: .7; }
.preg-edit-form { display: grid; gap: 6px; }
.preg-edit-top { display: flex; align-items: center; gap: 8px; }
.preg-num-input { width: 80px; }
.ta-preg { font-weight: 600; }
.ta-resp { background: #f7fbf3; }
.preg-edit-actions { display: flex; gap: 6px; }
.preg-edit-side { display: grid; gap: 6px; }

/* Setup de mesa */
.buzzer-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.bz { font-weight: 800; font-size: .82rem; padding: 4px 12px; border-radius: 999px; color: #fff; }
.bz-rojo { background: #e53935; }
.bz-azul { background: #1e88e5; }
.bz-amarillo { background: #fdd835; color: #1b2a14; }
.bz-verde { background: #43a047; }

.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pick { display: flex; align-items: center; gap: 10px; background: var(--card-2); border: 1px solid var(--linea);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.pick:hover { border-color: var(--verde); }
.pick input { width: auto; }
.pick-name { flex: 1; font-weight: 700; }
.pick-buzzer { font-size: .78rem; }

/* ---- Torneo ---- */
.ciclo-pill { font-size: .9rem; background: #fff; color: var(--verde-2); padding: 3px 12px; border-radius: 999px;
  font-weight: 800; vertical-align: middle; margin-left: 6px; box-shadow: var(--shadow-sm); }

/* Campeón */
.campeon-banner { display: flex; align-items: center; gap: 18px; background: linear-gradient(135deg, #ffe259, #ffa751);
  border-radius: 18px; padding: 18px 26px; margin-bottom: 20px; box-shadow: var(--shadow); color: #5a3d00; }
.campeon-trofeo { font-size: 3rem; line-height: 1; }
.campeon-info { flex: 1; min-width: 0; }
.campeon-label { font-weight: 700; text-transform: uppercase; letter-spacing: .5px; font-size: .8rem; opacity: .8; }
.campeon-nombre { font-size: 1.9rem; font-weight: 900; }
.campeon-pts { font-size: 1.6rem; font-weight: 900; white-space: nowrap; }
#confetti-win { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* Podio 2° y 3° */
.podio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
@media (max-width: 640px) { .podio-row { grid-template-columns: 1fr; } }
.podio-item { display: flex; align-items: center; gap: 14px; border-radius: 16px; padding: 14px 20px;
  box-shadow: var(--shadow-sm); }
.podio-item.plata { background: linear-gradient(135deg, #eef2f5, #c7ced6); color: #384049; }
.podio-item.bronce { background: linear-gradient(135deg, #f6ddc4, #d99a63); color: #5a3a1c; }
.podio-medalla { font-size: 2.2rem; line-height: 1; }
.podio-info { flex: 1; min-width: 0; }
.podio-label { font-weight: 700; text-transform: uppercase; letter-spacing: .5px; font-size: .74rem; opacity: .8; }
.podio-nombre { font-size: 1.35rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podio-pts { font-size: 1.25rem; font-weight: 900; white-space: nowrap; }

.mesa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.mesa-card { background: var(--card-2); border: 1px solid var(--linea); border-radius: 12px; padding: 12px; }
.mesa-card.done { opacity: .8; }
.mesa-card.des { border-color: var(--gold-deep); }
.mesa-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mesa-teams { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 5px; }
.mesa-teams li { display: flex; align-items: center; gap: 7px; font-size: .9rem; }
.mesa-teams li em { font-style: normal; margin-left: auto; font-weight: 800; color: var(--verde-2); }
.mesa-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.badge-play { background: #e4eefb; color: #1e6fc0; }

.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot-rojo { background: #e53935; } .dot-azul { background: #1e88e5; }
.dot-amarillo { background: #fdd835; } .dot-verde { background: #43a047; }

.tabla-pos { width: 100%; border-collapse: collapse; }
.tabla-pos th, .tabla-pos td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--linea); font-size: .92rem; }
.tabla-pos th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; }
.tabla-pos .num { text-align: center; font-weight: 700; }
.tabla-pos .total { color: var(--verde-2); font-weight: 800; }
.tabla-pos .fila-out { opacity: .5; }
.tabla-pos .fila-out td:first-child { text-decoration: line-through; }
.pts-input { width: 74px; text-align: center; font-weight: 800; color: var(--verde-2);
  padding: 6px 8px; border-radius: 8px; }
.tabla-guardar { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-top: 14px; }

.des-form { display: grid; gap: 10px; }
.des-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

/* Footer */
.foot { border-top: 1px solid rgba(255,255,255,.25); padding: 16px 22px; color: rgba(255,255,255,.9);
  font-size: .85rem; text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,.2); }
