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

html { scroll-behavior: smooth; }

body {
  background: #e8e8e8;
  color: #333;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

#pi-wallpaper {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 200vh;
  z-index: 0;
  overflow: hidden;
  color: rgba(0,0,0,0.06);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.3;
  word-break: break-all;
  pointer-events: none;
  padding: 8px;
  transition: opacity 0.5s;
}

.site-title {
  text-align: center;
  padding: 30px 20px 24px;
  transition: opacity 0.5s;
  position: relative;
  z-index: 2;
}

.site-title.sticky {
  position: sticky;
  top: 0;
}

.sticky-wrapper {
  position: sticky;
  top: 20px;
  z-index: 1;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px 20px;
  box-sizing: border-box;
  transition: opacity 0.5s;
}

h1 {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 6px;
  margin: 0 0 6px;
  color: #000;
}

.pi-svg-title {
  display: inline-block;
  height: 0.75em;
  vertical-align: middle;
  margin-top: -0.1em;
}

.pi-svg-welcome {
  height: 160px;
}

.subtitle {
  font-size: 1.1rem;
  color: #999;
  margin-bottom: 0;
  letter-spacing: 3px;
}

.pi-svg-subtitle {
  display: inline-block;
  height: 0.9em;
  vertical-align: middle;
  margin-top: -0.1em;
}

.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  position: relative;
  text-align: center;
  overflow: hidden;
  width: 860px;
  max-width: calc(100vw - 40px);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#card-inner {
  width: 100%;
  padding: 28px 36px 40px;
  box-sizing: border-box;
}

.counter {
  font-size: 14px;
  color: #888;
  margin-bottom: 6px;
  letter-spacing: 1px;
  transition: opacity 0.4s;
}

.counter strong {
  color: #e65100;
  font-size: 18px;
}

#digits-display {
  width: 100%;
  max-width: 600px;
  height: 36px;
  overflow: hidden;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 18px;
  color: #ccc;
  margin: 0 auto 2px;
  text-align: center;
  word-break: break-all;
  transition: opacity 0.4s;
}

#digits-display .current {
  font-weight: bold;
  font-size: 20px;
}


.chart-row {
  position: relative;
}

.side-text {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 180px;
  text-align: left;
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  transition: opacity 0.4s;
}

.side-text p {
  margin-bottom: 10px;
}

.side-text strong {
  color: #e65100;
}

.side-text .side-hint {
  font-size: 9px;
  color: #bbb;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 16px;
}

#pie-chart {
  display: block;
  margin: -10px auto -6px;
}

.bottom-charts {
  display: flex;
  gap: 0;
  align-items: flex-start;
  justify-content: center;
  transition: opacity 0.4s;
}

#fun-facts {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
  overflow: hidden;
}

#digit-scroller {
  position: absolute;
  top: 0; left: 0; right: 0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 16px;
  line-height: 1.35;
  color: rgba(0,0,0,0.12);
  word-break: break-all;
  padding: 10px;
  will-change: transform;
}

#digit-scroller .hl {
  color: #e65100;
  font-weight: 900;
  font-size: 20px;
  background: rgba(230, 81, 0, 0.12);
  border-radius: 4px;
  padding: 2px 4px;
  letter-spacing: 2px;
}

#digit-scroller .near {
  color: rgba(0,0,0,0.4);
}

#fact-card {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  padding: 24px 36px;
  text-align: center;
  max-width: 520px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

#fact-card.centered {
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

#fact-card .fact-title {
  font-size: 24px;
  font-weight: 900;
  color: #222;
  margin-bottom: 8px;
}

#fact-card .fact-desc {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

#fact-card .fact-position {
  font-size: 11px;
  color: #aaa;
  margin-top: 10px;
  letter-spacing: 1px;
}

#fact-next:hover { opacity: 0.7; }

.scroll-spacer {
  height: 56000px;
  position: relative;
  z-index: 0;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

@keyframes glow-breathe {
  0%, 100% { filter: drop-shadow(0 0 1px var(--glow-color)); }
  50% { filter: drop-shadow(0 0 5px var(--glow-color)); }
}

@keyframes glow-breathe-line {
  0%, 100% { filter: drop-shadow(0 0 1px var(--glow-color)); stroke-width: 3.5px; }
  50% { filter: drop-shadow(0 0 5px var(--glow-color)); stroke-width: 4px; }
}

.svg-glow-pie {
  filter: url(#glow-filter);
}

.svg-glow-bar {
  animation: glow-breathe 3s ease-in-out infinite;
}

.svg-glow-line {
  animation: glow-breathe-line 3s ease-in-out infinite;
}

.svg-dimmed {
  opacity: 0.25 !important;
  transition: opacity 0.4s;
}


#line-chart path,
#bar-chart .bar,
#pie-chart path {
  transition: opacity 0.4s, stroke-width 0.4s, filter 0.4s;
  cursor: pointer;
}


#jump-caption {
  text-align: center;
  font-size: 17px;
  color: #333;
  line-height: 1.6;
  opacity: 0;
  transition: opacity 0.5s;
  height: 0;
  overflow: visible;
}

#jump-caption.active {
  padding: 10px 0;
}

#jump-caption .jump-label {
  font-size: 28px;
  font-weight: 900;
  color: #222;
  display: block;
  margin-bottom: 4px;
}

#jump-caption .jump-sub {
  font-size: 14px;
  color: #888;
}


#progress-bar {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: rgba(230,81,0,0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 12px;
  border: 1px solid rgba(230,81,0,0.12);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  opacity: 1;
  transition: opacity 0.3s;
  user-select: none;
  overflow: hidden;
}

#progress-bar .seg {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 6px 12px;
  transition: background 0.3s;
}

#progress-bar .seg span {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #999;
  text-transform: uppercase;
  transition: color 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

#progress-bar .seg.done span {
  color: #777;
}

#progress-bar .seg.active span {
  color: #222;
  font-weight: 700;
}

#progress-bar .seg:hover {
  background: rgba(230,81,0,0.08);
}

#progress-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  background: #e65100;
  border-radius: 2px;
  transition: height 0.15s linear;
  pointer-events: none;
}

.reset-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  background: rgba(255,255,255,0.85);
  color: #999;
  border: none;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s, color 0.2s, background 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.reset-btn:hover { background: rgba(255,255,255,1); color: #333; }

#welcome-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 90;
  border-radius: 16px;
  transition: opacity 0.5s;
  text-align: center;
  padding: 40px;
}

#welcome-overlay .welcome-pi {
  margin-bottom: 12px;
}

#welcome-overlay .welcome-text {
  font-size: 18px;
  color: #555;
  max-width: 340px;
  line-height: 1.6;
  margin-bottom: 20px;
}

#welcome-overlay .welcome-hint {
  font-size: 13px;
  color: #aaa;
  letter-spacing: 2px;
}

#welcome-overlay .welcome-arrow {
  font-size: 20px;
  color: #bbb;
  animation: bounce 1.5s infinite;
  margin-top: 8px;
}

.pi-search {
  max-width: 400px;
  width: 100%;
}

.pi-search-input-row {
  display: flex;
  gap: 8px;
}

.pi-search-input-row input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.pi-search-input-row input:focus {
  border-color: #e65100;
}

.pi-search-input-row button {
  padding: 12px 20px;
  background: #e65100;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.pi-search-input-row button:hover {
  background: #c44500;
}

.pi-search-result {
  margin-top: 14px;
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  min-height: 24px;
}

.pi-search-result .found-position {
  font-weight: 900;
  color: #e65100;
  font-size: 18px;
}

.pi-search-result .found-context {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  color: #999;
  margin-top: 6px;
  word-break: break-all;
}

.pi-search-result .found-context .hl {
  color: #e65100;
  font-weight: 700;
}

/* --- MOBILE --- */
@media (max-width: 600px) {
  h1 {
    font-size: 2rem;
    letter-spacing: 3px;
  }

  .subtitle {
    font-size: 0.85rem;
    letter-spacing: 2px;
    margin-bottom: 16px;
  }

  .site-title {
    padding: 10px 10px 10px;
  }

  .sticky-wrapper {
    padding: 10px;
  }

  .card {
    border-radius: 12px;
  }

  #card-inner {
    padding: 12px 8px 20px;
  }

  .side-text {
    position: fixed;
    left: 50%;
    top: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    max-width: calc(100vw - 40px);
    text-align: center;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    padding: 14px 20px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.1);
    z-index: 60;
  }

  .side-text:empty {
    display: none;
  }

  .side-text .side-hint {
    font-size: 10px;
    margin-top: 6px;
  }

  #pie-chart {
    margin: 0 auto;
  }

  .bottom-charts {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  #bar-chart {
    display: none;
  }

  .chart-row {
    overflow: visible;
  }

  #digits-display {
    font-size: 14px;
    line-height: 22px;
    height: 44px;
    overflow: hidden;
    max-width: 100%;
  }

  .counter { font-size: 16px; }
  .counter strong { font-size: 22px; }

  #jump-caption .jump-label {
    font-size: 22px;
  }

  #jump-caption .jump-sub {
    font-size: 13px;
  }

  #fact-card {
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
    padding: 18px 20px;
    bottom: 30px;
  }

  #fact-card.centered {
    top: 50%;
    left: 10px;
    right: 10px;
    transform: translateY(-50%);
  }

  #fact-card .fact-title { font-size: 19px; }
  #fact-card .fact-desc { font-size: 13px; }

  #progress-bar {
    display: none;
  }

  .reset-btn {
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
  }

  #welcome-overlay {
    padding: 24px;
  }

  .pi-svg-welcome { width: 100px; height: 100px; }
  #welcome-overlay .welcome-text { font-size: 15px; max-width: 280px; }

  #ending {
    padding: 24px 20px !important;
  }

  #ending > div:first-child { font-size: 60px !important; margin-bottom: 8px !important; }
  #ending #ending-title { font-size: 24px !important; margin-bottom: 12px !important; }
  #ending > div:nth-child(3) { font-size: 14px !important; max-width: 100% !important; }
  #ending > div:nth-child(5) { font-size: 10px !important; letter-spacing: 1px !important; word-break: break-all; max-width: 100%; }

  .pi-search { max-width: 100%; }
  .pi-search-input-row input { font-size: 16px; padding: 10px 12px; }
  .pi-search-input-row button { padding: 10px 16px; font-size: 13px; }

  .pi-search-result { font-size: 12px; }
  .pi-search-result .found-position { font-size: 14px; }
  .pi-search-result .found-context { font-size: 11px; }

  #digit-scroller {
    font-size: 13px;
  }

  #digit-scroller .hl {
    font-size: 16px;
  }
}
