/* ===== CSS VARIABLES ===== */
:root {
  /* Colors */
  --primary: #667eea;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  
  --text: #2c3e50;
  --text-light: #555;
  --text-muted: #777;
  --border: #dee2e6;
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  
  /* Tennis specific */
  --super-tiebreak: #8e44ad;
  --super-tiebreak-active: #9b59b6;
  
  /* Gradients */
  --grad-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --grad-secondary: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  --grad-success: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
  --grad-danger: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
  --grad-warning: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  --grad-dark: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  --grad-super-tiebreak: linear-gradient(135deg, #8e44ad 0%, #e67e22 100%);
  --grad-super-tiebreak-active: linear-gradient(135deg, #9b59b6 0%, #f39c12 100%);
  
  /* Shadows */
  --shadow-light: 0 4px 15px rgba(0,0,0,0.1);
  --shadow-medium: 0 8px 25px rgba(102, 126, 234, 0.3);
  --shadow-heavy: 0 20px 40px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 15px rgba(255, 215, 0, 0.4);
  --shadow-glow-intense: 0 0 25px rgba(255, 215, 0, 0.6);
  --shadow-super-tiebreak: 0 0 15px rgba(142, 68, 173, 0.4);
  --shadow-super-tiebreak-intense: 0 0 25px rgba(142, 68, 173, 0.6);
  
  /* Header badges */
  --badge-bg: rgba(255, 255, 255, 0.15);
  --badge-text: rgba(255, 255, 255, 0.95);
  --badge-share: #8e44ad;
  --badge-controls-on: #6C9BD1;
  --badge-controls-off: #4A5F7A;
  --badge-border: rgba(255, 255, 255, 0.5);
  
  /* Spacing & sizing */
  --space-xs: 5px;
  --space-sm: 8px;
  --space-md: 15px;
  --space-lg: 20px;
  --space-xl: 25px;
  --space-2xl: 30px;
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 15px;
  --radius-round: 50%;
  
  /* Transitions */
  --transition: all 0.3s ease;
}

/* Dark mode overrides */
body.dark-mode {
  --grad-secondary: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --grad-dark: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --text: #e2e8f0;
  --text-light: #cbd5e0;
  --text-muted: #a0aec0;
  --border: #4a5568;
  --bg: #1a202c;
  --bg-alt: #2d3748;
  --shadow-light: 0 4px 15px rgba(0,0,0,0.3);
  --shadow-medium: 0 8px 25px rgba(102, 126, 234, 0.2);
  --shadow-heavy: 0 20px 40px rgba(0,0,0,0.3);
}

/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--grad-secondary);
  min-height: 100vh;
  padding: var(--space-lg);
  color: var(--text);
  transition: var(--transition);
}

.hidden { 
  display: none !important; 
}

/* ===== LAYOUT ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-heavy);
  overflow: hidden;
  transition: var(--transition);
}

.header {
  background: var(--grad-primary);
  color: white;
  padding: var(--space-2xl);
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 140px;
  align-items: center;
  justify-content: center;
}

.content {
  padding: var(--space-2xl);
  background: var(--bg);
  color: var(--text);
  transition: var(--transition);
}

.event-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 10px;
}

/* ===== HEADER COMPONENTS ===== */
.header-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid var(--badge-border);
  cursor: default;
  transition: var(--transition);
  user-select: none;
  min-height: 32px;
  background: var(--badge-bg);
  color: var(--badge-text);
  backdrop-filter: blur(10px);
}

.header-label.clickable {
  cursor: pointer;
}

.header-label.clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.header-label:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.header-title-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0;
  gap: 20px;
  flex-wrap: wrap;
}

.header-title-row .event-title {
  margin: 0;
  flex-shrink: 0;
}

.header-buttons {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.header-status {
  position: absolute;
  top: 15px;
  left: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.header-share {
  margin-top: 15px;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}

/* Header badge variants */
.connection-badge.disconnected {
  background: var(--danger);
  color: white;
}

.connection-badge.saving {
  background: var(--warning);
  color: #000;
}

.share-button {
  background: var(--badge-share);
  color: white;
}

.share-button:hover {
  background: color-mix(in srgb, var(--badge-share) 85%, white 15%);
}

.share-button.copied {
  background: var(--badge-controls-on);
}

.theme-toggle:not(.dark-mode),
.sound-toggle:not(.sound-off),
.screen-wake-toggle:not(.screen-off) {
  background: var(--badge-controls-on);
  color: white;
}

.theme-toggle:not(.dark-mode):hover,
.sound-toggle:not(.sound-off):hover,
.screen-wake-toggle:not(.screen-off):hover {
  background: color-mix(in srgb, var(--badge-controls-on) 85%, white 15%);
}

.theme-toggle.dark-mode,
.sound-toggle.sound-off,
.screen-wake-toggle.screen-off {
  background: var(--badge-controls-off);
  color: white;
}

.theme-toggle.dark-mode:hover,
.sound-toggle.sound-off:hover,
.screen-wake-toggle.screen-off:hover {
  background: color-mix(in srgb, var(--badge-controls-off) 85%, white 15%);
}

.screen-wake-toggle.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.screen-wake-toggle.disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Status indicator */
.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00ff88;
  margin-right: 6px;
  animation: pulse 2s infinite;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

.connection-badge.disconnected .status-indicator {
  background: #ff4444;
  box-shadow: 0 0 8px rgba(255, 68, 68, 0.6);
  animation: blink 1s infinite;
}

.connection-badge.saving .status-indicator {
  background: #ffaa00;
  box-shadow: 0 0 8px rgba(255, 170, 0, 0.6);
}

/* ===== SECTIONS ===== */
.section {
  margin-bottom: var(--space-2xl);
  padding: var(--space-xl);
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--primary);
  transition: var(--transition);
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text);
}

.section-controls {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.viewer-mode .admin-controls {
  display: none !important;
}

.viewer-mode .section {
  opacity: 0.9;
}

.password-section {
  background: rgba(255, 193, 7, 0.1);
  border-left-color: var(--warning);
}

.clickable-title {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: color 0.2s ease;
}

.clickable-title:hover {
  color: var(--primary);
}

.toggle-icon {
  font-size: 0.8em;
  transition: transform 0.2s ease;
}

.collapsible-content {
  transition: all 0.3s ease;
  overflow: hidden;
}

.collapsible-content.hidden {
  display: none;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-row {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.form-field {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-help {
  color: var(--warning);
  margin-top: var(--space-xs);
  display: block;
  font-size: 14px;
}

label {
  font-weight: 500;
  color: var(--text-light);
  display: block;
  margin-bottom: var(--space-sm);
}

input[type="text"], 
input[type="password"], 
select {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  transition: var(--transition);
  width: 100%;
  background: var(--bg);
  color: var(--text);
}

input[type="text"]:focus, 
input[type="password"]:focus, 
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-input {
  flex: 1;
  min-width: 200px;
}

/* ===== BUTTONS ===== */
.btn {
  background: var(--grad-primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 10px;
  margin-bottom: 10px;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.btn:focus,
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-success {
  background: var(--grad-success);
}

.btn-danger {
  background: var(--grad-danger);
}

.btn-primary {
  background: var(--grad-primary);
}

.control-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-round);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.control-btn:focus,
.control-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.control-btn:disabled {
  background: #666;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.plus-btn {
  background: var(--grad-success);
  color: white;
}

.plus-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 5px 20px rgba(86, 171, 47, 0.4);
}

.minus-btn {
  background: var(--grad-danger);
  color: white;
}

.minus-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 5px 20px rgba(255, 65, 108, 0.4);
}

/* ===== TENNIS SCOREBOARD ===== */
.tv-scoreboard {
  background: var(--grad-secondary);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin: var(--space-lg) 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  border: 2px solid var(--border);
}

.tv-score-row {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.08) 100%);
  border-radius: 10px;
  padding: var(--space-md);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(102, 126, 234, 0.15);
}

.tv-score-row:last-of-type {
  margin-bottom: 0;
}

.tv-player-name {
  flex: 1;
  font-weight: 700;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
  color: var(--text);
}

.tv-sets {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-right: var(--space-md);
}

.tv-set {
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  transition: var(--transition);
  background: rgba(255,255,255,0.8);
  color: var(--text);
}

.tv-set.completed {
  background: rgba(102, 126, 234, 0.1);
  color: var(--text);
  border: 2px solid var(--primary);
}

.tv-set.completed:hover {
  background: rgba(102, 126, 234, 0.2);
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.tv-set.current {
  background: var(--grad-warning);
  color: #1a1a2e;
  border: 2px solid #ffd700;
  box-shadow: var(--shadow-glow);
  animation: pulseGlow 2s infinite;
}

.tv-set.editing {
  background: #ffd700;
  color: #000000;
  animation: editPulse 1s infinite;
  border: 2px solid #ff8c00;
  box-shadow: 0 0 15px rgba(255, 140, 0, 0.6);
}

.tv-set.future {
  background: rgba(255,255,255,0.3);
  color: var(--text-muted);
  border: 2px solid rgba(0,0,0,0.1);
}

/* Super tiebreak styles */
.tv-set.super-tiebreak {
  background: var(--grad-super-tiebreak);
  color: white;
  border: 2px solid var(--super-tiebreak);
  box-shadow: var(--shadow-super-tiebreak);
}

.tv-set.super-tiebreak.current {
  background: var(--grad-super-tiebreak-active);
  animation: pulseSuperTiebreak 2s infinite;
  border: 2px solid var(--super-tiebreak);
}

.tv-set.super-tiebreak.completed {
  background: var(--grad-super-tiebreak);
  opacity: 0.9;
  border: 2px solid var(--super-tiebreak);
}

.tv-set.super-tiebreak.completed:hover {
  background: var(--grad-super-tiebreak-active);
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(142, 68, 173, 0.4);
}

.tv-set.super-tiebreak.editing {
  background: var(--grad-super-tiebreak-active);
  color: white;
  animation: editPulse 1s infinite;
  border: 2px solid var(--super-tiebreak);
  box-shadow: 0 0 15px rgba(142, 68, 173, 0.6);
}

/* Scoreboard data state styling */
.tv-scoreboard[data-editing="true"] .tv-set.current {
  background: rgba(255,255,255,0.3);
  color: var(--text-muted);
  border: 3px dashed #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  animation: none;
}

.tv-scoreboard[data-match-complete="true"][data-match-finished="false"] .control-btn {
  background: #666;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.tv-scoreboard[data-editing="true"] .control-btn {
  background: var(--grad-success);
  cursor: pointer;
}

.tv-scoreboard[data-editing="true"] .minus-btn {
  background: var(--grad-danger);
}

.tv-scoreboard[data-editing="true"] .control-btn:hover:not(:disabled) {
  transform: scale(1.1);
}

.tv-scoreboard[data-editing="true"] .plus-btn:hover:not(:disabled) {
  box-shadow: 0 5px 20px rgba(86, 171, 47, 0.4);
}

.tv-scoreboard[data-editing="true"] .minus-btn:hover:not(:disabled) {
  box-shadow: 0 5px 20px rgba(255, 65, 108, 0.4);
}

.admin-controls {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* ===== MATCH INFO ===== */
.match-info {
  text-align: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255,255,255,0.1);
}

.match-info[data-match-state="not-started"] .current-set-indicator {
  color: #666;
  font-weight: normal;
}

.match-info[data-match-state="in-progress"] .current-set-indicator {
  color: #ffd700;
  font-weight: bold;
}

.match-info[data-match-state="editing"] .current-set-indicator {
  color: #ff6b6b;
  font-weight: bold;
}

.match-info[data-match-state="complete-not-finished"] .current-set-indicator {
  color: #ffd700;
  font-weight: bold;
}

.match-info[data-match-state="finished"] .current-set-indicator {
  color: var(--success);
  font-weight: bold;
}

.match-controls {
  margin-bottom: var(--space-md);
}

.current-set-indicator {
  font-size: 16px;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: var(--space-xs);
}

.match-format {
  font-size: 14px;
  color: var(--text-muted);
}

.match-time {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.refresh-countdown {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
  font-style: italic;
}

.refresh-countdown.active {
  color: var(--info);
  font-weight: 500;
}

/* ===== MESSAGES ===== */
.error-message {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: var(--danger);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-weight: 500;
}

.auth-message,
.password-message {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.auth-message.success,
.password-message.success {
  background: rgba(40, 167, 69, 0.1);
  border: 1px solid rgba(40, 167, 69, 0.3);
  color: var(--success);
}

.auth-message.error,
.password-message.error {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: var(--danger);
}

.auth-message.info {
  background: rgba(23, 162, 184, 0.1);
  border: 1px solid rgba(23, 162, 184, 0.3);
  color: var(--info);
}

.instructions-list {
  color: var(--text-light);
  padding-left: var(--space-lg);
}

.instructions-list li {
  margin-bottom: var(--space-xs);
}

/* ===== LANDING PAGE ===== */
.hero-subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-bottom: 0;
}

.create-match-section {
  background: var(--grad-secondary);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  margin: var(--space-lg) 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  border: 2px solid var(--border);
}

.create-match-section .auth-message {
  margin-bottom: 1.5rem;
  margin-top: 2rem;
}

.url-builder {
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem;
  border-radius: 12px;
  margin: 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  flex-wrap: wrap;
  min-height: 60px;
}

.url-base {
  color: #2c3e50;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.match-input {
  border: none;
  background: transparent;
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  color: #667eea;
  font-weight: 600;
  min-width: 160px;
  flex: 1;
  max-width: 300px;
  text-align: left;
  outline: none;
  transition: all 0.3s ease;
}

.match-input::placeholder {
  color: #aaa;
  font-style: italic;
}

.button-row {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.random-btn {
  background: var(--grad-warning);
  color: #1a1a2e;
  min-width: 140px;
}

.random-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
  box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
}

.expiry-notice {
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.how-it-works-content {
  display: flex;
  flex-direction: column;
}

.feature-item {
  color: var(--text-light);
  line-height: 1.6;
  margin: 0;
  margin-top: 1rem;
}

.feature-item strong {
  color: var(--text);
  font-size: 1.1rem;
  display: inline;
  margin-bottom: 0;
  margin-right: 1rem;
}

/* ===== DARK MODE OVERRIDES ===== */
body.dark-mode .tv-scoreboard {
  background: var(--grad-dark);
  border: 2px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

body.dark-mode .tv-score-row {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
}

body.dark-mode .tv-set {
  background: rgba(255,255,255,0.1);
  color: #ffffff;
  border: 2px solid rgba(255,255,255,0.2);
}

body.dark-mode .tv-set.future {
  background: rgba(255,255,255,0.05);
  color: #666;
  border: 2px solid rgba(255,255,255,0.1);
}

body.dark-mode .tv-set.completed {
  background: rgba(255,255,255,0.1);
  color: #ffffff;
  border: 2px solid rgba(255,255,255,0.2);
}

body.dark-mode .tv-set.completed:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(255,255,255,0.2);
}

body.dark-mode .tv-set.current {
  background: #ffd700;
  color: #000000;
  border: 2px solid #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  animation: pulseGlow 2s infinite;
}

body.dark-mode .tv-set.editing {
  background: #ffd700;
  color: #000000;
  border: 2px solid #ff8c00;
  animation: editPulse 1s infinite;
  box-shadow: 0 0 15px rgba(255, 140, 0, 0.6);
}

body.dark-mode .tv-scoreboard[data-editing="true"] .tv-set.current {
  background: rgba(255,255,255,0.05);
  color: #666;
  border: 3px dashed #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
  animation: none;
}

/* Dark mode super tiebreak overrides - MUST come after regular dark mode rules */
body.dark-mode .tv-set.super-tiebreak {
  background: var(--grad-super-tiebreak);
  color: white;
  border: 2px solid var(--super-tiebreak);
  box-shadow: var(--shadow-super-tiebreak);
}

body.dark-mode .tv-set.super-tiebreak.completed {
  background: var(--grad-super-tiebreak);
  opacity: 0.9;
  border: 2px solid var(--super-tiebreak);
  color: white;
}

body.dark-mode .tv-set.super-tiebreak.completed:hover {
  background: var(--grad-super-tiebreak-active);
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(142, 68, 173, 0.4);
}

body.dark-mode .tv-set.super-tiebreak.current {
  background: var(--grad-super-tiebreak-active);
  color: white;
  border: 2px solid var(--super-tiebreak);
  box-shadow: var(--shadow-super-tiebreak-intense);
  animation: pulseSuperTiebreak 2s infinite;
}

body.dark-mode .tv-set.super-tiebreak.editing {
  background: var(--grad-super-tiebreak-active);
  color: white;
  border: 2px solid var(--super-tiebreak);
  animation: editPulse 1s infinite;
  box-shadow: 0 0 15px rgba(142, 68, 173, 0.6);
}

body.dark-mode .create-match-section {
  background: var(--grad-dark);
  border: 2px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

body.dark-mode .url-builder {
  background: rgba(255,255,255,0.1);
}

body.dark-mode .url-base {
  color: #e2e8f0;
}

body.dark-mode .match-input {
  color: #667eea;
}

body.dark-mode .expiry-notice {
  background: rgba(102, 126, 234, 0.2);
  border: 1px solid rgba(102, 126, 234, 0.4);
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

@keyframes pulseGlow {
  0% { box-shadow: var(--shadow-glow); }
  50% { box-shadow: var(--shadow-glow-intense); }
  100% { box-shadow: var(--shadow-glow); }
}

@keyframes pulseSuperTiebreak {
  0% { box-shadow: var(--shadow-super-tiebreak); }
  50% { box-shadow: var(--shadow-super-tiebreak-intense); }
  100% { box-shadow: var(--shadow-super-tiebreak); }
}

@keyframes editPulse {
  0% { box-shadow: 0 0 10px rgba(255, 140, 0, 0.4); }
  50% { box-shadow: 0 0 20px rgba(255, 140, 0, 0.6); }
  100% { box-shadow: 0 0 10px rgba(255, 140, 0, 0.4); }
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-contrast: high) {
  :root {
    --border: #000;
    --text: #000;
    --text-light: #000;
  }
  
  body.dark-mode {
    --border: #fff;
    --text: #fff;
    --text-light: #fff;
  }
  
  .tv-scoreboard {
    border: 3px solid var(--text);
  }
  
  .tv-set {
    border: 2px solid var(--text);
  }
  
  .header-label {
    border-width: 2px;
    font-weight: 700;
  }
  
  .status-indicator {
    border: 1px solid var(--text);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .status-indicator {
    animation: none;
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  body {
    padding: var(--space-sm);
  }
  
  .container {
    margin: 0;
  }
  
  .content {
    padding: var(--space-lg);
  }
  
  .header {
    padding: var(--space-lg);
    gap: 12px;
    line-height: normal;
  }
  
  .event-title {
    font-size: 24px;
  }
  
  .header-buttons {
    position: static;
    display: flex;
    flex-direction: row;
    justify-content: center;
    margin-top: 0;
    gap: 10px;
  }
  
  .header-status {
    position: static;
    display: flex;
    flex-direction: row;
    justify-content: center;
    margin-top: 0;
    gap: 10px;
    order: -1;
  }
  
  .header-label {
    padding: 6px 12px;
    min-height: 28px;
  }

  .header-title-row {
    gap: 15px;
  }

  .header-title-row .event-title {
    flex: none;
  }
  
  .status-indicator {
    width: 6px;
    height: 6px;
    margin-right: 4px;
  }
  
  .header-share {
    margin-top: 10px;
    margin-bottom: 5px;
  }
  
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .tv-score-row {
    flex-direction: column;
    padding: var(--space-md);
    min-height: 120px;
    position: relative;
    justify-content: space-between;
    align-items: stretch;
  }
  
  .tv-score-row:nth-of-type(1) {
    display: flex;
  }
  
  .tv-score-row:nth-of-type(1) .tv-player-name {
    position: absolute;
    top: var(--space-md);
    left: var(--space-md);
    text-align: left;
    margin: 0;
  }
  
  .tv-score-row:nth-of-type(1) .tv-sets {
    position: absolute;
    bottom: var(--space-md);
    right: var(--space-md);
    margin: 0;
  }
  
  .tv-score-row:nth-of-type(1) .admin-controls {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    display: flex;
    gap: var(--space-xs);
  }
  
  .tv-score-row:nth-of-type(2) {
    display: flex;
  }
  
  .tv-score-row:nth-of-type(2) .tv-player-name {
    position: absolute;
    bottom: var(--space-md);
    left: var(--space-md);
    text-align: left;
    margin: 0;
  }
  
  .tv-score-row:nth-of-type(2) .tv-sets {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    margin: 0;
  }
  
  .tv-score-row:nth-of-type(2) .admin-controls {
    position: absolute;
    bottom: var(--space-md);
    right: var(--space-md);
    display: flex;
    gap: var(--space-xs);
  }
  
  .tv-score-row .control-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .tv-player-name {
    font-size: 16px;
    flex: none;
  }
  
  .tv-sets {
    justify-content: center;
    gap: 8px;
  }
  
  .admin-controls {
    justify-content: center;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn {
    margin-right: 0;
    margin-bottom: 10px;
    width: 100%;
  }
  
  .auth-input {
    min-width: auto;
    margin-bottom: 10px;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .button-row {
    flex-direction: column;
    align-items: center;
  }
  
  .btn {
    width: 100%;
    max-width: 300px;
  }

  .how-it-works-content {
    gap: 1rem;
  }

  .feature-item strong {
    font-size: 1rem;
  }

  .url-builder {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0;
  }
  
  .match-input {
    width: 100%;
    text-align: center;
    min-width: auto;
    margin-top: 0.5rem;
    max-width: none;
    flex-basis: 100%;
  }
}

@media (max-width: 480px) {
  .event-title {
    font-size: 20px;
  }
  
  .header-label {
    padding: 5px 10px;
    min-height: 26px;
    letter-spacing: 0.3px;
  }

  .header-title-row {
    gap: 5px;
  }
  
  .tv-set {
    width: 35px;
    height: 35px;
    font-size: 16px;
  }
  
  .tv-sets {
    gap: 8px;
  }
  
  .control-btn {
    width: 35px;
    height: 35px;
    font-size: 18px;
  }
  
  .section {
    padding: var(--space-md);
  }

  .hero-subtitle {
    font-size: 0.9rem;
  }

  .url-base {
    font-size: 0.8rem;
  }

  .url-builder {
    padding: 0.7rem;
    font-size: 0.65rem;
  }

  .btn {
    padding: 12px 24px;
    font-size: 14px;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  body {
    background: white;
    padding: 0;
    color: #000;
  }
  
  .container {
    box-shadow: none;
    border: 1px solid #000;
    background: white;
  }
  
  .header {
    background: #000 !important;
    color: white !important;
  }
  
  .btn,
  .control-btn,
  .admin-controls,
  .section-controls,
  .form-actions,
  .header-buttons,
  .header-share,
  .header-label {
    display: none !important;
  }
  
  .tv-scoreboard {
    background: white !important;
    border: 2px solid #000 !important;
    color: #000 !important;
  }
  
  .tv-score-row {
    background: #f0f0f0 !important;
  }
  
  .player1,
  .player2 {
    color: #000 !important;
  }
  
  .tv-set {
    border: 1px solid #000 !important;
    background: white !important;
    color: #000 !important;
  }
  
  .tv-set.super-tiebreak {
    background: #e0e0e0 !important;
    color: #000 !important;
  }
  
  .content {
    background: white;
    color: #000;
  }
  
  .section {
    background: #f8f9fa;
  }
}