:root {
  --primary: #007aff;
  --green: #22c55e;
  --green-dark: #16a34a;
  --red: #ff3b30;
  --bg: #f5f5f7;
  --card: #ffffff;
  --border: #e5e5ea;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --radius: 20px;
  --shadow: 0 12px 32px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  padding: 14px 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #111;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.brand-title {
  font-size: 21px;
  font-weight: 750;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 360px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.section-header h2 {
  font-size: 15px;
  margin: 0 0 12px;
}

.file-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border-radius: 16px;
  background: #fbfbfd;
  border: 1px solid var(--border);
}

.track-label {
  font-size: 13px;
  font-weight: 700;
}

.track-one { color: var(--primary); }
.track-two { color: var(--red); }

input[type="file"] {
  font-size: 13px;
  color: var(--muted);
}

input[type="file"]::file-selector-button {
  border: none;
  border-radius: 999px;
  background: #111;
  color: #fff;
  padding: 7px 12px;
  margin-right: 8px;
  cursor: pointer;
}

.nick-input, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

.file-status {
  font-size: 12px;
  color: var(--muted);
}

.file-status.ok {
  color: var(--green-dark);
  font-weight: 700;
}

.file-status.bad {
  color: #dc2626;
  font-weight: 700;
}

#playPause {
  width: 100%;
  border: none;
  border-radius: 18px;
  padding: 16px 20px;
  background: var(--green);
  color: #fff;
  font-size: 22px;
  font-weight: 750;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 22px rgba(34,197,94,0.28);
}

#playPause:hover { background: var(--green-dark); }
#playPause:disabled {
  background: #b7dbc4;
  box-shadow: none;
  cursor: not-allowed;
}

.control-block {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.control-block label {
  font-size: 13px;
  font-weight: 700;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
}

#raceSlider { width: 100%; cursor: pointer; }

#currentTime, #racePercent {
  font-size: 12px;
  color: var(--muted);
}

.secondary-btn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 14px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  margin-top: 14px;
}

.secondary-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.status-message {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.35;
}

.map-area {
  flex: 1;
  padding: 16px;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  background: #fff;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.footer-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,.28);
}

.modal-overlay.visible { display: flex; }

.modal {
  width: min(620px, 94vw);
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 22px 60px rgba(0,0,0,.24);
  padding: 16px;
}

.chart-modal { width: min(920px, 94vw); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #f2f2f7;
  padding-bottom: 10px;
}

.modal-title {
  font-size: 16px;
  font-weight: 750;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
}

.modal-body {
  font-size: 14px;
  line-height: 1.45;
}

.modal-note {
  color: #303031;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.modal-btn {
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  font-weight: 600;
}

.modal-btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.modal-btn-secondary {
  background: #f5f5f7;
  color: var(--text);
}

.ts-ok {
  color: var(--green-dark);
  font-weight: 700;
}

.ts-missing {
  color: #dc2626;
  font-weight: 700;
}

.chart-wrapper {
  height: 420px;
  margin-top: 14px;
}

#raceChart {
  width: 100% !important;
  height: 100% !important;
}

#chartMessage {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

@media (max-width: 900px) {
  main { flex-direction: column; }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .map-area { padding: 12px; }

  #map { min-height: 60vh; }
}

@media (max-width: 600px) {
  header, footer { padding: 10px 14px; }
  .sidebar { padding: 12px; }
  .card { padding: 12px; }
  #playPause { font-size: 20px; padding: 15px; }

  footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (max-width: 900px) {
  .sidebar {
    overflow: visible;
  }

  .control-block {
    display: flex !important;
  }

  #raceSlider {
    display: block !important;
    width: 100% !important;
    min-height: 34px;
  }

  .slider-label-row {
    display: flex !important;
  }

  #currentTime,
  #racePercent {
    display: block !important;
  }
}

#openChart {display:none;}