:root {
  --bg: #f4efe4;
  --panel: #fefaf1;
  --ink: #2c2a25;
  --accent: #1f6f50;
  --accent-dark: #134c36;
  --warn: #e0c776;
  --correct: #72e74b;
  --border: #cbbd9c;
}

/* zoomed in slightly more so the map and sidebar fill the viewport without horizontal gaps */
html {
  zoom: 1.0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #fff7de 0%, var(--bg) 60%, #e4dbc7 100%);
  min-height: 100vh;
  font-size: 1.1rem;
}

.app {
  max-width: 1800px;
  width: 98%;
  margin: 0 auto;
  padding: 16px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

#home-screen {
  text-align: center;
  padding-top: 5vh;
}

#home-screen.active {
  /* when visible, make header + body layout */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.home-body {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  width: 100%;
  gap: 24px;
  min-height: calc(100vh - 140px);
  /* fill more of the viewport */
}

.home-content {
  flex: 3 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

h1 {
  font-size: clamp(2rem, 6vw, 4rem);
  margin: 0;
  letter-spacing: 0.02em;
}

.subtitle {
  margin-top: 8px;
  font-size: 1.1rem;
}

/* login/signup panel on home screen */
#login-panel {
  flex-shrink: 0;
  width: 300px;
  /* a bit wider so it balances cards */
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;

  #login-panel {
    flex-shrink: 0;
    width: 240px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: left;
  }

  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
  font-size: 1rem;
}

#login-form,
#signup-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* more breathing room */
}

#login-form input,
#signup-form input {
  padding: 12px 14px;
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: 8px;
}

#login-panel p a {
  font-size: 1rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
}

#login-panel p a:hover {
  text-decoration: underline;
}

.quiz-card {
  max-width: 640px;
  margin: 24px auto;
  padding: 24px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(160deg, #fff8e8, #f7f0dc);
  box-shadow: 0 10px 30px rgba(45, 34, 12, 0.12);
}

.quiz-card h2 {
  margin-top: 0;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.stats {
  display: flex;
  gap: 14px;
  font-weight: 700;
}

#guess-form {
  display: flex;
  gap: 8px;
  margin: 10px 0 8px;
}

#guess-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1.1rem;
}

.quiz-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
  margin-bottom: 8px;
}

.big-btn {
  padding: 16px 32px;
  font-size: 1.3rem;
  letter-spacing: 0.05em;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.big-btn:hover {
  transform: scale(1.05);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: #f8fff8;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.secondary-btn {
  background: #d9cdb0;
  color: #322b1b;
  margin-top: 12px;
}

.feedback {
  min-height: 24px;
  margin: 4px 0 10px;
  font-weight: 700;
}

.map-wrap {
  flex: 3 1 0;
  min-width: 0;
  border: 3px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(#3084ce, #2d76a7);
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.map-and-list {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.country-list {
  flex: 0 0 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 8px;
  background: #fefaf1;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.country-list-column {
  display: inline-block;
  vertical-align: top;
  width: 90px;
  margin-right: 8px;
}

.country-list-item {
  line-height: 1.4;
}

.country-list-item.guessed {
  text-decoration: line-through;
  color: var(--correct);
}

@media (max-width: 700px) {
  .map-and-list {
    flex-direction: column;
  }

  .country-list {
    width: 100%;
    max-height: 200px;
  }

  /* stack home content and login on narrow screens */
  #home-screen {
    flex-direction: column;
    align-items: center;
  }

  .home-body {
    flex-direction: column;
  }

  #login-panel {
    width: 100%;
    margin-top: 24px;
  }
}

#map-svg {
  width: 100%;
  display: block;
}

.map-and-list {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

#country-list {
  width: 380px;
  /* a bit wider for readability */
  max-height: 800px;
  /* more vertical space */
  overflow-y: auto;
  overflow-x: auto;
  padding: 8px;
  border-left: 2px solid var(--border);
  display: flex;
}

.country-column {
  display: flex;
  flex-direction: column;
  margin-right: 12px;
}

.country-column {
  display: flex;
  flex-direction: column;
}

.country-column h3 {
  margin: 0 0 4px;
  font-size: 0.9rem;
  text-align: left;
}

.country-item {
  min-height: 1.2em;
  line-height: 1.2;
  font-size: 0.9rem;
}

.background-country {
  fill: #a7a7a7;
  stroke: #7b7b7b;
  stroke-width: 0.7;
  pointer-events: none;
}

.country {
  fill: var(--warn);
  stroke: #393737;
  stroke-width: 0.5;
  transition: fill 140ms ease;
}

.country.guessed {
  fill: var(--correct);
}

.country.non-europe {
  fill: #9b9b9b;
}

.country.merged-segment {
  stroke: #393737;
  stroke-width: 0.5;
}

.marker-country {
  stroke-width: 1.2;
}

.island-halo {
  fill: rgba(255, 255, 255, 0.5);
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 1.4;
  pointer-events: none;
}

.island-halo.guessed {
  fill: rgba(114, 231, 75, 0.35);
  stroke: rgba(114, 231, 75, 0.9);
}

/* settings menu and modal */
#logged-in-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--panel);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.4rem;
}

#settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

#settings-form label {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
  margin-top: 8px;
}

#settings-form input {
  padding: 12px 14px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
}

#close-settings {
  width: 100%;
}

@media (max-width: 700px) {
  .quiz-header {
    flex-direction: column;
    align-items: flex-start;
  }

  #guess-form {
    flex-direction: column;
  }
}

.pb-badge {
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
}

.warn-btn {
  background: #d44c4c;
  color: #fff;
  margin-top: 12px;
}

.warn-btn:hover {
  background: #b63a3a;
}

.quiz-controls-bottom {
  display: flex;
  gap: 12px;
  align-items: center;
}

.small-btn {
  padding: 4px 8px;
  font-size: 0.9rem;
  line-height: 1;
}