* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  background: #16213e;
  padding: 1rem 2rem;
  border-bottom: 2px solid #e94560;
}

.header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  color: #fff;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.progress-bar {
  flex: 1;
  max-width: 400px;
  height: 20px;
  background: #0f3460;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #e94560, #ff6b6b);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.9rem;
  color: #aaa;
}

/* Main Layout */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
  overflow: auto;
  background: #0f3460;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.map-wrapper {
  position: relative;
  display: inline-block;
}

.map-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 200px);
  object-fit: contain;
  border-radius: 8px;
}

.route-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.route-line {
  stroke-width: 10;
  stroke-linecap: round;
  opacity: 1;
}

.route-line.remaining {
  stroke: #e74c3c;
}

.route-line.partial {
  stroke: #f39c12;
}

.route-line.completed {
  stroke: #2ecc71;
}

.route-line.highlighted {
  stroke: #3498db;
  stroke-width: 14;
}

.route-line.preview {
  stroke: #ffff00;
  stroke-width: 16;
}

.markers {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.marker {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #333;
  border: 3px solid #666;
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  z-index: 10;
}

.marker:hover {
  transform: translate(-50%, -50%) scale(1.3);
  z-index: 20;
}

.marker.selected {
  border-color: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  z-index: 15;
}

.marker.none-complete {
  background: #444;
  border-color: #666;
}

.marker.some-complete {
  background: #f39c12;
  border-color: #e67e22;
}

.marker.all-complete {
  background: #27ae60;
  border-color: #2ecc71;
}

.marker.connected {
  box-shadow: 0 0 12px 4px #3498db;
}

.marker.connected:hover {
  box-shadow: 0 0 16px 6px #3498db;
}

.marker-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  margin-bottom: 4px;
}

.marker:hover .marker-tooltip {
  opacity: 1;
}

/* Panel */
.panel {
  width: 350px;
  background: #16213e;
  border-left: 2px solid #e94560;
  overflow-y: auto;
  padding: 1rem;
}

.panel-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: #666;
}

.panel-content h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

.course-stats {
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #333;
}

.routes-section {
  margin-bottom: 1.5rem;
}

.routes-section h3 {
  font-size: 0.9rem;
  color: #e94560;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.route-list {
  list-style: none;
}

.route-item {
  display: flex;
  align-items: center;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  background: #0f3460;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.route-item:hover {
  background: #1a4a7a;
}

.route-item.completed {
  background: #1e5631;
}

.route-item.completed:hover {
  background: #267a3d;
}

.route-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid #666;
  border-radius: 4px;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.route-item.completed .route-checkbox {
  background: #2ecc71;
  border-color: #2ecc71;
}

.route-item.completed .route-checkbox::after {
  content: '\2713';
  color: #fff;
  font-weight: bold;
  font-size: 14px;
}

.route-name {
  flex: 1;
  font-size: 0.9rem;
}

.route-oneway {
  font-size: 0.7rem;
  background: #e94560;
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 0.5rem;
}

/* Footer */
.footer {
  background: #16213e;
  padding: 1rem 2rem;
  border-top: 2px solid #e94560;
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn {
  background: #0f3460;
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.btn:hover {
  background: #1a4a7a;
}

.btn-primary {
  background: #e94560;
}

.btn-primary:hover {
  background: #ff6b6b;
}

.btn-close {
  background: transparent;
  font-size: 1.5rem;
  padding: 0.25rem 0.75rem;
  line-height: 1;
}

/* Table Modal */
.table-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-modal-content {
  background: #16213e;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border: 2px solid #e94560;
}

.table-modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
}

.table-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.table-tabs {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  background: #0f3460;
  border: none;
  color: #aaa;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: #1a4a7a;
  color: #fff;
}

.tab-btn.active {
  background: #e94560;
  color: #fff;
}

.table-stats {
  padding: 0.75rem 1.5rem;
  background: #0f3460;
  font-size: 0.9rem;
  color: #aaa;
}

.table-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.5rem 1.5rem;
}

.routes-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.routes-table th,
.routes-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #333;
}

.routes-table th {
  background: #0f3460;
  position: sticky;
  top: 0;
  font-weight: 600;
  color: #e94560;
}

.routes-table tr:hover {
  background: rgba(233, 69, 96, 0.1);
}

.routes-table .status-completed {
  color: #2ecc71;
}

.routes-table .status-remaining {
  color: #e74c3c;
}

.routes-table .type-oneway {
  background: #e94560;
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
}

.routes-table .type-bidirectional {
  color: #666;
  font-size: 0.85rem;
}

.routes-table .clickable {
  cursor: pointer;
}

.routes-table .clickable:hover {
  text-decoration: underline;
  color: #3498db;
}

/* Stats Modal */
.stats-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-modal-content {
  background: #16213e;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  border: 2px solid #e94560;
}

.stats-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
}

.stats-modal-header h2 {
  margin: 0;
}

.stats-body {
  padding: 1.5rem;
}

.stats-overview {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.stat-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
}

.stat-ring {
  transform: rotate(-90deg);
}

.stat-ring-bg {
  fill: none;
  stroke: #0f3460;
  stroke-width: 8;
}

.stat-ring-fill {
  fill: none;
  stroke: #2ecc71;
  stroke-width: 8;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 0.5s ease;
}

.stat-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.stat-percent {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
  color: #2ecc71;
}

.stat-label {
  font-size: 0.75rem;
  color: #aaa;
}

.stat-numbers {
  flex: 1;
}

.stat-item {
  padding: 0.5rem 0;
  font-size: 1.1rem;
}

.stat-item span {
  font-weight: bold;
  color: #e94560;
  margin-right: 0.5rem;
}

.stats-breakdown {
  margin-bottom: 2rem;
}

.stats-breakdown h3,
.stats-courses h3 {
  font-size: 1rem;
  color: #e94560;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-bar-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.stat-bar-label {
  width: 100px;
  font-size: 0.9rem;
  color: #aaa;
}

.stat-bar {
  flex: 1;
  height: 12px;
  background: #0f3460;
  border-radius: 6px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: #2ecc71;
  transition: width 0.3s ease;
}

.stat-bar-value {
  width: 60px;
  font-size: 0.85rem;
  color: #aaa;
  text-align: right;
}

.course-list {
  max-height: 200px;
  overflow-y: auto;
}

.course-stat-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

.course-stat-item:hover {
  background: #0f3460;
}

.course-stat-name {
  flex: 1;
  font-size: 0.9rem;
}

.course-stat-progress {
  width: 80px;
  height: 6px;
  background: #0f3460;
  border-radius: 3px;
  overflow: hidden;
  margin-right: 0.75rem;
}

.course-stat-progress-fill {
  height: 100%;
  background: #2ecc71;
}

.course-stat-value {
  font-size: 0.8rem;
  color: #aaa;
  width: 50px;
  text-align: right;
}

.course-stat-item.complete .course-stat-name {
  color: #2ecc71;
}

/* History Modal */
.history-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-modal-content {
  background: #16213e;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  border: 2px solid #e94560;
}

.history-modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
}

.history-modal-header h2 {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.history-empty {
  color: #666;
  text-align: center;
  padding: 2rem;
}

.history-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: #0f3460;
}

.history-item.completed {
  border-left: 3px solid #2ecc71;
}

.history-item.uncompleted {
  border-left: 3px solid #e74c3c;
}

.history-item-text {
  flex: 1;
  font-size: 0.9rem;
}

.history-item-time {
  font-size: 0.75rem;
  color: #666;
}

/* Edit Mode */
.btn-edit {
  background: #e94560;
}

.btn-edit:hover {
  background: #ff6b6b;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.coords-display {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: rgba(0, 0, 0, 0.95);
  padding: 0.75rem 1rem;
  z-index: 1000;
  border: 2px solid #e94560;
  border-radius: 8px;
  max-width: 280px;
}

.coords-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.coords-header span {
  width: 100%;
  font-weight: bold;
  font-size: 0.85rem;
  color: #e94560;
}

.coords-current {
  font-family: monospace;
  font-size: 0.8rem;
  color: #aaa;
  max-height: 60px;
  overflow: hidden;
}

.edit-mode .marker {
  cursor: grab;
}

.edit-mode .marker:active {
  cursor: grabbing;
}

.edit-mode .marker.dragging {
  z-index: 100;
  box-shadow: 0 0 20px rgba(233, 69, 96, 0.8);
}

/* Responsive */
@media (max-width: 768px) {
  .main {
    flex-direction: column;
  }

  .panel {
    width: 100%;
    border-left: none;
    border-top: 2px solid #e94560;
    max-height: 40vh;
  }

  .map-container {
    min-height: 50vh;
  }

  .footer {
    flex-wrap: wrap;
  }
}

/* Head to Head Full Page */
.h2h-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a2e;
  z-index: 2000;
  overflow-y: auto;
}

.h2h-modal-content {
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}

.h2h-modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 2px solid #e94560;
  position: sticky;
  top: 0;
  background: #1a1a2e;
  z-index: 1;
}

.h2h-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  flex: 1;
}

.h2h-back-btn {
  background: #0f3460;
  color: #eee;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
  white-space: nowrap;
}

.h2h-back-btn:hover {
  background: #1a4a7a;
}

.h2h-body {
  padding: 1.5rem;
}

.h2h-section {
  margin-bottom: 0;
}

.h2h-section:last-child {
  margin-bottom: 0;
}

/* 2-column grid layout */
.h2h-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.h2h-grid-left,
.h2h-grid-right {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* Scoreboard prominence */
.h2h-section--scoreboard {
  background: #0f3460;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.h2h-section--scoreboard .h2h-player-score {
  font-size: 4rem;
}

/* Activity fills left column height */
.h2h-section--activity {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.h2h-section--activity .h2h-history {
  flex: 1;
  max-height: none;
}

.h2h-section-title {
  font-size: 1rem;
  color: #e94560;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Scoreboard */
.h2h-scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.h2h-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.h2h-player-name {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.h2h-david .h2h-player-name {
  color: #3498db;
}

.h2h-andrew .h2h-player-name {
  color: #e94560;
}

.h2h-player-score {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.h2h-david .h2h-player-score {
  color: #3498db;
}

.h2h-andrew .h2h-player-score {
  color: #e94560;
}

.h2h-vs {
  font-size: 1.25rem;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
}

/* Proportion Bar */
.h2h-proportion-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: #0f3460;
}

.h2h-proportion-david {
  background: #3498db;
  transition: width 0.3s ease;
}

.h2h-proportion-andrew {
  background: #e94560;
  transition: width 0.3s ease;
}

/* Record Wins Controls */
.h2h-controls {
  background: #0f3460;
  border-radius: 8px;
  padding: 1rem;
}

.h2h-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.h2h-control-row label {
  font-size: 0.9rem;
  color: #aaa;
}

.h2h-select {
  background: #16213e;
  color: #eee;
  border: 1px solid #333;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 200px;
}

.h2h-amount-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.h2h-amount-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.h2h-amount-input {
  width: 50px;
  text-align: center;
  background: #16213e;
  color: #eee;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0.4rem;
  font-size: 0.9rem;
  -moz-appearance: textfield;
}

.h2h-amount-input::-webkit-outer-spin-button,
.h2h-amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.h2h-add-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.h2h-add-david {
  flex: 1;
  background: #3498db;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem;
}

.h2h-add-david:hover {
  background: #5dade2;
}

.h2h-add-andrew {
  flex: 1;
  background: #e94560;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem;
}

.h2h-add-andrew:hover {
  background: #ff6b6b;
}

.h2h-undo-btn {
  width: 100%;
  background: #333;
  font-size: 0.85rem;
}

.h2h-undo-btn:hover:not(:disabled) {
  background: #555;
}

.h2h-undo-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Rally Breakdown */
.h2h-rally-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.h2h-rally-item {
  background: #0f3460;
  border-radius: 6px;
  padding: 0.75rem;
}

.h2h-rally-item.dimmed {
  opacity: 0.4;
}

.h2h-rally-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.h2h-rally-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.h2h-rally-cup {
  font-size: 0.75rem;
  color: #666;
}

.h2h-rally-scores {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.h2h-rally-score-david {
  color: #3498db;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 24px;
  text-align: right;
  white-space: nowrap;
}

.h2h-rally-score-andrew {
  color: #e94560;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 24px;
  text-align: left;
  white-space: nowrap;
}

.h2h-rally-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: #1a1a2e;
  display: flex;
}

.h2h-rally-bar-david {
  background: #3498db;
  transition: width 0.3s ease;
}

.h2h-rally-bar-andrew {
  background: #e94560;
  transition: width 0.3s ease;
}

.h2h-rally-no-races {
  font-size: 0.8rem;
  color: #666;
  text-align: center;
}

/* Recent Activity */
.h2h-history {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 300px;
  overflow-y: auto;
}

.h2h-history-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #0f3460;
  border-radius: 6px;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
}

.h2h-history-item.david {
  border-left-color: #3498db;
}

.h2h-history-item.andrew {
  border-left-color: #e94560;
}

.h2h-history-text {
  flex: 1;
}

.h2h-history-text .player-name {
  font-weight: 600;
}

.h2h-history-item.david .player-name {
  color: #3498db;
}

.h2h-history-item.andrew .player-name {
  color: #e94560;
}

.h2h-history-time {
  font-size: 0.75rem;
  color: #666;
  margin-left: 0.5rem;
  white-space: nowrap;
}

.h2h-history-empty {
  color: #666;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.9rem;
}

/* Streaks & Momentum */
.h2h-streaks {
  background: #0f3460;
  border-radius: 8px;
  padding: 1rem;
}

.h2h-streak-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
}

.h2h-streak-row + .h2h-streak-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.h2h-streak-label {
  font-size: 0.85rem;
  color: #aaa;
}

.h2h-streak-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #eee;
}

.h2h-momentum-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.6rem;
  margin-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.h2h-momentum-label {
  font-size: 0.85rem;
  color: #aaa;
  margin-right: 0.75rem;
}

.h2h-momentum-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.h2h-momentum-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.h2h-momentum-dot.david {
  background: #3498db;
}

.h2h-momentum-dot.andrew {
  background: #e94560;
}

.h2h-momentum-dot.empty {
  background: #333;
}

.h2h-momentum-summary {
  font-size: 0.8rem;
  font-weight: 600;
  color: #eee;
  margin-left: 0.75rem;
  white-space: nowrap;
}

/* Badges */
.h2h-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 0.5rem;
  white-space: nowrap;
}

.h2h-badge.david-owned {
  background: rgba(52, 152, 219, 0.25);
  color: #5dade2;
  border: 1px solid rgba(52, 152, 219, 0.4);
}

.h2h-badge.andrew-owned {
  background: rgba(233, 69, 96, 0.25);
  color: #ff6b6b;
  border: 1px solid rgba(233, 69, 96, 0.4);
}

.h2h-badge.contested {
  background: rgba(241, 196, 15, 0.2);
  color: #f1c40f;
  border: 1px solid rgba(241, 196, 15, 0.35);
}

/* Rally win rate text */
.h2h-rally-pct {
  font-size: 0.7rem;
  color: #888;
  margin-left: 2px;
}

/* Charts */
.h2h-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.h2h-chart-card {
  background: #0f3460;
  border-radius: 8px;
  padding: 1rem;
}

.h2h-chart-card h4 {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.h2h-timeline-chart svg,
.h2h-radar-chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.h2h-chart-empty {
  color: #666;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
}

/* H2H Responsive: mobile (≤768px) */
@media (max-width: 768px) {
  .h2h-modal-content {
    max-width: 640px;
  }

  .h2h-body {
    display: flex;
    flex-direction: column;
  }

  .h2h-grid,
  .h2h-grid-left,
  .h2h-grid-right {
    display: contents;
  }

  .h2h-section--scoreboard { order: 1; margin-bottom: 1.5rem; }
  .h2h-section--streaks    { order: 2; margin-bottom: 1.5rem; }
  .h2h-section--record     { order: 3; margin-bottom: 1.5rem; }
  .h2h-section--rally      { order: 4; margin-bottom: 1.5rem; }
  .h2h-section--charts     { order: 5; margin-bottom: 1.5rem; }
  .h2h-section--activity   { order: 6; margin-bottom: 0; }

  .h2h-charts {
    grid-template-columns: 1fr;
  }

  .h2h-section--scoreboard .h2h-player-score {
    font-size: 3rem;
  }

  .h2h-section--activity .h2h-history {
    max-height: 300px;
  }

  .h2h-section--activity {
    flex: initial;
  }
}

/* H2H Responsive: mid-size (769px–1000px) */
@media (min-width: 769px) and (max-width: 1000px) {
  .h2h-charts {
    grid-template-columns: 1fr;
  }
}

/* 1st Place stats under score */
.h2h-player-firsts {
  font-size: 0.8rem;
  color: #aaa;
  font-weight: 500;
}

/* 1st Place checkbox styling */
.h2h-checkbox {
  width: 20px;
  height: 20px;
  accent-color: #f1c40f;
  cursor: pointer;
}

/* 1st place entries in activity feed */
.h2h-history-item.first-place {
  border-left-color: #f1c40f;
}

/* 1st place counts in rally breakdown */
.h2h-rally-firsts {
  display: block;
  font-size: 0.75rem;
  color: #f1c40f;
  margin-top: 0.25rem;
}

/* Edit button on history items */
.h2h-history-edit {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  margin-left: 0.4rem;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.h2h-history-edit:hover {
  color: #eee;
  background: rgba(255, 255, 255, 0.1);
}

/* Inline edit form */
.h2h-edit-form {
  width: 100%;
}

.h2h-edit-fields {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.h2h-edit-form select,
.h2h-edit-form input {
  background: #16213e;
  color: #eee;
  border: 1px solid #333;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.h2h-edit-form select {
  min-width: 0;
}

.h2h-edit-count {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  color: #aaa;
  font-size: 0.8rem;
}

.h2h-edit-count input {
  width: 45px;
  text-align: center;
  -moz-appearance: textfield;
}

.h2h-edit-count input::-webkit-outer-spin-button,
.h2h-edit-count input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.h2h-edit-actions {
  display: flex;
  gap: 0.4rem;
}

.h2h-edit-delete {
  background: #c0392b !important;
}

.h2h-edit-delete:hover {
  background: #e74c3c !important;
}
