* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--background-color);
  color: var(--text-color);
  line-height: 1.6
}

body[data-theme="dark"] {
  background: #1a1a1a;
  color: #f8f9fa
}

:root {
  --background-color: #fff;
  --text-color: #333;
  --primary-color: #007bff;
  --secondary-color: #f1f3f5;
  --border-color: #ddd
}

[data-theme="dark"] {
  --background-color: #1a1a1a;
  --text-color: #f8f9fa;
  --primary-color: #0d6efd;
  --secondary-color: #2d2d2d;
  --border-color: #444
}

.app-container {
  max-width: 1200px;
  margin: 15px auto;
  padding: 10px;
  background: var(--background-color);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1)
}

.app-header {
  position: relative;
  text-align: center;
  margin-bottom: 20px;
  padding: 15px 5px;
  background: url('bg_new.jpg')center/cover no-repeat;
  height: 10rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white
}

.app-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 12px;
  z-index: 1
}

.header-content {
  z-index: 2
}

.header-text h1 {
  font-size: 1.6rem;
  color: #fc5200;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.8px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3)
}

.header-text p {
  font-size: 1rem;
  color: #f8f9fa;
  opacity: 0.8;
  font-weight: 500
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
  position: absolute;
  justify-content: end;
  margin-top: 30px;
  right: 0.2rem;
  bottom: 0.2rem
}

.theme-toggle label {
  font-size: 0.9rem;
  color: #f8f9fa;
  font-weight: 500
}

.theme-toggle input {
  appearance: none;
  width: 40px;
  height: 20px;
  background: var(--border-color);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease
}

.theme-toggle input:checked {
  background: var(--primary-color)
}

.theme-toggle input::before {
  content: "💡";
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  transition: left 0.3s ease
}

.theme-toggle input:checked::before {
  left: 22px
}

.header-divider {
  height: 2px;
  background: linear-gradient(90deg, var(--primary-color), transparent);
  margin-top: 15px;
  opacity: 0.3
}

[data-theme="dark"] .app-header {
  background: url('bg_new.jpg')center/cover no-repeat;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2)
}

[data-theme="dark"].app-header::before {
  background: rgba(0, 0, 0, 0.7)
}

[data-theme="dark"].header-text h1 {
  color: #fc5200
}

[data-theme="dark"].header-text p {
  color: #f8f9fa;
  opacity: 0.9
}

[data-theme="dark"].header-divider {
  background: linear-gradient(90deg, var(--primary-color), transparent)
}

@media(min-width:768px) {
  .header-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0
  }

  .header-text h1 {
    font-size: 2.5rem
  }

  .header-text p {
    font-size: 1.1rem
  }

  .theme-toggle label {
    font-size: 1rem
  }
}

.auth-button {
  display: block;
  width: 100%;
  padding: 15px;
  background: #fc5200;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease
}

.auth-button:hover {
  background: #fc5200;
  transform: translateY(-2px)
}

.auth-subtext {
  font-size: small
}

.month-selector {
  margin: 20px 0;
  text-align: center
}

.month-selector label {
  font-size: 1rem;
  margin-right: 10px;
  color: var(--text-color)
}

.month-selector select {
  padding: 8px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--background-color);
  color: var(--text-color);
  cursor: pointer;
  transition: border-color 0.3s ease
}

.month-selector select:hover {
  border-color: var(--primary-color)
}

.loader {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  color: var(--primary-color);
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 9999
}

.running-emoji {
  display: inline-block;
  animation: run-animation 0.8s infinite alternate ease-in-out
}

.loading-text::after {
  content: "";
  display: inline-block;
  animation: dots-animation 1.5s infinite steps(3)
}

@keyframes run-animation {
  from {
    transform: translateX(0)
  }

  to {
    transform: translateX(10px)
  }
}

@keyframes dots-animation {
  0% {
    content: "."
  }

  33% {
    content: ".."
  }

  66% {
    content: "..."
  }

  100% {
    content: ""
  }
}

.medals-container {
  text-align: center;
  margin: 20px 0
}

.medals-container h2 {
  font-size: 1.3rem;
  margin-bottom: 10px;
  color: var(--text-color)
}

.medals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 6px;
  margin-top: 10px
}

.medals-grid p {
  background: linear-gradient(135deg, #fc5200, #ffcc00);
  color: #333;
  padding: 4px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: bold;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.2)
}

.medals-grid p:hover {
  transform: scale(1.05);
  box-shadow: 4px 8px 16px rgba(0, 0, 0, 0.3)
}

.calendar-container {
  overflow-x: auto;
  margin-top: -20px;
  scrollbar-width: none;
  padding-bottom: 10px
}

.activity-table {
  padding-top: 15px
}

.activity-table h2 {
  font-size: 1.2rem
}

#calendarTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  margin-bottom: 40px
}

#calendarTable thead th {
  position: sticky;
  top: 0;
  background: var(--primary-color);
  z-index: 1
}

#calendarTable th,
#calendarTable td {
  padding: 2px;
  text-align: center;
  border: 1px solid var(--border-color)
}

#calendarTable th {
  background: var(--primary-color);
  color: #fff;
  font-weight: 600
}

#calendarTable td {
  cursor: pointer;
  border-color: var(--border-color);
  transition: background 0.3s ease, transform 0.2s ease;
  min-width: 4.6rem
}

#calendarTable td:hover {
  transform: scale(1.05)
}

#calendarTable tbody tr:nth-child(odd) {
  background: rgba(0, 123, 255, 0.05)
}

.athlete-name {
  cursor: pointer;
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: capitalize
}

.profile-photo-list {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-top: 5px;
  margin-bottom: 5px
}

.profile-photo-large {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin-bottom: 10px
}

.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px
}

.profile-card {
  background: var(--secondary-color);
  padding: 15px;
  border-radius: 10px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1)
}

.profile-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2)
}

.profile-card img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: 10px;
  border: 3px solid var(--primary-color)
}

.popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000
}

.popup-content {
  background: var(--background-color);
  color: var(--text-color);
  padding: 20px;
  border-radius: 12px;
  height: -webkit-fill-available;
  width: 90%;
  max-width: 400px;
  text-align: center;
  position: relative
}

.popup-content h3 {
  font-size: 1.2rem;
  margin: 10px;
  color: var(--text-color)
}

.popup-content p {
  font-size: 1.1rem;
  margin: 5px 0;
  color: var(--text-color)
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.5rem;
  cursor: pointer
}

.app-footer {
  text-align: center;
  background: #fc6b0094;
  color: white;
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center
}

.social-links a {
  margin: 0 10px;
  color: white;
  font-size: 1.5rem;
  transition: transform 0.2s ease
}

.social-links a:hover {
  transform: scale(1.1)
}

.strava-badge- {
  display: inline-block;
  height: 24px
}

.strava-badge-img {
  visibility: hidden;
  height: 24px
}

.strava-badge-:hover {
  background-position: 0-37px
}

.strava-badge-follow {
  height: 24px;
  width: 24px;
  background: url(//badges.strava.com/echelon-sprite-24.png) no-repeat 0 0;
}

.search-box {
  width: 100%;
  padding: 8px;
  font-size: 14px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 5px
}

.activity-cell {}

.cell--active {
  background-color: lightgreen;
}

.cell--rest {
  background-color: #80d9ff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><text x='50%' y='50%' font-size='50' text-anchor='middle' dominant-baseline='middle'>💤</text></svg>");
}

.cell--today {
  border: 2px solid blue;
  font-weight: bold;
}

.cell__emoji {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: top center;
}

.activity-text {
  display: block;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 3px;
  position: relative;
  z-index: 1
}

.activity-points {
  font-size: 12px;
  color: #555;
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 5px;
  border-radius: 3px;
  position: relative;
  z-index: 1
}

.date-range {
  font-size: 0.9rem;
  color: #fffffffa;
}

.category-filters {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 10px;
}

.filter-button {
  padding: 8px 14px;
  border: none;
  border-radius: 5px;
  background-color: #fda94f;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease;
  opacity: 0.6;
}

.filter-button.selected {
  background-color: #fc5200;
  opacity: 1;
}

.active-cell {
  background-color: lightgreen;
  cursor: pointer;
  font-weight: bold;
}

.athlete-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 8px 0;
  max-width: 120px;
  word-wrap: break-word;
  background: rgba(61, 98, 59, 0.91);
  min-width: 8rem;
}

.profile-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e73707b5;
  margin-bottom: 6px;
  background: #222;
  image-rendering: -webkit-optimize-contrast;
}

.athlete-info {
  text-align: center;
  width: 100%;
}

.athlete-name {
  background: #dc1a1a1a;
  font-size: 0.95rem;
  font-weight: bold;
  color: #c9e707cf;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.athlete-distance {
  font-size: 1rem;
  font-weight: bold;
  color: #ff9800;
  margin-bottom: 4px;
}

.progress-bar {
  background-color: #ddd;
  height: 8px;
  border-radius: 3px;
  width: 100%;
  max-width: 90%;
  margin: 0 auto;
}

.progress-fill {
  background-color: #4caf50;
  height: 100%;
  border-radius: 3px;
}

.row-virt {
  contain-intrinsic-size: auto 48px;
  content-visibility: auto;
}

/* the stamp */
.qualified-stamp {
position: absolute;
  top: 25px;
  left: 25px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #fc000066;
  border: 2px solid #28a745;
  border-radius: 6px;
  background: rgba(40, 167, 69, 0.12);
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.25);
  transform: rotate(-10deg) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease-out, transform .2s ease-out;
}

.athlete-cell.qualified .qualified-stamp {
  opacity: 1;
  transform: rotate(-10deg) scale(1);
}

/* one-time “stamp” animation */
@keyframes stamp-pop {
  0% {
    transform: rotate(-18deg) scale(2);
    opacity: 0;
  }

  60% {
    transform: rotate(-10deg) scale(0.95);
    opacity: 0.6;
  }

  100% {
    transform: rotate(-10deg) scale(1);
    opacity: 1;
  }
}
.qualified-stamp.stamp-animate {
  animation: stamp-pop 1520ms cubic-bezier(.2, .9, .2, 1) both;
}

.event-description {
  margin-top: 16px;
  line-height: 1.5;
  font-size: 1rem;
  color: #444;
}

.glowing-note {
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  text-align: center;
  margin: 1px 0;
  text-shadow:
    0 0 5px #ff4da6,
    0 0 10px #ff4da6,
    0 0 20px #ff4da6,
    0 0 30px #ff1a75;
  animation: glowFlash 3.0s ease-in-out infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
  .glowing-note {
    animation: none;
    text-shadow: 0 0 8px #ff9d00;
  }
}

@keyframes glowFlash {
  from {
    text-shadow:
      0 0 5px #ff4da6,
      0 0 10px #ff4da6,
      0 0 20px #ff4da6,
      0 0 30px #ff1a75;
    color: #484746;
  }

  to {
    text-shadow:
      0 0 5px #ffbf00,
      0 0 10px #ff9d00,
      0 0 20px #ff8800,
      0 0 30px #e66000;
    color: #484746;
  }
}

.lang-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.lang-btn {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #444;
  background: #1b1b1b;
  color: #eee;
  cursor: pointer;
}

.lang-btn.active {
  background: #ff7a00;
  color: #000;
  border-color: #ff7a00;
}

.lang-btn:focus-visible {
  outline: 2px solid #ff7a00;
  outline-offset: 2px;
}

/* Initial load state */
.app-main.hidden {
  opacity: 0;
  pointer-events: none;
}

.app-main {
  transition: opacity 0.3s ease-in-out;
  opacity: 1;
}

/* Empty state styling */
.empty-state {
  text-align: center;
  padding: 3rem;
  margin: 2rem 1rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fc5200;
  background: rgba(252, 82, 0, 0.08);
  border: 2px dashed #fc5200;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Dummy Badge */
.dummy-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background-color: #ff9800;
  color: white;
  font-size: 0.7rem;
  padding: 2px 5px;
  border-radius: 4px;
  z-index: 10;
  font-weight: bold;
}

/* Authorize Cell */
.authorize-cell {
  text-align: left !important;
  vertical-align: middle;
  padding: 10px 20px !important;
  background-color: rgba(0, 0, 0, 0.05);
}

.authorize-btn {
  background-color: #fc5200;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9rem;
  transition: background-color 0.3s;
}

.authorize-btn:hover {
  background-color: #e04600;
}