:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-alt: #eef4ff;
  --primary: #1f5f8b;
  --primary-dark: #18496c;
  --accent: #ffb703;
  --text: #1f2937;
  --muted: #5b6472;
  --success: #2e8b57;
  --shadow: 0 18px 35px rgba(31, 95, 139, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #eef5ff 0%, #eaf7ee 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(31, 95, 139, 0.12);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.nav {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav a,
.nav-reset-btn {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  transition: 0.2s ease;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.nav a.active,
.nav a:hover,
.nav-reset-btn:hover {
  background: var(--panel-alt);
  color: var(--primary-dark);
}

.nav-reset-btn {
  border-color: rgba(31, 95, 139, 0.12);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.panel {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(31, 95, 139, 0.08);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 22px 26px;
  margin-bottom: 24px;
}

.panel h1 {
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

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

.editor-status {
  margin-top: 12px !important;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.96rem;
}

.map-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(31, 95, 139, 0.08);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 18px;
}

.editor-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

#game-map,
#admin-map {
  width: 100%;
  height: 72vh;
  min-height: 420px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(31, 95, 139, 0.08);
  background: #dfeef8;
}

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

.leaflet-container {
  background: #dfeef8;
  font: inherit;
}

.city-marker {
  background: transparent;
  border: none;
  border-radius: 50%;
  box-shadow: none;
  width: 18px !important;
  height: 18px !important;
  margin-left: -9px !important;
  margin-top: -9px !important;
}

.city-marker.visited {
  background: transparent;
  box-shadow: none;
}

.city-marker span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.18);
}

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

.city-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(31, 95, 139, 0.08);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 16px;
}

.city-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.city-button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid rgba(31, 95, 139, 0.15);
  background: #f8fbff;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s ease;
}

.city-button.active,
.city-button:hover {
  background: var(--panel-alt);
  border-color: rgba(31, 95, 139, 0.3);
  transform: translateY(-1px);
}

.city-delete-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(180, 35, 24, 0.2);
  background: #fff0f0;
  color: #b42318;
  border-radius: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.city-delete-btn:hover {
  background: #ffe1e1;
}

.question-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(31, 95, 139, 0.08);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 22px;
}

.question-form label {
  font-weight: 700;
  color: var(--primary-dark);
}

.question-form input,
.question-form textarea {
  width: 100%;
  border: 1px solid rgba(31, 95, 139, 0.15);
  border-radius: 12px;
  background: #f9fbff;
  padding: 12px 14px;
  resize: vertical;
  color: var(--text);
}

.question-form textarea {
  min-height: 140px;
}

.question-form select {
  width: 100%;
  border: 1px solid rgba(31, 95, 139, 0.15);
  border-radius: 12px;
  background: #f9fbff;
  padding: 12px 14px;
  color: var(--text);
}

.marker-color-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(31, 95, 139, 0.12);
  border-radius: 12px;
  background: #f7faff;
}

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

.color-picker-header label {
  margin: 0;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.marker-color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(17, 24, 39, 0.18);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.marker-color-btn:hover,
.marker-color-btn:focus-visible {
  transform: translateY(-1px);
}

.marker-color-btn.active {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.18);
}

.small-btn {
  padding: 7px 10px;
  font-size: 0.8rem;
}

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

.response-toggle-row {
  display: flex;
  justify-content: flex-start;
}

.answer-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.hidden {
  display: none !important;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.secondary-btn {
  background: #eaf3ff;
  color: var(--primary-dark);
  border: 1px solid rgba(31, 95, 139, 0.2);
}

.danger-btn {
  background: #fff0f0;
  color: #b42318;
  border: 1px solid rgba(180, 35, 24, 0.15);
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn.active {
  background: var(--primary-dark);
  color: white;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(70vw, calc(100vw - 28px));
  max-height: 78vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.24);
  padding: 22px 18px 20px;
  box-sizing: border-box;
}

.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  background: #f3f7fb;
  border-radius: 50%;
  font-size: 1.6rem;
  color: var(--muted);
  cursor: pointer;
}

#modal-title {
  margin: 0;
  color: var(--primary-dark);
}

.modal-stage {
  position: relative;
  min-height: 120px;
}

.modal-content {
  width: 100%;
  min-height: 0;
  display: block;
  overflow-x: hidden;
  animation: modal-slide-in-left 0.35s ease;
}

.modal-content.answer-view {
  animation: modal-slide-in-right 0.35s ease;
}

.modal-content > * {
  max-width: 100%;
}

@keyframes modal-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes modal-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.modal-question,
.answer-question,
.answer-text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.modal-question {
  margin: 0;
  line-height: 1.7;
  color: var(--text);
  font-size: 1.05rem;
}

.modal-media {
  margin-top: 16px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.modal-media img,
.modal-media video,
.modal-media audio {
  display: block;
  margin-top: 10px;
}

.modal-media img,
.modal-media video {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 520px;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(31, 95, 139, 0.12);
  margin: 10px auto 0;
}

.modal-media audio {
  width: 100%;
  max-width: 420px;
}

.toggle-answer-btn {
  background: #eaf3ff;
  color: var(--primary-dark);
  border: 1px solid rgba(31, 95, 139, 0.2);
  border-radius: 999px;
  padding: 8px 14px;
  margin-right: 35px;
  font-weight: 700;
  cursor: pointer;
}

.toggle-answer-btn.active {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
}

.answer-panel {
  padding-top: 6px;
  border-top: 1px solid rgba(31, 95, 139, 0.12);
}

.answer-panel h3 {
  margin: 0 0 12px;
  color: var(--primary-dark);
}

.answer-question {
  margin: 0 0 12px;
  line-height: 1.6;
  color: #475569;
  font-weight: 500;
  font-size: 0.96rem;
}

.answer-text {
  line-height: 1.7;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.answer-panel .modal-media {
  margin-top: 0;
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    gap: 12px;
    padding: 18px 18px 14px;
  }

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

  .page {
    padding-left: 12px;
    padding-right: 12px;
  }

  #game-map {
    height: 60vh;
  }
}
