/* Mobile-first styling for the volleyball KO tournament. */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273549;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #f97316;       /* volleyball orange */
  --win: #22c55e;
  --win-bg: rgba(34, 197, 94, 0.16);
  --bronze: #b45309;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}
.auth { display: flex; align-items: center; gap: 0.5rem; }
.admin-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 40px;            /* touch friendly */
}
.btn-primary { background: var(--accent); color: #1a1206; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-small { padding: 0.35rem 0.6rem; min-height: 34px; font-size: 0.8rem; background: var(--panel-2); color: var(--text); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-win {
  background: var(--panel-2);
  color: var(--win);
  border: 1px solid var(--line);
  padding: 0;
  width: 38px;
  height: 34px;
  min-height: 34px;
  font-size: 1rem;
}
.btn-win:not(:disabled):active { background: var(--win); color: #052e12; }

.undo { margin-top: 0.4rem; }
.btn-undo {
  width: 100%;
  background: transparent;
  color: var(--muted, #9aa);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  min-height: 32px;
}
.btn-undo:active { background: var(--panel-2); color: var(--text); }

/* ---------- Layout ---------- */
.container { padding: 1rem; }

.flashes { margin-bottom: 1rem; }
.flash {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.flash-error { background: rgba(239, 68, 68, 0.15); border: 1px solid #ef4444; }

.hint { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 1rem; }

/* ---------- Admin team editor ---------- */
.admin-teams {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.admin-teams summary { cursor: pointer; font-weight: 600; }
.team-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.team-edit { display: flex; align-items: center; gap: 0.5rem; }
.team-edit .seed { color: var(--muted); width: 2.2rem; font-size: 0.8rem; }
.name-input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font-size: 0.95rem;
}

/* ---------- Bracket ---------- */
.bracket {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}
.round {
  flex: 0 0 auto;
  min-width: 165px;
  display: flex;
  flex-direction: column;
}
.round-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.75rem;
  text-align: center;
}
.matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
  gap: 0.75rem;
}

.match {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.match.bronze { border-color: var(--bronze); }
.round-5 .round-title { color: var(--bronze); }

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
}
.team-row + .team-row { border-top: 1px solid var(--line); }
.team-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-row.winner { background: var(--win-bg); }
.team-row.winner .name { color: var(--win); font-weight: 700; }
.team-row.loser .name { color: var(--muted); text-decoration: line-through; }
.pick { display: flex; }

/* ---------- Login ---------- */
.login-card {
  max-width: 360px;
  margin: 2rem auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
}
.login-card h1 { margin-top: 0; font-size: 1.3rem; }
.login-card label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: var(--muted); }
.login-card input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.7rem;
  font-size: 1rem;
}
.back-link { display: inline-block; margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }

/* ---------- Larger screens ---------- */
@media (min-width: 720px) {
  .container { padding: 1.5rem 2rem; }
  .team-grid { grid-template-columns: 1fr 1fr; }
  .round { min-width: 200px; }
  .bracket { gap: 1.5rem; }
}
