@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #040812;
  --panel-bg: rgba(10, 18, 36, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --panel-border-glow: rgba(0, 245, 212, 0.35);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #00f5d4;
  --accent-blue: #00b4d8;
  --accent-purple: #7b2cbf;
  --accent-gold: #ffd166;
  --accent-glow: 0 0 25px rgba(0, 245, 212, 0.4);
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-main);
  color: var(--text-primary);
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

#globe-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: grab;
  touch-action: none;
}

#globe-container canvas {
  display: block;
  touch-action: none;
}

#globe-container:active {
  cursor: grabbing;
}

/* Glassmorphism Common Style */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--panel-border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
}

/* Uniwersalne Menu Hamburger & Drawer dla wszystkich rozdzielczości */
.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 16px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  z-index: 100;
  cursor: pointer;
  border: 2px solid rgba(0, 245, 212, 0.4);
  background: rgba(10, 18, 36, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--accent-cyan);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 245, 212, 0.25);
  transition: var(--transition);
}

.mobile-menu-btn:hover {
  transform: scale(1.05);
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 245, 212, 0.4);
}

.mobile-menu-btn:active {
  transform: scale(0.94);
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

.mobile-menu-btn .icon-close {
  display: none;
}

body.mobile-menu-open .mobile-menu-btn .icon-hamburger {
  display: none;
}

body.mobile-menu-open .mobile-menu-btn .icon-close {
  display: block;
  color: #ffffff;
}

/* Przycisk Quiz umieszczony pod menu hamburger */
.btn-quiz {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 76px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  z-index: 100;
  cursor: pointer;
  border: 2px solid rgba(255, 209, 102, 0.45);
  background: rgba(10, 18, 36, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--accent-gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(255, 209, 102, 0.25);
  transition: var(--transition);
  padding: 0;
}

.btn-quiz:hover {
  transform: scale(1.05);
  border-color: var(--accent-gold);
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7), 0 0 25px rgba(255, 209, 102, 0.5);
}

.btn-quiz:active {
  transform: scale(0.94);
}

.btn-quiz svg {
  width: 20px;
  height: 20px;
}

.btn-quiz .quiz-btn-label {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}

.btn-quiz.active {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.25), rgba(247, 127, 0, 0.25));
  border-color: #ffd166;
  color: #ffffff;
  box-shadow: 0 0 25px rgba(255, 209, 102, 0.7);
  animation: pulse-quiz 1.5s infinite ease-in-out;
}

@keyframes pulse-quiz {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 209, 102, 0.4); }
  50% { box-shadow: 0 0 35px rgba(255, 209, 102, 0.9); }
}

/* Baner Quizu z aktualnym zadaniem */
.quiz-banner {
  position: fixed;
  top: 76px;
  left: 16px;
  transform: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 18px;
  border-radius: 30px;
  z-index: 92;
  background: rgba(8, 14, 28, 0.92);
  border: 2px solid var(--accent-gold);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 25px rgba(255, 209, 102, 0.3);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  max-width: calc(100vw - 84px);
  transition: all 0.3s ease;
}

.quiz-banner.hidden {
  display: none !important;
}

.quiz-info {
  display: flex;
  align-items: center;
  font-size: 1.1rem;
}

.quiz-target-name {
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.6);
}

.quiz-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
}

.quiz-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Przezroczysta strefa zamykania menu poza panelem bocznym (bez przyciemniania globusa) */
.mobile-drawer-backdrop {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
}

body.mobile-menu-open .mobile-drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Uniwersalna boczna szuflada z opcjami i danymi o państwach */
#mobile-drawer {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 92vw);
  height: 100vh;
  background: rgba(8, 14, 28, 0.94);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.85);
  z-index: 95;
  padding: 82px 20px 36px;
  overflow-y: auto;
  gap: 16px;
  transform: translateX(110%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

body.mobile-menu-open #mobile-drawer {
  transform: translateX(0);
}

/* 1. Okno Brand (Logo) wewnątrz szuflady */
.brand {
  width: 100%;
  padding: 14px 20px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(0, 245, 212, 0.5);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  color: #040812;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(0, 245, 212, 0.18);
  border: 1px solid rgba(0, 245, 212, 0.4);
  color: var(--accent-cyan);
  border-radius: 20px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* 2. Okno Toolbar (Narzędzia) wewnątrz szuflady */
.toolbar-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
  padding: 16px;
  border-radius: 20px;
}

.tool-btn {
  width: 100%;
  font-size: 1.15rem;
  padding: 12px 18px;
  justify-content: flex-start;
  gap: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: var(--transition);
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.tool-btn.active {
  background: rgba(0, 245, 212, 0.18);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 245, 212, 0.35);
}

.tool-btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.lang-selector {
  width: 100%;
  padding: 4px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
}

.lang-selector select {
  font-size: 1.1rem;
  height: 44px;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-weight: 600;
  cursor: pointer;
}

.lang-selector select option {
  background: #0d1b2a;
  color: #ffffff;
}

/* 3. Panel Szczegółów Kraju wewnątrz szuflady */
.country-panel {
  position: static;
  transform: none;
  opacity: 1;
  width: 100%;
  max-width: 100%;
  max-height: none;
  padding: 22px 20px;
  gap: 18px;
  border-radius: 20px;
  box-shadow: none;
  transition: none;
  display: flex;
  flex-direction: column;
}

.country-panel.hidden {
  display: none !important;
}

.panel-close-btn {
  display: none;
}

.country-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-right: 0;
}

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

.country-name-pl {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.15;
}

.country-name-en {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
}

.country-region-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
}

.country-region-tag svg {
  width: 18px;
  height: 18px;
}

/* Przyciski mowy i nawigacji */
.voice-action-box {
  display: flex;
  gap: 12px;
}

.btn-speak {
  width: 54px;
  height: 54px;
  min-height: 54px;
  flex: 0 0 54px;
  background: linear-gradient(135deg, rgba(0, 245, 212, 0.2), rgba(0, 180, 216, 0.2));
  border: 2px solid var(--accent-cyan);
  color: #ffffff;
  border-radius: 16px;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 0 20px rgba(0, 245, 212, 0.3);
}

.btn-speak svg {
  width: 24px;
  height: 24px;
}

.btn-speak:hover {
  background: linear-gradient(135deg, rgba(0, 245, 212, 0.3), rgba(0, 180, 216, 0.3));
  box-shadow: 0 0 30px rgba(0, 245, 212, 0.45);
  transform: translateY(-2px);
}

.btn-speak:active {
  transform: translateY(0);
}

.btn-speak.speaking {
  animation: pulse-speak 1.2s infinite ease-in-out;
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(255, 209, 102, 0.2);
}

@keyframes pulse-speak {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 209, 102, 0.4); }
  50% { box-shadow: 0 0 35px rgba(255, 209, 102, 0.9); }
}

.btn-locate {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  border-radius: 16px;
  width: 54px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-locate svg {
  width: 22px;
  height: 22px;
}

.btn-locate:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Statystyki kraju */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #ffffff;
  line-height: 1.15;
}

/* Ciekawostka o kraju */
.fact-section {
  background: linear-gradient(145deg, rgba(255, 209, 102, 0.06), rgba(123, 44, 191, 0.06));
  border: 2px solid rgba(255, 209, 102, 0.25);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fact-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-gold);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fact-title-box svg {
  width: 20px;
  height: 20px;
}

.fact-text {
  font-size: 1.1rem;
  line-height: 1.55;
  color: #e2e8f0;
  font-weight: 400;
}

/* Header & Górny Pasek Wyszukiwarki */
.top-nav {
  position: fixed;
  top: 16px;
  left: 16px;
  width: min(460px, calc(100vw - 84px));
  display: flex;
  justify-content: flex-start;
  align-items: center;
  z-index: 50;
  pointer-events: none;
}

.search-wrapper {
  pointer-events: auto;
  position: relative;
  width: 100%;
}

.search-input-container {
  display: flex;
  align-items: center;
  padding: 0 18px;
  min-height: 52px;
  height: 52px;
  gap: 12px;
  border-radius: 30px;
  border-width: 2px;
  transition: var(--transition);
}

.search-input-container:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 25px rgba(0, 245, 212, 0.4);
}

.search-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

#country-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 500;
  color: #ffffff;
}

#country-search::placeholder {
  color: var(--text-muted);
}

.search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  padding: 6px;
  font-size: 1.1rem;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 10px;
  border-radius: 20px;
  z-index: 50;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.search-result-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: #ffffff;
}

.search-result-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
}


/* Ekran ładowania */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-spinner {
  width: 60px;
  height: 60px;
  border: 3px solid rgba(0, 245, 212, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  margin-top: 20px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.loader-subtext {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Pasek przewijania */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Dostosowanie dla wąskich ekranów telefonów */
@media (max-width: 480px) {
  .top-nav {
    top: 12px;
    left: 12px;
    right: 68px;
    width: auto;
    max-width: none;
  }

  .search-input-container {
    height: 46px;
    min-height: 46px;
    padding: 0 14px;
    gap: 8px;
  }

  .search-icon {
    width: 18px;
    height: 18px;
  }

  #country-search {
    font-size: 0.95rem;
  }

  .mobile-menu-btn {
    top: 12px;
    right: 12px;
    width: 46px;
    height: 46px;
  }

  .mobile-menu-btn svg {
    width: 22px;
    height: 22px;
  }

  .btn-quiz {
    top: 66px;
    right: 12px;
    width: 46px;
    height: 46px;
  }

  .btn-quiz svg {
    width: 18px;
    height: 18px;
  }

  .btn-quiz .quiz-btn-label {
    font-size: 0.55rem;
  }

  .quiz-banner {
    top: 66px;
    left: 12px;
    right: 68px;
    max-width: none;
    height: 46px;
    min-height: 46px;
    padding: 0 14px;
    gap: 8px;
  }

  .quiz-info {
    font-size: 0.95rem;
  }

  .quiz-target-name {
    font-size: 1.1rem;
  }

  #mobile-drawer {
    width: 100vw;
    padding: 72px 16px 28px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
