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

:root {
  --color-bg-light: #f8fafc;
  --color-bg-accent: #e3f2ff;
  --color-text-main: #123;
  --color-text-subtle: #456;
  --color-border-soft: #c5d7f2;
  --color-primary: #4f69e7;
  --color-primary-strong: #2c6bff;
  --color-card-bg: rgba(255, 255, 255, 0.82);
  --color-panel-bg: rgba(255, 255, 255, 0.78);
  --color-highlight-fill: rgba(79, 105, 231, 0.45);
  --color-highlight-hover: rgba(79, 105, 231, 0.35);
  --shadow-soft: 0 0.4rem 1.2rem rgba(15, 52, 96, 0.06);
  --shadow-strong: 0 0.85rem 2rem rgba(18, 50, 100, 0.1);
  --shadow-drop: 0 1rem 2rem rgba(17, 35, 68, 0.14);
  --shadow-tooltip: 0 0.75rem 1.5rem rgba(10, 31, 61, 0.2);
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--color-text-main);
  background: linear-gradient(160deg, var(--color-bg-light) 0%, var(--color-bg-accent) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  padding: 1.5rem clamp(1.5rem, 2vw, 3rem);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-soft);
}

.top-bar h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 700;
}

.tagline {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--color-text-subtle);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr);
  gap: clamp(1rem, 2vw, 2rem);
  padding: clamp(1rem, 2vw, 2rem);
  flex: 1;
}

.body-panel {
  background: var(--color-card-bg);
  border-radius: 1.5rem;
  padding: clamp(1rem, 1.8vw, 1.25rem);
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
}

.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.control {
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid #b5c9ea;
  font: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 0.4rem 1rem rgba(12, 38, 78, 0.06);
}

.btn-outline {
  border: 1px solid rgba(79, 105, 231, 0.6);
  background: rgba(79, 105, 231, 0.08);
  color: var(--color-primary-strong);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(79, 105, 231, 0.4);
  background: rgba(79, 105, 231, 0.1);
  color: var(--color-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover:not(:disabled),
.btn:focus-visible:not(:disabled) {
  background: rgba(79, 105, 231, 0.18);
  box-shadow: 0 0.75rem 1.5rem rgba(79, 105, 231, 0.22);
  outline: none;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-outline {
  border: 1px solid rgba(79, 105, 231, 0.65);
  background: rgba(79, 105, 231, 0.05);
  color: var(--color-primary-strong);
}

.btn-outline:hover:not(:disabled),
.btn-outline:focus-visible:not(:disabled) {
  background: rgba(79, 105, 231, 0.12);
  box-shadow: 0 0.65rem 1.25rem rgba(79, 105, 231, 0.18);
}

.body-view {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 480px;
}

.body-map {
  display: block;
  width: min(100%, 360px);
  max-height: min(620px, 80vh);
  height: auto;
  filter: drop-shadow(var(--shadow-drop));
}

.region-layer {
  pointer-events: none;
}

.region-shape {
  pointer-events: auto;
  fill: rgba(79, 105, 231, 0);
  stroke: rgba(79, 105, 231, 0);
  stroke-width: 2;
  cursor: pointer;
  transition: fill 0.2s ease, stroke 0.2s ease, transform 0.2s ease,
    filter 0.25s ease;
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 0 0 rgba(137, 175, 255, 0));
}

.region-shape:hover {
  fill: var(--color-highlight-hover);
  stroke: rgba(79, 105, 231, 0.4);
  filter: drop-shadow(0 0 12px rgba(137, 175, 255, 0.45));
}

.region-shape.highlighted {
  fill: var(--color-highlight-fill);
  stroke: rgba(79, 105, 231, 0.6);
  transform: scale(1.03);
}

.region-shape:focus-visible {
  outline: none;
  stroke: rgba(44, 107, 255, 0.8);
  stroke-width: 3;
  fill: rgba(79, 105, 231, 0.28);
  filter: drop-shadow(0 0 12px rgba(137, 175, 255, 0.45));
}

.tooltip {
  position: fixed;
  padding: 0.4rem 0.6rem;
  background: #203659;
  color: #fff;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  pointer-events: none;
  box-shadow: var(--shadow-tooltip);
  z-index: 1000;
}

.info-panel {
  background: var(--color-panel-bg);
  border-radius: 1.5rem;
  padding: clamp(1rem, 1.8vw, 1.25rem);
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.cell-summary h2 {
  margin: 0 0 0.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.cell-summary p {
  margin: 0 0 0.65rem;
  line-height: 1.6;
}

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1rem;
}

.cell-figure {
  margin: 0;
  background: rgba(76, 112, 239, 0.08);
  border: 1px solid rgba(76, 112, 239, 0.18);
  border-radius: 1rem;
  padding: 0.75rem;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 0.5rem;
  position: relative;
}

.cell-figure__media {
  position: relative;
  overflow: hidden;
  border-radius: 0.75rem;
}

.cell-figure picture {
  display: block;
}

.cell-figure img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 260px;
  margin: 0 auto;
  border-radius: 0.75rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition: opacity 0.2s ease;
}

.cell-figure__skeleton {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    100deg,
    rgba(137, 175, 255, 0.18) 0%,
    rgba(137, 175, 255, 0.36) 20%,
    rgba(137, 175, 255, 0.18) 40%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  pointer-events: none;
  display: none;
}

.cell-figure.is-loading img {
  opacity: 0;
}

.cell-figure.is-loading .cell-figure__skeleton {
  display: block;
}

.region-list h3,
.study-tips h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: #1f3a60;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.regions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.regions li {
  background: rgba(76, 112, 239, 0.08);
  border: 1px solid rgba(76, 112, 239, 0.15);
  border-radius: 0.9rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.regions li h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #1d2f53;
}

.regions-item:focus-visible {
  outline: none;
  border-color: rgba(79, 105, 231, 0.35);
  box-shadow: 0 0 0 3px rgba(79, 105, 231, 0.2);
  transform: translateY(-1px);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 24, 48, 0.6);
  display: grid;
  place-items: center;
  padding: 2rem;
  z-index: 1500;
}

.modal-overlay[hidden] {
  display: none;
}

.quiz-overlay {
  background: rgba(5, 8, 20, 0.88);
}

.modal-dialog {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 1.25rem;
  width: min(90vw, 960px);
  max-height: 90vh;
  padding: 1.5rem;
  box-shadow: 0 1.5rem 3rem rgba(15, 24, 48, 0.25);
  display: grid;
  gap: 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  border: none;
  background: rgba(79, 105, 231, 0.12);
  color: var(--color-primary-strong);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.modal-close:hover,
.modal-close:focus-visible {
  outline: none;
  background: rgba(79, 105, 231, 0.25);
  transform: rotate(90deg);
}

.modal-body {
  overflow: auto;
  border-radius: 1rem;
  background: rgba(79, 105, 231, 0.08);
  padding: 0.75rem;
}

.modal-body picture {
  display: block;
}

.modal-body img {
  width: 100%;
  height: auto;
  border-radius: 0.75rem;
}

body.modal-open {
  overflow: hidden;
}

body.quiz-active .body-panel,
body.quiz-active .info-panel {
  filter: blur(6px);
}

body.quiz-active::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(12, 24, 52, 0.6) 0,
      rgba(12, 24, 52, 0.6) 6px,
      rgba(4, 8, 20, 0.75) 6px,
      rgba(4, 8, 20, 0.75) 12px
    ),
    rgba(0, 5, 15, 0.82);
  backdrop-filter: blur(10px) contrast(0.85);
  pointer-events: none;
  z-index: 1400;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.quiz-dialog {
  max-width: min(720px, 94vw);
}

.quiz-body {
  display: grid;
  gap: 1rem;
}

.quiz-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.quiz-mode__label {
  font-size: 0.85rem;
  color: #6b7a99;
}

.quiz-mode__options {
  display: inline-flex;
  background: rgba(79, 105, 231, 0.1);
  border: 1px solid rgba(79, 105, 231, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.quiz-mode__option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1f3a60;
  cursor: pointer;
}

.quiz-mode__option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.quiz-mode__option input:checked + span,
.quiz-mode__option input:checked ~ span {
  color: #fff;
}

.quiz-mode__option:has(input:checked) {
  background: rgba(79, 105, 231, 0.85);
  color: #fff;
}

.quiz-mode__option:focus-within {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.quiz-mode__option span {
  display: inline-block;
}

.quiz-progress {
  font-size: 0.85rem;
  color: #6b7a99;
}

.quiz-question {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.quiz-choices {
  display: grid;
  gap: 0.65rem;
}

.quiz-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(79, 105, 231, 0.18);
  background: rgba(79, 105, 231, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease,
    transform 0.2s ease, background 0.2s ease;
  cursor: pointer;
}

.quiz-choice:hover,
.quiz-choice:focus-within {
  border-color: rgba(79, 105, 231, 0.45);
  box-shadow: 0 0 0 3px rgba(79, 105, 231, 0.18);
  background: rgba(79, 105, 231, 0.14);
  transform: translateY(-1px);
}

.quiz-choice input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.quiz-choice__text {
  flex: 1;
  line-height: 1.5;
}

.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
}

.quiz-result {
  background: rgba(79, 105, 231, 0.08);
  border: 1px solid rgba(79, 105, 231, 0.15);
  border-radius: 1rem;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.quiz-answer-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.5rem;
}

.quiz-answer-list li {
  padding-left: 0.25rem;
  color: #1f3a60;
  display: grid;
  gap: 0.35rem;
}

.quiz-answer-list li.is-correct {
  color: #2f7a4b;
}

.quiz-answer-list li.is-incorrect {
  color: #9c2c2c;
}

.quiz-answer-list__status {
  font-weight: 700;
}

.quiz-answer-list__text {
  display: block;
}

.quiz-answer-list li small {
  color: #56617a;
  line-height: 1.4;
}

.regions li p {
  margin: 0;
  font-size: 0.85rem;
  color: #3c516f;
}

.study-tips ul {
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
  list-style: none;
}

.study-tips li {
  padding: 0.6rem 0.75rem;
  border-radius: 0.9rem;
  background: rgba(30, 126, 231, 0.08);
  border: 1px dashed rgba(30, 126, 231, 0.3);
  font-size: 0.85rem;
}


.footnote {
  padding: clamp(1rem, 2vw, 1.2rem) 0;
  text-align: center;
  font-size: 0.85rem;
  color: #6b7a99;
  border-top: 1px solid rgba(17, 38, 146, 0.06);
}

.footnote p {
  margin: 0;
  max-width: min(960px, 92%);
  margin-inline: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .body-panel {
    order: 1;
  }

  .info-panel {
    order: 2;
  }
}

@media (max-width: 600px) {
  .top-bar {
    text-align: center;
  }

  .control-bar {
    justify-content: center;
  }

  .body-view {
    min-height: 380px;
  }
}
