:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
  background: #eaf0f8;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;

  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --secondary: #0891b2;
  --text: #0f172a;
  --muted: #64748b;
  --surface: rgba(255, 255, 255, 0.96);
  --soft: #f1f5f9;
  --border: rgba(148, 163, 184, 0.22);
  --shadow: 0 20px 55px rgba(15, 23, 42, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #eaf0f8;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 4%, rgba(79, 70, 229, 0.12), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(8, 145, 178, 0.1), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, #e7eef7 55%, #dce7f3 100%);
}

button {
  font: inherit;
}

.app {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding:
    calc(20px + env(safe-area-inset-top))
    16px
    calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 2px 0;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--primary);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.icon-button {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(239, 246, 255, 0.9));
  box-shadow:
    0 12px 30px rgba(15, 23, 42, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-size: 1.35rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.progress-area {
  padding: 13px 15px 14px;
  display: grid;
  gap: 9px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 0.96rem;
  font-weight: 850;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #d7dfeb;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.08);
}

.progress-bar {
  width: 10%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #6366f1, var(--secondary));
  box-shadow: 0 0 15px rgba(79, 70, 229, 0.35);
  transition: width 0.35s ease;
}

.country-card {
  position: relative;
  width: 100%;
  min-height: 530px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 32px;
  background: var(--surface);
  color: inherit;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.country-card::before {
  content: "";
  position: absolute;
  top: -100px;
  right: -100px;
  width: 270px;
  height: 270px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.09), transparent 68%);
  pointer-events: none;
}

.country-card::after {
  content: "";
  position: absolute;
  bottom: -110px;
  left: -90px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(8, 145, 178, 0.08), transparent 68%);
  pointer-events: none;
}

.card-view {
  position: relative;
  z-index: 1;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: premiumFade 0.32s ease both;
}

.hidden {
  display: none;
}

.flag-image {
  display: block;
  width: min(100%, 560px);
  max-height: 330px;
  object-fit: contain;
  border-radius: 20px;
  box-shadow:
    0 20px 42px rgba(15, 23, 42, 0.19),
    0 2px 8px rgba(15, 23, 42, 0.12);
  animation: flagEnter 0.38s ease both;
}

.small-flag {
  width: 132px;
  max-height: 88px;
  object-fit: contain;
  margin-bottom: 22px;
  border-radius: 12px;
  box-shadow: 0 13px 30px rgba(15, 23, 42, 0.17);
}

h2 {
  max-width: 100%;
  margin: 0 0 7px;
  font-size: clamp(2.15rem, 9vw, 3.65rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}

.latvian-name {
  margin: 7px 0 30px;
  font-size: clamp(1.35rem, 5.5vw, 1.75rem);
  font-weight: 800;
  color: var(--primary);
}

.tap-hint {
  margin: 31px 0 0;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--muted);
}

.country-info {
  width: 100%;
  margin: 13px 0 0;
  display: grid;
  gap: 12px;
  text-align: left;
}

.country-info div {
  position: relative;
  min-height: 88px;
  padding: 17px 16px 16px 60px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(248, 250, 252, 0.98), rgba(238, 244, 250, 0.94));
  box-shadow:
    0 8px 22px rgba(15, 23, 42, 0.065),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  animation: infoRise 0.36s ease both;
}

.country-info div::before {
  position: absolute;
  left: 16px;
  top: 20px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(79, 70, 229, 0.1);
  font-size: 1.15rem;
}

.country-info div:nth-child(1)::before {
  content: "🏛️";
}

.country-info div:nth-child(2)::before {
  content: "🌍";
}

.country-info div:nth-child(3)::before {
  content: "👥";
}

.country-info div:nth-child(4)::before {
  content: "🗣️";
}

.country-info div:nth-child(5)::before {
  content: "💰";
}

.country-info div:nth-child(6)::before {
  content: "⭐";
}

.country-info div:nth-child(1) {
  animation-delay: 0.02s;
}

.country-info div:nth-child(2) {
  animation-delay: 0.07s;
}

.country-info div:nth-child(3) {
  animation-delay: 0.12s;
}

.country-info div:nth-child(4) {
  animation-delay: 0.17s;
}

.country-info div:nth-child(5) {
  animation-delay: 0.22s;
}

.country-info div:nth-child(6) {
  animation-delay: 0.27s;
}

.country-info dt {
  margin-bottom: 6px;
  font-size: 0.79rem;
  line-height: 1.25;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: #64748b;
}

.country-info dd {
  margin: 0;
  font-size: clamp(1rem, 4.2vw, 1.14rem);
  font-weight: 800;
  line-height: 1.38;
  color: var(--text);
  overflow-wrap: anywhere;
}

.controls {
  position: sticky;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  grid-template-columns: 0.95fr 1.1fr 0.95fr;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 22px;
  background: rgba(241, 245, 249, 0.83);
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.controls button {
  min-height: 53px;
  padding: 10px 8px;
  border: 0;
  border-radius: 16px;
  font-size: 0.88rem;
  font-weight: 850;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

#previousButton {
  background: #e2e8f0;
  color: #1e293b;
}

#restartButton {
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.96);
  color: #334155;
}

#nextButton {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  box-shadow: 0 9px 22px rgba(79, 70, 229, 0.28);
}

.controls button:active,
.icon-button:active,
.country-card:active {
  transform: scale(0.975);
}

@keyframes premiumFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flagEnter {
  from {
    opacity: 0;
    transform: scale(0.965);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes infoRise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
    gap: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .country-card {
    min-height: 500px;
    padding: 17px;
    border-radius: 27px;
  }

  .card-view {
    min-height: 462px;
  }

  .flag-image {
    border-radius: 17px;
  }

  .country-info div {
    padding-left: 56px;
  }

  .controls {
    gap: 7px;
    padding: 7px;
  }

  .controls button {
    min-height: 50px;
    padding: 8px 5px;
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================================================
   PHASE 2.1 – LETZTER PREMIUM-FEINSCHLIFF
   ================================================== */

/* Größere Flagge als Hauptmotiv */
.flag-image {
  width: min(100%, 630px);
  max-height: 380px;
}

/* Deutscher und lettischer Ländername getrennt */
#infoCountryName {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}

.country-name-de {
  display: block;
  color: #0f172a;
  font-size: clamp(2.05rem, 8.5vw, 3.5rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.country-name-lv {
  display: block;
  color: #4f46e5;
  font-size: clamp(1.28rem, 5.2vw, 1.72rem);
  font-weight: 850;
  line-height: 1.15;
}

/* Fortschrittstext besser lesbar */
#progressText {
  display: flex;
  align-items: center;
  min-height: 24px;
  font-weight: 900;
}

/* Dezente individuelle Farbakzente der Infokarten */
.country-info div:nth-child(1) {
  border-left: 5px solid #d4a72c;
  background:
    linear-gradient(145deg, rgba(255, 252, 239, 0.98), rgba(248, 250, 252, 0.96));
}

.country-info div:nth-child(2) {
  border-left: 5px solid #3b82f6;
  background:
    linear-gradient(145deg, rgba(239, 246, 255, 0.98), rgba(248, 250, 252, 0.96));
}

.country-info div:nth-child(3) {
  border-left: 5px solid #22a06b;
  background:
    linear-gradient(145deg, rgba(239, 253, 246, 0.98), rgba(248, 250, 252, 0.96));
}

.country-info div:nth-child(4) {
  border-left: 5px solid #8b5cf6;
  background:
    linear-gradient(145deg, rgba(247, 243, 255, 0.98), rgba(248, 250, 252, 0.96));
}

.country-info div:nth-child(5) {
  border-left: 5px solid #f59e0b;
  background:
    linear-gradient(145deg, rgba(255, 248, 235, 0.98), rgba(248, 250, 252, 0.96));
}

.country-info div:nth-child(6) {
  border-left: 5px solid #eab308;
  background:
    linear-gradient(145deg, rgba(255, 253, 232, 0.98), rgba(248, 250, 252, 0.96));
}

/* Wechselanimation zum nächsten Land */
.country-card.slide-next {
  animation: countrySlideNext 0.34s ease both;
}

/* Wechselanimation zum vorherigen Land */
.country-card.slide-previous {
  animation: countrySlidePrevious 0.34s ease both;
}

@keyframes countrySlideNext {
  0% {
    opacity: 0.35;
    transform: translateX(24px) scale(0.985);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes countrySlidePrevious {
  0% {
    opacity: 0.35;
    transform: translateX(-24px) scale(0.985);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@media (max-width: 520px) {
  .flag-image {
    width: 100%;
    max-height: 355px;
  }

  .country-info div {
    border-left-width: 4px;
  }
}

/* ==================================================
   PHASE 3 – FLAGGENQUIZ
   ================================================== */

.topbar {
  position: relative;
}

.quiz-start-button {
  width: 54px;
  height: 54px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff, #eef2ff);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.13);
  font-size: 1.35rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s ease;
}

.quiz-start-button:active {
  transform: scale(0.96);
}

.quiz-open {
  overflow: hidden;
}

.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding:
    calc(14px + env(safe-area-inset-top))
    12px
    calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background:
    radial-gradient(circle at 10% 5%, rgba(79, 70, 229, 0.2), transparent 32%),
    radial-gradient(circle at 90% 10%, rgba(8, 145, 178, 0.16), transparent 28%),
    rgba(226, 232, 240, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: quizOverlayEnter 0.25s ease both;
}

.quiz-panel {
  width: min(100%, 700px);
  min-height: calc(100vh - 28px);
  margin: 0 auto;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 25px 65px rgba(15, 23, 42, 0.18);
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.quiz-header h2 {
  margin: 0;
  font-size: clamp(1.75rem, 7vw, 2.6rem);
}

.quiz-eyebrow {
  margin: 0 0 5px;
  color: #4f46e5;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.17em;
}

.quiz-subtitle {
  margin: 5px 0 0;
  color: #64748b;
  font-weight: 700;
}

.quiz-close-button {
  flex: 0 0 auto;
  width: 47px;
  height: 47px;
  border: 0;
  border-radius: 15px;
  background: #eef2f7;
  color: #334155;
  font-size: 1.25rem;
  font-weight: 900;
}

.quiz-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  font-size: 0.92rem;
  font-weight: 850;
}

.quiz-progress-track {
  height: 9px;
  overflow: hidden;
  margin-bottom: 20px;
  border-radius: 999px;
  background: #d9e1ec;
}

.quiz-progress-bar {
  width: 10%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f46e5, #0891b2);
  transition: width 0.3s ease;
}

.quiz-flag-card {
  min-height: 260px;
  padding: 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(203, 213, 225, 0.65);
  border-radius: 25px;
  background:
    radial-gradient(circle at 70% 10%, rgba(99, 102, 241, 0.08), transparent 34%),
    #f8fafc;
  box-shadow: 0 13px 34px rgba(15, 23, 42, 0.1);
}

.quiz-flag-card img {
  display: block;
  width: min(100%, 470px);
  max-height: 280px;
  object-fit: contain;
  border-radius: 17px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
  animation: quizFlagEnter 0.3s ease both;
}

.quiz-answers {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quiz-answer-button {
  min-height: 85px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border: 2px solid transparent;
  border-radius: 19px;
  background: #eef2f7;
  color: #0f172a;
  text-align: left;
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.075);
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    border-color 0.2s ease;
}

.quiz-answer-button:not(:disabled):active {
  transform: scale(0.975);
}

.quiz-answer-button.correct {
  border-color: #16a34a;
  background: #dcfce7;
}

.quiz-answer-button.wrong {
  border-color: #dc2626;
  background: #fee2e2;
}

.quiz-answer-de {
  font-size: 1.05rem;
  font-weight: 900;
}

.quiz-answer-lv {
  color: #4f46e5;
  font-size: 0.9rem;
  font-weight: 800;
}

.quiz-answer-button.correct .quiz-answer-lv,
.quiz-answer-button.wrong .quiz-answer-lv {
  color: inherit;
}

.quiz-feedback {
  min-height: 28px;
  margin: 17px 0 10px;
  text-align: center;
  font-weight: 900;
}

.quiz-feedback.correct {
  color: #15803d;
}

.quiz-feedback.wrong {
  color: #b91c1c;
}

.quiz-next-button {
  width: 100%;
  min-height: 55px;
  padding: 12px 18px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.26);
}

.quiz-result {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.quiz-result.hidden {
  display: none;
}

.quiz-trophy {
  margin-bottom: 18px;
  font-size: 5rem;
}

.quiz-result h2 {
  margin-bottom: 14px;
}

.quiz-result p {
  margin-bottom: 28px;
  color: #475569;
  font-size: 1.12rem;
  line-height: 1.6;
}

@keyframes quizOverlayEnter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes quizFlagEnter {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 520px) {
  .quiz-panel {
    padding: 16px;
    border-radius: 25px;
  }

  .quiz-flag-card {
    min-height: 230px;
    padding: 17px;
  }

  .quiz-answers {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .quiz-answer-button {
    min-height: 72px;
  }
}

/* ==================================================
   PHASE 5 – AUSKLAPPBARES LÄNDERWISSEN
   ================================================== */

.knowledge-section {
  width: 100%;
  margin-top: 17px;
}

.knowledge-toggle {
  width: 100%;
  min-height: 58px;
  padding: 13px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 18px;
  background:
    linear-gradient(
      145deg,
      rgba(238, 242, 255, 0.98),
      rgba(240, 249, 255, 0.96)
    );
  color: #3730a3;
  box-shadow:
    0 8px 22px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
  text-align: left;
  font-size: 0.96rem;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.knowledge-toggle:active {
  transform: scale(0.985);
}

#knowledgeArrow {
  flex: 0 0 auto;
  font-size: 1.45rem;
  line-height: 1;
}

.knowledge-content {
  margin-top: 13px;
  animation: knowledgeOpen 0.28s ease both;
}

.knowledge-info {
  margin-top: 0;
}

.knowledge-info div {
  padding-left: 17px;
}

.knowledge-info div::before {
  display: none;
}

.knowledge-info div:nth-child(1) {
  border-left: 5px solid #64748b;
  background:
    linear-gradient(
      145deg,
      rgba(241, 245, 249, 0.99),
      rgba(248, 250, 252, 0.97)
    );
}

.knowledge-info div:nth-child(2) {
  border-left: 5px solid #0ea5e9;
  background:
    linear-gradient(
      145deg,
      rgba(240, 249, 255, 0.99),
      rgba(248, 250, 252, 0.97)
    );
}

.knowledge-info div:nth-child(3) {
  border-left: 5px solid #ec4899;
  background:
    linear-gradient(
      145deg,
      rgba(253, 242, 248, 0.99),
      rgba(248, 250, 252, 0.97)
    );
}

.knowledge-info div:nth-child(4) {
  border-left: 5px solid #f97316;
  background:
    linear-gradient(
      145deg,
      rgba(255, 247, 237, 0.99),
      rgba(248, 250, 252, 0.97)
    );
}

.knowledge-info div:nth-child(5) {
  border-left: 5px solid #6366f1;
  background:
    linear-gradient(
      145deg,
      rgba(238, 242, 255, 0.99),
      rgba(248, 250, 252, 0.97)
    );
}

@keyframes knowledgeOpen {
  from {
    opacity: 0;
    transform: translateY(-7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .knowledge-toggle {
    min-height: 55px;
    padding: 12px 14px;
    font-size: 0.86rem;
  }

  .knowledge-info div {
    padding-left: 15px;
  }
}
