:root {
    --font-serif-zh: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "PMingLiU", serif;
    --font-sans-zh: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    --font-ui-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
}

body {
    margin: 0;
    padding: 0;
    background: #fffff8;
    --vivid-background: #fffff8;
    --vivid-foreground: #000;
    --dull-background: #f0f0f0;
    --dull-foreground: #666;
    --accent: #2a623d;
    --race-background: #8b0000;
    --slowdown-background: #437a37;
    color: #111;
    font-family: var(--font-serif-zh);
  }
  #myInfographic {
    position: fixed;
    top: 0; /* Always stay at the top */
    max-width: 500px;
    width: 100%; /* Ensure it takes full width of container */
    margin: 0 auto; /* Center horizontally */
    padding: 110px 24px 40px;
    margin-top: 0px;
    box-sizing: border-box; /* Include padding in width calculation */
    z-index: 10; /* Ensure it's above other content */
  }
  .section-title {
    font-weight: 600;
    margin: 0 0 10px 0;
  }
  .tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(0, 40, 0, 0.8);
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
  }
  .linechart-container {
    position: relative;
    width: 100%;
    height: 132px;
    margin-bottom: 26px;
  }
  .progressbar-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px 16px;
    align-content: start;
  }
  .progressbar-item {
    display: block;
    align-items: center;
    position: relative;
  }
  .progressbar-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
    font-size: 0.88rem;
    line-height: 1.25;
    margin-bottom: 2px;
  }
  .progressbar-label-icon {
    width: 14px;
    height: 14px;
    color: #111;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
  }
  .progressbar-label-icon svg {
    width: 14px;
    height: 14px;
    display: block;
  }
  .progressbar-label-text {
    white-space: nowrap;
  }
  .progressbar-track {
    flex: 1;
    background: #d2d2d2;
    border-radius: 10px;
    height: 11px;
    overflow: visible;
    position: relative;
  }
  .progressbar-fill {
    background: #4caf50;
    height: 100%;
    width: 0%;
    border-radius: 10px;
    transition: width 0.5s;
  }
  .checkpoint {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 16px;
    background: #ffffff;
  }
  .donutchart-container {
    position: relative;
    width: 280px;
    height: 200px;
    margin: 0 auto;
  }
  .donut-middle-text {
    font-size: 12px;
    text-anchor: middle;
    fill: #333;
  }
  .segment-label {
    font-size: 10px;
    fill: #fff;
    text-anchor: middle;
    pointer-events: none;
  }
  .stats-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 16px;
    margin-bottom: 16px;
    gap: 12px;
  }
  .stats-box {
    /*flex: 1;
    background: #fafafa;
    border-radius: 4px;
    padding: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);*/
    font-size: 0.72rem;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1 1 208px;
    min-width: 0;
  }
  /* we want "subclass" ".value" with larger font*/
  .stats-box .value {
    font-size: 1.02rem;
    font-weight: 500;
  }
  .stats-item {
    font-size: 0.9rem;
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
  }
  .tasks-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
  }
  .task-section {
    /*margin-right: 30px;*/
    width:32%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .task-title {
    font-weight: 600;
    margin-bottom: 6px;
    min-height: 2.8em;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    text-wrap: balance;
  }
  .task-item {
    margin-right: 0;
    font-size: 0.76rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .task-icons {
    width: 100%;
    justify-content: center;
  }
  .copies-text {
    font-weight: 600;
    line-height: 1.4;
    text-align: right;
    letter-spacing: 0;
  }
  .copies-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    width: 100%;
  }
  .people-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 360px;
  }
  .copies-separator {
    line-height: 1;
    flex: 0 0 auto;
  }
  .bolts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 80px;
  }
  .section-title-vertical {
    writing-mode: vertical-rl; /* Rotate text vertically */
    transform: none;
    text-align: center;
    text-orientation: mixed;
    margin: 0 8px 0 0;
    padding: 0;
    min-width: 1.6em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  p {
    margin-top: 0;
    margin-bottom: 0.2rem;
    padding-right: 0;
    vertical-align: baseline;
    text-wrap: pretty;
  }

  /* Base layout */
  #mainWrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    height: 100vh;
    position: relative; /* Add this to all screen sizes */
  }
  #textContent {
    flex: 1;
    max-width: 980px;
    padding: 34px 40px 96px;
    box-sizing: border-box;
  }
  /* For screens >= 900px */
  #infographicWrapper {
    max-width: 500px;
    flex: 0 0 500px;
    padding: 0; /* Remove padding since it's handled by myInfographic */
    box-sizing: border-box;
    position: relative; /* Changed from sticky */
    height: 100vh;
    border-left: 1px solid rgba(42, 98, 61, 0.18);
    overflow-y: auto;
  }
  #infographicControl {
    position: absolute;
    top: 5px;
    right: 5px;
    display: none;
  }

/* For screens less than 900px */
  @media (max-width: 900px) {
    #mainWrapper {
      flex-direction: column;
      height: auto;
      position: relative; /* Add this */
    }
    #infographicWrapper {
      position: fixed; /* Change to fixed positioning */
      bottom: 0; /* Position at the bottom */
      left: 0;
      max-width: 100%;
      width: 100%;
      transition: transform 0.3s ease;
      height: 80vh; /* Set a defined height */
      background: #fffff8;
      box-shadow: 0 -2px 10px rgba(0,0,0,0.1); /* Add shadow for visibility */
      z-index: 100; /* Ensure it appears above other content */
    }
    #myInfographic {
      position: relative;
      padding: 18px 18px 30px;
    }
    #textContent {
      max-width: none;
      padding: 20px 18px 165px;
    }
    .task-title {
      min-height: 3.2em;
    }
    .people-group {
      max-width: calc(100% - 100px);
    }
    .bolts {
      flex-basis: 72px;
    }
    #infographicWrapper.mobile-folded {
      /* Show only 120px from the bottom */
      transform: translateY(calc(100% - 120px));
    }
    #infographicWrapper.expanded {
      /* Full screen infographic when unfolded */
      transform: translateY(0);
      top: 0;
      height: 100%;
    }
    #infographicControl {
      display: block;
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 101;
    }
    
    #toggleInfographic {
      padding: 10px;
      background: rgba(42, 98, 61, 0.8);
      color: white;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      font-size: 16px;
    }
  }

#textContent {
  font-size: 1.36rem;
  line-height: 2.08rem;
  letter-spacing: 0.01em;
  font-family: var(--font-serif-zh);
  .hero-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 8px;
  }
  .hero-top-row h1 {
    margin-bottom: 0;
    margin-right: 16px;
  }
  .hero-nav {
    display: flex;
    align-items: center;
    gap: 26px;
    margin-top: 6px;
    font-family: var(--font-ui-serif);
    font-size: 1.02rem;
    line-height: 1.2;
    white-space: nowrap;
  }
  .hero-nav-link {
    text-decoration: none;
  }
  .hero-nav-link:hover {
    text-decoration: underline;
  }
  .hero-nav-link.about {
    border: 1px solid rgba(0, 0, 0, 0.45);
    border-radius: 7px;
    padding: 4px 9px;
  }
  h1 {
    font-family: var(--font-ui-serif);
    font-weight: 700;
    letter-spacing: 0.02em;
    font-variant-ligatures: none;
  }
  .textItem {
    margin-bottom: 1.25rem;
  }
  p {
    margin-bottom: 0.62rem;
  }
  .textItem > p:last-child {
    margin-bottom: 0;
  }
  a {
    color: inherit;
    text-decoration: underline;
    text-decoration-skip-ink: auto;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 1.5px;
  }
  a:hover {
    text-decoration-thickness: from-font;
  }
}
@media (max-width: 900px) {
  #textContent .hero-top-row {
    display: block;
  }
  #textContent .hero-nav {
    display: none;
  }
}
#textContent .hero-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}
#textContent .hero-top-row h1 {
  margin-bottom: 0;
  margin-right: 16px;
  white-space: nowrap;
}
#textContent .hero-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-top: 6px;
  font-family: var(--font-ui-serif);
  font-size: 1.02rem;
  line-height: 1.2;
  white-space: nowrap;
}
#textContent .hero-nav-link {
  text-decoration: none;
}
#textContent .hero-nav-link:hover {
  text-decoration: underline;
}
#textContent .hero-nav-link.about {
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 7px;
  padding: 4px 9px;
}
/* Spoiler styles */
.spoiler {
  border: 1px solid var(--accent);
  border-radius: 8px;
  margin: 22px 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.spoiler-header {
  background-color: rgba(42, 98, 61, 0.05);
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--font-sans-zh);
  line-height: 1.45;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spoiler-header::after {
  content: "\f078"; /* Font Awesome chevron-down icon */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  transition: transform 0.3s;
}

.spoiler-content {
  max-height: 0;
  padding: 0 18px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.spoiler.active .spoiler-content {
  max-height: 250000px; /* Adjust based on your content needs */
  padding: 18px;
}

.spoiler.active .spoiler-header::after {
  transform: rotate(-180deg);
}

table {
  border: 1px solid var(--accent);
  font-size: 0.7rem;
}
table th {
  background-color:  #aaa;
}
table th, table td {
  border-bottom: 1px solid var(--accent);
}

.footnote-tooltip {
  position: absolute;
  /*background-color: #2a623d;*/
  border: 0px solid #ccc;
  color: #fff;
  padding: 10px;
  border-radius: 4px;
  width: 470px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  z-index: 1000;
  display: none;
  pointer-events: auto;
  font-size: 1.1rem;
  line-height: 1.4rem;
  a {
    color: inherit;
    text-decoration: underline;
    text-decoration-skip-ink: auto;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 1.5px;
  }
  a:hover {
    text-decoration-thickness: from-font;
  }
  .footnote-index-border {
    border: 1px solid rgb(255, 255, 255);
    border-radius: 15%;
    min-width: 2em;
    height: 1.7em;
    margin-right: 0.5em;
    font-size: 1.5rem;
    font-weight: 2;
    float: left;
    align-items: center;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
.footnote-tooltip.main {
  background-color: var(--accent)
}
.footnote-tooltip.slowdown {
  background-color: var(--slowdown-background);
}
.footnote-tooltip.race {
  background-color: #8b0000;
}
.footnote-tooltip.translater {
  background-color: #375b7a;
}
sup.main {
    color: var(--accent)
  }
sup.slowdown {
    color: var(--slowdown-background);
  }
sup.race {
    color: #8b0000;
  }
sup.translater {
    color: #375b7a;
  }

#slowdownButton {
  background-color: var(--slowdown-background);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  width: 45%;
}
#raceButton {
  background-color: #8b0000;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  width: 45%;
}


.spoiler-multi {
  border: none;
  border-radius: 0;
  margin: 16px 0 10px;
  overflow: visible;
  transition: none;
}
.spoiler-multi-content {
  display: none;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(42, 98, 61, 0.55);
  border-radius: 8px;
  background-color: rgba(42, 98, 61, 0.03);
  p {
    margin-bottom: 1rem;
  }
}
.spoiler-multi-content.active { display: block; }

.spoiler-multi-headers {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.spoiler-multi-header { 
  background-color: transparent;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 7px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--font-ui-serif);
  font-size: 1.02rem;
  line-height: 1.25;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
 }
.spoiler-multi-header.active {
  font-weight: 600;
  border-color: rgba(0, 0, 0, 0.8);
  background-color: rgba(0, 0, 0, 0.035);
}

@media (max-width: 900px) {
  #textContent .hero-top-row {
    display: block !important;
  }
  #textContent .hero-nav {
    display: none !important;
  }
}

#myInfographic,
.tooltip,
.progressbar-label,
.stats-box,
.task-title,
.task-item,
#slowdownButton,
#raceButton,
#toggleInfographic {
  font-family: var(--font-sans-zh);
}
