:root {
  --text: #f0f4ff;
  --text-dim: rgba(240, 244, 255, 0.62);
  --glass: rgba(12, 16, 32, 0.55);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(18, 24, 48, 0.72);
  --accent: #7c5cff;
  --accent-2: #00e5ff;
  --ok: #3dff9a;
  --warn: #ffc14a;
  --bad: #ff5c7a;
  --radius: 18px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Outfit", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: #06070f;
  overflow-x: hidden;
}
.bg-aurora {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 20%, #1a0a3a 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, #0a1a3a 0%, transparent 50%),
    linear-gradient(160deg, #06070f 0%, #0d1020 40%, #120818 100%);
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(60px);
  opacity: 0.65; mix-blend-mode: screen; will-change: transform;
}
.blob-1 {
  width: 55vmax; height: 55vmax; top: -15%; left: -20%;
  background: radial-gradient(circle, #7c5cff 0%, transparent 70%);
  animation: drift1 14s ease-in-out infinite alternate;
}
.blob-2 {
  width: 50vmax; height: 50vmax; bottom: -20%; right: -15%;
  background: radial-gradient(circle, #00e5ff 0%, transparent 70%);
  animation: drift2 18s ease-in-out infinite alternate;
}
.blob-3 {
  width: 40vmax; height: 40vmax; top: 40%; left: 30%;
  background: radial-gradient(circle, #ff4ecd 0%, transparent 70%);
  animation: drift3 12s ease-in-out infinite alternate; opacity: 0.45;
}
.blob-4 {
  width: 30vmax; height: 30vmax; top: 10%; right: 10%;
  background: radial-gradient(circle, #5b8cff 0%, transparent 70%);
  animation: drift1 20s ease-in-out infinite alternate-reverse; opacity: 0.4;
}
.noise {
  position: absolute; inset: 0; opacity: 0.04; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}
@keyframes drift1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8%, 12%) scale(1.12); }
  100% { transform: translate(-5%, 6%) scale(0.95); }
}
@keyframes drift2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-12%, -8%) scale(1.08); }
  100% { transform: translate(6%, -4%) scale(1.15); }
}
@keyframes drift3 {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { transform: translate(-10%, 15%) scale(1.2) rotate(25deg); }
}
#app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 32px; }
header { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.5), rgba(0, 229, 255, 0.35));
  border: 1px solid var(--glass-border); box-shadow: 0 0 24px rgba(124, 92, 255, 0.35);
}
.brand-text h1 {
  margin: 0; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 0%, #b8c0ff 40%, #00e5ff 100%);
  background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 5s linear infinite;
}
@keyframes shimmer { to { background-position: 200% center; } }
.subtitle { font-size: 0.7rem; color: var(--text-dim); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.badge {
  font-size: 0.72rem; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--text-dim);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.badge.admin { color: var(--ok); border-color: rgba(61, 255, 154, 0.35); box-shadow: 0 0 16px rgba(61, 255, 154, 0.15); }
nav { display: flex; gap: 8px; padding: 4px 16px 14px; }
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--text-dim);
  padding: 11px 10px; border-radius: 14px; font-weight: 600; font-size: 0.88rem; font-family: inherit;
  cursor: pointer; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: all 0.25s ease;
}
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.85), rgba(0, 229, 255, 0.55));
  border-color: rgba(255, 255, 255, 0.22); box-shadow: 0 4px 24px rgba(124, 92, 255, 0.4);
}
.tab:active { transform: scale(0.97); }
main { padding: 0 16px 24px; }
.card {
  position: relative; background: var(--glass-strong); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow); overflow: hidden;
}
.card h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 700; }
.meta { color: var(--text-dim); font-size: 0.8rem; line-height: 1.5; }
.status {
  display: inline-block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 3px 9px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06); margin-bottom: 8px; border: 1px solid transparent;
}
.status.open { color: var(--ok); background: rgba(61, 255, 154, 0.1); border-color: rgba(61, 255, 154, 0.25); }
.status.in_progress { color: var(--warn); background: rgba(255, 193, 74, 0.1); border-color: rgba(255, 193, 74, 0.25); }
.status.finished { color: var(--text-dim); }
button.action {
  margin-top: 12px; width: 100%; border: none;
  background: linear-gradient(135deg, #7c5cff, #4a9fff); color: #fff;
  padding: 12px 14px; border-radius: 12px; font-weight: 700; font-size: 0.9rem; font-family: inherit;
  cursor: pointer; box-shadow: 0 4px 20px rgba(124, 92, 255, 0.35);
}
button.danger { background: linear-gradient(135deg, #ff5c7a, #ff3d5e); box-shadow: 0 4px 20px rgba(255, 92, 122, 0.35); }
button.ghost { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-border); box-shadow: none; color: var(--text); }
.back { margin-bottom: 12px; }
.bracket {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.72rem;
  white-space: pre-wrap; line-height: 1.45; overflow-x: auto; color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 12px; border: 1px solid rgba(255, 255, 255, 0.06);
}
.empty { color: var(--text-dim); text-align: center; padding: 48px 16px; font-weight: 500; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 16px; color: var(--text-dim); font-weight: 500; }
.loader-ring {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1); border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ===== BRACKET TREE ===== */
.card-bracket { padding-bottom: 18px; }

.bracket-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 24px 8px;
  font-size: 0.85rem;
}

.bracket-scroll {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 8px 4px 4px;
  -webkit-overflow-scrolling: touch;
}

.bracket-tree {
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-width: min-content;
  padding-bottom: 8px;
}

.round {
  display: flex;
  flex-direction: column;
  min-width: 148px;
  flex-shrink: 0;
}

.round-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  text-align: center;
  margin-bottom: 10px;
  opacity: 0.9;
}

.round-matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 12px;
  flex: 1;
}

.match {
  position: relative;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.match.played {
  border-color: rgba(124, 92, 255, 0.35);
}

.match.pending {
  border-color: rgba(255, 255, 255, 0.08);
}

.match-num {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.25);
  font-weight: 600;
}

.slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 36px;
}

.slot:last-of-type { border-bottom: none; }

.slot.winner {
  background: linear-gradient(90deg, rgba(61, 255, 154, 0.18), transparent);
  color: var(--ok);
}

.slot.empty, .slot.bye-slot {
  color: rgba(255, 255, 255, 0.28);
  font-weight: 500;
  font-style: italic;
}

.slot-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.crown {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--ok);
}

.participants {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.participant {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.p-idx {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.5), rgba(0, 229, 255, 0.35));
  color: #fff;
  flex-shrink: 0;
}


/* ===== ROLE BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  letter-spacing: 0.02em;
}
.badge-admin {
  color: #fff;
  background: linear-gradient(135deg, #7c5cff, #00c6ff);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 20px rgba(124, 92, 255, 0.45), inset 0 1px 0 rgba(255,255,255,0.2);
  animation: badge-glow 2.4s ease-in-out infinite alternate;
}
.badge-player {
  color: var(--ok);
  border-color: rgba(61, 255, 154, 0.35);
  background: rgba(61, 255, 154, 0.1);
}
.badge-guest {
  color: var(--text-dim);
  opacity: 0.85;
}
@keyframes badge-glow {
  from { box-shadow: 0 0 12px rgba(124, 92, 255, 0.3); }
  to   { box-shadow: 0 0 28px rgba(0, 198, 255, 0.55); }
}

/* ===== PROFILE CARD ===== */
.profile-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.6), rgba(0, 229, 255, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 20px rgba(124, 92, 255, 0.3);
  overflow: hidden;
}
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-rows {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.profile-row .label { color: var(--text-dim); }
.profile-row .value { font-weight: 600; text-align: right; }
