body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #1f2937;
  margin: 0;
  position: relative;
}

.question-img {
  width: 160px;
  display: block;
  margin: 0.5rem auto 1rem;
}

.app {
  width: min(100%, 480px);
  background: #111827;
  color: #f3f4f6;
  min-height: 100vh;
  padding: 1rem;
  padding-top: 0;
  box-sizing: border-box;
  margin: 0 auto;
}

#options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

button.option {
  position: relative;
  display: inline-block;
  padding: 10px;
  background: #1f2937;
  color: #f3f4f6;
  border: 1px solid #374151;
  border-radius: 0.4rem;
  text-align: left;
  cursor: pointer;
}

button.option:hover:not(:disabled) {
  background: #374151;
}

button.option.correct {
  background: #1f2937;
  border-color: #00c853;
}

button.option.wrong {
  background: #1f2937;
  border-color: #ff3d00;
}

.answer-icon {
  position: absolute;
  right: 4px;
  top: 0;
  bottom: 0;
  margin: auto 0;
  max-height: 22px;
}

#feedback {
  margin-top: 0.5rem;
  min-height: 1.2rem;
  color: #d1d5db;
  flex: 1;
  font-weight: 600;
}

#feedback.feedback-correct {
  color: #00c853;
}

#feedback.feedback-wrong {
  color: #ff3d00;
}

/* Feedback and Next button container */
.feedback-next-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

/* Next and Restart buttons */
#nextBtn,
#resultsRestartBtn {
  background: #374151;
  color: #f3f4f6;
  border: 1px solid #4b5563;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

#nextBtn:hover,
#resultsRestartBtn:hover {
  background: #4b5563;
  border-color: #6b7280;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#nextBtn:active,
#resultsRestartBtn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#resultsRestartBtn {
  margin-top: 1rem;
}

#results {
  text-align: center;
}

#resultsTitle {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

#resultsScore {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none;
}

footer {
  font-size: 0.75rem;
  text-align: center;
  margin-top: 1rem;
  color: #9ca3af;
}

footer a {
  color: #60a5fa;
  text-decoration: none;
}

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

/* ===== Cookie Consent Banner ===== */

.cookie-consent {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1f2937;
  border-top: 2px solid #374151;
  padding: 1rem;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.cookie-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.cookie-content p {
  margin: 0;
  color: #f3f4f6;
  flex: 1;
  min-width: 250px;
  font-size: 0.9rem;
}

.cookie-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 0.4rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.cookie-accept {
  background: #10b981;
  color: white;
}

.cookie-accept:hover {
  background: #059669;
}

.cookie-decline {
  background: #374151;
  color: #f3f4f6;
}

.cookie-decline:hover {
  background: #4b5563;
}

/* ===== Ad containers ===== */

.ad-container {
  margin: 1rem 0;
  padding: 1rem;
  background: transparent;
  border: 2px dotted #6b7280;
  border-radius: 0.5rem;
  text-align: center;
  min-height: 100px;
  display: block !important;
}

.ad-placeholder {
  display: none;
}

/* Side ads - hidden on mobile */
.ad-sidebar {
  display: none;
}

/* ===== Header layout ===== */

.app-header {
  width: 100%;
  box-sizing: border-box;
  background: #111827;
  color: #f9fafb;
  padding: 0.5rem 1rem;

  /* NEW: layout for burger, language, title */
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  position: relative;
}

/* Hamburger on the left */
#menuToggle {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.header-logo {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  max-height: 35px;
}

/* Language selection on the right */
.header-language {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

/* Center any title element in the header */
.app-header h1,
.app-header h2,
.app-header .app-title,
.app-header #titleText {
  grid-column: 1 / -1;
  grid-row: 1;
  justify-self: center;
  margin: 0;
  text-align: center;
  white-space: nowrap;
}

.header-language {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  z-index: 1;
}

.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;
}

.flag-icon {
  width: 24px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.language-flag-dropdown {
  position: relative;
}

.language-flag-button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.language-flag-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  padding: 0.25rem 0;
  z-index: 20;
  min-width: 140px;
}

.language-flag-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.25rem 0.75rem;
  border: none;
  background: none;
  color: #f3f4f6;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}

.language-flag-option:hover {
  background: #374151;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  color: #d1d5db;
}

.toolbar label {
  margin-right: 0.15rem;
  color: #d1d5db;
}

.toolbar select {
  font-size: 0.85rem;
  background: #1f2937;
  color: #f3f4f6;
  border: 1px solid #374151;
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
}

/* Progress bar */
.progress-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 150px;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.progress-bar {
  flex: 1;
  height: 2px;
  background: #374151;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #4b5563;
}

.progress-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease, background-color 0.3s ease;
  background: #6b7280;
  border-radius: 10px;
}

.progress-fill.low {
  background: #ef4444;
}

.progress-fill.medium {
  background: #f59e0b;
}

.progress-fill.high {
  background: #10b981;
}

.progress-text {
  font-size: 0.85rem;
  color: #d1d5db;
  font-weight: 500;
  min-width: 45px;
  text-align: right;
}

/* hamburger button */

.icon-button {
  background: none;
  border: none;
  padding: 0.25rem;
  font-size: 1.4rem;
  cursor: pointer;
  color: #ffffff; /* Make hamburger icon white on dark header */
}

/* ===== Slide-in menu ===== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 20;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.side-menu {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  max-width: 80%;
  background: #1f2937;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.5);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 30;
  padding: 0.75rem 0;
  box-sizing: border-box;
  overflow-y: auto;
}

.side-menu.open {
  transform: translateX(0);
}

.menu-group-title {
  padding: 0.35rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #f3f4f6;
  padding: 0.55rem 1.25rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.menu-item:hover {
  background: #374151;
}

.menu-footer {
  border-top: 1px solid #374151;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem 0.25rem;
}

.menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #d1d5db;
}

.menu-toggle input[type="checkbox"] {
  transform: scale(1.1);
}

/* Hide topic / country / continent controls from main view */
#topicLabel,
#countryLabel,
#continentLabel,
#topicSelect,
#countrySelect,
#continentSelect {
  display: none;
}

/* ===== Desktop behavior: big monitor ===== */
@media (min-width: 1000px) {
  /* keep quiz card centered, but make header act as a proper top bar */
  .app-header {
    position: sticky;
    top: 0;
    z-index: 40;
  }

  /* side menu always visible and starts below the header bar */
  .side-menu {
    transform: none;
    box-shadow: none;
    top: 3.25rem; /* approximate header height so it doesn't cover the bar */
  }

  .side-menu.open {
    transform: none;
  }

  .overlay {
    display: none;
  }

  #menuToggle {
    display: none;
  }

  /* Show side ads on desktop */
  .ad-sidebar {
    display: block;
    position: fixed;
    top: 100px;
    width: 160px;
    height: 600px;
    padding: 1rem;
    background: transparent;
    border: 2px dotted #6b7280;
    border-radius: 0.5rem;
    text-align: center;
    z-index: 10;
  }

  .ad-sidebar-left {
    left: 20px;
  }

  .ad-sidebar-right {
    right: 20px;
  }

  /* Keep the below-quiz ad on desktop too */
  .ad-container {
    margin: 1.5rem 0;
  }
}

/* ===== WELCOME CONTENT ===== */
.welcome-content {
  max-width: 800px;
  margin: 2rem auto;
  padding: 2rem;
  background: #1f2937;
  border-radius: 0.5rem;
  line-height: 1.6;
}

.welcome-content h1 {
  color: #60a5fa;
  margin-bottom: 1rem;
  font-size: 2rem;
}

.welcome-content h2 {
  color: #93c5fd;
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.welcome-content h3 {
  color: #bfdbfe;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.welcome-content p {
  margin-bottom: 1rem;
  color: #d1d5db;
}

.quiz-info {
  margin: 2rem 0;
}

.topic-card {
  background: #111827;
  padding: 1.5rem;
  margin: 1rem 0;
  border-radius: 0.5rem;
  border-left: 4px solid #60a5fa;
}

.quiz-features ul {
  list-style: none;
  padding-left: 0;
}

.quiz-features li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
  color: #d1d5db;
}

.quiz-features li:before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #10b981;
  font-weight: bold;
}

.how-to-start ol {
  padding-left: 1.5rem;
  color: #d1d5db;
}

.how-to-start li {
  margin: 0.5rem 0;
}

.welcome-content.hidden {
  display: none;
}

@media (max-width: 768px) {
  .welcome-content {
    padding: 1rem;
  }
  
  .welcome-content h1 {
    font-size: 1.5rem;
  }
  
  .welcome-content h2 {
    font-size: 1.25rem;
  }
}
