:root {
  color-scheme: light;
  --ink: #1c2530;
  --muted: #5e6b76;
  --paper: #f7f3e8;
  --panel: #ffffff;
  --line: #cfd8df;
  --blue: #2468a2;
  --blue-deep: #113f67;
  --green: #4f9d69;
  --orange: #e17b3f;
  --red: #c94747;
  --yellow: #f0c84b;
  --shadow: 0 18px 48px rgba(24, 43, 58, 0.14);
  font-family:
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    Meiryo,
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(36, 104, 162, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 104, 162, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 6px 18px rgba(27, 50, 70, 0.08);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-deep);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.2vw, 2.3rem);
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar__badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 2px solid var(--blue);
  border-radius: 6px;
  color: var(--blue-deep);
  font-size: 0.9rem;
  font-weight: 800;
  background: #f4fbff;
}

.action-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.85fr) minmax(0, 0.7fr) minmax(0, 0.85fr);
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 22px rgba(27, 50, 70, 0.1);
}

.comment-block.comment-block--featured {
  margin-top: 12px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(27, 50, 70, 0.12);
}

.featured-comment-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: stretch;
}

.judge-copy-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.comment-block.comment-block--featured p {
  font-size: clamp(1rem, 1.25vw, 1.18rem);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  margin-top: 20px;
}

.map-panel,
.metrics-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map-panel {
  position: relative;
  overflow: hidden;
  min-height: 620px;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #9fb0bf;
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 4px 10px rgba(26, 43, 58, 0.1);
  cursor: pointer;
}

.tool-button--large {
  min-height: 62px;
  padding: 14px 18px;
  font-size: 1.08rem;
  font-weight: 900;
}

.tool-button span:first-child {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--blue);
  font-weight: 800;
  line-height: 1;
}

.tool-button--large span:first-child {
  width: 30px;
  height: 30px;
}

.tool-button--primary {
  color: #ffffff;
  border-color: var(--blue-deep);
  background: var(--blue);
}

.tool-button--primary span:first-child {
  color: var(--blue-deep);
  background: #ffffff;
}

.tool-button:focus-visible,
.control-point:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.map-svg {
  display: block;
  width: 100%;
  height: min(78vh, 860px);
  min-height: 620px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.prefecture-path {
  vector-effect: non-scaling-stroke;
}

.prefecture-path--original {
  fill: rgba(40, 91, 127, 0.05);
  stroke: rgba(17, 63, 103, 0.58);
  stroke-width: 2;
  stroke-dasharray: 8 8;
}

.prefecture-path--current {
  fill: rgba(98, 169, 117, 0.56);
  stroke: var(--blue-deep);
  stroke-width: 3;
}

.city-marker {
  vector-effect: non-scaling-stroke;
  fill: var(--red);
  stroke: #ffffff;
  stroke-width: 2;
}

.city-label {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.94);
  stroke-width: 4px;
  filter: url("#labelShadow");
  pointer-events: none;
}

.control-group {
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.control-point {
  vector-effect: non-scaling-stroke;
  fill: #ffffff;
  stroke: var(--orange);
  stroke-width: 4;
  cursor: grab;
  touch-action: none;
}

.control-point.is-active {
  fill: var(--yellow);
  cursor: grabbing;
}

.control-halo {
  fill: rgba(225, 123, 63, 0.18);
  stroke: transparent;
  stroke-width: 18;
  cursor: grab;
  touch-action: none;
}

.metrics-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.panel-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.meter-block,
.distance-block,
.development-block,
.comment-block,
.source-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.risk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.risk-header strong {
  color: var(--blue-deep);
  font-size: 1.8rem;
  line-height: 1;
}

.risk-meter {
  height: 12px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebef;
}

.risk-meter span {
  display: block;
  width: 12%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition:
    width 160ms ease,
    background-color 160ms ease;
}

.distance-list {
  display: grid;
  gap: 9px;
}

.distance-row,
.development-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid #e3e8ed;
}

.distance-row:last-child,
.development-row:last-child {
  border-bottom: 0;
}

.distance-row span,
.development-row span {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

.distance-row strong,
.development-row strong {
  font-size: 0.95rem;
  white-space: nowrap;
}

.distance-row strong.is-plus,
.development-row strong.is-plus {
  color: var(--red);
}

.distance-row strong.is-minus,
.development-row strong.is-minus {
  color: var(--green);
}

.development-row strong.is-growth {
  color: var(--green);
}

.development-row strong.is-decline {
  color: var(--red);
}

.city-development-list {
  display: grid;
  gap: 4px;
}

.development-row em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 700;
}

.comment-block {
  border-color: #e7c879;
  background: #fff9e3;
}

.comment-block.is-pending {
  border-color: var(--line);
  background: #f8fafc;
}

.governor-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px;
  border: 1px solid rgba(225, 123, 63, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.governor-card img {
  width: 92px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(26, 43, 58, 0.18);
}

.governor-card strong {
  display: block;
  font-size: 1rem;
}

.governor-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.comment-block p,
.source-block p {
  margin: 0;
  line-height: 1.7;
}

.comment-block p {
  font-size: 1rem;
  font-weight: 800;
}

.comment-block p.is-placeholder {
  color: var(--muted);
  font-weight: 700;
}

.source-block {
  background: #f6f8fa;
}

.source-block p {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---- 称号・共有 ---- */

.title-row[hidden],
.emergency-banner[hidden] {
  display: none;
}

.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid #e7c879;
  border-radius: 8px;
  background: var(--blue-deep);
  animation: titlePop 360ms cubic-bezier(0.2, 1.6, 0.4, 1);
}

.title-badge {
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--blue-deep);
  background: var(--yellow);
  font-size: 0.76rem;
  font-weight: 900;
}

.title-row strong {
  flex: 1 1 auto;
  color: #ffffff;
  font-size: 1.14rem;
  letter-spacing: 0.02em;
}

.tool-button--share {
  color: #ffffff;
  border-color: #000000;
  background: #0f1419;
}

.tool-button--share span:first-child {
  color: #0f1419;
  background: #ffffff;
}

.tool-button--share:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 20, 25, 0.35);
}

@keyframes titlePop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- 知事の表情差分 ---- */

.governor-portrait {
  position: relative;
  width: 92px;
}

.governor-mood-emoji {
  position: absolute;
  right: -8px;
  bottom: -8px;
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 3px rgba(26, 43, 58, 0.35));
  pointer-events: none;
}

.governor-mood-label {
  color: var(--blue-deep) !important;
  font-weight: 800 !important;
}

.governor-card[data-mood="uneasy"] img {
  animation: govSway 900ms ease-in-out 2;
}

.governor-card[data-mood="worried"] img {
  animation: govShake 420ms ease-in-out 3;
  filter: saturate(0.9);
}

.governor-card[data-mood="worried"] .governor-mood-label {
  color: var(--orange) !important;
}

.governor-card[data-mood="emergency"] {
  border-color: var(--red);
  background: #fff2f2;
}

.governor-card[data-mood="emergency"] img {
  animation: govShake 280ms ease-in-out 5;
  filter: saturate(1.15) contrast(1.05);
}

.governor-card[data-mood="emergency"] .governor-mood-label {
  color: var(--red) !important;
}

@keyframes govSway {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-2deg);
  }
  75% {
    transform: rotate(2deg);
  }
}

@keyframes govShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px) rotate(-1.5deg);
  }
  75% {
    transform: translateX(3px) rotate(1.5deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .governor-card img,
  .title-row {
    animation: none !important;
  }
}

/* ---- 緊急会見バナー ---- */

.emergency-banner {
  margin-bottom: 12px;
  padding: 9px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: repeating-linear-gradient(45deg, #c94747, #c94747 16px, #a83232 16px, #a83232 32px);
  font-size: 0.94rem;
  font-weight: 900;
  text-align: center;
  animation: bannerPulse 1.4s ease-in-out infinite;
}

@keyframes bannerPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.78;
  }
}

@media (prefers-reduced-motion: reduce) {
  .emergency-banner {
    animation: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .action-bar {
    grid-template-columns: 1fr 1fr;
  }

  .featured-comment-layout {
    grid-template-columns: 220px 1fr;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: auto;
  }

  .map-svg {
    height: min(72vh, 720px);
    min-height: 520px;
  }

  .metrics-panel {
    padding: 14px;
  }
}

@media (max-width: 540px) {
  .topbar {
    padding: 14px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .action-bar {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .featured-comment-layout {
    grid-template-columns: 1fr;
  }

  .tool-button {
    flex: 1 1 128px;
    justify-content: center;
    padding: 8px 10px;
  }

  .tool-button--large {
    min-height: 58px;
    padding: 12px 14px;
  }

  .map-svg {
    min-height: 470px;
  }

  .governor-card {
    grid-template-columns: 72px 1fr;
  }

  .governor-card img,
  .governor-portrait {
    width: 72px;
  }

  .title-row strong {
    font-size: 1rem;
  }
}
