/* Kilpailusivu sovelluksen RaceDetailsScreenin mukaan
   (pointsapp/lib/screens/race_details_screen.dart). Ladataan race.css:n
   jälkeen ja ohittaa sen; body.app-theme tulee app-theme.css:stä. */

body.app-theme {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; /* kuten sovelluksen kisanäkymä */
}
body.app-theme .container {
  max-width: 750px;
  margin: 0 auto 100px;
  padding: 64px 6px 0;
  background: transparent;
  border-radius: 0;
}

/* _SmallLogo 140 × 78 */
body.app-theme .logo-link { display: flex; justify-content: center; }
body.app-theme .logo-link img {
  width: 140px;
  min-width: 0;
  max-width: none;
  height: 78px;
  margin: 0;
  object-fit: contain;
}

/* _RaceInfo */
body.app-theme .race-info {
  margin: 0;
  padding: 10px;
  background: transparent;
  border-radius: 0;
}
.race-location {
  display: inline-flex;
  align-items: flex-start;
  gap: 5px;
  color: #0066CC;
  font-size: 16px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #0066CC;
}
.race-location:not([href]) { color: #333; text-decoration: none; }
.race-location:not([href]) .open-icon { display: none; }
.race-location .open-icon { flex: none; width: 15px; height: 15px; margin-top: 3px; fill: #0066CC; }
body.app-theme .race-info p { margin: 0; }
body.app-theme .race-info .race-meta { margin-top: 8px; font-size: 14px; color: rgba(0, 0, 0, .87); }
body.app-theme .race-info .race-sub { margin-top: 3px; font-size: 12px; color: #555; white-space: pre-wrap; }

/* Detailed stats (ExpansionTile) */
body.app-theme .race-stats { margin: 7px 0 0; font-size: 13px; }
body.app-theme .race-stats details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
body.app-theme .race-stats details summary::-webkit-details-marker { display: none; }
body.app-theme .race-stats details summary::before { display: none; }
.race-stats .expand-icon { width: 24px; height: 24px; fill: #49454F; transition: transform .2s; }
.race-stats details[open] .expand-icon { transform: rotate(180deg); }
body.app-theme .stats-grid { display: flex; gap: 12px; margin: 0 0 8px; flex-wrap: nowrap; }
body.app-theme .stats-section {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .95);
  border: .6px solid rgba(0, 56, 113, .06);
  box-shadow: 0 0 1px rgba(0, 56, 113, .02), 0 0 10px rgba(0, 56, 113, .035);
}
body.app-theme .stats-section h4 {
  margin: 0 0 5px;
  color: #777;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  opacity: 1;
}
body.app-theme .stat-row { padding: 2px 0; border: 0; font-size: 11px; }
body.app-theme .stat-label { opacity: 1; }
body.app-theme .stat-value { font-weight: 600; }

/* GlassSegmentedControl */
.race-views-wrap { padding: 4px 12px; }
#race-views {
  display: flex;
  margin: 0;
  border-bottom: 0;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 56, 113, .06);
  box-shadow: inset 0 0 0 .5px rgba(0, 56, 113, .08);
}
#race-views:empty { display: none; }
#race-views button {
  flex: 1;
  height: 34px;
  margin: 0;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #667085;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .2s, color .2s, box-shadow .2s;
}
#race-views button::after { display: none; }
#race-views button:hover { color: #003871; }
#race-views button[aria-pressed="true"] {
  background: rgba(255, 255, 255, .98);
  color: #003871;
  font-weight: 700;
  box-shadow:
    0 0 1.2px rgba(0, 56, 113, .03),
    0 0 12px rgba(0, 56, 113, .045),
    inset 0 0 0 .5px rgba(0, 56, 113, .08);
}

.race-view-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#race-view-label { padding: 12px 0; color: #7A8491; font-size: 12px; }
.startlist-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 12px 6px;
  color: #003871;
  font-size: 12px;
  cursor: pointer;
}
.startlist-select[hidden] { display: none; }
.startlist-select select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding-right: 18px;
  cursor: pointer;
}
.startlist-select svg { position: absolute; right: 4px; width: 18px; height: 18px; fill: #003871; pointer-events: none; }

/* _Updated */
body.app-theme .update-controls { gap: 0; margin: 0; }
body.app-theme .updated {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  padding: 9px 14px;
  border: .6px solid rgba(0, 56, 113, .06);
  border-radius: 18px;
  background: linear-gradient(rgba(241, 247, 254, .95), rgba(227, 240, 253, .88));
  box-shadow: 0 0 1px rgba(0, 56, 113, .02), 0 0 10px rgba(0, 56, 113, .035);
  color: #555;
  font-size: 12px;
}
body.app-theme .updated::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2196F3;
}
body.app-theme .last-event {
  margin: 0 0 12px;
  padding: 9px 14px;
  border: 0;
  border-left: 0;
  border-radius: 18px;
  background: rgba(255, 179, 0, .12);
  box-shadow: inset 0 0 0 1px rgba(255, 179, 0, .45);
  color: #333;
}
body.app-theme .controls { margin: -4px 4px 8px; }
body.app-theme .checkbox-group input[type="checkbox"] { accent-color: #003871; }

/* Tulostaulukko: GlassSurface(radius 18, regularTint) */
.results-card {
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(rgba(255, 255, 255, .965), rgba(255, 255, 255, .95) 50%);
  box-shadow:
    0 0 2px rgba(0, 56, 113, .04),
    0 0 20px rgba(0, 56, 113, .07),
    inset 0 0 0 .5px rgba(0, 56, 113, .08);
}
body.app-theme #results-table {
  width: 100%;
  border: 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}
/* _resultFlex = [6, 8, 38, 8, 12, 13, 15] */
#results-table col.c-rank   { width: 6%; }
#results-table col.c-bib    { width: 8%; }
#results-table col.c-name   { width: 38%; }
#results-table col.c-nation { width: 8%; }
#results-table col.c-diff   { width: 12%; }
#results-table col.c-fis    { width: 13%; }
#results-table col.c-points { width: 15%; }
body.app-theme #results-table th,
body.app-theme #results-table td {
  width: auto;
  padding: 0 3px;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.app-theme #results-table thead th {
  position: static;
  height: 38px;
  border: 0;
  background: #003871;
  color: #fff;
  font-weight: 600;
  text-align: center;
}
body.app-theme #results-table thead th.name { text-align: left; }
body.app-theme #race-points-header { font-weight: 700; cursor: pointer; user-select: none; }
body.app-theme #race-points-header:hover { background: #0a4a8c; }

/* _ResultRow */
body.app-theme #results tr { background: transparent; }
body.app-theme #results tr.athlete-row td {
  height: 39px;
  border-bottom: 1px solid #DDD;
  color: rgba(0, 0, 0, .87);
  text-align: center;
  font-weight: 400;
}
body.app-theme #results tr.athlete-row.striped { background: rgba(30, 90, 200, .05); }
body.app-theme #results tr.athlete-row td.rank,
body.app-theme #results tr.athlete-row td.bib,
body.app-theme #results tr.athlete-row td.diff,
body.app-theme #results tr.athlete-row td.time { font-weight: 600; }
body.app-theme #results tr.athlete-row td.time1 { color: rgba(0, 0, 0, .87); }
body.app-theme #results td.time.race-better { color: #028821; font-weight: 600; }
body.app-theme #results tr.athlete-row td.name { text-align: left; }
#results td.name { line-height: 1.05; }
#results td.name .name-text strong { font-weight: 700; }
#results .row-bananas { margin-left: 3px; font-size: 9.5px; letter-spacing: -1.5px; }
#results .fis-rank { font-size: 9px; font-weight: 700; }

/* Tilat: DNS harmaa, DNF/DSQ/DQP punertava */
body.app-theme #results tr.dns, body.app-theme #results tr.dns-1, body.app-theme #results tr.dns-2 {
  background: rgba(0, 0, 0, .07) !important;
}
body.app-theme #results tr.dnf, body.app-theme #results tr.dnf-1, body.app-theme #results tr.dnf-2,
body.app-theme #results tr.dsq, body.app-theme #results tr.dsq-1, body.app-theme #results tr.dsq-2,
body.app-theme #results tr.dqp, body.app-theme #results tr.dqp-1, body.app-theme #results tr.dqp-2 {
  background: rgba(255, 48, 48, .1) !important;
  font-style: normal;
}
body.app-theme #results tr[class*="dn"] td,
body.app-theme #results tr[class*="dsq"] td,
body.app-theme #results tr[class*="dqp"] td { color: rgba(0, 0, 0, .87); }

/* Korostukset: suosikki ja maa */
body.app-theme #results tr.highlight-nation { background: #D7E5FC !important; }
body.app-theme #results tr.highlight-athlete { background: #ABC8F3 !important; }
body.app-theme #results .fav-star { display: none; }

/* Viimeisin tapahtuma: 2 px keltainen reunus */
body.app-theme #results tr.last-event-row {
  outline: 2px solid #FFB300;
  outline-offset: -2px;
  animation: none;
}

@media (hover: hover) {
  body.app-theme #results tr.athlete-row:hover { background-color: rgba(0, 56, 113, .05); }
}

/* CountryFlag(size: 24) */
body.app-theme #results td.nation { padding: 0; text-overflow: clip; }
body.app-theme #results .flag-icon {
  display: block;
  width: 24px;
  height: 18px;
  margin: 0 auto;
  box-sizing: border-box;
  border: 1px solid #858585;
  border-radius: 2px;
  object-fit: cover;
  cursor: pointer;
}

/* _AthleteDetails */
body.app-theme #results tr.details-row { background: transparent !important; }
body.app-theme #results tr.details-row td {
  padding: 0 !important;
  border: 0 !important;
  border-bottom: 1px solid #DDD !important;
  white-space: normal;
  text-align: left;
  overflow: visible;
}
body.app-theme .details-content {
  padding: 11px 14px 13px;
  border-left: 0;
  background: rgba(0, 56, 113, .04);
  font-size: 11px;
  overflow-x: auto;
  animation: details-open .18s ease-out;
}
@keyframes details-open { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { body.app-theme .details-content { animation: none; } }

.athlete-details-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.athlete-full-name { font-size: 14px; font-weight: 700; color: rgba(0, 0, 0, .87); }
.member-badge { display: inline-flex; align-items: center; gap: 4px; }
.member-name { color: #0066CC; font-size: 12px; text-decoration: underline; }
.tag-pill {
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .4px;
}
.athlete-meta { margin-top: 3px; color: #555; font-size: 11px; white-space: pre-wrap; }
.athlete-bananas { margin-top: 6px; color: #555; font-size: 12px; white-space: pre-wrap; }
.athlete-bananas a { color: #0066CC; }
.athlete-times { display: flex; margin-top: 10px; }
.athlete-times > div { flex: 1; min-width: 0; }
.time-label { color: #777; font-size: 9px; text-transform: uppercase; }
.time-value { margin-top: 2px; color: rgba(0, 0, 0, .87); font-size: 13px; font-weight: 600; }
.fis-profile {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 9px;
  color: #0066CC;
  font-size: 12px;
}
.fis-profile svg { width: 14px; height: 14px; fill: #0066CC; }

/* Väliajat ja sektorit (vain nettisivulla) samaan tyyliin */
.split-title {
  margin: 14px 0 6px;
  color: #777;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.split-runs { display: flex; flex-wrap: wrap; gap: 10px; }
body.app-theme .run-details {
  display: block;
  flex: 1 1 200px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .95);
  border: .6px solid rgba(0, 56, 113, .06);
}
body.app-theme .run-details h5 {
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  color: #333;
  font-size: 12px;
  font-weight: 600;
}
body.app-theme .run-details table { width: 100%; font-size: 11px; }
body.app-theme .run-details th {
  position: static;
  padding: 3px 4px;
  background: transparent !important;
  color: #777;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  border: 0;
}
body.app-theme .run-details td {
  padding: 3px 4px;
  border: 0;
  background: transparent !important;
  font-size: 11px;
}

/* Viestit */
body.app-theme #results td.loading { padding: 0; height: auto; border: 0; white-space: normal; }
#results .spinner {
  width: 32px;
  height: 32px;
  margin: 48px auto;
  border: 3px solid rgba(0, 56, 113, .15);
  border-top-color: #003871;
  border-radius: 50%;
  animation: race-spin .9s linear infinite;
}
@keyframes race-spin { to { transform: rotate(360deg); } }
.race-message { padding: 26px 24px; text-align: center; }
.race-message h3 { margin: 0 0 6px; color: #003871; font-size: 17px; }
.race-message p { margin: 0; color: #607D8B; font-size: 13px; }
body.app-theme #results .flag-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 18px;
  margin: 0 auto;
  box-sizing: border-box;
  border: 1px solid #858585;
  border-radius: 2px;
  font-size: 8px;
}

/* Pyörivä kello pysähtyy hetkeksi väliaikaan. */
body.app-theme #results tr.athlete-row td.diff.split-hold {
  font-weight: 700;
}

/* R26 points shown: red outline drawn from the toggle corner (race.php r26Outline). */
.results-card {
  position: relative;
}
.results-card .r26-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}
.results-card .r26-outline path {
  fill: none;
  stroke: #e02424;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dashoffset .9s ease-in-out;
}

/* Live-boksi (kuten sovelluksen _LiveBox): tiivis kortti, ikonit
   Next (talo) / On course (laskija) / Last finish (maali), alhaalla LIVE ja päivitysaika. */
.live-box {
  margin: 0 0 10px;
  overflow: hidden;
  border-radius: 14px;
  background: linear-gradient(rgba(255, 255, 255, .965), rgba(255, 255, 255, .95) 50%);
  box-shadow: 0 0 1px rgba(0, 56, 113, .03), 0 0 10px rgba(0, 56, 113, .05);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.live-box[hidden] { display: none; }
.live-box-row {
  display: flex;
  align-items: center;
  height: 32px;
  padding-right: 10px;
  font-size: 12px;
  color: rgba(0, 0, 0, .87);
  position: relative;
}
/* Divider(indent: 36) */
.live-box-row + .live-box-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 36px;
  right: 0;
  height: 1px;
  background: #E9ECF0;
}
.live-box-icon {
  flex: none;
  width: 17px;
  height: 17px;
  margin: 0 9.5px;
  fill: #7A8491;
}
.live-box-bib {
  flex: none;
  width: 26px;
  color: #003871;
  font-weight: 800;
}
.live-box-flag { flex: none; display: flex; margin-right: 7px; }
.live-box-flag .flag-icon { width: 22px; height: auto; }
.live-box-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.live-box-empty { color: #B0B7C0; }
.live-box-value {
  flex: none;
  margin-left: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.live-box-course .live-box-value { font-size: 12.5px; }
.live-box-rank { color: #003871; font-weight: 800; margin-right: 6px; }
.live-box-out { color: #D32F2F; }
.live-box-points { color: #7A8491; font-weight: 400; }
.live-box .live-clock.split-hold { font-weight: 800; }
.live-box-foot {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 10px;
  border-top: 1px solid #E9ECF0;
  background: rgba(0, 56, 113, .03);
  color: #8A939E;
  font-size: 9.5px;
}
.live-box-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FF4B4B;
}
.live-box-live { font-weight: 700; letter-spacing: .4px; }
.live-box-updated { margin-left: auto; }
.live-box-race-points { margin-left: 12px; }
.live-box-race-points.race-better { color: #028821; }
