/* ===== RESET & ROOT ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-bg:      #0a0a14;
  --clr-surface: rgba(255,255,255,0.05);
  --clr-glass:   rgba(255,255,255,0.08);
  --clr-border:  rgba(255,255,255,0.1);
  --clr-accent1: #7c3aed;   /* violet */
  --clr-accent2: #06b6d4;   /* cyan   */
  --clr-accent3: #f59e0b;   /* amber  */
  --clr-green:   #10b981;
  --clr-red:     #ef4444;
  --clr-text:    #f1f5f9;
  --clr-muted:   #94a3b8;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --shadow-glow: 0 0 40px rgba(124,58,237,0.35);
  --fnt: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--fnt);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== PARTICLES ===== */
.particles {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.particle {
  position: absolute;
  border-radius: 50%;
  animation: floatUp linear infinite;
  opacity: 0;
}
@keyframes floatUp {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ===== APP LAYOUT ===== */
.app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--clr-glass);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: 18px 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.stats-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.reset-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-reset {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--clr-muted);
  font-size: 0.78rem;
  padding: 7px 14px;
  border-radius: 10px;
  gap: 5px;
  transition: var(--transition);
}
.btn-reset:hover {
  background: rgba(239,68,68,0.15);
  border-color: var(--clr-red);
  color: var(--clr-red);
  transform: translateY(-1px);
}
.btn-reset .btn-icon { font-size: 0.85rem; }

.btn-list {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--clr-muted);
  font-size: 0.78rem;
  padding: 7px 14px;
  border-radius: 10px;
  gap: 5px;
  transition: var(--transition);
}
.btn-list:hover {
  background: rgba(6,182,212,0.15);
  border-color: var(--clr-accent2);
  color: var(--clr-accent2);
  transform: translateY(-1px);
}
.btn-list .btn-icon { font-size: 0.85rem; }

.reload-note {
  font-size: 0.68rem;
  color: var(--clr-muted);
  opacity: 0.7;
  white-space: nowrap;
}

.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon {
  font-size: 2.4rem;
  animation: spin3d 8s linear infinite;
  display: inline-block;
}
@keyframes spin3d {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}
.logo h1 {
  font-size: 1.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--clr-accent2), var(--clr-accent1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.tagline { font-size: 0.75rem; color: var(--clr-muted); margin-top: 2px; }

.stats-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--clr-accent2);
  line-height: 1;
  transition: var(--transition);
}
.stat-label { font-size: 0.65rem; color: var(--clr-muted); margin-top: 2px; }
.stat-divider {
  width: 1px; height: 36px;
  background: var(--clr-border);
}

/* ===== SLOT MACHINE ===== */
.slot-machine {
  position: relative;
  border-radius: var(--radius-xl);
  padding: 6px;
  background: linear-gradient(135deg, var(--clr-accent1), var(--clr-accent2), var(--clr-accent3));
  box-shadow: var(--shadow-glow), 0 20px 60px rgba(0,0,0,0.5);
}
.slot-glow {
  position: absolute; inset: -2px;
  border-radius: calc(var(--radius-xl) + 4px);
  background: linear-gradient(135deg, var(--clr-accent1), var(--clr-accent2), var(--clr-accent3));
  filter: blur(16px);
  opacity: 0.5;
  z-index: -1;
  animation: glowPulse 2s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 0.8; transform: scale(1.02); }
}

.slot-window {
  background: #0f0f1e;
  border-radius: calc(var(--radius-xl) - 4px);
  height: 220px;
  overflow: hidden;
  position: relative;
}

.slot-track {
  display: flex;
  flex-direction: column;
  will-change: transform;
  /* JS controls translateY */
}

.slot-item {
  flex-shrink: 0;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot-item img {
  width: 280px;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  user-select: none;
  -webkit-user-drag: none;
}

.slot-shine {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius-xl) - 4px);
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.12) 0%,
    transparent 40%,
    transparent 60%,
    rgba(0,0,0,0.3) 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* ===== SPEED BAR ===== */
.speed-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
  opacity: 0;
  transform: translateY(-8px);
  transition: var(--transition);
}
.speed-bar-wrap.visible {
  opacity: 1;
  transform: translateY(0);
}
.speed-label { font-size: 0.7rem; color: var(--clr-muted); white-space: nowrap; }
.speed-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
}
.speed-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--clr-accent2), var(--clr-accent1));
  transform-origin: left;
  transition: transform 0.1s linear;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  gap: 14px;
  justify-content: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--fnt);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  padding: 14px 28px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.96); }
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon { font-size: 1.1rem; }

.btn-spin {
  flex: 1;
  background: linear-gradient(135deg, var(--clr-accent1), #9f67ff);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124,58,237,0.5);
}
.btn-spin:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124,58,237,0.7);
}

.btn-stop {
  flex: 1;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  box-shadow: 0 4px 20px rgba(244,63,94,0.5);
  animation: none;
}
.btn-stop:not(:disabled) {
  animation: pulseStop 1s ease-in-out infinite;
}
.btn-stop:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(244,63,94,0.7);
}
@keyframes pulseStop {
  0%, 100% { box-shadow: 0 4px 20px rgba(244,63,94,0.5); }
  50%       { box-shadow: 0 4px 32px rgba(244,63,94,0.9); }
}

.btn-show {
  background: linear-gradient(135deg, var(--clr-accent3), #d97706);
  color: #1a0000;
  font-weight: 900;
  box-shadow: 0 4px 20px rgba(245,158,11,0.4);
}
.btn-show:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(245,158,11,0.6);
}

.btn-correct {
  background: linear-gradient(135deg, var(--clr-green), #059669);
  color: #fff;
  box-shadow: 0 4px 20px rgba(16,185,129,0.4);
}
.btn-correct:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(16,185,129,0.6);
}

.btn-wrong {
  background: linear-gradient(135deg, var(--clr-red), #b91c1c);
  color: #fff;
  box-shadow: 0 4px 20px rgba(239,68,68,0.4);
}
.btn-wrong:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(239,68,68,0.6);
}

/* ===== ANSWER CARD ===== */
.answer-card {
  background: var(--clr-glass);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.4,0,0.2,1),
              transform 0.5s cubic-bezier(0.4,0,0.2,1);
}
.answer-card.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.current-flag-wrap {
  position: relative;
  display: inline-block;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}
.current-flag {
  display: block;
  width: 280px;
  height: 175px;
  object-fit: cover;
  border-radius: 16px;
}
.flag-shine {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}

.guess-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.guess-prompt {
  font-size: 1rem;
  color: var(--clr-muted);
  font-weight: 400;
}

.answer-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 60px;
}
.country-name {
  font-size: 1.9rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--clr-accent2), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.country-name.show {
  opacity: 1;
  transform: translateY(0);
}
.country-code {
  font-size: 0.8rem;
  color: var(--clr-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.5s ease 0.15s;
}
.country-code.show { opacity: 1; }

.action-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(20,20,40,0.95);
  border: 1px solid var(--clr-border);
  border-radius: 14px;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--clr-text);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.4s;
  opacity: 0;
  z-index: 100;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .header { flex-direction: column; align-items: flex-start; }
  .slot-item img { width: 220px; height: 140px; }
  .slot-window { height: 170px; }
  .slot-item { height: 170px; }
  .current-flag { width: 220px; height: 138px; }
  .country-name { font-size: 1.4rem; }
  .btn { padding: 13px 18px; font-size: 0.85rem; }
}

/* ===== UTILITY ANIMATIONS ===== */
@keyframes bounceIn {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 16px 0 4px;
  font-size: 0.78rem;
  color: var(--clr-muted);
  opacity: 0.6;
  letter-spacing: 0.03em;
}
.footer-name {
  font-weight: 700;
  background: linear-gradient(135deg, var(--clr-accent2), var(--clr-accent1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== LOADER OVERLAY ===== */
.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--clr-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}
.loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--clr-glass);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: 40px 48px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-glow), 0 32px 80px rgba(0,0,0,0.6);
  text-align: center;
  max-width: 400px;
  width: 90vw;
}

.loader-globe {
  font-size: 3.5rem;
  animation: spin3d 3s linear infinite;
  display: inline-block;
  line-height: 1;
}

.loader-title {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--clr-accent2), var(--clr-accent1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loader-sub {
  font-size: 0.82rem;
  color: var(--clr-muted);
  min-height: 1.2em;
  transition: color 0.3s;
}

.loader-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
}
.loader-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--clr-accent1), var(--clr-accent2), var(--clr-accent3));
  background-size: 200% 100%;
  transition: width 0.2s ease;
  animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loader-count {
  font-size: 0.78rem;
  color: var(--clr-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* mini flag strip shown during loading */
.loader-preview {
  display: flex;
  gap: 6px;
  overflow: hidden;
  height: 36px;
  width: 100%;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
}
.loader-preview img {
  height: 36px;
  width: 56px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  animation: popIn 0.3s cubic-bezier(0.4,0,0.2,1) both;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ===== COUNTRY LIST MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5, 5, 15, 0.80);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4,0,0.2,1),
              visibility 0.35s;
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.modal-card {
  background: #12121f;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 32px 90px rgba(0,0,0,0.7), var(--shadow-glow);
  transform: translateY(24px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}
.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

/* Modal header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}
.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-icon { font-size: 1.8rem; line-height: 1; }
.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--clr-accent2), var(--clr-accent1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}
.modal-total {
  font-size: 0.72rem;
  color: var(--clr-muted);
  margin: 2px 0 0;
}

.modal-close {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--clr-border);
  color: var(--clr-muted);
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  line-height: 1;
  font-family: var(--fnt);
}
.modal-close:hover {
  background: rgba(239,68,68,0.2);
  border-color: var(--clr-red);
  color: var(--clr-red);
  transform: rotate(90deg);
}

/* Search bar */
.modal-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
  position: relative;
}
.search-icon { font-size: 1rem; flex-shrink: 0; }
.modal-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--fnt);
  font-size: 0.95rem;
  color: var(--clr-text);
  caret-color: var(--clr-accent2);
}
.modal-search::placeholder { color: var(--clr-muted); opacity: 0.6; }
.search-clear {
  background: none;
  border: none;
  color: var(--clr-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: var(--transition);
  font-family: var(--fnt);
}
.search-clear:hover { color: var(--clr-red); }

/* Grid */
.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}
.modal-grid::-webkit-scrollbar { width: 6px; }
.modal-grid::-webkit-scrollbar-track { background: transparent; }
.modal-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
}
.modal-grid::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Country card */
.country-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: 14px;
  padding: 12px 8px;
  cursor: default;
  transition: var(--transition);
  animation: fadein 0.25s ease both;
}
.country-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(6,182,212,0.4);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.country-card img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  display: block;
}
.country-card-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--clr-text);
  text-align: center;
  line-height: 1.3;
}
.country-card-code {
  font-size: 0.6rem;
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Empty state */
.modal-empty {
  text-align: center;
  color: var(--clr-muted);
  padding: 40px 20px;
  font-size: 0.95rem;
}

/* Responsive modal */
@media (max-width: 480px) {
  .modal-card { max-height: 94vh; }
  .modal-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .country-card img { height: 56px; }
}


