:root {
  --bg: #0b0d1d;
  --bg-2: #131634;
  --panel: rgba(30, 34, 74, 0.55);
  --panel-solid: #1b1f42;
  --panel-border: rgba(120, 130, 220, 0.22);
  --text: #f2f3ff;
  --muted: #a3a9d4;
  --gold: #ffc233;
  --gold-deep: #e8a800;
  --gold-text: #241a00;
  --p0: #52a8ff;
  --p1: #ff5fa2;
  --danger: #ff6161;
  --radius: 14px;
  --radius-sm: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 15% -5%, rgba(122, 60, 220, 0.35), transparent 60%),
    radial-gradient(900px 500px at 85% -5%, rgba(255, 94, 58, 0.28), transparent 60%),
    radial-gradient(1100px 700px at 50% 110%, rgba(30, 90, 200, 0.25), transparent 65%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
  background-attachment: fixed;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }

.view { min-height: 100vh; }
.center-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* ------------------------------------------------------------------ */
/* Cards / gates                                                       */
/* ------------------------------------------------------------------ */

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
}

.gate-card { width: min(430px, 100%); text-align: center; }
.gate-card h1 { margin: 0.5rem 0 0.25rem; letter-spacing: 0.01em; }

.brand-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0.75rem 0 0.25rem;
  background: linear-gradient(180deg, #fff 20%, #ffd76a 60%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.5em;
  margin-top: 0.35rem;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  font-weight: 600;
}

/* The BB eye */
.eye-logo { display: flex; justify-content: center; }
.eye-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 74px; height: 74px;
  border-radius: 50%;
  background: conic-gradient(from 40deg, #ff5e3a, #ffc233, #38e1c4, #52a8ff, #b06bff, #ff5e3a);
  box-shadow: 0 0 34px rgba(255, 194, 51, 0.35);
  animation: spin 14s linear infinite;
}
.eye-ring::after {
  content: "";
  position: absolute;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--bg-2);
}
.eye-pupil {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 18%, var(--gold) 20% 45%, #12142e 55%);
  z-index: 1;
}
.eye-mini .eye-ring { width: 34px; height: 34px; animation-duration: 10s; box-shadow: none; }
.eye-mini .eye-ring::after { width: 26px; height: 26px; }
.eye-mini .eye-pupil { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

#passcode-form { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1.4rem; }

input[type="password"] {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(10, 12, 30, 0.6);
  color: var(--text);
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.12em;
}
input[type="password"]:focus { outline: 2px solid var(--gold); border-color: transparent; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.06s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: var(--gold-text);
  box-shadow: 0 6px 22px rgba(255, 194, 51, 0.28);
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--panel-border);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(160, 170, 255, 0.5); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 97, 97, 0.5); }
.btn-danger:hover { background: rgba(255, 97, 97, 0.1); }
.btn-small { padding: 0.45rem 0.85rem; font-size: 0.83rem; }

.identity-buttons { display: flex; gap: 1rem; margin-top: 1.6rem; }
.identity-btn {
  flex: 1;
  padding: 1.4rem 1rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.identity-btn:hover { transform: translateY(-3px); }
.identity-btn.player-0 { background: linear-gradient(160deg, #2a6fd8, #123a7c); box-shadow: 0 10px 30px rgba(82, 168, 255, 0.3); }
.identity-btn.player-1 { background: linear-gradient(160deg, #d84a8c, #7c1246); box-shadow: 0 10px 30px rgba(255, 95, 162, 0.3); }

/* ------------------------------------------------------------------ */
/* Topbar + turn banner                                                */
/* ------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.25rem;
  background: rgba(11, 13, 29, 0.8);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}
.topbar-title { display: flex; align-items: center; gap: 0.7rem; }
.topbar-title strong { display: block; font-size: 1rem; letter-spacing: 0.02em; }
.topbar-tag {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.topbar-right { display: flex; align-items: center; gap: 0.7rem; }
.badge {
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
}
.badge.player-0 { color: var(--p0); border-color: rgba(82, 168, 255, 0.45); }
.badge.player-1 { color: var(--p1); border-color: rgba(255, 95, 162, 0.45); }

.turn-banner {
  text-align: center;
  padding: 0.95rem 1rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.turn-banner.my-turn {
  color: var(--gold);
  background: linear-gradient(90deg, transparent 5%, rgba(255, 194, 51, 0.14), transparent 95%);
  text-shadow: 0 0 24px rgba(255, 194, 51, 0.45);
  animation: pulse 1.7s ease-in-out infinite;
}
.turn-banner.their-turn { color: var(--muted); font-weight: 600; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ------------------------------------------------------------------ */
/* Draft layout                                                        */
/* ------------------------------------------------------------------ */

.draft-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1.4rem;
  padding: 0.25rem 1.4rem 2.5rem;
  max-width: 1280px;
  margin: 0 auto;
}
@media (max-width: 900px) { .draft-layout { grid-template-columns: 1fr; } }

.section-head { display: flex; align-items: center; gap: 0.8rem; margin: 0.4rem 0 1rem; }
.section-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: 0.02em; }
.count-pill {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid rgba(255, 194, 51, 0.4);
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
}

.hg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 0.9rem;
}

.hg-card {
  position: relative;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel-solid);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.hg-card:hover:not(:disabled) {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--gold), 0 0 26px rgba(255, 194, 51, 0.22);
}
.hg-card:disabled { cursor: default; }
.hg-card:disabled .hg-photo { filter: saturate(0.35) brightness(0.75); }

.hg-photo {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  background: #23264d;
}
.hg-info { padding: 0.6rem 0.7rem 0.75rem; }
.hg-name { font-weight: 800; font-size: 0.98rem; line-height: 1.2; }
.hg-meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.22rem; line-height: 1.35; }
.hg-note {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid rgba(255, 194, 51, 0.45);
  background: rgba(255, 194, 51, 0.08);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
}
.note-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid rgba(255, 194, 51, 0.45);
  background: rgba(255, 194, 51, 0.08);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

/* ------------------------------------------------------------------ */
/* Side panel: teams + log                                             */
/* ------------------------------------------------------------------ */

.side-panel { display: flex; flex-direction: column; gap: 1.1rem; padding-top: 0.4rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  backdrop-filter: blur(10px);
}
.panel h3 { margin: 0 0 0.8rem; font-size: 0.95rem; letter-spacing: 0.03em; }

.team-panel { margin-bottom: 1.1rem; border-top: 3px solid transparent; }
.team-panel.player-0 { border-top-color: var(--p0); }
.team-panel.player-1 { border-top-color: var(--p1); }
.team-panel h3 { display: flex; justify-content: space-between; align-items: baseline; }
.team-panel.player-0 h3 .name { color: var(--p0); }
.team-panel.player-1 h3 .name { color: var(--p1); }
.team-panel .count { color: var(--muted); font-size: 0.75rem; font-weight: 600; }

.team-list { list-style: none; margin: 0; padding: 0; }
.team-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.32rem 0;
  border-bottom: 1px solid rgba(120, 130, 220, 0.12);
  font-size: 0.92rem;
  font-weight: 600;
}
.team-list li:last-child { border-bottom: none; }
.team-list .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--panel-border);
  flex-shrink: 0;
  background: #23264d;
}
.team-list .pick-num { color: var(--muted); font-size: 0.72rem; font-weight: 700; min-width: 1.7em; }
.team-list .empty { color: var(--muted); font-style: italic; font-weight: 400; }

.log-panel { max-height: 250px; overflow-y: auto; }
.pick-log { margin: 0; padding-left: 1.3rem; font-size: 0.87rem; }
.pick-log li { padding: 0.18rem 0; color: var(--muted); }
.pick-log li strong { color: var(--text); }

.danger-zone { display: flex; gap: 0.6rem; justify-content: flex-end; }

/* ------------------------------------------------------------------ */
/* Summary                                                             */
/* ------------------------------------------------------------------ */

.summary-layout { max-width: 1100px; margin: 0 auto; padding: 1.8rem 1.4rem 3rem; text-align: center; }
.summary-title {
  margin: 0.4rem 0 0.2rem;
  font-size: 2.3rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff 20%, #ffd76a 60%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.summary-subtitle { color: var(--muted); margin: 0 0 1.4rem; }

.summary-teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin: 1.6rem 0;
  text-align: left;
}
@media (max-width: 760px) { .summary-teams { grid-template-columns: 1fr; } }

.summary-team { border-top: 4px solid transparent; }
.summary-team.player-0 { border-top-color: var(--p0); }
.summary-team.player-1 { border-top-color: var(--p1); }
.summary-team h3 { font-size: 1.25rem; margin-bottom: 1rem; }
.summary-team.player-0 h3 { color: var(--p0); }
.summary-team.player-1 h3 { color: var(--p1); }

.summary-hg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.7rem;
}
.summary-hg { text-align: center; }
.summary-hg img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: #23264d;
}
.summary-hg .hg-name { font-size: 0.85rem; margin-top: 0.35rem; }
.summary-hg .pick-num { color: var(--muted); font-size: 0.72rem; font-weight: 700; }

.export-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.summary-log { text-align: left; max-height: 320px; margin-top: 1.5rem; }

/* ------------------------------------------------------------------ */
/* Modal                                                               */
/* ------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 16, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal {
  display: flex;
  width: min(560px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
  animation: modal-in 0.16s ease-out;
}
@keyframes modal-in { from { transform: scale(0.94); opacity: 0; } }
.modal-photo {
  width: 220px;
  object-fit: cover;
  flex-shrink: 0;
  background: #23264d;
}
.modal-body { padding: 1.4rem 1.4rem 1.2rem; display: flex; flex-direction: column; }
.modal-body h2 { margin: 0 0 0.3rem; }
.modal-body .muted { margin: 0 0 0.6rem; line-height: 1.45; }
.modal-actions { display: flex; gap: 0.7rem; margin-top: auto; padding-top: 1rem; }
.modal-actions .btn { flex: 1; }
@media (max-width: 560px) {
  .modal { flex-direction: column; }
  .modal-photo { width: 100%; max-height: 300px; }
}

/* ------------------------------------------------------------------ */
/* Toast                                                               */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  bottom: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-solid);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 22px rgba(255, 194, 51, 0.18);
  z-index: 100;
}
