:root {
  --bg: #FBF9F4;
  --fg: #2A2620;
  --muted: #6B655A;
  --border: #E7E1D4;
  --warn-bg: #FCEEDD;
  --warn-fg: #7A4B14;
  --error-bg: #FBEAEA;
  --error-fg: #8A2C2C;
  --accent: #2F6B59;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  width: 100%;
  overflow-x: hidden;
}

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.header {
  text-align: center;
  margin-bottom: 16px;
}

.header h1 {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  margin: 0 0 4px;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.banner {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 16px;
}

.banner--warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.state-message {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.state-message--error {
  color: var(--error-fg);
  background: var(--error-bg);
  border-radius: 12px;
  padding: 24px 16px;
}

.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.chart-area {
  width: 100%;
  display: flex;
  justify-content: center;
}

.chart-canvas-wrap {
  position: relative;
  width: min(320px, 80vw);
  aspect-ratio: 1 / 1;
}

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

.chart-center-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
}

.legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 8px;
  flex-shrink: 0;
}

.legend .legend-name {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.legend .legend-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.legend .legend-change {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 6px;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  margin: 0;
}

.disclaimer {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  width: 100%;
}

@media (min-width: 640px) {
  .content {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
  }

  .chart-area {
    width: auto;
    flex: 0 0 auto;
  }

  .legend {
    flex: 1 1 280px;
  }

  .meta,
  .disclaimer {
    flex-basis: 100%;
  }
}
