/* 
   Beerpong Tournament Manager CSS (Version 5)
   Theme: Apple iOS / Liquid Glass (OLED Black, System Gradients, Translucent Cards)
   Optimized for iPad Safari Touch
*/

:root {
  color-scheme: dark;
  
  /* Color Palette - Apple Dark Mode Colors */
  --bg-color: #000000;
  --bg-gradient: linear-gradient(180deg, #000000 0%, #0c0c0e 100%);
  --system-grouped-bg: #1c1c1e;
  --system-secondary-bg: rgba(28, 28, 30, 0.7);
  
  --card-bg: rgba(28, 28, 30, 0.6);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-active: rgba(255, 255, 255, 0.2);
  
  --text-main: #ffffff;
  --text-secondary: #8e8e93;
  --text-muted: #636366;
  
  /* iOS System Accent Colors */
  --accent-gold: #ffd700;
  --accent-gold-glow: rgba(255, 215, 0, 0.35);
  --accent-gold-bg: rgba(255, 215, 0, 0.12);
  
  --accent-red: #ff453a;
  --accent-red-glow: rgba(255, 69, 58, 0.35);
  --accent-red-bg: rgba(255, 69, 58, 0.12);
  
  --accent-blue: #0a84ff;
  --accent-blue-glow: rgba(10, 132, 255, 0.35);
  --accent-blue-bg: rgba(10, 132, 255, 0.12);
  
  --accent-green: #30d158;
  --accent-green-glow: rgba(48, 209, 88, 0.35);
  --accent-green-bg: rgba(48, 209, 88, 0.15);
  
  --accent-orange: #ff9f0a;
  --accent-orange-bg: rgba(255, 159, 10, 0.15);
  
  --accent-grey: rgba(255, 255, 255, 0.1);
  --accent-grey-active: rgba(255, 255, 255, 0.18);
  
  /* Layout & Blur */
  --glass-blur: blur(25px);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  /* Fonts */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", sans-serif;
}

/* CSS Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

html {
  background-color: #0c0c0e;
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  height: 100vh;
  height: 100lvh;
  height: -webkit-fill-available;
  overflow: auto;
}

body {
  font-family: var(--font-family);
  background-color: #0c0c0e;
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--text-main);
  height: 100vh;
  height: 100lvh;
  height: -webkit-fill-available;
  overflow: auto;
}

button, input, select {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* App Container Layout */
.app-container {
  display: grid;
  grid-template-columns: clamp(350px, 30vw, 420px) 1fr;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  height: -webkit-fill-available;
  overflow: hidden;
}

/* iPad Sidebar (Like Files or Notes Sidebar) */
.sidebar {
  background: rgba(18, 18, 18, 0.6);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 10;
}

.sidebar-header {
  padding: 24px 20px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
}
.ypb-logo {
  grid-column: 1;
  justify-self: start;
  width: 60px;
  height: 36px;
  flex-shrink: 0;
}

.sidebar-title {
  grid-column: 2;
  justify-self: center;
  font-family: 'Orbitron', var(--font-family);
  font-size: 1.15rem !important;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent-gold);
  white-space: nowrap;
  margin: 0;
  text-align: center;
}

.sidebar-right-container {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Outlined minimalist live status badge - hidden for Spielleiter (admin) by default */
.live-badge {
  display: none;
  font-family: var(--font-family);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  user-select: none;
  transition: all 0.3s ease;
  line-height: 1.2;
}

/* Only show sync/live status badge for spectators (read-only-mode) */
body.read-only-mode .live-badge {
  display: inline-block;
}

.live-badge.synced {
  color: #a3e635; /* light green */
  border: 1px solid rgba(163, 230, 53, 0.4);
  background: rgba(163, 230, 53, 0.05);
}

.live-badge.syncing {
  color: #fbbf24; /* amber */
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.05);
}

.live-badge.offline {
  color: #9ca3af; /* gray */
  border: 1px solid rgba(156, 163, 175, 0.4);
  background: rgba(156, 163, 175, 0.05);
}

.live-badge.error {
  color: #f87171; /* red */
  border: 1px solid rgba(248, 113, 113, 0.6);
  background: rgba(248, 113, 113, 0.05);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.2);
}

.ypb-sub {
  color: var(--accent-gold);
  font-size: 0.9rem;
  font-weight: 600;
}

.table-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 10px;
  -webkit-overflow-scrolling: touch;
}

/* Sticky Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--card-border);
  background: rgba(18, 18, 18, 0.85);
  display: flex;
  gap: 10px;
  align-items: center;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  table-layout: fixed;
}

th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  background: rgb(18, 18, 18);
  z-index: 2;
}

td {
  padding: 12px 8px;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  vertical-align: middle;
}

.row-player.active-in-match {
  background: rgba(255, 255, 255, 0.04);
}

.row-player.active-in-match td:first-child {
  box-shadow: inset 2px 0 0 #ffffff;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

.row-player.active-in-match td:last-child {
  box-shadow: inset -2px 0 0 #ffffff;
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

.row-player.paused-player {
  opacity: 0.35;
  font-style: italic;
}

/* Rank column */
.col-rank {
  width: 10%;
  text-align: center;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
}

.rank-1 .rank-badge { background: #ffd700; color: #000; font-weight: 800; }
.rank-2 .rank-badge { background: #c0c0c0; color: #000; font-weight: 800; }
.rank-3 .rank-badge { background: #cd7f32; color: #000; font-weight: 800; }
.rank-4 .rank-badge { background: var(--accent-green); color: #000; font-weight: 800; }
.rank-other .rank-badge { color: var(--text-secondary); }

.col-name {
  font-weight: 600;
  width: 45%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paused-tag {
  font-size: 0.6rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 5px;
  vertical-align: middle;
}

.col-wins {
  width: 15%;
  font-variant-numeric: tabular-nums;
}

.col-diff {
  width: 15%;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.diff-positive { color: var(--accent-green); }
.diff-negative { color: var(--accent-red); }
.diff-neutral { color: var(--text-secondary); }

.col-games {
  width: 15%;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* Main Content Area */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 24px 30px calc(24px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

/* Tournament Arena Stack */
.tournament-arena {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

/* Two Active Matches Container */
.active-matches-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.table-slot-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.table-slot-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

/* Match Card design (Apple widget style, translucent glass) */
.match-card-active {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px 48px 20px 20px; /* Increased right padding for rotated skip button */
  display: flex;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 5; /* High z-index prevents table-slot overlap click bug */
}

/* Vertical Rotated Skip Button on Right Edge */
.btn-skip {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 34px;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  border-left: 1px solid var(--card-border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.btn-skip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-skip:active {
  background: rgba(255, 255, 255, 0.12);
  transform: none; /* No scale for side tab */
}

.btn-skip-text {
  transform: rotate(90deg);
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: inline-block;
}

.teams-vs-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

/* Liquid Glass Team blocks (pure player names focus) */
.team-selection-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  min-height: 90px;
  container-type: inline-size;
}

.team-selection-block:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.team-selection-block:active {
  transform: scale(0.97);
}

.team-selection-block.selected {
  background: var(--accent-gold-bg);
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px var(--accent-gold-glow);
}

.players-names-list {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.players-names-list span {
  display: block;
}

.players-names-list span.and-separator {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin: 2px 0;
}

.vs-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* 2-Tap Inline Cups Selector Styles (iPad Safari Safe) */
.cups-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.25, 1, 0.5, 1), padding-top 0.35s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease;
  width: 100%;
  padding-top: 0;
  opacity: 0;
  pointer-events: none;
}

.cups-wrapper.open {
  max-height: 120px;
  padding-top: 14px;
  opacity: 1;
  pointer-events: auto;
}

.inline-cups-container {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(10, auto);
  justify-content: center;
  gap: 5px;
  margin-top: 0;
  width: fit-content;
  margin: 0 auto;
  padding-bottom: 6px;
}

@container (max-width: 395px) {
  .inline-cups-container {
    grid-template-columns: repeat(5, auto);
  }
}

.inline-cup-btn {
  width: 32px;
  height: 38px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  position: relative;
}

.inline-cup-btn:active {
  transform: scale(0.9);
}

.inline-cup-btn:hover {
  color: var(--accent-gold);
  filter: drop-shadow(0 0 5px var(--accent-gold-glow));
}

/* Shared Cup Icon & Number Styles */
.cup-icon-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.beer-cup-svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  transition: fill 0.2s ease;
}

.cup-number-text {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  font-weight: 800;
  color: #ffffff;
  pointer-events: none;
}

/* Match Flow Grid (Pipeline queue and completed list) */
.match-flow-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  min-height: 250px;
  margin-top: 10px;
}

.flow-panel {
  background: rgba(20, 20, 22, 0.4);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

.panel-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.match-item-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}

/* Grid Aligned VS columns inside dynamic lists */
.match-item-teams {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  align-items: center;
  width: 100%;
}

.match-item-team {
  display: flex;
  flex-direction: column;
}

.match-item-team.team-l { text-align: right; }
.match-item-team.team-r { text-align: left; }

.match-item-team span {
  font-size: 0.82rem;
  color: var(--text-main);
  white-space: nowrap;
}

.match-item-vs {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 4px;
  border-radius: 3px;
  text-align: center;
  justify-self: center;
  width: fit-content;
}

.match-item-index {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 700;
  text-align: right;
  min-width: 25px;
}

/* History played match card */
.match-item-card.played-match {
  opacity: 0.8;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.match-item-card.played-match:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.match-item-card.played-match:active {
  transform: scale(0.98);
}

.match-item-card.played-match .winner-side {
  font-weight: 700;
  color: var(--accent-gold);
}

.match-item-card.played-match .loser-side {
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.15);
}

.played-match-score {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 8px;
  text-align: right;
  min-width: 75px;
}

.played-match-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 80px;
}

.played-match-index {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.score-won-white {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Premium Translucent Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Empty states */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 10px;
}

/* BUTTONS - Apple Native Design */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: #fff;
}

.btn:active {
  transform: scale(0.95);
}

.btn:disabled {
  opacity: 0.25;
  pointer-events: none;
}

/* Standard Gray Translucent Capsule (Abbrechen, Bearbeiten, etc.) */
.btn-secondary {
  background: var(--accent-grey);
}
.btn-secondary:hover {
  background: var(--accent-grey-active);
}

/* iOS Primary Buttons */
.btn-primary {
  background: var(--accent-blue);
}

.btn-accent {
  background: linear-gradient(135deg, #ffd700 0%, #ff9f0a 100%);
  color: #000000;
  font-weight: 700;
}

.btn-danger {
  background: var(--accent-red);
}

.btn-warning {
  background: var(--accent-orange-bg);
  color: var(--accent-orange);
  border: 1px solid rgba(255, 159, 10, 0.3);
}
.btn-warning:hover {
  background: rgba(255, 159, 10, 0.25);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(255, 69, 58, 0.35);
  color: var(--accent-red);
}
.btn-danger-outline:hover {
  background: rgba(255, 69, 58, 0.08);
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 0.85rem;
}
.btn-text:hover {
  color: var(--text-main);
}

/* Sizes */
.btn-sm {
  padding: 8px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-md {
  padding: 10px 18px;
  font-size: 0.9rem;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
}

.btn-icon-only-large {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.btn-icon-only-large:hover {
  background: rgba(255, 255, 255, 0.12);
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 2px 6px;
  border-radius: 6px;
}

/* MODAL OVERLAYS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(12, 12, 14, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex !important;
}

.modal-card {
  background: #1c1c1e;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-card.modal-lg {
  max-width: 580px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
}
.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.scrollable-modal-body {
  max-height: 65vh;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-info-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* FORM ELEMENTS & Apple custom SELECT dropdown style */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.95rem;
  color: #fff;
  transition: all 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.07);
}

.form-select {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 1rem;
  color: #fff;
  outline: none;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  transition: all 0.2s ease;
}

.form-select:focus {
  border-color: var(--accent-blue);
  background-color: rgba(255, 255, 255, 0.07);
}

/* Inline Add Player Form in Modal */
.inline-add-player-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.inline-add-player-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.inline-add-player-form input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  color: #fff;
  outline: none;
  transition: all 0.2s ease;
}

.inline-add-player-form input:focus {
  border-color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.07);
}

.form-helper-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
  transition: color 0.2s ease;
}

.form-helper-text.warning {
  color: var(--accent-orange);
}

.form-helper-text.error {
  color: var(--accent-red);
}

.settings-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 16px 0;
}

/* Danger Zone in Modal */
.danger-zone-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

/* PLAYER LIST MANAGEMENT PANEL */
.edit-players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.edit-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  gap: 10px;
}

.edit-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.input-edit-name {
  background: transparent;
  border: 1px solid transparent;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  width: 140px;
  transition: all 0.2s ease;
}

.input-edit-name:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  outline: none;
}

.edit-player-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-toggle-active {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle-active.status-active {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border-color: rgba(48, 209, 88, 0.1);
}

.btn-toggle-active.status-paused {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border-color: var(--card-border);
}

.btn-delete-player {
  background: rgba(255, 69, 58, 0.08);
  color: var(--accent-red);
  border: 1px solid rgba(255, 69, 58, 0.15);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-delete-player:hover {
  background: var(--accent-red);
  color: #fff;
}
.btn-delete-player:disabled {
  opacity: 0.15;
  pointer-events: none;
}

/* CELEBRATION TROPHY OVERLAY */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(12, 12, 14, 0.98);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500000;
}

.celebration-overlay.open {
  display: flex !important;
}

.celebration-card {
  text-align: center;
  max-width: 460px;
  padding: 30px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 40px rgba(255, 159, 10, 0.12);
  transform: scale(0.9);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.celebration-overlay.open .celebration-card {
  transform: scale(1);
}

.trophy-icon {
  font-size: 4.5rem;
  margin-bottom: 16px;
  animation: bounce-trophy 2s infinite ease-in-out;
  display: inline-block;
}

.celebration-card h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #ffd700;
}

.champions-display {
  margin: 20px 0;
  padding: 14px;
  background: rgba(255, 159, 10, 0.08);
  border: 1px solid rgba(255, 159, 10, 0.2);
  border-radius: var(--radius-md);
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffd700;
}

.celebration-subtext {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ANIMATIONS */
@keyframes pulse {
  0% {
    opacity: 0.6;
    box-shadow: 0 0 2px rgba(255, 69, 58, 0.15);
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(255, 69, 58, 0.4);
  }
}

@keyframes bounce-trophy {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

/* RESPONSIVE RESPONSES */
@media (max-width: 950px) {
  html, body {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    background-attachment: scroll !important;
  }

  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto !important;
    overflow: visible !important;
  }
  
  .sidebar {
    height: auto !important;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
    padding-top: calc(85px + env(safe-area-inset-top)) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    overflow: visible !important;
  }

  .table-container {
    height: auto !important;
    overflow-y: visible !important;
    padding: 0 16px 16px !important;
  }
  
  .sidebar-header {
    padding: calc(12px + env(safe-area-inset-top)) 20px 12px !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 99999 !important;
    background: #0c0c0e !important;
    border-bottom: 1px solid var(--card-border) !important;
    transform: translate3d(0, 0, 0) !important;
    -webkit-transform: translate3d(0, 0, 0) !important;
  }

  th {
    position: static !important;
  }
  
  .sidebar-footer {
    padding: 8px 16px 12px;
  }
  
  .main-content {
    height: auto !important;
    overflow-y: visible !important;
  }
}

@media (max-width: 650px) {
  .ypb-logo {
    width: 50px;
    height: 30px;
  }
  
  .sidebar-title {
    font-size: 1.3rem !important;
  }
  
  .main-content {
    padding: 16px 16px calc(120px + env(safe-area-inset-bottom));
  }
  
  .inline-cups-container {
    display: grid;
    grid-template-columns: repeat(5, auto);
    justify-content: center;
    gap: 5px;
    width: fit-content;
    margin: 0 auto;
  }
  
  .match-flow-grid {
    grid-template-columns: 1fr;
  }
  
  .teams-vs-container {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .vs-badge {
    margin: 0 auto;
  }
  
  .cups-selector {
    flex-wrap: wrap;
  }
  
  .cup-btn {
    flex: 0 0 36px;
    height: 36px;
  }
}

/* Edit Match Modal (Tactile Buttons & Cup Grid) Styles */
.modal-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: block;
}

.edit-winner-teams-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.edit-winner-team-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
}

.edit-winner-team-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.edit-winner-team-btn:active {
  transform: scale(0.97);
}

/* Selected states for edit winner team buttons */
.edit-winner-team-btn.selected {
  background: var(--accent-gold-bg);
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px var(--accent-gold-glow);
  color: var(--text-main);
}

.and-separator-modal {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
  margin-bottom: 2px;
}

/* Cup buttons in editor */
.edit-cups-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.edit-cup-btn {
  width: 44px;
  height: 52px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  position: relative;
  margin: 0 auto;
}

.edit-cup-btn:hover {
  color: rgba(255, 255, 255, 0.4);
}

.edit-cup-btn:active {
  transform: scale(0.92);
}

.edit-cup-btn .cup-number-text {
  font-size: 1.1rem;
  font-weight: 800;
}

/* Selected cup highlighting in editor */
.edit-cup-btn.selected {
  color: var(--accent-gold);
  filter: drop-shadow(0 0 8px var(--accent-gold-glow));
}

/* Victory flash and pop animation */
.victory-flash {
  animation: victoryPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes victoryPop {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 215, 0, 0);
  }
  30% {
    transform: scale(1.03);
    background: rgba(255, 215, 0, 0.15);
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 215, 0, 0);
  }
}

/* Info Button & Modal Copy */
.btn-info-trigger {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-grey);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  z-index: 10;
}

.btn-info-trigger:hover {
  background: var(--accent-grey-active);
  color: var(--text-main);
  border-color: var(--card-border-active);
}

.btn-info-trigger:active {
  transform: scale(0.92);
}

.info-p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 16px;
}

.info-details-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-details-box p {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0;
}

.info-details-box strong {
  color: var(--accent-gold);
}

/* Inline button does not need absolute position overrides */

/* Read Only Mode for Live Spectators */
body.read-only-mode .sidebar-footer,
body.read-only-mode #btn-info-toggle,
body.read-only-mode #btn-share-live,
body.read-only-mode #btn-undo-last {
  display: none !important;
}

/* Enable active tables in read-only but disable clicking */
body.read-only-mode .active-matches-container {
  pointer-events: none;
}

/* Hide interactive controls inside table cards for read-only viewer */
body.read-only-mode .btn-skip {
  display: none !important;
}

body.read-only-mode .cups-wrapper {
  display: none !important;
}

body.read-only-mode .team-selection-block {
  cursor: default !important;
  pointer-events: none;
}

body.read-only-mode .vs-badge {
  cursor: default !important;
  pointer-events: none;
}



/* App Footer / Login Styles */
.app-footer {
  margin-top: 40px;
  padding: 20px 0;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-login-btn {
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
}

.footer-login-btn:hover {
  color: var(--accent-gold);
  transform: translateY(-1px);
}

/* Disable clicks on played matches in read-only-mode */
body.read-only-mode .match-item-card.played-match {
  cursor: default !important;
  pointer-events: none;
}

/* Highlight selected player in leaderboard and cards */
.row-player.leaderboard-row-highlighted {
  background: rgba(10, 132, 255, 0.1) !important;
}

.row-player.leaderboard-row-highlighted td {
  background: rgba(10, 132, 255, 0.05) !important;
  border-top: 1px solid rgba(10, 132, 255, 0.4);
  border-bottom: 1px solid rgba(10, 132, 255, 0.4);
}

.row-player.leaderboard-row-highlighted td:first-child {
  border-left: 1px solid rgba(10, 132, 255, 0.4);
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.row-player.leaderboard-row-highlighted td:last-child {
  border-right: 1px solid rgba(10, 132, 255, 0.4);
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* If active, add the blue bracket overriding the white one */
.row-player.active-in-match.leaderboard-row-highlighted td:first-child {
  box-shadow: inset 2px 0 0 var(--accent-blue) !important;
}

.row-player.active-in-match.leaderboard-row-highlighted td:last-child {
  box-shadow: inset -2px 0 0 var(--accent-blue) !important;
}

.player-name-highlighted {
  color: var(--accent-blue) !important;
  font-weight: 600;
  text-shadow: 0 0 4px rgba(10, 132, 255, 0.2);
  display: inline-block;
  padding-right: 4px;
}

/* Notification overlay when it's your turn (slides down below title and logo header) */
.active-turn-overlay {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(-250px);
  background: rgba(18, 18, 18, 0.95);
  border: 2px solid var(--accent-gold);
  box-shadow: 0 12px 40px rgba(255, 215, 0, 0.45);
  border-radius: 12px;
  padding: 16px 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(12px);
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 320px;
  text-align: center;
  cursor: pointer;
  touch-action: none;
}

.active-turn-overlay.show {
  transform: translateX(-50%) translateY(0);
}

.active-turn-title {
  color: var(--accent-gold);
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.active-turn-text {
  color: #fff;
  font-size: 14px;
}

/* Welcome Modal Player Grid & Pills styling */
.welcome-players-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-height: 250px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.welcome-player-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: #fff;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.welcome-player-pill:hover {
  background: rgba(255, 215, 0, 0.12);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.footer-separator {
  color: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  margin: 0 4px;
}

/* Global utility to hide elements */
.hidden {
  display: none !important;
}
