:root {
  --bg: #ecf3f0;
  --bg-deep: #d7e5df;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-strong: rgba(255, 255, 255, 0.93);
  --surface-soft: rgba(243, 248, 246, 0.8);
  --text: #12201d;
  --muted: #61746f;
  --line: rgba(18, 32, 29, 0.1);
  --accent: #ea6d2f;
  --accent-strong: #c45118;
  --accent-soft: rgba(234, 109, 47, 0.14);
  --correct: #149e53;
  --correct-soft: rgba(20, 158, 83, 0.16);
  --wrong: #e13333;
  --wrong-soft: rgba(225, 51, 51, 0.16);
  --shadow: 0 24px 56px rgba(18, 32, 29, 0.1);
  --shadow-soft: 0 14px 32px rgba(18, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(234, 109, 47, 0.18), transparent 24%),
    radial-gradient(circle at 86% 10%, rgba(73, 143, 129, 0.16), transparent 18%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)),
    linear-gradient(160deg, #f7f2e7 0%, var(--bg) 44%, var(--bg-deep) 100%);
}

.page {
  width: min(1500px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.8rem 0 1rem;
}

.topbar,
.controls,
.question-card,
.map-card {
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 0.8rem;
  align-items: stretch;
  padding: 1rem 1.05rem;
  border-radius: 30px;
  position: relative;
  overflow: hidden;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(234, 109, 47, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 42%);
  pointer-events: none;
}

.title-block {
  display: grid;
  gap: 0.35rem;
  align-content: center;
  padding: 0.45rem 0.25rem;
  position: relative;
  z-index: 1;
}

.title-block h1,
.question-card h2,
.map-title,
.results-panel h3 {
  margin: 0;
  font-family: "Fraunces", serif;
}

.title-block h1 {
  font-size: clamp(1.75rem, 3vw, 2.9rem);
  line-height: 0.94;
  letter-spacing: -0.03em;
}

.eyebrow,
.question-tag,
.stat-label,
label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.69rem;
  font-weight: 700;
}

.eyebrow,
.question-tag,
.stat-label {
  margin: 0;
  color: var(--accent-strong);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  position: relative;
  z-index: 1;
}

.stat-chip {
  display: grid;
  gap: 0.28rem;
  min-height: 5.2rem;
  padding: 0.75rem 0.85rem;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 249, 247, 0.72));
  border: 1px solid rgba(20, 35, 33, 0.07);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 8px 24px rgba(18, 32, 29, 0.05);
}

.stat-chip strong {
  display: block;
  font-size: clamp(1.05rem, 1.7vw, 1.35rem);
  line-height: 1.05;
}

.stat-good {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(24, 169, 87, 0.09));
}

.stat-good strong {
  color: var(--correct);
}

.stat-wrong {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(224, 51, 51, 0.09));
}

.stat-wrong strong {
  color: var(--wrong);
}

.controls {
  margin-top: 0.75rem;
  padding: 0.8rem;
  border-radius: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  align-items: end;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(243, 248, 246, 0.72));
}

.control-block {
  display: grid;
  gap: 0.4rem;
}

label {
  color: var(--muted);
}

select,
input,
button {
  font: inherit;
}

select,
input {
  width: 100%;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

select:focus,
input:focus {
  border-color: rgba(226, 104, 44, 0.38);
  box-shadow: 0 0 0 4px rgba(226, 104, 44, 0.12);
  background: #fff;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, opacity 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-button,
.ghost-button {
  min-height: 3rem;
  border-radius: 999px;
  padding: 0.82rem 1.15rem;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  color: #fffdf9;
  background: linear-gradient(135deg, var(--accent) 0%, #f08d44 100%);
  box-shadow: 0 12px 26px rgba(226, 104, 44, 0.24);
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(20, 35, 33, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 8px 18px rgba(18, 32, 29, 0.04);
}

.progress-bar {
  height: 12px;
  margin: 0.75rem 0;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(20, 35, 33, 0.08);
  box-shadow: inset 0 1px 2px rgba(20, 35, 33, 0.08);
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, #f3bf67 100%);
  transition: width 0.24s ease;
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
}

.question-card,
.map-card {
  border-radius: 30px;
  padding: 1rem;
}

.question-card {
  display: grid;
  gap: 0.85rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 249, 247, 0.78));
  position: sticky;
  top: 0.8rem;
}

.question-card h2 {
  font-size: clamp(1.3rem, 2vw, 1.95rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.question-tag {
  display: inline-flex;
  width: fit-content;
  padding: 0.38rem 0.62rem;
  border-radius: 999px;
  background: var(--accent-soft);
}

.question-hint,
.map-instruction,
.feedback small,
.results-summary,
.mistakes-list li {
  color: var(--muted);
}

.question-hint {
  margin: 0;
  min-height: 1.1rem;
  font-size: 0.92rem;
}

.answer-form {
  display: grid;
  gap: 0.75rem;
}

.answer-form[hidden],
.field-block[hidden],
.results-panel[hidden],
.mistakes-block[hidden] {
  display: none !important;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.field-block {
  display: grid;
  gap: 0.4rem;
}

.feedback {
  min-height: 4.4rem;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(20, 35, 33, 0.08);
  box-shadow: var(--shadow-soft);
}

.feedback[hidden] {
  display: block;
  visibility: hidden;
}

.feedback.correct {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), var(--correct-soft));
  border-color: rgba(24, 169, 87, 0.26);
  color: #0d8b45;
}

.feedback.wrong {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), var(--wrong-soft));
  border-color: rgba(224, 51, 51, 0.22);
  color: #c82626;
}

.question-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.results-panel {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--line);
}

.results-summary {
  font-size: 0.95rem;
}

.mistakes-block h3 {
  font-size: 1rem;
  margin-bottom: 0.45rem;
}

.mistakes-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
  max-height: 12rem;
  overflow: auto;
}

.mistakes-list li {
  padding: 0.7rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(20, 35, 33, 0.08);
}

.mistakes-list strong {
  color: var(--text);
}

.map-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(240, 246, 244, 0.8));
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.map-title {
  font-size: 1.02rem;
}

.map-instruction {
  margin: 0;
  font-size: 0.9rem;
  text-align: right;
}

.map-frame {
  height: calc(100vh - 13.2rem);
  min-height: 24rem;
  max-height: 76vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 26px;
  border: 1px solid rgba(20, 35, 33, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(241, 247, 245, 0.72));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

.map-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-layer {
  position: relative;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  flex: 0 1 auto;
  line-height: 0;
}

.map-layer img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
}

.marker {
  position: absolute;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  font: inherit;
  transform: translate(-50%, -50%);
  box-shadow: none;
}

.marker:hover,
.marker:focus-visible {
  transform: translate(-50%, -50%);
}

.marker-badge {
  min-width: 1.22rem;
  height: 1.22rem;
  padding: 0 0.16rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: rgba(8, 15, 17, 0.98);
  border: 2px solid rgba(255, 255, 255, 1);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 8px 20px rgba(0, 0, 0, 0.34);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.marker.clickable {
  cursor: pointer;
}

.marker.locked {
  cursor: default;
}

.marker.clickable:hover .marker-badge {
  background: rgba(226, 104, 44, 0.98);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 0 0 8px rgba(226, 104, 44, 0.22),
    0 8px 20px rgba(0, 0, 0, 0.34);
}

.marker.active .marker-badge {
  background: rgba(226, 104, 44, 0.98);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 0 0 8px rgba(226, 104, 44, 0.22),
    0 8px 20px rgba(0, 0, 0, 0.34);
  animation: pulse 1.45s ease-in-out infinite;
}

.marker.correct .marker-badge {
  background: rgba(24, 169, 87, 0.98);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.28),
    0 0 0 8px rgba(24, 169, 87, 0.24),
    0 8px 20px rgba(0, 0, 0, 0.32);
}

.marker.wrong .marker-badge {
  background: rgba(224, 51, 51, 0.98);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.28),
    0 0 0 8px rgba(224, 51, 51, 0.22),
    0 8px 20px rgba(0, 0, 0, 0.32);
}

@keyframes pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.3),
      0 0 0 0 rgba(226, 104, 44, 0.34),
      0 8px 20px rgba(0, 0, 0, 0.34);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.3),
      0 0 0 12px rgba(226, 104, 44, 0),
      0 8px 20px rgba(0, 0, 0, 0.34);
  }
}

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

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .question-card {
    position: static;
  }

  .map-frame {
    height: min(68vh, 42rem);
  }
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 0.75rem, 1500px);
    padding-top: 0.55rem;
  }

  .topbar,
  .controls,
  .question-card,
  .map-card {
    border-radius: 22px;
  }

  .stats,
  .controls,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .stat-chip {
    min-height: auto;
  }

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

  .map-instruction {
    text-align: left;
  }

  .map-frame {
    min-height: 18rem;
    height: min(58vh, 34rem);
    padding: 0.35rem;
  }

  .question-actions {
    flex-direction: column;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
