/* Dark theme (default) */
:root {
  --bg: #1a1a1f;
  --fg: #f8f8f2;
  --comment: #7970a9;
  --menu: #2d2d37;
  --visual: #44475a;
  --gutter-fg: #4b5263;
  --nontext: #424450;
  --selection: #454158;
  --red: #ff9580;
  --green: #8aff80;
  --yellow: #ffff80;
  --purple: #9580ff;
  --pink: #ff80bf;
  --cyan: #80ffea;
  --white: #f8f8f2;
  --bright-red: #ffaa99;
  --bright-green: #a2ff99;
  --bright-yellow: #ffff99;
  --bright-blue: #aa99ff;
  --bright-magenta: #ff99cc;
  --bright-cyan: #99ffee;
  --bright-white: #ffffff;

  /* Additional colors for landing page */
  --primary-color: #9580ff;
  --secondary-color: #7970a9;
  --tertiary-color: #454158;
  --text-color: #f8f8f2;
  --bg-color: #17161d;
  --textarea-bg: #22212c;
  --border-color: #454158;
  --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  --border-radius: 8px;
  --menu-color: #21222c;
}

/* Light theme */
[data-theme="light"] {
  --bg: #f5f5f5;
  --fg: #1f1f1f;
  --comment: #635d97;
  --menu: #e5e5e5;
  --visual: #c5c5c5;
  --gutter-fg: #4f4f4f;
  --nontext: #3f3f3f;
  --selection: #cfcfde;
  --red: #cb3a2a;
  --green: #14710a;
  --yellow: #846e15;
  --purple: #644ac9;
  --pink: #a3144d;
  --cyan: #036a96;
  --white: #1f1f1f;
  --bright-red: #cb3a2a;
  --bright-green: #14710a;
  --bright-yellow: #846e15;
  --bright-blue: #336699;
  --bright-magenta: #644ac9;
  --bright-cyan: #036a96;
  --bright-white: #f5f5f5;

  /* Light theme additional colors */
  --primary-color: #644ac9;
  --secondary-color: #635d97;
  --tertiary-color: #c5c5c5;
  --text-color: #1f1f1f;
  --bg-color: #f5f5f5;
  --textarea-bg: #f5f5f5;
  --border-color: #c5c5c5;
  --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --selection-color: #cfcfde;
  --menu-color: #e5e5e5;
  --hover-animation-color: rgba(51, 102, 153, 0.15);
}

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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Theme Switcher */
.theme-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  position: fixed;
  right: 1.5rem;
  top: 1.5rem;
  z-index: 1000;
}

.theme-toggle:hover {
  color: var(--accent-color);
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  color: var(--primary-color);
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Game Area */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen {
  display: none;
  width: 100%;
  max-width: 600px;
  text-align: center;
}

.screen.active {
  display: block;
}

/* Flag Container */
.flag-container {
  margin-bottom: 30px;
}

.flag-image {
  max-width: 300px;
  max-height: 200px;
  width: 100%;
  height: auto;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  background: var(--textarea-bg);
  object-fit: contain;
}

/* Input Container */
.input-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.autocomplete-container {
  position: relative;
}

.country-input {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--textarea-bg);
  color: var(--text-color);
  transition: border-color 0.3s ease;
}

.country-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--menu-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-item {
  padding: 10px 15px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--tertiary-color);
}

/* Result Screen */
.result-container {
  text-align: center;
}

.result-message {
  font-size: 1.5rem;
  margin: 20px 0;
  font-weight: bold;
}

.result-message.correct {
  color: var(--green);
}

.result-message.incorrect {
  color: var(--red);
}

.correct-answer {
  font-size: 1.2rem;
  color: var(--secondary-color);
  margin-bottom: 20px;
}

/* Wrong Review */
.wrong-review {
  margin-top: 30px;
  padding: 20px;
  background: var(--menu-color);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  max-width: none;
  width: 100%;
}

.wrong-review h3 {
  color: var(--red);
  margin-bottom: 15px;
}

.wrong-countries-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  width: 100%;
  max-width: none;
}

/* Force multiple columns on desktop */
@media (min-width: 1201px) {
  .wrong-countries-list {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .wrong-countries-list {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 769px) and (max-width: 900px) {
  .wrong-countries-list {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 601px) and (max-width: 768px) {
  .wrong-countries-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1200px) {
  .wrong-countries-list {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 900px) {
  .wrong-countries-list {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .wrong-countries-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }
}

@media (max-width: 600px) {
  .wrong-countries-list {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .wrong-countries-list {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }
}

.wrong-country-item {
  text-align: center;
  padding: 10px;
  background: var(--textarea-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.wrong-country-flag {
  width: 60px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 5px;
}

.wrong-country-name {
  font-size: 0.9rem;
  color: var(--text-color);
}

/* Controls */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  padding: 20px 0;
  border-top: 1px solid var(--border-color);
  width: 100%;
  max-width: 100%;
}

.score-display {
  font-size: 1.2rem;
  font-weight: bold;
}

.score-correct {
  color: var(--green);
}

.score-wrong {
  color: var(--red);
}

.score-total {
  color: var(--secondary-color);
}

.button-group {
  display: flex;
  justify-content: center;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
}

.btn-finish {
  background: transparent;
  border: 2px solid var(--red);
  color: var(--red);
}

.btn-finish:hover {
  background: var(--red);
  color: var(--bg);
  transform: translateY(-2px);
}

.btn-start {
  background: transparent;
  border: 2px solid var(--green);
  color: var(--green);
}

.btn-start:hover {
  background: var(--green);
  color: var(--bg);
  transform: translateY(-2px);
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .flag-image {
    max-width: 250px;
    max-height: 167px;
  }

  .controls {
    flex-direction: column;
    gap: 15px;
  }

  .theme-switcher {
    top: 10px;
    right: 10px;
  }

  .theme-toggle-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
}
