:root {
  --island-width: min(650px, 94vw);
  --flag-width: min(252px, 63vw);
  --flag-height: min(126px, 22.4vh);
}

body {
  margin: 0;
  background: #0f3aa8;
  font-family: "Press Start 2P", monospace;
  color: white;
  text-align: center;
}

img {
  max-width: 100%;
  height: auto;
}

.top-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 18px;
}

.menu-card .top-banner,
.quiz-card .top-banner {
  margin-top: 0;
}

.end-card .top-banner {
  margin-top: 0;
}

.logo,
#game-title {
  display: inline-flex;
  gap: 6px;
  margin: 0;
  font-size: clamp(22px, 5vw, 44px);
  text-shadow: 4px 4px #2b2b2b;
  color: #f7d51d;
}

.logo span,
#game-title span {
  display: inline-block;
  animation: logoGlow 6s linear infinite;
}

.logo span:nth-child(1),
#game-title span:nth-child(1) { animation-delay: 0s; }
.logo span:nth-child(2),
#game-title span:nth-child(2) { animation-delay: 0.4s; }
.logo span:nth-child(3),
#game-title span:nth-child(3) { animation-delay: 0.8s; }
.logo span:nth-child(4),
#game-title span:nth-child(4) { animation-delay: 1.2s; }
.logo span:nth-child(5),
#game-title span:nth-child(5) { animation-delay: 1.6s; }
.logo span:nth-child(6),
#game-title span:nth-child(6) { animation-delay: 2s; }
.logo span:nth-child(7),
#game-title span:nth-child(7) { animation-delay: 2.4s; }

@keyframes logoGlow {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

button,
input,
select,
textarea {
  font-family: "Press Start 2P", monospace;
}

/* hidden utility */
.hidden {
  display: none !important;
}

/* TITLE SCREEN */
#title-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #0f3aa8;
}

#game-title {
  margin-top: 120px;
}

.subtitle {
  margin-top: 20px;
  font-size: 13px;
  color: #0d1d55;
}

#title-screen .subtitle {
  color: white;
}

.top-banner .subtitle {
  color: #0d1d55;
  font-size: 16px;
  margin: 2px 0 0;
}

.press-any {
  margin-top: 54px;
  font-size: 20px;
  animation: blink 1.8s infinite steps(2, start);
}

.map-wrapper {
  display: inline-block;
  margin-top: 60px;
  padding: 20px 22px;
  background: linear-gradient(180deg, #0c3fb8 0%, #0a2d8f 100%);
  border: 4px solid black;
  box-shadow: 0 12px 0 #081f62;
  animation: mapFloat 4s ease-in-out infinite;
}

#pixel-map {
  display: block;
  width: min(480px, 80vw);
  max-width: 100%;
  height: auto;
  background: #0a2a7c;
  border: 4px solid black;
  image-rendering: pixelated;
}

@keyframes mapFloat {
  0% { transform: translateY(0); }
  50% { transform: translateY(8px); }
  100% { transform: translateY(0); }
}

/* blinking */
@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}

/* menu */
#start-screen,
#quiz-screen,
#end-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 12px 36px;
  gap: 10px;
}

#quiz-screen {
  padding-top: 4px;
}

.menu-card,
.quiz-card,
.end-card {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.island {
  background: #e1e1e1;
  color: #11193d;
  width: 100%;
  max-width: var(--island-width);
  border-radius: 24px;
  padding: 13px 18px;
  border: 5px solid #d0d6e8;
  box-shadow: 0 12px 0 #0a2d8f;
  box-sizing: border-box;
}

.menu-card.island {
  padding: 10px 17px;
}

.quiz-card.island {
  padding: 11px 17px 15px;
  min-height: 0;
}

.quiz-card .top-banner {
  margin-bottom: 12px;
}

.menu-title {
  margin: 6px 0 6px;
  font-size: calc(24px - 7pt);
}

.menu-section {
  background: #f3f3f3;
  border: 4px solid #d0d6e8;
  border-radius: 18px;
  padding: 16px 24px;
  box-shadow: inset 0 10px 0 #eef1f8;
}


.rounds-section {
  margin: 4px auto 0;
}

.section-title {
  margin: 0 0 10px;
  font-size: calc(18px - 2pt);
}

.region-filter {
  margin: 6px auto 0;
  max-width: 840px;
  padding: 14px 18px 14px;
}



.region-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  justify-items: stretch;
}

.region-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px;
  border: 3px solid black;
  background: #0d3aa8;
  color: white;
  border-radius: 12px;
  box-shadow: none;
  cursor: pointer;
  transition: none;
}

.region-toggle {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.region-box {
  position: relative;
  width: 20px;
  height: 20px;
  background: #f7d51d;
  border: 3px solid black;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1b1b1b;
  font-size: calc(16px - 3pt);
  line-height: 1;
  text-shadow: none;
  box-sizing: border-box;
  flex: 0 0 20px;
  transition: background-color 0.18s ease;
}

.region-toggle:not(:checked) + .region-box {
  background: #ffec7a;
  box-shadow: none;
}

.region-option:hover .region-box {
  background: #ffe45c;
}

.region-toggle:checked + .region-box::after {
  content: "X";
  display: block;
  font-weight: 700;
}

.region-name {
  font-size: 14px;
  text-shadow: 2px 2px #0a2d8f;
  letter-spacing: 0.3px;
}


.region-option:hover,
.region-option:active {
  transform: none;
  box-shadow: none;
}

.region-toggle:focus-visible + .region-box {
  outline: 3px solid #ffeb3b;
  outline-offset: 3px;
}

.countries-loaded {
  margin-top: 8px;
  font-size: calc(14px - 2pt);
  color: black;
}

.rounds-container {
  margin-top: 8px;
}

.round-btn {
  padding: 7px 9px;
  margin: 4px;
  font-size: calc(20px - 5pt);
  cursor: pointer;
}

.round-btn.active {
  background: yellow;
  color: black;
}

.round-btn.disabled,
.round-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #5f6b8d;
  color: #d9dce7;
}

.start-button {
  display: block;
  width: min(100%, 360px);
  margin: 3px auto 0;
  padding: 14px 26px;
  border-radius: 12px;
  border: 2px solid #ff6f6f;
  background: linear-gradient(135deg, #ff9966, #ff5f6d);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  animation: startPulse 2s infinite ease-in-out;
  box-shadow: 0 6px 0 #c74747;
}

.start-button:hover {
  box-shadow: 0 6px 0 #a94242;
  filter: brightness(1.05);
}

.choose-game-button {
  width: min(100%, 252px);
  padding: 10px 18px;
  font-size: 0.95rem;
  margin-top: 10px;
  box-shadow: 0 4px 0 #1f7a4a;
  animation: none;
  background: linear-gradient(135deg, #6ee7a0, #3bbf7a);
  border-color: #28915a;
  color: #0e2c1b;
}

.choose-game-button:hover {
  box-shadow: 0 4px 0 #18633c;
}

.start-button.disabled,
.start-button:disabled {
  cursor: not-allowed;
  background: linear-gradient(135deg, #ff9966, #ff5f6d);
  color: #ffffff;
  border: 2px solid #ff6f6f;
  box-shadow: 0 6px 0 #c74747;
  transform: none;
  animation: none;
}

@keyframes startPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.state-menu {
  max-width: 520px;
  margin: 0 auto;
  background: #f9f9ff;
  border: 2px solid #d0d4ea;
  border-radius: 16px;
  padding: 18px 16px 22px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12);
  text-align: center;
}

.state-menu .menu-title {
  margin-bottom: 6px;
}

.state-top-banner {
  margin-bottom: 10px;
}

.state-logo span {
  animation: stateColorCycle 2.4s linear infinite;
}

.state-logo span:nth-child(1) { animation-delay: 0s; }
.state-logo span:nth-child(2) { animation-delay: 0.14s; }
.state-logo span:nth-child(3) { animation-delay: 0.28s; }
.state-logo span:nth-child(4) { animation-delay: 0.42s; }
.state-logo span:nth-child(5) { animation-delay: 0.56s; }
.state-logo span:nth-child(6) { animation-delay: 0.70s; }
.state-logo span:nth-child(7) { animation-delay: 0.84s; }

.state-subtitle {
  margin: 4px 0 2px;
  color: #0d1d55;
  letter-spacing: 0.08em;
}

@keyframes stateColorCycle {
  0%   { filter: hue-rotate(0deg); }
  50%  { filter: hue-rotate(180deg); }
  100% { filter: hue-rotate(360deg); }
}

.intro {
  color: #0d1d55;
  font-weight: 600;
  text-align: center;
  margin: 0 0 10px;
}

.settings-block {
  margin-top: 12px;
  padding: 12px 10px;
  border: 1px solid #d0d4ea;
  border-radius: 12px;
  background: #ffffff;
}

.settings-title {
  margin: 0 0 8px;
  font-weight: 700;
  color: #0d1d55;
}

.rounds-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.rounds-buttons .round-btn {
  min-width: 64px;
}

.data-status {
  margin: 10px 0 2px;
  font-size: 0.85rem;
  color: #61657c;
  text-align: center;
}

/* quiz */
.quiz-card {
  margin-top: 6px;
  min-height: 0;
}

#quiz-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 15px;
  color: #0d1d55;
  width: 100%;
}

#question-counter,
#score-display {
  flex: 1;
}

#question-counter {
  text-align: left;
}

#score-display {
  text-align: right;
}

#flag-container {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: var(--flag-height);
}

#flag-img {
  width: 100%;
  max-width: var(--flag-width);
  max-height: var(--flag-height);
  border: none;
  object-fit: contain;
}

#capital-question {
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: calc(17px - 2pt);
  color: #0d1d55;
  line-height: 1.6em;
  min-height: calc(1.6em * 2);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.country-name {
  color: #d4af37;
  font-weight: 700;
}

.answer-btn {
  display: block;
  margin: 6px auto;
  padding: 9px 12px;
  width: min(calc(var(--flag-width) * 1.3), 94vw);
  font-size: calc(16px - 2pt);
  cursor: pointer;
  background: #e7ebf6;
  border: 2px solid #d0d6e8;
  border-radius: 10px;
  color: #0d1d55;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
  box-shadow: 0 6px 0 #d0d6e8;
}

.answer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #b9c1da;
  background: #f6f8ff;
}

.answer-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #b9c1da;
}

.next-btn {
  padding: 9px 13px;
  font-size: calc(15px - 2pt);
  background: #c5ccdb;
  color: white;
  border: 2px solid #9ea6ba;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 0 #9ea6ba;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.next-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #9ea6ba;
  background: #d7dde8;
}

.next-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #0a2d8f;
}

.next-btn:disabled {
  background: #c5ccdb;
  color: white;
  border: 2px solid #9ea6ba;
  box-shadow: 0 6px 0 #9ea6ba;
  cursor: not-allowed;
  transform: none;
}

.next-btn.ready {
  background: #0f3aa8;
  border-color: #0a2d8f;
  box-shadow: 0 6px 0 #0a2d8f;
}

.next-btn.ready:hover {
  background: #1a4ecf;
}

.quiz-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 14px;
}

.quiz-actions-row {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.next-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
}

.next-wrapper .next-btn {
  width: min(calc(var(--flag-width) * 1.3), 94vw);
}

.quit-btn {
  background: #3a3a3a;
  border-color: #2a2a2a;
  box-shadow: 0 6px 0 #2a2a2a;
  color: white;
}

.quit-btn:hover {
  background: #4d4d4d;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #2a2a2a;
}

.quit-btn:active {
  box-shadow: 0 4px 0 #2a2a2a;
}

/* end screen */
.end-card h2 {
  margin: 8px 0 4px;
  font-size: calc(24px - 3pt);
}

.score-message {
  margin-top: 7px;
  font-size: calc(20px - 3pt);
}

.end-card.compact-fit {
  height: var(--menu-height);
  max-height: var(--menu-height);
  gap: 10px;
  overflow: hidden;
  transform-origin: top center;
  transform: scaleY(var(--end-scale, 1));
}

#review-list {
  text-align: left;
  margin-top: 16px;
  font-size: calc(16px - 2pt);
}

#final-score {
  margin: 4px 0 6px;
  font-size: calc(24px - 1pt);
}

.review-section {
  width: min(560px, 94%);
  margin: 16px auto 0;
  padding: 14px 18px 18px;
  border: 3px solid white;
  border-radius: 16px;
  background: #f2f2f2;
}

.review-section h3 {
  margin: 0 0 12px;
  font-size: calc(20px - 2pt);
}

.end-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
}

.restart-btn,
.main-menu-btn {
  padding: 9px 13px;
  font-size: calc(15px - 2pt);
  background: #0f3aa8;
  color: white;
  border: 2px solid #0a2d8f;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 0 #0a2d8f;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
}

.restart-btn:hover,
.main-menu-btn:hover {
  background: #1a4ecf;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #0a2d8f;
}

.restart-btn:active,
.main-menu-btn:active,
.next-btn.ready:active {
  box-shadow: 0 4px 0 #0a2d8f;
  transform: translateY(2px);
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10;
}

.modal-content {
  background: #0f3aa8;
  border: 4px solid black;
  padding: 28px 36px;
  width: min(360px, 90vw);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.modal-text {
  margin: 0 0 20px;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.modal-btn {
  flex: 1;
  padding: 14px 0;
  font-size: 16px;
  cursor: pointer;
}

@media (max-width: 600px) {
  :root {
    --island-width: 100vw;
    --flag-width: 70vw;
    --flag-height: min(126px, 25.2vh);
  }

  #title-screen {
    position: relative;
    min-height: 100vh;
    padding: 32px 18px 60px;
    box-sizing: border-box;
  }

  #game-title {
    margin-top: 90px;
  }

  .map-wrapper {
    width: 100%;
    max-width: 520px;
    margin-top: 36px;
    padding: 16px 18px;
    box-sizing: border-box;
  }

  .top-banner {
    margin-top: 16px;
  }

  .top-banner .subtitle {
    font-size: 14px;
  }

  #start-screen,
  #quiz-screen,
  #end-screen {
    padding: 28px 12px 44px;
  }

  .island {
    padding: 17px 14px;
    border-radius: 18px;
  }

  .menu-card.island {
    padding: 14px 13px;
  }

  .quiz-card.island {
    padding: 11px 11px 17px;
  }

  .menu-section {
    padding: 12px 14px;
  }

  .region-filter {
    padding: 14px 14px 16px;
  }

  .region-options {
    grid-template-columns: 1fr;
  }

  .menu-title {
    font-size: 18px;
  }

  .section-title,
  .region-name,
  .round-btn,
  .press-any {
    font-size: 14px;
  }

  #quiz-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
  }

  #capital-question {
    font-size: 14px;
  }

  .answer-btn {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
  }

  .quiz-actions .next-btn,
  .quiz-actions .quit-btn,
  .restart-btn,
  .main-menu-btn,
  .start-button {
    width: 100%;
  }

  .next-wrapper {
    justify-content: center;
  }

  .end-actions {
    flex-direction: column;
    width: 100%;
  }
}
