html:has(.jda-root),
body:has(.jda-root) {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body:has(.jda-root) {
  overflow: hidden;
}

.jda-root {
  --main: #12345b;
  --main-2: #245f9d;
  --accent: #e4b91f;
  --text: #17304f;
  --muted: #6a7a8d;
  --border: #e4e9ef;
  --surface: #fff;
  --font: system-ui, -apple-system, "Segoe UI",
    "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;

  position: relative;
  display: flex;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  background: #f6f8fb;
  color: var(--text);
  font-family: var(--font);
}

body.admin-bar .jda-root {
  height: calc(100dvh - 32px);
}

.jda-root,
.jda-root * {
  box-sizing: border-box;
}

.jda-root [hidden] {
  display: none !important;
}

.jda-main-header {
  display: grid;
  grid-template-columns:
    auto 122px minmax(145px,.8fr) minmax(170px,1fr) minmax(180px,1fr);
  align-items: center;
  gap: 8px;
  height: 54px;
  min-height: 54px;
  flex: 0 0 54px;
  padding: 6px 12px;
  background: linear-gradient(90deg, #102e53, #173d69);
  color: #fff;
}

.jda-brand {
  white-space: nowrap;
  font-size: 18px;
  font-weight: 900;
}

.jda-header-field {
  min-width: 0;
}

.jda-header-field select {
  width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 4px 30px 4px 12px;
  border: 0;
  border-radius: 9px;
  background: #fff;
  color: #132b48;
  font-size: 15px;
  font-weight: 800;
}

.jda-main-header .screen-reader-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
}

.jda-stage {
  position: relative;
  display: grid;
  width: 100%;
  height: auto;
  min-height: 0;
  flex: 1 1 0%;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.jda-stage.is-single {
  grid-template-columns: 1fr;
}

.jda-stage.is-dual {
  grid-template-columns: 1fr 1fr;
}

.jda-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(18,52,91,.1);
}

.jda-pane.is-active {
  border-color: var(--accent);
}

.jda-pane-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.jda-fixed-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 70;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.jda-side-arrow {
  position: absolute;
  top: 52%;
  z-index: 60;
  display: grid;
  width: 54px;
  height: 112px;
  place-items: center;
  border: 0;
  background: rgba(255,255,255,.66);
  color: var(--main);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  font-size: 44px;
  cursor: pointer;
  transform: translateY(-50%);
}

.jda-side-arrow-left {
  left: 0;
  border-radius: 0 18px 18px 0;
}

.jda-side-arrow-right {
  right: 0;
  border-radius: 18px 0 0 18px;
}

.jda-float-menu {
  position: absolute;
  right: 18px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.jda-float-menu button {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.96);
  color: var(--main);
  box-shadow: 0 5px 16px rgba(0,0,0,.2);
  font-size: 20px;
  cursor: pointer;
}

.jda-float-menu button.is-active {
  background: var(--main);
  color: #fff;
}

.jda-float-menu button[data-jda-pin],
.jda-float-menu button[data-jda-open-settings],
.jda-float-menu button[data-jda-open-graph-settings] {
  background: var(--accent);
  color: #21334a;
}

.jda-float-menu button[data-jda-pin].is-active {
  background: var(--main);
  color: #fff;
}

.jda-message {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

@media screen and (max-width: 782px) {
  body.admin-bar .jda-root {
    height: calc(100dvh - 46px);
  }
}

@media (max-width: 820px) {
  .jda-stage.is-dual {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .jda-main-header {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .jda-header-field {
    flex: 0 0 145px;
  }

  .jda-year-field {
    flex-basis: 105px;
  }
}

/* 地図 */
.jda-map-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 12px 70px 74px;
}

.jda-map-stage {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
}

.jda-normal-map {
  width: min(100%, 760px);
  max-height: 100%;
}

.jda-map-path {
  stroke: #fff;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.jda-block-map {
  display: grid;
  grid-template-columns: repeat(35, 21px);
  grid-template-rows: repeat(23, 21px);
  gap: 2px;
  width: max-content;
}

.jda-block-pref {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.14);
  border-radius: 3px;
  font-size: 8px;
  cursor: pointer;
}

.jda-map-legend {
  position: absolute;
  left: 50%;
  bottom: 72px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  transform: translateX(-50%);
}

.jda-map-legend i {
  width: 26px;
  height: 10px;
  border-radius: 3px;
}

/* ランキング */
.jda-ranking-wrap {
  display: grid;
  width: min(900px, 84%);
  height: 100%;
  grid-template-rows: auto 1fr;
  gap: 14px;
  align-content: center;
  margin: 0 auto;
  padding: 26px 0 82px;
}

.jda-ranking-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: end;
}

.jda-podium-card {
  display: grid;
  min-height: 132px;
  place-content: center;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: #fff;
  text-align: center;
  box-shadow: 0 6px 18px rgba(18,52,91,.1);
}

.jda-podium-card.is-first {
  min-height: 154px;
  border-color: #d5ae24;
  background: #fffdf4;
}

.jda-podium-medal {
  font-size: 28px;
}

.jda-podium-pref {
  margin-top: 7px;
  color: var(--main);
  font-size: 20px;
  font-weight: 900;
}

.jda-podium-value {
  margin-top: 7px;
  font-weight: 900;
}

.jda-ranking-rest {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.jda-ranking-rest li {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 45px;
  padding: 8px 12px;
  border-radius: 11px;
  background: #f6f8fb;
}

.jda-ranking-rest .rank,
.jda-ranking-rest .value {
  font-weight: 900;
}

/* グラフ共通 */
.jda-graph-wrap {
  width: 100%;
  height: 100%;
  padding: 24px 70px 82px;
}

/* 棒グラフ */
.jda-bars {
  display: grid;
  width: min(920px, 84%);
  height: 100%;
  align-content: center;
  gap: 9px;
  margin: 0 auto;
}

.jda-bar {
  display: grid;
  grid-template-columns: 32px 92px minmax(0,1fr) 120px;
  align-items: center;
  gap: 9px;
}

.jda-bar-rank {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #e7edf5;
  color: var(--main);
  font-weight: 900;
}

.jda-bar.is-top .jda-bar-rank {
  background: var(--main);
  color: #fff;
}

.jda-bar-pref {
  font-weight: 800;
}

.jda-bar-track {
  height: 28px;
  overflow: hidden;
  border-radius: 8px;
  background: #edf2f7;
}

.jda-bar-track i {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #2d6cb0, #12345b);
}

.jda-bar strong {
  text-align: right;
}

/* 円・ドーナツ */
.jda-pie-layout {
  display: grid;
  width: min(1320px, 96%);
  height: 100%;
  grid-template-columns: minmax(430px, 1.25fr) minmax(390px, .9fr);
  align-items: center;
  gap: 34px;
  margin: 0 auto;
}

.jda-pie-shell {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
}

.jda-pie {
  position: relative;
  width: min(64vh, 650px);
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.jda-pie::after {
  position: absolute;
  inset: 31%;
  z-index: 2;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.jda-donut-center {
  position: absolute;
  inset: 33%;
  z-index: 4;
  display: grid;
  place-content: center;
  text-align: center;
}

.jda-donut-center span,
.jda-donut-center small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.jda-donut-center strong {
  margin: 4px 0;
  color: var(--main);
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 900;
}

.jda-slice-label {
  position: absolute;
  z-index: 5;
  width: 120px;
  text-align: center;
  color: #fff;
  font-size: clamp(11px, 1.2vw, 17px);
  font-weight: 900;
  line-height: 1.25;
  text-shadow: 0 1px 4px rgba(0,0,0,.42);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.jda-slice-label.is-light {
  color: var(--main);
  text-shadow: 0 1px 2px rgba(255,255,255,.8);
}

.jda-slice-label small {
  display: block;
  margin-top: 2px;
  font-size: .78em;
}

.jda-pie-legend {
  display: grid;
  gap: 9px;
}

.jda-pie-row {
  display: grid;
  grid-template-columns: 20px 52px 1fr auto auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin: 0;
  padding: 9px 14px;
  border-radius: 12px;
  background: #f6f8fb;
}

.jda-pie-row i {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.jda-pie-row .rank,
.jda-pie-row .value,
.jda-pie-row strong {
  font-weight: 900;
}

/* 詳細カード */
.jda-pref-card {
  position: absolute;
  top: 70px;
  right: 20px;
  z-index: 80;
  width: 250px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 12px 28px rgba(0,0,0,.22);
}

.jda-pref-card-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: 0;
  background: transparent;
  font-size: 20px;
}


/* モーダル */
.jda-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15,23,42,.56);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.jda-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.jda-modal {
  width: min(520px, 94vw);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}

.jda-modal h3 {
  margin: 0 0 16px;
  color: var(--main);
}

.jda-form-grid {
  display: grid;
  gap: 14px;
}

.jda-form-grid fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.jda-form-grid legend {
  color: var(--main);
  font-weight: 900;
}

.jda-choice-grid {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 8px;
}

.jda-choice-grid-three {
  grid-template-columns: repeat(3,1fr);
}

.jda-choice-grid input {
  position: absolute;
  opacity: 0;
}

.jda-choice-grid span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid #c8d1db;
  border-radius: 10px;
  background: #f8fafc;
  font-weight: 800;
}

.jda-choice-grid input:checked + span {
  border-color: var(--main);
  background: var(--main);
  color: #fff;
}

.jda-choice-grid label.is-disabled {
  opacity: .42;
}

.jda-period-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.jda-period-grid select {
  min-height: 40px;
  border: 1px solid #c8d1db;
  border-radius: 8px;
  background: #fff;
}

.jda-period-field p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.jda-info-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
}

.jda-info-grid > div {
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
}

.jda-info-grid span,
.jda-info-grid strong {
  display: block;
}

.jda-info-grid span {
  color: var(--muted);
  font-size: 11px;
}

.jda-modal-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 16px;
}

.jda-modal-actions button {
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  font-weight: 900;
}

.jda-apply {
  background: var(--accent);
}

.jda-close {
  background: #edf2f7;
  color: var(--main);
}

@media (max-width: 980px) {
  .jda-main-header {
    grid-template-columns: auto 105px 125px minmax(140px,1fr) minmax(150px,1fr) auto;
  }

  .jda-brand {
    font-size: 15px;
  }

  .jda-pie-layout {
    grid-template-columns: minmax(350px,1fr) minmax(320px,.9fr);
    gap: 18px;
  }

  .jda-pie {
    width: min(54vh, 520px);
  }
}

@media (max-width: 760px) {
  .jda-main-header {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .jda-brand {
    flex: 0 0 auto;
  }

  .jda-header-field {
    flex: 0 0 auto;
    width: 145px;
  }

  .jda-year-field {
    width: 105px;
  }

  .jda-stage {
    padding: 7px;
  }

  .jda-bottom-tabs {
    width: calc(100% - 120px);
    gap: 5px;
  }

  .jda-bottom-tabs button {
    min-height: 46px;
    padding: 5px 7px;
  }

  .jda-pie-layout {
    grid-template-columns: 1fr;
    gap: 8px;
    overflow: hidden;
  }

  .jda-pie {
    width: min(44vh, 380px);
  }

  .jda-pie-legend {
    grid-template-columns: repeat(2,1fr);
  }

  .jda-pie-row {
    grid-template-columns: 15px 1fr auto;
    min-height: 38px;
    font-size: 11px;
  }

  .jda-pie-row .rank,
  .jda-pie-row .value {
    display: none;
  }

  .jda-slice-label {
    width: 78px;
    font-size: 10px;
  }
}
