/* ═══════════════════════════════════════════════════════════════════════════
   APP WEBVIEW — Instant hide of intro + game-over modal
   html.app-client is set by the inline <script> in <head> as the VERY FIRST
   thing that runs, from URL params (?in_app=app / ?client=android / ios).
   This CSS fires before any render, eliminating any flash of these elements.
   ═══════════════════════════════════════════════════════════════════════════ */
html.app-client #introScreen,
html.app-client #gameOverModal {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ===== CSS Reset & Base Styles ===== */

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

:root {
  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Default Theme Colors (Cyan/Turquoise) */
  --theme-primary: #78f2ff;
  --theme-secondary: #4fd1c5;
  --theme-accent: #38b2ac;
  --theme-dark: #0c5e98;
  --theme-light: #b2f5ea;
  --theme-bg: #e6fffa;
  --theme-gradient-start: #78f2ff;
  --theme-gradient-end: #ffffff;

  --cell-bg: #fff4e6;
  --cell-border: #ffe4c4;
  --cell-text: #1a202c;

  --word-pending-bg: #0c5e98;
  --word-pending-border: #1e6fa9;
  --word-pending-text: #ffffff;
  --word-found-bg: #6b6b6b;
  --word-found-border: #626262;
  --word-found-text: #ffffff;

  --nav-btn-bg: rgba(255, 255, 255, 0.35);
  --nav-btn-color: #0c5e98;
  --nav-btn-hover-bg: rgba(255, 255, 255, 0.5);

  --header-bg-start: #e6fffa;
  --header-bg-end: #d4fafe;
  --header-border: #76f1ff;
  --header-text: #0c5e98;

  --title-color: #0c5e98;
  --icon-color: #0c5e98;

  --success-color: #48bb78;
  --success-light: #9ae6b4;

  --text-dark: #1a202c;
  --text-medium: #4a5568;
  --text-light: #718096;
  --white: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-strong: rgba(0, 0, 0, 0.2);
}

/* Sunset Theme (Red) */
body.theme-sunset {
  --theme-primary: #e31e25;
  --theme-secondary: #ff4757;
  --theme-accent: #c6181d;
  --theme-dark: #8b0000;
  --theme-light: #ffb3b8;
  --theme-bg: #ffe5e7;
  --theme-gradient-start: #e31e25;
  --theme-gradient-end: #ffffff;

  --cell-bg: #ffe5e7;
  --cell-border: #ffb3b8;
  --cell-text: #8b0000;

  --word-pending-bg: #ff4757;
  --word-pending-border: #c6181d;
  --word-pending-text: #ffffff;
  --word-found-bg: #8b0000;
  --word-found-border: #6b0000;
  --word-found-text: #ffffff;

  --nav-btn-bg: rgba(255, 255, 255, 0.4);
  --nav-btn-color: #ffffff;
  --nav-btn-hover-bg: rgba(255, 255, 255, 0.6);

  --header-bg-start: rgba(255, 255, 255, 0.3);
  --header-bg-end: rgba(255, 255, 255, 0.1);
  --header-border: rgba(255, 255, 255, 0.4);
  --header-text: #ffffff;

  --title-color: #ffffff;
  --icon-color: #ffffff;
}

/* Ocean Theme (Blue) */
body.theme-ocean {
  --theme-primary: #a1c4fd;
  --theme-secondary: #4299e1;
  --theme-accent: #2c5282;
  --theme-dark: #1a365d;
  --theme-light: #bee3f8;
  --theme-bg: #ebf8ff;
  --theme-gradient-start: #a1c4fd;
  --theme-gradient-end: #ffffff;

  --cell-bg: #ebf8ff;
  --cell-border: #bee3f8;
  --cell-text: #1a365d;

  --word-pending-bg: #4299e1;
  --word-pending-border: #2c5282;
  --word-pending-text: #ffffff;
  --word-found-bg: #1a365d;
  --word-found-border: #0f2847;
  --word-found-text: #ffffff;

  --nav-btn-bg: rgba(255, 255, 255, 0.35);
  --nav-btn-color: #1a365d;
  --nav-btn-hover-bg: rgba(255, 255, 255, 0.5);

  --header-bg-start: rgba(255, 255, 255, 0.4);
  --header-bg-end: rgba(255, 255, 255, 0.2);
  --header-border: rgba(161, 196, 253, 0.6);
  --header-text: #1a365d;

  --title-color: #1a365d;
  --icon-color: #2c5282;
}

/* Forest Theme (Green) */
body.theme-forest {
  --theme-primary: #d4fc79;
  --theme-secondary: #48bb78;
  --theme-accent: #2f855a;
  --theme-dark: #22543d;
  --theme-light: #c6f6d5;
  --theme-bg: #f0fff4;
  --theme-gradient-start: #d4fc79;
  --theme-gradient-end: #ffffff;

  --cell-bg: #f0fff4;
  --cell-border: #c6f6d5;
  --cell-text: #22543d;

  --word-pending-bg: #48bb78;
  --word-pending-border: #2f855a;
  --word-pending-text: #ffffff;
  --word-found-bg: #22543d;
  --word-found-border: #1a3a2e;
  --word-found-text: #ffffff;

  --nav-btn-bg: rgba(255, 255, 255, 0.35);
  --nav-btn-color: #22543d;
  --nav-btn-hover-bg: rgba(255, 255, 255, 0.5);

  --header-bg-start: rgba(255, 255, 255, 0.4);
  --header-bg-end: rgba(255, 255, 255, 0.2);
  --header-border: rgba(150, 230, 161, 0.6);
  --header-text: #22543d;

  --title-color: #22543d;
  --icon-color: #2f855a;
}

/* Royal Theme (Purple) */
body.theme-royal {
  --theme-primary: #667eea;
  --theme-secondary: #764ba2;
  --theme-accent: #553c9a;
  --theme-dark: #44337a;
  --theme-light: #d6bcfa;
  --theme-bg: #faf5ff;
  --theme-gradient-start: #667eea;
  --theme-gradient-end: #ffffff;

  --cell-bg: #faf5ff;
  --cell-border: #d6bcfa;
  --cell-text: #44337a;

  --word-pending-bg: #764ba2;
  --word-pending-border: #553c9a;
  --word-pending-text: #ffffff;
  --word-found-bg: #44337a;
  --word-found-border: #322659;
  --word-found-text: #ffffff;

  --nav-btn-bg: rgba(255, 255, 255, 0.4);
  --nav-btn-color: #ffffff;
  --nav-btn-hover-bg: rgba(255, 255, 255, 0.6);

  --header-bg-start: rgba(255, 255, 255, 0.3);
  --header-bg-end: rgba(255, 255, 255, 0.1);
  --header-border: rgba(255, 255, 255, 0.4);
  --header-text: #ffffff;

  --title-color: #ffffff;
  --icon-color: #ffffff;
}

/* Gold Theme (Orange/Yellow) */
body.theme-gold {
  --theme-primary: #f6d365;
  --theme-secondary: #fda085;
  --theme-accent: #f77f00;
  --theme-dark: #d62828;
  --theme-light: #ffeaa7;
  --theme-bg: #fffbeb;
  --theme-gradient-start: #f6d365;
  --theme-gradient-end: #ffffff;

  --cell-bg: #fffbeb;
  --cell-border: #ffeaa7;
  --cell-text: #d62828;

  --word-pending-bg: #fda085;
  --word-pending-border: #f77f00;
  --word-pending-text: #ffffff;
  --word-found-bg: #d62828;
  --word-found-border: #a81f1f;
  --word-found-text: #ffffff;

  --nav-btn-bg: rgba(255, 255, 255, 0.35);
  --nav-btn-color: #d62828;
  --nav-btn-hover-bg: rgba(255, 255, 255, 0.5);

  --header-bg-start: rgba(255, 255, 255, 0.4);
  --header-bg-end: rgba(255, 255, 255, 0.2);
  --header-border: rgba(253, 160, 133, 0.6);
  --header-text: #d62828;

  --title-color: #d62828;
  --icon-color: #f77f00;
}

body {
  font-family:
    "Poppins",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  min-height: 100vh;
  padding: var(--spacing-md);
  color: var(--text-dark);
  overflow-x: hidden;
}

body::after {
  content: " ";
  width: 100%;
  height: 300px;
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  background: linear-gradient(
    180deg,
    var(--theme-gradient-start) 0%,
    var(--theme-gradient-end) 100%
  );
}

.main_container {
  max-width: 460px;
  margin: auto;
}

/* ===== Top Navigation Bar ===== */
.top-nav {
  max-width: 1200px;
  /* margin: 0 auto var(--spacing-md); */
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* padding: var(--spacing-sm) 0; */
}

.game-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--title-color);
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  margin: 0;
  letter-spacing: 1px;
}

.nav-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--nav-btn-bg);
  backdrop-filter: blur(10px);
  border: 0px solid rgba(255, 255, 255, 0.3);
  color: var(--nav-btn-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-medium);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-btn:hover {
  background: var(--nav-btn-hover-bg);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.nav-btn:active {
  transform: scale(0.95);
}

/* ===== Dropdown Menu ===== */
.menu-container {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 70px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-medium);
  z-index: 1000;
  padding: 8px;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-icon-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--nav-btn-bg);
  backdrop-filter: blur(10px);
  border: 0px solid rgba(255, 255, 255, 0.3);
  color: var(--nav-btn-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-medium);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.dropdown-icon-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.dropdown-icon-btn:active {
  transform: scale(0.95);
}

.dropdown-icon-btn svg {
  flex-shrink: 0;
}

/* Ensure SVG icons use theme colors - darker shade for better contrast */
.nav-btn svg,
.dropdown-icon-btn svg {
  color: var(--theme-dark);
}

.nav-btn svg path,
.nav-btn svg circle,
.dropdown-icon-btn svg path,
.dropdown-icon-btn svg circle {
  stroke: var(--theme-dark);
  /* fill: var(--theme-dark); */
}

/* Settings icon - also use theme dark color */
#settingsMenuItem svg path {
  stroke: var(--theme-dark);
}

#settingsMenuItem svg rect {
  stroke: transparent;
}

/* ===== Leaderboard Section ===== */
.leaderboard-container {
  max-width: 1200px;
  margin: 0 auto 100px;
}

.leaderboard {
  background: transparent;
  border-radius: 0;
  padding: var(--spacing-xl) var(--spacing-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-xs);
  position: relative;
  animation: slideDown 0.6s ease;
  max-width: 1000px;
  margin: 0 auto;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.leader-item {
  /* display: flex; */
  flex-direction: row;
  align-items: center;
  gap: var(--spacing-sm);
  position: relative;
  z-index: 2;
}

.leader-item.left {
  flex-shrink: 0;
}

.leader-item.right {
  flex-shrink: 0;
  flex-direction: row-reverse;
}

.leader-item.center {
  flex-shrink: 0;
  flex-direction: column;
  gap: 0;
}

.rank-badge {
  background: var(--white);
  color: var(--text-dark);
  font-weight: 800;
  font-size: 1.8rem;
  padding: 12px 20px;
  border-radius: 50px;
  box-shadow: 0 4px 15px var(--shadow);
  min-width: auto;
  text-align: center;
  white-space: nowrap;
}

.avatar {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  overflow: visible;
  border: 5px solid var(--white);
  box-shadow: 0 8px 25px var(--shadow-strong);
  transition: transform var(--transition-medium);
  position: relative;
}

.avatar:hover {
  transform: scale(1.05);
}

.avatar.current-user {
  width: 120px;
  height: 120px;
  border: 6px solid var(--white);
  box-shadow: 0 10px 35px var(--shadow-strong);
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.score-badge {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(
    135deg,
    var(--success-color) 0%,
    var(--success-light) 100%
  );
  color: var(--white);
  padding: 6px 12px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 4px 15px rgba(72, 187, 120, 0.5);
  animation: bounceIn 0.6s ease;
  /* border: 3px solid var(--white); */
  z-index: 10;
  white-space: nowrap;
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.coin-icon {
  font-size: 1.2rem;
  animation: rotate 3s linear infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes rotate {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(360deg);
  }
}

/* Progress bars between avatars */
.progress-bar-container {
  flex: 1;
  max-width: 250px;
  display: flex;
  align-items: center;
  padding: 0;
  z-index: 1;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2c7a7b 0%, #319795 50%, #2c7a7b 100%);
  border-radius: 10px;
  width: 65%;
  animation: progressGrow 1s ease-out;
}

@keyframes progressGrow {
  from {
    width: 0%;
  }
  to {
    width: 60%;
  }
}

/* Congratulations Banner */
.congrats-banner {
  max-width: 360px;
  margin: 0 auto var(--spacing-md);
  background: linear-gradient(
    135deg,
    var(--success-color) 0%,
    var(--success-light) 100%
  );
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--white);
  font-weight: 600;
  font-size: 1.1rem;
  box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
  animation: slideInBounce 0.6s ease-out;
  display: none;
  position: absolute;
  z-index: 999;
  margin: auto;
  left: 0;
  right: 0;
  margin-top: -110px;
  width: fit-content;
}

.congrats-banner.show {
  display: block;
}

@keyframes slideInBounce {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  60% {
    transform: translateY(5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Game Container ===== */
.game-container {
  max-width: 600px;
  margin: 0 auto;
  /* background: var(--white); */
  border-radius: var(--radius-xl);
  /* padding: var(--spacing-sm); */
  /* box-shadow: 0 20px 60px var(--shadow-strong); */
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Game Header ===== */
.game-header {
  background: linear-gradient(
    180deg,
    var(--header-bg-start) 0%,
    var(--header-bg-end) 100%
  );
  border-radius: var(--radius-md);
  padding: 0 var(--spacing-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  /* box-shadow: 0 4px 15px var(--shadow); */
  border: 2px solid var(--header-border);
}

.header-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-weight: 600;
}

.timer-icon,
.rank-icon,
.star-icon {
  font-size: 2rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.timer-value {
  font-size: 1.2rem;
  color: var(--header-text);
  font-weight: 700;
}

.rank-section {
  position: relative;
  flex-direction: row;
  align-items: center;
  gap: var(--spacing-xs);
}

.rank-value {
  font-size: 1.2rem;
  color: var(--text-dark);
  font-weight: 800;
}

.score-change {
  position: absolute;
  top: auto;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(
    135deg,
    var(--success-color) 0%,
    var(--success-light) 100%
  );
  color: var(--white);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
  animation: scorePopInBottom 0.5s ease;
  display: none;
  z-index: 100;
}

.score-change.show {
  display: block;
}

@keyframes scorePopInBottom {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.best-score-value {
  font-size: 1.2rem;
  color: var(--cell-text);
  font-weight: 700;
}

/* ===== Word Grid ===== */
.word-grid-container {
  position: relative;
  margin-bottom: var(--spacing-md);
}

.word-connections {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--spacing-md);
  padding: var(--spacing-xs);
  border-radius: var(--radius-lg);
  position: relative;
  z-index: 2;
}

/* Loading skeleton shown while grid generation runs (before first paint of cells) */
.grid-loading-skeleton {
  width: 100%;
  height: 320px;            /* approximate grid height — prevents layout shift */
  border-radius: var(--radius-lg, 12px);
  background: linear-gradient(90deg,
    rgba(200,200,200,0.15) 25%,
    rgba(200,200,200,0.35) 50%,
    rgba(200,200,200,0.15) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.2s ease-in-out infinite;
}

@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.grid-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-full);
  border: 2px solid var(--cell-border);
  background: var(--cell-bg);
  color: var(--cell-text);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-medium);
  user-select: none;
  box-shadow: 0 3px 3px var(--shadow);
  position: relative;
  z-index: 3;
}

.grid-cell:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--shadow-strong);
}

.grid-cell.selected {
  background: linear-gradient(
    135deg,
    var(--selection-color, var(--orange-primary)) 0%,
    var(--selection-color-dark, var(--orange-dark)) 100%
  );
  color: var(--white);
  border-color: var(--selection-color-dark, var(--orange-dark));
  transform: scale(1.1);
  animation: cellPop 0.3s ease;
}

@keyframes cellPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1.1);
  }
}

.grid-cell.found {
  background: linear-gradient(
    135deg,
    var(--green-success) 0%,
    var(--green-light) 100%
  );
  /* color: var(--white); */
  border-color: var(--green-success);
  animation: celebrate 0.6s ease;
}

@keyframes celebrate {
  0%,
  100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.2) rotate(-10deg);
  }
  75% {
    transform: scale(1.2) rotate(10deg);
  }
}

@keyframes drawLine {
  from {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    opacity: 0;
  }
  to {
    stroke-dasharray: 1000;
    stroke-dashoffset: 0;
    opacity: 0.7;
  }
}

.grid-cell.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Word List Display ===== */
.word-list-container {
  background: linear-gradient(135deg, #fff9f0 0%, #ffffff 100%);
  border-radius: var(--radius-lg);
  padding: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  border: 2px solid var(--cream-dark);
  position: relative;
}

.pattern-display {
  text-align: center;
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-xs);
  background: var(--white);
  border-radius: var(--radius-md);
  border: 2px solid var(--selection-color, var(--orange-primary));
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  position: absolute;
  top: -23px;
  margin: auto;
  left: 0;
  right: 0;
  width: max-content;
}

.word-list {
  display: flex;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--spacing-xs);
  justify-content: center;
  flex-wrap: wrap;
}

.word-item {
  padding: var(--spacing-xs);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  position: relative;
  /* overflow: hidden; */
  transition: all var(--transition-medium);
  border: 2px solid transparent;
}

/* .word-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--green-success);
  transform: scaleY(0);
  transition: transform var(--transition-medium);
} */

.word-item.pending {
  background: var(--word-pending-bg);
  color: var(--word-pending-text);
  border-color: var(--word-pending-border);
}

.word-item.pending::before {
  background: var(--cream-dark);
}

.word-item.found {
  background: var(--word-found-bg);
  color: var(--word-found-text);
  border-color: var(--word-found-border);
  animation: wordFound 0.5s ease;
}

.word-item.found::before {
  transform: scaleY(1);
}

@keyframes wordFound {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: center;
}

.btn {
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-medium);
  font-family: "Poppins", sans-serif;
  box-shadow: 0 4px 15px var(--shadow);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-strong);
}

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

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--blue-medium) 0%,
    var(--blue-dark) 100%
  );
  color: var(--white);
}

.btn-secondary {
  background: linear-gradient(
    135deg,
    var(--orange-primary) 0%,
    var(--orange-dark) 100%
  );
  color: var(--white);
}

/* ===== Intro/Welcome Screen ===== */
.intro-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #e8f0fe 0%, #f5f9ff 100%);
  z-index: 10000;
  /* display: flex; */
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
  padding: 0 10px;
  background: linear-gradient(180deg, #e31e25 0%, #ffffff 100%);
  position: absolute;
}

.intro-screen.hidden {
  display: none;
}

.intro-content {
  max-width: 460px;
  width: 100%;
  padding: 0px;
  text-align: center;
  margin: auto;
}

.intro-instruction {
  background: #2c2c2c;
  color: white;
  padding: 16px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.intro-grid-demo {
  background: white;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  margin-bottom: 10px;
  position: relative;
}

.intro-demo-gif {
  width: 100%;
  /* max-width: 400px; */
  height: auto;
  border-radius: 12px;
  display: block;
  margin: 0 auto;
}

.intro-start-btn {
  background: linear-gradient(135deg, #e31e25 0%, #c6181d 100%);
  color: white;
  border: none;
  padding: 18px 60px;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(227, 30, 37, 0.4);
  transition: all 0.3s ease;
  font-family: inherit;
  margin-bottom: 50px;
}

.intro-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(227, 30, 37, 0.5);
  background: linear-gradient(135deg, #f5222d 0%, #e31e25 100%);
}

.intro-start-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(227, 30, 37, 0.4);
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
  z-index: 9999;
}

.modal.show {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--white);
  padding: var(--spacing-md);
  border-radius: var(--radius-xl);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px var(--shadow-strong);
  animation: modalSlideUp 0.4s ease;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-content h2 {
  color: var(--blue-dark);
  margin-bottom: var(--spacing-md);
  font-size: 2rem;
}

.final-score {
  margin: var(--spacing-lg) 0;
  font-size: 1.2rem;
  color: var(--text-medium);
}

.final-score span {
  color: var(--orange-primary);
  font-weight: 700;
  font-size: 1.5rem;
}

/* ===== Game Over Modal Redesign ===== */
.game-over-modal {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 50%, #ff4757 100%);
  padding: 4.5rem 2rem 2rem;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
  max-width: 500px;
  box-shadow: 0 25px 70px rgba(255, 71, 87, 0.4);
}

/* Decorative background circles */
.game-over-modal::before {
  content: "";
  position: absolute;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  top: -50px;
  right: -50px;
  z-index: 0;
}

.game-over-modal::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  bottom: -30px;
  left: -30px;
  z-index: 0;
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  font-weight: 300;
  line-height: 1;
}

.modal-close-btn:hover {
  transform: scale(1.1);
}

.modal-coin-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: coinBounce 0.6s ease;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  position: relative;
  z-index: 1;
}

@keyframes coinBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-20px) scale(1.1);
  }
}

.modal-title {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.coins-earned {
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffd700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.congrats-text {
  color: #ffe66d;
  font-weight: 800;
}

.modal-message {
  color: white;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.modal-scores {
  color: white;
  margin-bottom: 2rem;
  position: relative;
  z-index: 1;
}

.modal-score-item {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-score-item .score-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffd700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.modal-refresh-btn {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border: none;
  border-radius: 16px;
  padding: 0.8rem 2rem;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 0 auto;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
  font-family: "Poppins", sans-serif;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.modal-refresh-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

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

.modal-refresh-btn svg {
  animation: rotateRefresh 2s linear infinite;
}

@keyframes rotateRefresh {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ===== Claim Coins Button (matches old game's #claim button) ===== */
.claim-coins-btn {
  background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
  color: #1a1a1a;
  border: none;
  border-radius: 16px;
  padding: 0.9rem 2.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 auto 1rem;
  width: 100%;
  max-width: 280px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
  font-family: "Poppins", sans-serif;
  box-shadow: 0 6px 20px rgba(255, 165, 0, 0.5);
  animation: claimPulse 2s ease-in-out infinite;
  letter-spacing: 0.5px;
}

.claim-coins-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 28px rgba(255, 165, 0, 0.65);
}

.claim-coins-btn:active {
  transform: translateY(0) scale(0.98);
}

.claim-coins-btn:disabled {
  animation: none;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

/* Gap 4: Web mobile "ऐप से क्लेम करें" button — red, matches bottom sheet style */
.web-claim-btn {
  background: #E31E25;
  color: #fff;
  box-shadow: 0 6px 20px rgba(227, 30, 37, 0.45);
  animation: webClaimPulse 2s ease-in-out infinite;
}
.web-claim-btn:hover {
  background: #c9191f;
  box-shadow: 0 10px 28px rgba(227, 30, 37, 0.6);
}
@keyframes webClaimPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(227, 30, 37, 0.45); }
  50%       { box-shadow: 0 8px 28px rgba(227, 30, 37, 0.7);  }
}


@keyframes claimPulse {
  0%,
  100% {
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.5);
  }
  50% {
    box-shadow:
      0 6px 30px rgba(255, 215, 0, 0.8),
      0 0 20px rgba(255, 215, 0, 0.4);
  }
}

/* ===== Theme-Specific Modal Colors ===== */
/* Default theme - Red/Coral */
body .game-over-modal,
body.theme-default .game-over-modal {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 50%, #ff4757 100%);
}

/* Sunset theme - Deep Red to Orange */
body.theme-sunset .game-over-modal {
  background: linear-gradient(135deg, #e31e25 0%, #ff6b6b 50%, #ff8e53 100%);
}

/* Ocean theme - Blue gradient */
body.theme-ocean .game-over-modal {
  background: linear-gradient(135deg, #667eea 0%, #5a67d8 50%, #4c51bf 100%);
}

/* Forest theme - Green gradient */
body.theme-forest .game-over-modal {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 50%, #2f855a 100%);
}

/* Royal theme - Purple gradient */
body.theme-royal .game-over-modal {
  background: linear-gradient(135deg, #9f7aea 0%, #805ad5 50%, #6b46c1 100%);
}

/* Gold theme - Yellow/Gold gradient */
body.theme-gold .game-over-modal {
  background: linear-gradient(135deg, #f6d365 0%, #ecc94b 50%, #d69e2e 100%);
}

/* Adjust text colors for lighter themes */
body.theme-forest .modal-title,
body.theme-forest .modal-message,
body.theme-gold .modal-title,
body.theme-gold .modal-message {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.theme-gold .coins-earned {
  color: #744210;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.5);
}

body.theme-gold .congrats-text {
  color: #975a16;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  body {
    padding: var(--spacing-sm);
  }

  .leaderboard {
    padding: var(--spacing-sm);
  }

  .avatar {
    width: 50px;
    height: 50px;
  }

  .avatar.current-user {
    width: 70px;
    height: 70px;
  }

  .rank-badge {
    font-size: 1rem;
    padding: 0.3rem 0.6rem;
  }

  .score-badge {
    font-size: 1.2rem;
    padding: 0rem 0.8rem;
  }

  .game-header {
    padding: 0 var(--spacing-sm);
  }

  .timer-value,
  .rank-value,
  .best-score-value {
    font-size: 1.3rem;
  }

  .grid-cell {
    font-size: 1rem;
  }

  .word-list {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }

  .controls {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .leaderboard::before,
  .leaderboard::after {
    display: none;
  }

  .word-grid {
    gap: 0.9rem;
    padding: var(--spacing-xs);
  }

  .grid-cell {
    font-size: 1rem;
  }
}
.game-container {
  position: relative;
}
.game-header {
  position: absolute;
  top: -80px;
  left: 0;
  z-index: 99;
  width: 100%;
  height: auto;
  max-width: 350px;
  right: 0;
  margin: auto;
  min-height: 70px;
}
.settings-content {
  background: #024a86; /* Dark navy as per reference */
  color: white;
  text-align: left;
  padding: var(--spacing-lg);
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: var(--theme-dark);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.settings-header h2 {
  color: white;
  margin: 0;
  font-size: 1.5rem;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.settings-divider {
  border-top: 1px dashed rgba(255, 255, 255, 0.3);
  margin-bottom: var(--spacing-md);
}

.settings-section {
  margin-bottom: var(--spacing-lg);
}

.settings-section h3 {
  font-size: 1.1rem;
  margin-bottom: var(--spacing-sm);
  font-weight: 600;
}

.language-select {
  width: 100%;
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.language-select:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
}

.language-select option {
  background: var(--blue-dark);
  color: var(--white);
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  font-size: 1.1rem;
  font-weight: 500;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
  min-width: 60px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.4s;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.4s;
}

input:checked + .slider {
  background-color: #2ecc71;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Theme Grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--spacing-xs);
}

.theme-option {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition-fast);
}

.theme-option.active {
  border-color: #2ecc71;
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .settings-content {
    width: 95%;
    max-width: none;
  }
}
.lbt-avatar {
  border: none;
  box-shadow: none;
  font-size: 80px;
  text-align: center;
}
@media (max-width: 768px) {
  .lbt-avatar {
    font-size: 45px;
  }
}
.modal-content img {
  /* width: 100%;
  max-width: 200px; */
  vertical-align: bottom;
}

.rank-section {
  visibility: hidden;
}
.game-header {
  background: transparent;
  border: none;
  min-height: fit-content;
  position: relative;
  top: 5px;
  max-width: 600px;
}
.leaderboard-container {
  margin: 0;
  display: none;
}
.word-list-container {
  padding: 10px 5px;
  margin-bottom: 10px;
}
.congrats-banner {
  margin-top: 0;
}
.main_container:has(.top-nav .menu-container .dropdown-menu.show)::after {
  content: " ";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  pointer-events: none;
}
.menu-container {
  z-index: 9999;
}
.dropdown-icon-btn,
.main_container:has(.top-nav .menu-container .dropdown-menu.show)
  .top-nav
  .menu-container
  .nav-btn {
  background: rgba(255, 255, 255, 0.8);
}
.dropdown-menu {
  padding: 0;
}
/* #soundMenuItem[style="opacity: 0.5; background-color: rgb(0, 0, 0);"]
  svg:is(path, polygon) {
  stroke: #fff;
} */

#introScreen .game-title {
  text-align: center;
  padding: 10px 0;
}

.setting-item[style="opacity: 0.5; pointer-events: none;"] {
  display: none;
}
body.theme-sunset:has(#introScreen[class="intro-screen"]) {
  background: transparent;
}

/* =====================================================================
   Bottom Sheet — Web-to-App Promotion  (dark design matching reference)
   ===================================================================== */

/* ── Backdrop overlay ──────────────────────────────────────────────── */
.shabdkhoj_webtoapp_back {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.shabdkhoj_webtoapp_back.visible {
  display: block;
}

/* ── Bottom sheet container ────────────────────────────────────────── */
.shabdkhoj_webtoapp {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  background: #2b2b2b;          /* dark charcoal — matches reference */
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
  max-height: 90vh;
}
.shabdkhoj_webtoapp.visible {
  display: block;
}

/* ── Lock icon — protruding circle at top center ───────────────────── */
.bs-lock-icon {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2b2b2b;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #3d3d3d;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
  z-index: 1;
}

/* The sheet itself needs relative positioning for the lock to sit on */
.shabdkhoj_webtoapp {
  position: fixed;
}
.shabdkhoj_webtoapp > .bs-lock-icon {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
}

/* ── Inner content wrapper ─────────────────────────────────────────── */
.bs-content {
  padding: 36px 24px 28px;  /* extra top room for lock icon */
  position: relative;
  text-align: center;
}

/* ── Close button (top-right, light on dark) ───────────────────────── */
.bs-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  line-height: 1;
  transition: color 0.2s;
}
.bs-close-btn:hover { color: #fff; }

/* ── Body text ─────────────────────────────────────────────────────── */
.bs-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #f0f0f0;
  line-height: 1.6;
  margin: 0 0 20px;
  padding: 0 16px;
}

/* ── Desktop row: QR + store buttons ──────────────────────────────── */
.bs-desktop-row {
  display: flex;
  align-items: center;
  gap: 20px;
  background: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  max-width: 520px;
  margin: 0 auto;
}

/* QR image box */
.bs-qr-wrap {
  flex-shrink: 0;
}
.bs-qr-img {
  border-radius: 6px;
  display: block;
}

/* Store buttons column */
.bs-store-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}
.bs-scan-text {
  font-size: 0.85rem;
  color: #333;
  margin: 0 0 6px;
  line-height: 1.5;
  font-weight: 500;
}
.bs-store-btn {
  display: block;
  text-decoration: none;
}
.bs-store-btn img {
  display: block;
  height: 40px;
  width: auto;
}

/* ── Mobile button (hidden on desktop ≥ 600px) ────────────────────── */
.bs-mobile-btn {
  display: none;   /* hidden by default on desktop */
  width: 100%;
  background: #E31E25;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 16px 0;
  border-radius: 8px;
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.02em;
  transition: background 0.2s;
}
.bs-mobile-btn:hover { background: #c9191f; }

/* ── Responsive: mobile (≤ 600px) ─────────────────────────────────── */
@media (max-width: 600px) {
  .bs-desktop-row { display: none; }   /* hide QR + store buttons */
  .bs-mobile-btn  { display: block; }  /* show red download button */

  .bs-text {
    font-size: 1rem;
    padding: 0 8px;
    margin-bottom: 22px;
  }
  .bs-content {
    padding: 38px 16px 28px;
  }
}
.pre_loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  background-color: rgba(229, 229, 229, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #555;
}
.pre_loader img {
  width: 250px;
  height: auto;
}
.pre_loader p {
  font-size: 20px;
  color: #ffffff;
  margin-top: 8px;
}
body:has(.word-grid-container #wordConnections:empty) .pre_loader{
  display: none !important;
}
.main_container:has(#introScreen:not([style*="display: none"])) ~ .pre_loader {
    display: none;
}
