/* ===================================
   Переменные
   =================================== */
:root {
  --bg:           #0e0e12;
  --bg-card:      #16161e;
  --bg-card-hover:#1c1c26;
  --border:       #2a2a38;
  --accent:       #e8619d;   /* osu! pink */
  --accent-dim:   rgba(232, 97, 157, 0.15);
  --text:         #e8e8f0;
  --text-muted:   #7878a0;
  --text-dim:     #4a4a6a;
  --success:      #4caf82;
  --error:        #e85050;
  --radius:       10px;
  --radius-sm:    6px;
  --font-body:    'Inter', sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --transition:   0.18s ease;
}

/* ===================================
   Reset
   =================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }

/* ===================================
   Layout
   =================================== */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.main-content {
  flex: 1;
  padding: 48px 0 80px;
}

/* ===================================
   Header
   =================================== */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(14, 14, 18, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 60px;
}

.site-logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo-bracket { color: var(--accent); }

.site-nav {
  display: flex;
  gap: 24px;
  flex: 1;
}
.site-nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); }

.header-auth {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-username {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

/* ===================================
   Buttons
   =================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover {
  background: #d4558e;
  color: #fff;
  text-decoration: none;
}
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn--ghost:hover {
  border-color: var(--text-muted);
  color: var(--text);
  text-decoration: none;
}
.btn--sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

/* ===================================
   Page header
   =================================== */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 32px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.team-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===================================
   Teams grid
   =================================== */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
}
.team-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-card-hover);
}

.team-card__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.team-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}
.team-avatar--placeholder {
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.team-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.team-pp-total {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===================================
   Player rows inside card
   =================================== */
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.player-row:last-child { border-bottom: none; }
.player-row:hover {
  background: var(--accent-dim);
  text-decoration: none;
}

.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.player-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.player-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex-shrink: 0;
}
.player-pp {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}
.player-rank {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===================================
   Register form
   =================================== */
.register-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 640px;
}

.captain-info {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  margin-bottom: 28px;
}
.captain-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
.captain-label {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.captain-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.captain-pp {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.register-form { display: flex; flex-direction: column; gap: 28px; }

.form-section { display: flex; flex-direction: column; gap: 16px; }
.form-section-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}
.optional { color: var(--text-dim); font-weight: 400; }

.form-group input,
.form-group textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 10px 14px;
  transition: border-color var(--transition);
  width: 100%;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===================================
   Alerts
   =================================== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.alert--success {
  background: rgba(76, 175, 130, 0.12);
  border: 1px solid rgba(76, 175, 130, 0.3);
  color: var(--success);
}
.alert--error {
  background: rgba(232, 80, 80, 0.1);
  border: 1px solid rgba(232, 80, 80, 0.3);
  color: var(--error);
}

/* ===================================
   Empty state
   =================================== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ===================================
   Footer
   =================================== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 640px) {
  .site-nav { display: none; }
  .teams-grid { grid-template-columns: 1fr; }
  .register-card { padding: 20px 16px; }
  .page-title { font-size: 1.5rem; }
}

/* ===================================
   Tournament banner
   =================================== */
.tournament-banner {
  position: relative;
  height: 220px;
  background: var(--bg-card);
  overflow: hidden;
  margin-bottom: 0;
}
.banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
}
.banner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px 32px;
  background: linear-gradient(to top, rgba(14,14,18,0.95) 0%, transparent 100%);
}
.tournament-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 10px;
}
.tournament-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge--green {
  background: rgba(76,175,130,0.15);
  color: var(--success);
  border-color: rgba(76,175,130,0.3);
}

/* ===================================
   Tournament nav
   =================================== */
.tournament-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tournament-nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition);
}
.tournament-nav a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.tournament-nav .btn {
  margin-left: auto;
}

/* ===================================
   Home grid
   =================================== */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 32px;
}
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.info-card h2 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.date-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.date-list dt { color: var(--text-dim); font-size: 0.85rem; }
.date-list dd { color: var(--text); font-size: 0.85rem; font-weight: 500; }

/* ===================================
   BBCode styles
   =================================== */
.rules-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 780px;
}
.bbcode-content { line-height: 1.75; color: var(--text); }
.bbcode-heading {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 24px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.bbcode-list {
  padding-left: 20px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bbcode-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 12px 0;
  overflow: hidden;
}
.bbcode-box summary {
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bbcode-box summary::before {
  content: '▸';
  color: var(--accent);
  font-size: 0.8rem;
  transition: transform var(--transition);
}
.bbcode-box[open] summary::before { transform: rotate(90deg); }
.bbcode-box__body {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

/* ===================================
   Debug banner
   =================================== */
.debug-banner {
  background: rgba(255, 180, 0, 0.12);
  border-bottom: 1px solid rgba(255, 180, 0, 0.3);
  color: #f0b429;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  padding: 6px;
  letter-spacing: 0.04em;
}
