:root {
  --bg: #0b1118;
  --bg-gradient: radial-gradient(circle at 15% 15%, #141e2b 0%, #0b1118 70%);
  --panel: #131d27;
  --panel-border: #1f2f3f;
  --panel-elevated: #1a2836;
  --input-bg: #0f1822;
  --input-border: #283c50;
  
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.35);
  --target: #f59e0b;
  --target-glow: rgba(245, 158, 11, 0.5);
  --ok: #22c55e;
  --ok-glow: rgba(34, 197, 94, 0.3);
  --bad: #ef4444;
  --bad-glow: rgba(239, 68, 68, 0.3);
  --warn: #eab308;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --map-ocean: #090f16;
  --map-land-quiz: #26384a;
  --map-land-bg: #141e27;
  --map-lake: #090f16;
  --map-stroke: #0c141d;
  --map-stroke-quiz: #1a2634;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--panel-border);
}

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

.brand-icon {
  font-size: 2rem;
  line-height: 1;
}

.brand-titles h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-titles p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.mode-selector {
  display: flex;
  background: var(--panel);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  gap: 2px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.active {
  background: var(--accent);
  color: #04131f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Stats Ribbon */
.stats-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 2px;
}

.progress-container {
  height: 6px;
  background: #141f2b;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0284c7, var(--accent));
  transition: width 0.35s ease;
}

/* Main Board Layout */
.main-board {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 16px;
  flex: 1;
  align-items: stretch;
  min-height: 560px;
}

/* Map Section */
.map-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.map-header {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 10;
  pointer-events: none;
}

.map-tag {
  background: rgba(15, 23, 34, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-ctrl-btn {
  background: rgba(19, 29, 39, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.15s ease;
}

.map-ctrl-btn:hover {
  background: var(--panel-elevated);
  border-color: var(--accent);
  color: var(--accent);
}

.map-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
  background: var(--map-ocean);
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-viewport:active {
  cursor: grabbing;
}

#africa-svg {
  width: 100%;
  height: 100%;
  display: block;
  max-height: 720px;
}

/* SVG Land styling */
.country-bg {
  fill: var(--map-land-bg);
  stroke: var(--map-stroke);
  stroke-width: 0.6;
  transition: fill 0.2s ease;
}

.country-quiz {
  fill: var(--map-land-quiz);
  stroke: var(--map-stroke-quiz);
  stroke-width: 0.8;
  cursor: pointer;
  transition: fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
}

.country-quiz:hover {
  filter: brightness(1.2);
}

/* Target country highlighting */
.country-quiz.target {
  fill: var(--target) !important;
  stroke: #ffffff;
  stroke-width: 1.6;
  animation: targetPulse 1.8s ease-in-out infinite;
}

@keyframes targetPulse {
  0%, 100% {
    fill: #f59e0b;
    filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.8));
  }
  50% {
    fill: #fcd34d;
    filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.95));
  }
}

.country-quiz.correct {
  fill: var(--ok) !important;
  stroke: #ffffff;
  stroke-width: 1.2;
}

.country-quiz.wrong {
  fill: var(--bad) !important;
  stroke: #ffffff;
  stroke-width: 1.2;
}

.country-quiz.done {
  fill: #2d3e4e;
  stroke: #18222c;
}

.lake {
  fill: var(--map-lake);
  stroke: #101c27;
  stroke-width: 0.5;
  pointer-events: none;
}

/* Island marker / indicator */
.island-marker {
  cursor: pointer;
  transition: all 0.2s ease;
}

.island-marker circle.outer {
  fill: rgba(245, 158, 11, 0.25);
  stroke: var(--target);
  stroke-width: 1.2;
  animation: ringPulse 1.8s infinite;
}

@keyframes ringPulse {
  0% { r: 5; opacity: 1; }
  100% { r: 18; opacity: 0; }
}

.island-marker circle.core {
  fill: var(--target);
}

.island-marker.target circle.core {
  fill: var(--target);
}

.island-marker.correct circle.core {
  fill: var(--ok);
}

.island-marker.wrong circle.core {
  fill: var(--bad);
}

/* Map tooltip */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(13, 21, 31, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #2d4257;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: #fff;
  z-index: 50;
  display: none;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  line-height: 1.35;
  transition: opacity 0.15s ease;
}

.map-tooltip .tt-country {
  font-weight: 700;
  font-size: 0.92rem;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-tooltip .tt-capital {
  margin-top: 3px;
  font-size: 0.83rem;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 5px;
}

.map-tooltip .tt-capital b {
  color: #fef08a;
  font-weight: 700;
}

.map-tooltip .tt-badge-s {
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.6);
  color: #fcd34d;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

/* Quiz Card / Panel */
.quiz-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.question-header {
  margin-bottom: 20px;
}

.badge-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.73rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-qnum {
  background: var(--panel-elevated);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
}

.badge-cap-req {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.badge-cap-not-req {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent);
}

.question-title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
}

.question-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-label span.req {
  color: var(--target);
  font-size: 0.75rem;
}

.input-box {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1.05rem;
  color: #fff;
  outline: none;
  transition: all 0.2s ease;
}

.input-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-box::placeholder {
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Action Buttons */
.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #041726;
  flex: 2;
  min-width: 130px;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
  background: var(--panel-elevated);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  flex: 1;
}

.btn-secondary:hover {
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  border: 1px dashed var(--panel-border);
  color: var(--text-muted);
  flex: 1;
}

.btn-ghost:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

/* Feedback Section */
.feedback-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 0.94rem;
  display: none;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.feedback-box.ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid var(--ok);
  color: #86efac;
  display: block;
}

.feedback-box.bad {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--bad);
  color: #fca5a5;
  display: block;
}

.feedback-box.info {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid var(--accent);
  color: #bae6fd;
  display: block;
}

.feedback-header {
  font-weight: 700;
  margin-bottom: 4px;
}

.hint-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Final Completion View */
.final-view {
  text-align: center;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.final-badge {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 4px;
}

.final-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 6px 0;
}

.final-stat-box {
  background: var(--panel-elevated);
  border: 1px solid var(--panel-border);
  padding: 10px;
  border-radius: 10px;
}

.final-stat-box b {
  display: block;
  font-size: 1.35rem;
  color: var(--accent);
}

.final-stat-box span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.mistakes-container {
  text-align: left;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 16px;
  max-height: 220px;
  overflow-y: auto;
}

.mistakes-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fca5a5;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mistake-item {
  padding: 6px 0;
  border-bottom: 1px solid #1c2b3a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

.mistake-item:last-child {
  border-bottom: none;
}

.mistake-cap {
  font-size: 0.78rem;
  background: #1e2c3b;
  padding: 2px 8px;
  border-radius: 6px;
  color: #93c5fd;
}

/* Explore Mode Panel */
.explore-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.explore-country-card {
  background: var(--panel-elevated);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
}

.explore-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.explore-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 14px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  border-top: 1px solid #141f2b;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 960px) {
  .main-board {
    grid-template-columns: 1fr;
  }
  .map-card {
    min-height: 440px;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 10px 12px 24px;
  }
  header {
    flex-direction: column;
    align-items: stretch;
  }
  .mode-selector {
    justify-content: center;
  }
  .btn-group {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
}
