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

html {
  background: #0f172a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%) fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #e2e8f0;
  overflow-y: auto;
  overscroll-behavior: none;
}

.container {
  width: 100%;
  max-width: 460px;
  margin: 40px 20px;
  position: relative;
  z-index: 1;
}

#contact {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(255,255,255,0.05) inset;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.logo-wrap {
  text-align: center;
  margin: 0 auto 12px;
  cursor: pointer;
  transition: transform 0.3s ease;
}
.logo-wrap:hover { transform: scale(1.05); }
.logo-svg {
  width: 130px;
  height: 130px;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.4));
}

fieldset {
  border: none;
  margin: 0 0 8px;
  padding: 0;
  width: 100%;
}

.autocomplete { position: relative; display: block; width: 100%; }

#contact input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: #f1f5f9;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
#contact input[type="text"]::placeholder { color: rgba(255,255,255,0.4); }
#contact input[type="text"]:focus {
  border-color: rgba(99,179,237,0.6);
  background: rgba(255,255,255,0.12);
}

#contact button[type="submit"] {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.5px;
}
#contact button[type="submit"]:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}
#contact button[type="submit"]:active { transform: scale(0.98); }

/* Legend (inside modal) */
.legend-modal {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot-navy   { background: #003399; }
.legend-dot-blue   { background: #0064c8; }
.legend-dot-green  { background: #008000; }
.legend-dot-orange { background: #c87800; }
.legend-dot-red    { background: #b40000; }
.legend-dot-black  { background: #500000; }
.legend-icon { font-size: 14px; }
.legend-label { font-size: 13px; font-weight: 600; }
.legend-desc { font-size: 12px; color: rgba(255,255,255,0.45); }

/* Results */
.result-box {
  margin-top: 20px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  line-height: 1.6;
}
.result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.result-icon {
  font-size: 28px;
  line-height: 1;
}
.result-label {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.result-box .result-countries {
  font-size: 15px;
  opacity: 0.8;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}
.result-box .result-text {
  font-size: 14px;
  line-height: 1.7;
  opacity: 0.85;
}

/* Falling flags */
#flag-rain {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.falling-flag {
  position: absolute;
  top: -40px;
  animation: flagFall linear infinite;
  will-change: transform;
}
@keyframes flagFall {
  0%   { transform: translateY(0)     translateX(0); }
  25%  { transform: translateY(25vh)  translateX(12px); }
  50%  { transform: translateY(50vh)  translateX(-8px); }
  75%  { transform: translateY(75vh)  translateX(10px); }
  100% { transform: translateY(110vh) translateX(0); }
}

/* Colour-coded result backgrounds */
.result-navy   { background: rgba(0,0,128,0.25); border-color: rgba(0,51,153,0.4); }
.result-blue   { background: rgba(0,100,200,0.2); border-color: rgba(0,100,200,0.35); }
.result-green  { background: rgba(0,128,0,0.2); border-color: rgba(0,128,0,0.35); }
.result-orange { background: rgba(200,120,0,0.2); border-color: rgba(200,120,0,0.35); }
.result-red    { background: rgba(180,0,0,0.2); border-color: rgba(180,0,0,0.35); }
.result-black  { background: rgba(80,0,0,0.25); border-color: rgba(120,0,0,0.4); }

/* Autocomplete dropdown */
.autocomplete-items {
  position: absolute;
  border-radius: 0 0 12px 12px;
  z-index: 99;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.autocomplete-items div {
  padding: 10px 16px;
  cursor: pointer;
  background: rgba(30,45,75,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #e2e8f0;
  font-size: 14px;
}
.autocomplete-items div:hover { background: rgba(37,99,235,0.4); }
.autocomplete-items div:last-child { border-radius: 0 0 12px 12px; }
.autocomplete-active { background: rgba(37,99,235,0.6) !important; color: #fff; }

/* Spinner */
.lds-ring {
  display: none;
  margin: 20px auto 0;
  width: 36px;
  height: 36px;
  position: relative;
}
.lds-ring div {
  box-sizing: border-box;
  display: block;
  position: absolute;
  width: 32px;
  height: 32px;
  margin: 2px;
  border: 3px solid rgba(99,179,237,0.8);
  border-radius: 50%;
  animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  border-color: rgba(99,179,237,0.8) transparent transparent transparent;
}
.lds-ring div:nth-child(1) { animation-delay: -0.45s; }
.lds-ring div:nth-child(2) { animation-delay: -0.3s; }
.lds-ring div:nth-child(3) { animation-delay: -0.15s; }
@keyframes lds-ring {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.modal-content {
  background: #1e293b;
  color: #e2e8f0;
  margin: 8% auto;
  padding: 28px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  overflow-y: auto;
  max-height: 80vh;
  width: 90%;
  max-width: 500px;
  font-size: 15px;
  line-height: 1.7;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
}
.modal-content::after {
  content: '';
  display: table;
  clear: both;
}
.modal-content b { color: #93c5fd; }
.close {
  color: rgba(255,255,255,0.5);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}
.close:hover { color: #fff; }
.left {
  height: 120px;
  float: left;
  padding: 0 14px 10px 0;
  border-radius: 8px;
}

/* Dark mode toggle — hidden since we're always dark now */
html body label { display: none; }

/* Mobile */
@media (max-width: 500px) {
  .container { margin: 20px 16px; }
  #contact { padding: 28px 20px; }
  .logo { height: 100px; }
}
