.kcm-game {
  --kcm-bg: #f7f8fc;
  --kcm-card: #ffffff;
  --kcm-text: #263238;
  --kcm-sub: #68727d;
  --kcm-line: #dbe1e8;
  --kcm-accent: #5865f2;
  --kcm-accent-soft: #eef0ff;
  --kcm-good: #1f9d68;
  --kcm-bad: #e24d4d;
  max-width: 920px;
  margin: 24px auto;
  color: var(--kcm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

.kcm-game *, .kcm-game *::before, .kcm-game *::after { box-sizing: border-box; }

.kcm-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--kcm-line);
  border-radius: 24px;
  background: var(--kcm-card);
  box-shadow: 0 12px 38px rgba(30, 44, 75, 0.09);
}

.kcm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.kcm-eyebrow {
  margin: 0 0 3px;
  color: var(--kcm-accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.kcm-title { margin: 0; font-size: clamp(25px, 4vw, 38px); line-height: 1.2; }

.kcm-reset, .kcm-replay, .kcm-retry-wrong {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
}

.kcm-reset {
  flex: 0 0 auto;
  padding: 9px 14px;
  background: #f0f2f5;
  color: #4d5966;
  font-size: 13px;
}

.kcm-reset:hover, .kcm-replay:hover, .kcm-retry-wrong:hover { transform: translateY(-1px); }

.kcm-status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.kcm-stat {
  min-width: 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--kcm-bg);
  text-align: center;
}

.kcm-stat span { display: block; margin-bottom: 1px; color: var(--kcm-sub); font-size: 11px; font-weight: 700; }
.kcm-stat strong { font-size: 17px; }

.kcm-progress {
  height: 7px;
  overflow: hidden;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #edf0f4;
}

.kcm-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--kcm-accent);
  transition: width .28s ease;
}

/* 問題カードは「中央に収まる小さめの帯」にする */
.kcm-question-box {
  width: min(100%, 560px);
  margin: 0 auto 8px;
  padding: 10px 16px 11px;
  border-radius: 18px;
  background: var(--kcm-accent-soft);
  text-align: center;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 0 !important;
}

.kcm-question-label,
.kcm-instruction {
  display: block;
  margin: 0 !important;
  color: var(--kcm-sub);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.kcm-question {
  margin: 0 !important;
  color: var(--kcm-accent);
  font-size: clamp(24px, 4.2vw, 34px);
  font-weight: 900;
  line-height: 1.08;
}

.kcm-instruction {
  margin: 0 !important;
}

.kcm-feedback {
  min-height: 22px;
  margin: 4px 0 6px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
}

.kcm-feedback.is-good { color: var(--kcm-good); }
.kcm-feedback.is-bad { color: var(--kcm-bad); }

.kcm-map-wrap {
  position: relative;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 8px;
  border-radius: 20px;
  background: linear-gradient(180deg, #fafdff 0%, #f4f8fb 100%);
  touch-action: manipulation;
}

.kcm-map-wrap .geolonia-svg-map { display: block; width: 100%; height: auto; }

.kcm-map-wrap .prefecture {
  fill: #e8edf2 !important;
  stroke: #647381 !important;
  stroke-width: 1.4 !important;
  cursor: pointer;
  outline: none;
  transition: fill .15s ease, opacity .15s ease;
}

.kcm-map-wrap .prefecture:hover, .kcm-map-wrap .prefecture:focus { fill: #d7dcff !important; }
.kcm-map-wrap .prefecture.is-cleared { fill: #c8eadb !important; }
.kcm-map-wrap .prefecture.is-correct { fill: #4dc490 !important; }
.kcm-map-wrap .prefecture.is-wrong { fill: #f27b7b !important; }

.kcm-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(2px);
}
.kcm-overlay[hidden] { display: none; }

.kcm-overlay-panel {
  width: min(100%, 470px);
  padding: 18px 18px 16px;
  border: 2px solid #b8e8cd;
  border-radius: 24px;
  background: linear-gradient(180deg, #f6fff9 0%, #eff8ff 100%);
  box-shadow: 0 16px 34px rgba(30,44,75,.12);
  text-align: center;
}

.kcm-overlay-title { margin: 0 0 4px; color: var(--kcm-good); font-size: clamp(30px, 5vw, 46px); font-weight: 900; line-height: 1.05; }
.kcm-overlay-name { margin: 0; color: #1e3552; font-size: clamp(24px, 4.4vw, 36px); font-weight: 900; line-height: 1.15; }

.kcm-overlay-shape {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 142px;
  margin: 8px auto 4px;
}

.kcm-shape-svg { display: block; width: min(100%, 190px); height: 132px; overflow: visible; }
.kcm-shape-svg .kcm-shape-geometry path,
.kcm-shape-svg .kcm-shape-geometry polygon,
.kcm-shape-svg .kcm-shape-geometry rect,
.kcm-shape-svg .kcm-shape-geometry circle {
  fill: #4dc490 !important;
  stroke: #1f7b58 !important;
  stroke-width: 1.6 !important;
  vector-effect: non-scaling-stroke;
}




.kcm-answer-visuals {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}

.kcm-shape-card {
  width: min(100%, 260px);
  padding: 8px 10px 6px;
  border: 1px solid #dce5e1;
  border-radius: 14px;
  background: #fff;
}

.kcm-visual-label {
  margin-bottom: 5px;
  color: #5d6b7b;
  font-size: 11px;
  font-weight: 800;
}

.kcm-answer-visuals .kcm-overlay-shape {
  min-height: 150px;
  margin: 0;
}

.kcm-answer-visuals .kcm-shape-svg {
  width: min(100%, 180px);
  height: 150px;
}

.kcm-shape-note {
  margin-top: 2px;
  color: #8a5664;
  font-size: 11px;
  font-weight: 800;
}

.kcm-shape-marker text {
  fill: #d74646;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke fill;
  stroke: #ffffff;
  stroke-width: 1.6;
  stroke-linejoin: round;
}


.kcm-overlay-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  color: #4e5d71;
  font-size: 14px;
  font-weight: 800;
}

.kcm-spinner {
  width: 21px;
  height: 21px;
  border: 3px solid #d2daff;
  border-top-color: var(--kcm-accent);
  border-radius: 50%;
  animation: kcm-spin .8s linear infinite;
}

@keyframes kcm-spin { to { transform: rotate(360deg); } }

.kcm-wrong-panel {
  width: min(100%, 680px);
  margin: 12px auto 0;
  padding: 11px 13px;
  border: 1px solid #f2c4c4;
  border-radius: 14px;
  background: #fff7f7;
}
.kcm-wrong-panel[hidden] { display: none; }
.kcm-wrong-heading { margin-bottom: 7px; color: #a73f3f; font-size: 13px; font-weight: 800; }
.kcm-wrong-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kcm-wrong-chip { padding: 4px 9px; border-radius: 999px; background: #ffe2e2; color: #8f3535; font-size: 12px; font-weight: 800; }

.kcm-complete {
  width: min(100%, 760px);
  margin: 16px auto 0;
  padding: 18px 16px 16px;
  border: 2px solid #ffd76d;
  border-radius: 20px;
  background: #fffaf0;
  text-align: center;
}
.kcm-complete[hidden] { display: none; }
.kcm-complete-icon {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 6px;
}
.kcm-complete h3 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.2;
}
.kcm-complete p {
  margin: 0;
  line-height: 1.5;
}
.kcm-complete p[data-kcm-complete-message] {
  margin-bottom: 12px;
}
.kcm-result {
  margin: 0 0 10px;
  font-size: 16px;
}
.kcm-complete-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.kcm-replay, .kcm-retry-wrong { min-width: 230px; padding: 11px 18px; }
.kcm-replay { background: var(--kcm-accent); color: #fff; box-shadow: 0 7px 18px rgba(88,101,242,.24); }
.kcm-retry-wrong { background: #e55656; color: #fff; box-shadow: 0 7px 18px rgba(226,77,77,.2); }
.kcm-retry-wrong[hidden] { display: none; }

@media (max-width: 600px) {
  .kcm-game { margin: 12px auto; }
  .kcm-card { padding: 14px 11px 17px; border-radius: 18px; }
  .kcm-header { align-items: center; margin-bottom: 10px; }
  .kcm-reset { padding: 8px 11px; font-size: 12px; }
  .kcm-stat { padding: 7px 5px; }
  .kcm-stat strong { font-size: 15px; }
  .kcm-progress { margin-bottom: 8px; }
  .kcm-question-box { padding: 4px 8px 5px; border-radius: 10px; }
  .kcm-question-label, .kcm-instruction { font-size: 10px; }
  .kcm-question { font-size: 23px; }
  .kcm-feedback { min-height: 20px; margin: 3px 0 5px; font-size: 13px; }
  .kcm-map-wrap { padding: 2px; }
  .kcm-map-wrap .prefecture { stroke-width: 2 !important; }
  .kcm-overlay { padding: 9px; }
  .kcm-overlay-panel { padding: 15px 12px 13px; border-radius: 20px; }
  .kcm-answer-visuals { margin-top: 8px; }
  .kcm-shape-card { width: min(100%, 220px); padding: 7px 8px 5px; }
  .kcm-answer-visuals .kcm-overlay-shape { min-height: 105px; }
  .kcm-answer-visuals .kcm-shape-svg { height: 105px; }
  .kcm-overlay-shape { min-height: 118px; }
  .kcm-shape-svg { height: 108px; width: min(100%, 165px); }
  .kcm-wrong-panel { margin-top: 9px; padding: 9px 10px; }
  .kcm-complete {
    width: 100%;
    margin-top: 14px;
    padding: 16px 12px 14px;
    border-radius: 18px;
  }
  .kcm-complete-icon { font-size: 30px; margin-bottom: 4px; }
  .kcm-complete h3 { margin-bottom: 7px; font-size: 24px; }
  .kcm-complete p[data-kcm-complete-message] { margin-bottom: 10px; }
  .kcm-result { margin-bottom: 9px; font-size: 15px; }
  .kcm-complete-actions { gap: 8px; margin-top: 6px; }
  .kcm-replay, .kcm-retry-wrong { width: 100%; min-width: 0; padding: 11px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .kcm-game *, .kcm-game *::before, .kcm-game *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}


.kcm-overlay-sub {
  margin-top: 3px;
  color: #5d6b7b;
  font-size: 15px;
  font-weight: 800;
}
