:root {
  --ink: #101b35;
  --muted: #6d7380;
  --paper: #f4f2ec;
  --paper-bright: #fbfaf6;
  --rule: rgba(16, 27, 53, 0.18);
  --accent: #e65435;
  --blue: #1f5ba6;
  --cyan: #75b8d6;
  --shadow: 0 24px 70px rgba(16, 27, 53, 0.18);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(16, 27, 53, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 27, 53, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 4vw;
  color: #fff;
  background: rgba(16, 27, 53, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: #fff;
  text-decoration: none;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand strong { font-weight: 500; color: #9ecce0; }

.brand-mark {
  display: flex;
  align-items: end;
  gap: 2px;
  width: 27px;
  height: 27px;
  padding: 5px;
  background: var(--accent);
  border-radius: 5px;
}

.brand-mark i { display: block; width: 4px; background: #fff; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 11px; }

.header-meta { display: flex; align-items: center; gap: 20px; color: #cdd5e1; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 7px; }
.status i { width: 6px; height: 6px; background: #82d5b5; border-radius: 50%; box-shadow: 0 0 0 4px rgba(130, 213, 181, 0.12); }

main { overflow: hidden; }

.intro {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 46px 5vw 38px;
  border-bottom: 1px solid var(--rule);
}

.intro::after {
  content: "47";
  position: absolute;
  top: 16px;
  right: 4vw;
  z-index: -1;
  color: rgba(16, 27, 53, 0.045);
  font-family: "DM Mono", monospace;
  font-size: clamp(130px, 18vw, 260px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.12em;
}

.eyebrow { display: flex; gap: 14px; margin-bottom: 24px; font-family: "DM Mono", monospace; font-size: 11px; color: var(--blue); letter-spacing: .08em; }
.eyebrow span + span::before { content: "—"; margin-right: 14px; color: var(--muted); }

h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(34px, 4.6vw, 62px);
  line-height: 1.13;
  letter-spacing: -0.055em;
  font-weight: 800;
}

.lead { margin: 16px 0 0; color: var(--muted); font-size: 16px; line-height: 1.8; }

.map-section { max-width: 1440px; margin: 0 auto; padding: 28px 4vw 72px; }
.section-index { margin: 0 0 8px; color: var(--accent); font-family: "DM Mono", monospace; font-size: 11px; letter-spacing: .08em; }
.notes h2 { margin: 0; font-size: clamp(24px, 3vw, 38px); letter-spacing: -.04em; }

.map-meta { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.map-key { display: flex; align-items: center; gap: 7px; margin: 18px 1vw 0; color: var(--muted); font-size: 11px; }
.map-key i { width: 21px; height: 8px; border-radius: 1px; }
.key-low { background: #dbe8ef; }
.key-mid { background: #6fa7cb; }
.key-high { background: #1b4e8a; }

.map-frame {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 30px;
  background: #f7f7f7;
  border: 1px solid var(--ink);
  box-shadow: 12px 12px 0 rgba(16, 27, 53, 0.07);
}

.map-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(54, minmax(0, 1fr));
  grid-template-rows: repeat(22, minmax(0, 1fr));
  gap: 0;
  width: max(880px, 100%);
  max-width: none;
  aspect-ratio: 54 / 22;
  margin: 0 auto;
}

.prefecture-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  grid-column: var(--map-x) / span var(--map-w);
  grid-row: var(--map-y) / span var(--map-h);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 2px 5px 1px;
  color: var(--tile-ink, #10284a);
  background: var(--tile-bg, #e0ebef);
  border: 1px solid #d7d9de;
  border-bottom: 3px solid var(--tile-bg, #8fbed1);
  border-radius: 3px;
  text-align: center;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.prefecture-card:hover { z-index: 3; transform: translateY(-2px); filter: saturate(1.08) brightness(1.03); box-shadow: 0 7px 18px rgba(16, 27, 53, .16); }
.prefecture-card:focus-visible { z-index: 4; outline: 3px solid var(--accent); outline-offset: 2px; }
.prefecture-card[aria-expanded="true"] { z-index: 3; transform: translateY(-3px); box-shadow: 0 0 0 2px var(--ink), 0 9px 20px rgba(16, 27, 53, .2); }
.prefecture-name { font-size: 12px; font-weight: 800; line-height: 1.1; letter-spacing: -.03em; white-space: nowrap; }
.prefecture-company { display: block; width: 100%; overflow: hidden; margin-top: 1px; font-size: 10px; font-weight: 600; line-height: 1.1; white-space: nowrap; text-overflow: ellipsis; }
.prefecture-cap { display: none; }

.tap-note { margin: 20px 1vw 0; color: var(--muted); font-size: 12px; text-align: right; }

.notes { padding: 62px max(5vw, calc((100vw - 1296px) / 2)); color: #fff; background: var(--ink); }
.notes .section-index { color: #8dc4dc; }
.notes-grid { display: grid; grid-template-columns: .8fr 1.25fr .75fr; gap: 7vw; align-items: start; }
.notes h2 { color: #fff; }
.notes-grid p { margin: 0; color: #e3e8f0; font-size: 15px; line-height: 1.9; }
.notes-grid .fine-print { margin-top: 20px; color: #9ca8bb; font-size: 12px; line-height: 1.8; }
.source-block { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.source-block span { margin-bottom: 7px; color: #8491a6; font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .1em; }
.source-block a { width: fit-content; color: #fff; font-size: 13px; text-decoration-color: rgba(255,255,255,.35); text-underline-offset: 4px; }
.source-block a:hover { color: #9ed1e8; }

footer { display: flex; justify-content: space-between; gap: 24px; padding: 24px 5vw; color: #727b8c; background: #0a1327; font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .04em; }

.ranking-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(780px, calc(100dvh - 40px));
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1px solid var(--ink);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.ranking-dialog::backdrop { background: rgba(6, 13, 29, .58); backdrop-filter: blur(4px); }
.ranking-dialog[open] { animation: dialog-in .22s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }

.dialog-shell { padding: 28px 30px 30px; }
.dialog-handle { display: none; }
.dialog-header { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 22px; border-bottom: 1px solid var(--ink); }
.dialog-region { margin: 0 0 5px; color: var(--accent); font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .08em; }
.dialog-header h2 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.close-button { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; color: var(--ink); background: transparent; border: 1px solid var(--rule); border-radius: 50%; cursor: pointer; }
.close-button:hover { color: #fff; background: var(--ink); }
.close-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.close-button span { transform: translateY(-1px); font-size: 28px; font-weight: 300; }
.dialog-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 16px 0; color: var(--muted); border-bottom: 1px solid var(--rule); }
.dialog-summary p { margin: 0; font-size: 13px; }
.dialog-summary span { font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: .06em; }
.ranking-list { margin: 0; padding: 0; list-style: none; }
.rank-item { border-bottom: 1px solid var(--rule); }
.rank-link { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 18px 6px; text-decoration: none; }
.rank-link:hover { background: rgba(16, 27, 53, .035); }
.rank-link:hover .rank-company strong { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.rank-link:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.rank-number { align-self: start; padding-top: 2px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 13px; }
.rank-item:first-child .rank-number { color: var(--accent); }
.rank-company { min-width: 0; }
.rank-company strong { display: block; font-size: 16px; line-height: 1.4; }
.rank-company strong::after { content: "↗"; margin-left: 7px; color: var(--muted); font-size: .72em; font-weight: 500; }
.rank-company span { display: block; margin-top: 5px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.rank-value { text-align: right; }
.rank-value strong { display: block; font-family: "DM Mono", monospace; font-size: 16px; }
.rank-bar { width: 88px; height: 3px; margin-top: 8px; overflow: hidden; background: #dde1e5; }
.rank-bar i { display: block; width: var(--bar); height: 100%; background: var(--region-color); }
.dialog-note { margin: 18px 0 0; color: var(--muted); font-size: 11px; }
.empty-ranking { padding: 28px 0; color: var(--muted); font-size: 14px; line-height: 1.8; border-bottom: 1px solid var(--rule); }
.ranking-more {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  padding: 11px 16px;
  color: #fff;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 3px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.ranking-more:hover { color: var(--ink); background: transparent; }
.ranking-more:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ranking-more[hidden] { display: none; }

@media (max-width: 900px) {
  .intro { padding-top: 48px; }
  .map-frame { padding: 24px 20px; }
  .prefecture-company { font-size: 9px; }
  .notes-grid { grid-template-columns: 1fr 1.4fr; }
  .source-block { grid-column: 2; }
}

@media (max-width: 680px) {
  .site-header { min-height: 60px; padding: 0 18px; }
  .brand { font-size: 13px; }
  .brand-mark { width: 25px; height: 25px; }
  .header-meta { display: none; }
  .intro { padding: 28px 20px 26px; }
  .intro::after { top: 26px; right: 20px; font-size: 120px; }
  .eyebrow { margin-bottom: 16px; }
  h1 { font-size: clamp(29px, 8.5vw, 40px); line-height: 1.2; }
  .lead { margin-top: 17px; font-size: 14px; }
  .map-section { padding: 22px 12px 54px; }
  .map-frame {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px;
    box-shadow: 7px 7px 0 rgba(16, 27, 53, .07);
    overscroll-behavior-x: contain;
    scrollbar-color: #8d96a5 #e4e2dc;
    scrollbar-width: thin;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }
  .map-frame::before, .map-frame::after { display: none; }
  .map-frame:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
  .map-frame::-webkit-scrollbar { height: 8px; }
  .map-frame::-webkit-scrollbar-track { background: #e4e2dc; }
  .map-frame::-webkit-scrollbar-thumb { background: #8d96a5; border-radius: 8px; }
  .map-grid {
    margin: 0;
  }
  .prefecture-card {
    justify-content: center;
    gap: 1px;
    grid-column: var(--map-x) / span var(--map-w);
    grid-row: var(--map-y) / span var(--map-h);
    min-height: 0;
    overflow: hidden;
    padding: 2px 4px 1px;
    border-bottom-width: 3px;
    border-radius: 3px;
    box-shadow: none;
    text-align: center;
    touch-action: manipulation;
  }
  .prefecture-card:hover { transform: none; filter: none; box-shadow: none; }
  .prefecture-card:active { transform: scale(.96); }
  .prefecture-card[aria-expanded="true"] { transform: none; box-shadow: inset 0 0 0 2px var(--ink); }
  .prefecture-name {
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
  }
  .prefecture-company {
    display: block;
    width: 100%;
    overflow: hidden;
    margin-top: 1px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .prefecture-cap { display: none; }
  .map-meta { flex-direction: column; align-items: flex-start; gap: 8px; }
  .map-key { margin: 16px 4px 0; }
  .tap-note { margin: 0 4px; text-align: left; }
  .notes { padding: 48px 20px; }
  .notes-grid { grid-template-columns: 1fr; gap: 26px; }
  .source-block { grid-column: auto; }
  footer { flex-direction: column; gap: 7px; padding: 22px 20px; }
  .ranking-dialog {
    width: 100%;
    max-width: none;
    max-height: 86dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
  }
  .ranking-dialog[open] { animation: sheet-in .28s cubic-bezier(.2,.8,.2,1); }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(100%); } }
  .dialog-shell { padding: 10px 20px 26px; }
  .dialog-handle { display: block; width: 42px; height: 4px; margin: 0 auto 13px; background: #c9cbd0; border-radius: 4px; }
  .dialog-header { padding-bottom: 17px; }
  .dialog-header h2 { font-size: 24px; }
  .rank-link { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 8px; padding: 16px 4px; }
  .rank-company strong { font-size: 14px; }
  .rank-value strong { font-size: 14px; }
  .rank-bar { width: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
