@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;900&display=swap');
*{box-sizing:border-box;margin:0;padding:0;}
body{font-family:'Inter',sans-serif;background:#0a0a0f;color:#fff;min-height:100vh;padding-bottom:3rem;overflow-x:hidden;}
:root{--gold:#FFCC00;--gold2:#e6b800;--glass:#161616;--border:rgba(255,255,255,0.1);--bg:#0a0a0a;}
header{background:#000;padding:1rem;padding-bottom:0;text-align:center;border-bottom:1px solid var(--border);}
.header-banner{max-width:100%;height:auto;max-height:120px;object-fit:contain;display:block;margin:0 auto;}
@media (max-width:600px){ .header-banner{max-height:80px;} }
.top-bar { position: sticky; top: 0; z-index: 100; padding: 0.8rem 1.5rem; display: flex; justify-content: center; align-items: center; background: rgba(10,10,15,0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.hamburger-btn { background: transparent; border: none; color: var(--gold); font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-family: inherit; font-weight: 600; transition: color 0.2s; }
.hamburger-btn:hover { color: #fff; }

.glass-menu { position: fixed; top: 0; right: -100%; width: 280px; height: 100vh; background: rgba(10,10,15,0.95); backdrop-filter: blur(15px); border-left: 1px solid var(--border); z-index: 200; display: flex; flex-direction: column; padding: 1.5rem 0; transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: -5px 0 30px rgba(0,0,0,0.5); }
.glass-menu.open { right: 0; }
.close-menu { align-self: flex-end; background: transparent; border: none; color: #fff; font-size: 2rem; cursor: pointer; margin-right: 1.5rem; margin-bottom: 1rem; line-height: 1; transition: color 0.2s; }
.close-menu:hover { color: var(--gold); }

.glass-menu button { background: transparent; border: none; border-bottom: 1px solid rgba(255,255,255,0.05); color: #ccc; padding: 1.2rem 1.5rem; text-align: left; font-family: inherit; font-size: 1rem; cursor: pointer; transition: all 0.2s; border-left: 3px solid transparent; font-weight: 500; }
.glass-menu button:hover { background: rgba(255,204,0,0.05); color: #fff; padding-left: 2rem; }
.glass-menu button.active { color: var(--gold); border-left: 3px solid var(--gold); background: rgba(255,204,0,0.1); font-weight: 700; }

#menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 150; visibility: hidden; opacity: 0; transition: all 0.3s; backdrop-filter: blur(2px); }
#menu-overlay.open { visibility: visible; opacity: 1; }
.section{display:none;padding:1rem;max-width:1300px;margin:0 auto;}
.section.active{display:block;}

/* Grupos */
.groups-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:1rem;}
.group-card{background:var(--glass);border:1px solid var(--border);border-radius:12px;overflow:hidden;transition:all .2s;}
.group-card:hover{border-color:rgba(255,204,0,0.5);}
.group-header{background:#000;padding:.6rem 1rem;font-weight:700;color:var(--gold);border-bottom:1px solid var(--border);}
.team-row{display:flex;align-items:center;padding:.5rem;gap:.5rem;border-bottom:1px solid rgba(255,255,255,.05);color:#ddd;}
.pos-btn{width:24px;height:24px;border-radius:50%;border:1px solid var(--border);background:transparent;color:#fff;cursor:pointer;font-size:.7rem;transition:all .2s;}
.pos-btn.p1{background:var(--gold);color:#000;font-weight:700;border-color:var(--gold);}
.pos-btn.p2{background:#aaa;color:#000;font-weight:700;border-color:#fff;}
.pos-btn.p3{background:rgba(255,204,0,0.2);color:var(--gold);font-weight:700;border-color:var(--gold);}

.thirds-section{margin-top:2rem;background:var(--glass);padding:1.5rem;border-radius:12px;border:1px solid var(--border);}
.thirds-grid{display:flex;flex-wrap:wrap;gap:.8rem;margin-top:1rem;}
.third-chip{padding:.6rem 1.2rem;border-radius:20px;border:1px solid var(--border);background:transparent;color:#fff;cursor:pointer;opacity:.5;transition:all .2s;font-size:.9rem;}
.third-chip.selected{background:rgba(255,204,0,.1);border-color:var(--gold);opacity:1;font-weight:700;color:var(--gold);box-shadow:0 0 10px rgba(255,204,0,.15);}

.btn-primary{display:block;margin:2rem auto;padding:1rem 2.5rem;background:transparent;color:var(--gold);border:1px solid var(--gold);border-radius:30px;font-weight:600;cursor:pointer;font-size:1.1rem;transition:all .2s;}
.btn-primary:hover{background:var(--gold);color:#000;box-shadow:0 0 15px rgba(255,204,0,.3);transform:scale(1.02);}
.stats{display:flex;justify-content:center;gap:2rem;margin-bottom:1.5rem;font-size:.9rem;}
.stat-badge{background:var(--glass);padding:.5rem 1rem;border-radius:20px;border:1px solid var(--border);color:var(--gold);font-weight:600;}

/* Bracket (Fase Final) */
#knockout{max-width:100%;}
.bracket-wrapper{overflow-x:auto;padding:1rem 0;scrollbar-width:thin;}
.bracket{display:flex;min-width:1500px;gap:2rem;padding:0 1rem;padding-bottom:2rem;}
.bracket-col{display:flex;flex-direction:column;flex:1;min-height:0;}
.col-title{text-align:center;color:var(--gold);font-weight:700;font-size:1rem;text-transform:uppercase;margin-bottom:1.5rem;letter-spacing:1px;position:sticky;top:0;background:var(--bg);padding:1rem 0;z-index:2;}
.col-matches{display:flex;flex-direction:column;flex:1;min-height:0;position:relative;}

.match-card{background:var(--glass);border:1px solid var(--border);border-radius:12px;margin:5px 0;position:relative;min-width:200px;flex-shrink:0;transition:all .2s;}
.match-card:hover{border-color:var(--gold);box-shadow:0 0 15px rgba(255,204,0,.15);transform:translateY(-2px);}
.match-info{font-size:.65rem;padding:.4rem .6rem;background:#000;color:#888;border-bottom:1px solid var(--border);border-radius:12px 12px 0 0;}
.match-team{padding:.6rem;cursor:pointer;display:flex;align-items:center;gap:.5rem;font-size:.85rem;transition:background .2s;color:#ccc;}
.match-team:hover{background:rgba(255,204,0,.05);}
.match-team.winner{background:rgba(255,204,0,.1);font-weight:700;color:var(--gold);}
.match-team + .match-team{border-top:1px solid var(--border);}
.t-name{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

/* Líneas conectores CSS (Árboles) */
.match-pair {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1 1 0%;
  min-height: 0;
  position: relative;
}

.bracket-col:not(:last-child) .match-pair::after {
  content: '';
  position: absolute;
  top: 25%;
  bottom: 25%;
  right: -1rem;
  width: 1rem;
  border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
}

.bracket-col:not(:last-child) .match-pair::before {
  content: '';
  position: absolute;
  top: 50%;
  right: -2rem;
  width: 1rem;
  height: 1px;
  background: var(--border);
}

/* Champion Section */
.champion-box{text-align:center;max-width:600px;margin:2rem auto;padding:3rem;background:#111;border-radius:16px;border:1px solid var(--gold);box-shadow:0 0 30px rgba(255,204,0,.15);display:none;animation:fadeIn .5s ease-in;}
@keyframes fadeIn { from {opacity:0; transform:scale(.95);} to {opacity:1; transform:scale(1);} }
.champion-box h2{color:var(--gold);font-size:1.5rem;margin-bottom:1rem;text-transform:uppercase;letter-spacing:2px;}
.champion-team{font-size:3.5rem;font-weight:900;text-shadow:0 0 20px rgba(255,204,0,.4);color:#fff;}
/* Toast Notifications */
#toast{position:fixed;bottom:-100px;left:50%;transform:translateX(-50%);background:var(--gold);color:#000;padding:1rem 2rem;border-radius:30px;font-weight:700;z-index:9999;transition:all .3s cubic-bezier(0.68, -0.55, 0.265, 1.55);box-shadow:0 10px 30px rgba(255,204,0,.4);text-align:center;max-width:90%;}
#toast.show{bottom:30px;}

/* Link inválido (solo si falta ?id=) */
#link-error{display:none;max-width:500px;margin:3rem auto;padding:2rem;text-align:center;background:var(--glass);border:1px solid var(--border);border-radius:12px;}
#link-error h2{color:var(--gold);margin-bottom:.5rem;}

/* Modales (admin, gracias) */
.overlay-modal{display:none;position:fixed;inset:0;z-index:10000;background:rgba(0,0,0,.75);backdrop-filter:blur(4px);align-items:center;justify-content:center;padding:1rem;}
.overlay-modal.open{display:flex;}
.overlay-modal .modal-box{background:#111;border:1px solid var(--gold);border-radius:12px;padding:1.5rem;max-width:400px;width:100%;}
.overlay-modal label{display:block;margin:.75rem 0 .25rem;font-size:.85rem;color:#aaa;}
.overlay-modal input{width:100%;padding:.6rem;border-radius:8px;border:1px solid var(--border);background:#0a0a0a;color:#fff;font-family:inherit;}
.thankyou-box{text-align:center;max-width:420px;}

/* Solo lectura */
body.read-only .pos-btn,
body.read-only .third-chip{cursor:default;opacity:.85;}
body.read-only .match-team[data-pick]{cursor:default;}
body.read-only #btn-autofill,
body.read-only #btn-submit{display:none!important;}

/* Spinner en botón submit */
.btn-primary.is-loading{pointer-events:none;opacity:.85;}
.btn-spinner{display:inline-block;width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:spin .6s linear infinite;vertical-align:-.15em;margin-right:.35em;}
@keyframes spin{to{transform:rotate(360deg);}}
