/* Brekitz Web - Design System */

:root {
  --background: #0A0A0B;
  --surface: #141416;
  --surface-elevated: #1C1C1F;
  --primary: #FF6B35;
  --accent: #7C3AED;
  --success: #10B981;
  --text: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;
  --border: #27272A;
  --radius: 12px;
  --radius-lg: 16px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* App Banner */
.app-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

.banner-content {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.app-text .app-name {
  display: block;
  font-weight: 600;
  font-size: 16px;
}

.app-text .app-tagline {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  border: 1px solid var(--border);
  cursor: pointer;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
}

.btn-text:hover {
  color: var(--text);
}

/* Main Content */
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 20px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state span {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Error State */
.error-state {
  text-align: center;
  padding: 48px 20px;
}

.error-icon {
  width: 64px;
  height: 64px;
  background: var(--surface-elevated);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
}

.error-state h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.error-state p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

/* Tournament Card */
.tournament-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.2;
}

/* Tags and Badges */
.tag {
  display: inline-block;
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-right: 8px;
  margin-bottom: 12px;
}

.badge {
  display: inline-block;
  background: var(--surface-elevated);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 20px;
}

/* Progress Section */
.progress-section {
  margin-bottom: 20px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.progress-bar {
  height: 8px;
  background: var(--surface-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

/* Current Stage */
.current-stage {
  background: var(--surface-elevated);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}

.current-stage .label {
  display: block;
  margin-bottom: 4px;
}

.stage-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}

/* Winner Section */
.winner-section {
  text-align: center;
  padding: 24px;
  background: linear-gradient(135deg, rgba(255,107,53,0.1), rgba(124,58,237,0.1));
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.trophy-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.winner-section .label {
  display: block;
  margin-bottom: 4px;
}

.winner-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* Participants Section */
.participants-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.participants-list {
  list-style: none;
  margin-top: 12px;
}

.participants-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.participants-list li:last-child {
  border-bottom: none;
}

.seed {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 24px;
}

/* Real-time Indicator */
.realtime-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.realtime-indicator.disconnected .pulse {
  background: var(--text-muted);
  animation: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

.store-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.store-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  color: white;
}

.store-btn.ios {
  background: #000;
}

.store-btn.android {
  background: #414141;
}

.store-btn span {
  font-size: 10px;
  opacity: 0.8;
}

.store-btn strong {
  font-size: 16px;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Landing Page Styles */
.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 20px;
}

.landing-logo {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 24px;
}

.landing-container h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.landing-container .tagline {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.landing-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

/* Round Robin Standings */
.standings-table {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 24px;
}

.standings-header {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.standings-row {
  display: flex;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.standings-row:last-child {
  border-bottom: none;
}

.standings-row.leader {
  background: rgba(255, 107, 53, 0.08);
}

.standings-row.leader .name,
.standings-row.leader .pts {
  color: var(--primary);
  font-weight: 600;
}

.standings-table .rank {
  width: 32px;
  text-align: center;
}

.standings-table .name {
  flex: 1;
  padding-right: 12px;
}

.standings-table .trophy {
  font-size: 12px;
}

.standings-table .stat {
  width: 40px;
  text-align: center;
}

.standings-table .win {
  color: var(--primary);
}

.standings-table .draw {
  color: #F59E0B;
}

.standings-table .loss {
  color: var(--text-muted);
}

.standings-table .positive {
  color: var(--success);
}

.standings-table .negative {
  color: #EF4444;
}

/* Round Robin Matches */
.round-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-elevated);
  cursor: pointer;
  user-select: none;
}

.round-header:hover {
  background: var(--surface);
}

.round-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.round-progress {
  font-size: 12px;
  color: var(--text-muted);
}

.matches-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  opacity: 0.5;
}

.match-card.completed {
  opacity: 1;
}

.match-player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}

.match-player.winner {
  color: var(--primary);
  font-weight: 600;
}

.match-player .score {
  font-size: 16px;
  font-weight: 600;
  margin-left: 12px;
}

.match-player.winner .score {
  color: var(--primary);
}

.match-player .checkmark {
  color: var(--primary);
  font-size: 18px;
  margin-left: 12px;
}

.match-vs {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 0;
}

/* ============================================
   BRACKET VISUALIZATION
   ============================================ */

/* View Header */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-elevated);
  border-radius: var(--radius);
  flex: 1;
}

/* Fullscreen Button */
.fullscreen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.fullscreen-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--primary);
}

.view-btn {
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn:hover {
  color: var(--text);
}

.view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Bracket Container */
.bracket-container {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
}

.bracket-svg {
  display: block;
  min-width: 100%;
}

/* Connectors */
.connector {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
  transition: stroke 0.3s;
}

.connector.highlighted {
  stroke: var(--primary);
}

.connector.loser-line {
  stroke-dasharray: 6 4;
}

/* Round Labels */
.round-label {
  fill: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bracket-label {
  fill: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Match Cards */
.bracket-match {
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0.5;
  transition: all 0.2s;
}

.bracket-match.playable {
  opacity: 1;
  border-color: var(--accent);
}

.bracket-match.completed {
  opacity: 1;
}

.bracket-match.bye {
  opacity: 0.6;
}

.bracket-match.finals {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(255,107,53,0.08), rgba(124,58,237,0.08));
}

.bracket-player {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  min-height: 0;
}

.bracket-player.winner {
  background: rgba(255, 107, 53, 0.1);
}

.bracket-player.winner .player-name {
  color: var(--primary);
  font-weight: 600;
}

.bracket-player.winner .player-score {
  color: var(--primary);
}

.player-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.player-score {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 8px;
}

.bracket-divider {
  height: 1px;
  background: var(--border);
}

/* Participants List (when toggled) */
.participants-list-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ============================================
   FULLSCREEN MODE
   ============================================ */

#fullscreen-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.fullscreen-overlay {
  width: 100%;
  height: 100%;
  background: var(--background);
  display: flex;
  flex-direction: column;
}

.fullscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fullscreen-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fullscreen-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
  flex-shrink: 0;
}

.fullscreen-close:hover {
  background: var(--surface-elevated);
  color: var(--text);
}

.fullscreen-bracket {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.fullscreen-bracket .bracket-svg {
  display: block;
}

.fullscreen-realtime {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

.fullscreen-realtime .pulse {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
