:root {
  --bg: #10100d;
  --panel: #1b1913;
  --panel-soft: #242116;
  --line: #4e442d;
  --gold: #caa65a;
  --gold-bright: #f2cf82;
  --sand: #e6d7b8;
  --muted: #a99d83;
  --danger: #d36c5f;
  --success: #7fb678;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--sand);
  background:
    linear-gradient(135deg, rgba(202, 166, 90, 0.08), transparent 32%),
    radial-gradient(circle at top right, rgba(242, 207, 130, 0.08), transparent 30%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.training-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.training-nav a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--sand);
  background: rgba(255, 255, 255, 0.03);
  text-decoration: none;
  font-weight: 700;
}

.training-nav a:hover {
  border-color: var(--gold);
  color: #fff7e2;
}

.screen {
  min-height: calc(100vh - 64px);
}

.is-hidden {
  display: none !important;
}

.start-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
  align-items: center;
}

.brand-panel {
  padding: 40px 0;
}

.kicker {
  margin: 0 0 10px;
  color: var(--gold-bright);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 18px;
  color: #fff7e2;
  font-size: clamp(3rem, 7vw, 5.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  color: #fff7e2;
  font-size: clamp(1.7rem, 3.5vw, 3rem);
  line-height: 1;
}

h3 {
  margin-bottom: 14px;
  color: #fff7e2;
}

.intro {
  max-width: 640px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.control-panel,
.result-stat,
.wrong-list-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(36, 33, 22, 0.96), rgba(24, 23, 18, 0.96));
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.button-row > button {
  flex: 1;
}

.panel-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.toggle-row {
  color: var(--muted);
  font-size: 0.92rem;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #5b5139;
  border-radius: 6px;
  padding: 0 12px;
  color: #fff7e2;
  background: #11100c;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(242, 207, 130, 0.18);
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
  line-height: 1.4;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

.primary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--gold-bright);
  color: #15120b;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--sand);
  background: rgba(255, 255, 255, 0.03);
}

.quiz-screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-login-screen {
  display: grid;
  place-items: center;
}

.admin-login-panel {
  width: min(430px, 100%);
}

.admin-layout {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-layout .map-stage {
  max-height: none;
}

.admin-coords {
  min-height: 42px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--gold-bright);
  background: rgba(255, 255, 255, 0.03);
}

.admin-place-list {
  display: grid;
  gap: 10px;
}

.admin-place-list h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.quiz-header,
.feedback-row,
.result-heading,
.result-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span {
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: #fff7e2;
  background: var(--panel);
  text-align: center;
  font-weight: 700;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #15130e;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transition: width 180ms ease;
}

.map-section {
  flex: 1;
  min-height: 0;
}

.map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--map-aspect, 16 / 10);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(202, 166, 90, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(202, 166, 90, 0.12) 1px, transparent 1px),
    #17160f;
  background-size: 48px 48px;
  box-shadow: var(--shadow);
}

.map-stage.is-disabled {
  pointer-events: none;
}

.leaflet-map {
  background: #17160f;
}

.leaflet-top .leaflet-control {
  margin-left: 14px;
  margin-top: 14px;
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.leaflet-control-zoom a,
.leaflet-reset-button {
  border: 1px solid var(--line) !important;
  color: var(--sand) !important;
  background: rgba(17, 16, 12, 0.92) !important;
  font-weight: 700;
}

.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 34px !important;
  font-size: 1.35rem !important;
}

.leaflet-control-zoom a:hover,
.leaflet-reset-button:hover {
  border-color: var(--gold) !important;
  color: #fff7e2 !important;
}

.leaflet-reset-button {
  min-width: 54px;
  min-height: 28px;
  border-radius: 4px;
  padding: 0 8px;
  font: inherit;
}

.map-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--sand);
  background: rgba(16, 16, 13, 0.78);
  text-align: center;
}

.map-fallback span {
  color: var(--muted);
}

.marker {
  position: absolute;
  z-index: 3;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.user-marker {
  border: 2px solid #ffffff;
  background: var(--danger);
}

.answer-marker {
  border: 2px solid #15120b;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(127, 182, 120, 0.25);
}

.admin-draft-marker {
  border: 2px solid #15120b;
  background: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(242, 207, 130, 0.24);
}

.radius-preview {
  position: absolute;
  z-index: 2;
  border: 2px dashed rgba(127, 182, 120, 0.85);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: rgba(127, 182, 120, 0.1);
}

.feedback-row {
  min-height: 54px;
}

.feedback-row p {
  margin: 0;
  color: var(--muted);
}

.feedback-row p.is-correct {
  color: var(--success);
}

.feedback-row p.is-wrong {
  color: var(--danger);
}

.result-screen {
  display: grid;
  align-content: center;
  gap: 20px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.result-stat {
  padding: 18px;
}

.result-stat span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-stat strong {
  color: #fff7e2;
  font-size: 1.8rem;
}

.wrong-list-section {
  padding: 18px;
}

.wrong-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wrong-list li {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(230, 215, 184, 0.12);
  padding: 10px 0;
  color: var(--muted);
}

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

.inline-danger-button {
  min-height: 34px;
  border: 1px solid rgba(211, 108, 95, 0.65);
  border-radius: 6px;
  padding: 0 10px;
  color: #ffd5d0;
  background: rgba(211, 108, 95, 0.12);
  font-size: 0.86rem;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.wrong-list li:last-child {
  border-bottom: 0;
}

@media (max-width: 900px) {
  .start-screen {
    grid-template-columns: 1fr;
    align-items: start;
  }

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

  .brand-panel {
    padding-bottom: 0;
  }

  .map-stage {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0;
  }

  .screen {
    min-height: calc(100vh - 32px);
  }

  .settings-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-header,
  .feedback-row,
  .result-heading,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    justify-content: stretch;
  }

  .status-strip span {
    flex: 1;
    min-width: 0;
  }
}
