/* =======================================================
   🎨 CONTEXTO STYLES (NAMESPACED)
   ======================================================= */
  .contexto * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    color: #423232;
  }

  body {
    background-color: #121213;
    margin: 0;
    padding: 0;
    min-height: 100vh;
  }

  .contexto {
    background-color: #f8f4ed;
    display: flex;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    min-height: 100vh;
    position: relative;
  }

  /* Dark mode container */
  .contexto-dark {
    background-color: #15202b !important;
  }
  .contexto-dark * {
    color: #ffffff !important;
  }

  /* Background overlay (dim layer between bg image/video and game content) */
  .contexto-bg-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
  }

  /* Background video element */
  #contexto-bg-video {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
  }
  
  .contexto .container {
    max-width: 500px;
    width: 100%;
    margin-top: 30px;
    position: relative;
    z-index: 2;
  }
  
  .contexto .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
  }
  
  .contexto .title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
  }
  
  .contexto .unlimited-img {
    height: 60px;
    width: auto;
  }

  .interactive-logo {
    height: 29px;
    width: auto;
    margin-right: 8px;
    margin-bottom: 3px;
  }
  
  .contexto .title {
    font-size: 30px;
    font-weight: bold;
    color: #3b302a;
  }
  
  .contexto .menu-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #3b302a;
  }
  
  .contexto .game-info {
    margin-bottom: 15px;
    font-size: 18px;
    color: #3b302a;
  }
  
  .contexto .game-info .label {
    font-weight: 700;
  }
  
  .contexto .spellcheck-toggle {
    cursor: pointer;
    vertical-align: bottom;
    margin-left: 5px;
    height: 24px;
    display: none;
  }
  
  .contexto .input-container {
    position: relative;
    margin-bottom: 5px;
  }
  
  .contexto .word-input {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 18px;
    outline: none;
  }
  
  .contexto .last-guess {
    border: 3px solid #423232;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 15px;
    display: none;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    font-size: 18px;
    font-weight: 900;
    z-index: 0;
  }
  /* centered attribution for last guess */
  .contexto .last-guess .guess-attrib {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 800;
    color: #333;
  }
  
  .contexto .guesses-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  
  .contexto .guess-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 18px;
    position: relative;
    overflow: hidden;
    color: #333;
    z-index: 0;
  }
  /* Only the most recent guess has a border; others have none */
  .contexto-dark .guess-recent { border-color: #ffffff; }
  /* Attribution centered overlay inside guess item */
  .contexto .guess-attrib {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 700;
    color: #333;
  }
  .contexto .guess-attrib-photo {
    width: 43px;
    height: 43px;
    object-fit: cover;
  }
  .contexto .guess-attrib-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .contexto .guess-recent {
    border: 3px solid #423232;
    border-radius: 8px;
  }
  /* Ensure recent guess has white border in dark mode */
  .contexto-dark .guess-recent {
    border: 3px solid #ffffff;
  }
  
  .contexto .progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    z-index: -1;
    border-radius: 5px;
  }
  
  .contexto .blue-bg .progress-bar { background-color: #b6e0d8; }
  .contexto .yellow-bg .progress-bar { background-color: #f6e4a1; }
  .contexto .red-bg .progress-bar { background-color: #f2c4c4; }

  /* Dark mode guess tier colors */
  .contexto-dark .blue-bg .progress-bar { background-color: #00ba7c; }
  .contexto-dark .yellow-bg .progress-bar { background-color: #ef7d31; }
  .contexto-dark .red-bg .progress-bar { background-color: #f91880; }

  .contexto-dark .word-input {
    background: #0f1620;
    color: #ffffff;
    border-color: #22303c;
  }
  .contexto-dark .last-guess { border-color: #ffffff; }
  .contexto-dark .error { color: #ffb3b3; }
  
  /* Overlays specific to CONTEXTO (renamed to prevent collision) */
  .contexto-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
  }
  
  .contexto-modal {
    background-color: #f8f4ed;
    border-radius: 10px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    max-height: 500px;
    overflow-y: auto;
    position: absolute;
    top: 10%;
  }

  /* Apply dark mode palette to contexto-modal */
  .contexto-dark .contexto-modal {
    background-color: #15202b;
    color: #ffffff;
  }
  
  .contexto .menu-option {
    display: flex;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
    border-bottom: 1px solid #eee;
  }
  
  .contexto .menu-option:last-child { border-bottom: none; }
  .contexto .menu-option i { margin-right: 10px; width: 24px; text-align: center; }

  .icon-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
  }

  .icon-item img {
    width: 40px;
    height: 40px;
    margin-right: 15px;
  }
  
  .contexto .close-modal {
    position: absolute;
    top: 10px; right: 10px;
    background: none; border: none;
    font-size: 20px; cursor: pointer;
  }
  
  /* Congrats Modal */
  .contexto .congrats-content {
    padding: 25px;
    text-align: center;
    line-height: 1.6;
  }
  .contexto .congrats-content p { margin-bottom: 15px; font-size: 18px; }
  .contexto .congrats-content strong { font-weight: 900; }
  .contexto .promo-text { margin-top: 20px; font-size: 16px; }
  .contexto .website-link {
    background-color: #3b302a;
    color: #f8f4ed;
    padding: 8px 16px;
    border-radius: 5px;
    font-weight: 800;
    font-size: 20px;
    display: inline-block;
  }
  .contexto #playAgain {
    display:block;
    margin-top:50px;
    cursor:pointer;
    color: #b6e0d8;
  }
  
  /* Misc subcomponents */
  .contexto .random-button,
  .contexto .continue-btn,
  .contexto .custom-game-input button {
    background-color: #b6e0d8;
    color: #3b302a;
    border: none;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
  }
  .contexto .back-btn {
    background-color: #f2c4c4;
    color: #3b302a;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    padding: 10px;
  }
  
  /* Spinner */
  .contexto .spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 3px solid #b6e0d8;
    width: 20px; height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* =======================================================
     🖤 EXISTING TEMPLATE STYLES (UNMODIFIED)
     ======================================================= */  

body.dark-mode .floating-leaderboard {
  background: #1a1a1a;
  border-color: #444;
}

body.dark-mode .floating-leaderboard-header {
  background: #2d2d2d;
  border-bottom-color: #444;
}

body.dark-mode .leaderboard-item {
  background: #2d2d2d;
}

body.dark-mode .leaderboard-username {
  color: #e0e0e0;
}

body.dark-mode .leaderboard-rank {
  color: #b0b0b0;
}

body.dark-mode .leaderboard-page-info {
  color: #b0b0b0;
}

body.dark-mode .leaderboard-nav-btn:hover:not(:disabled) {
  background: #444;
}

body.dark-mode .leaderboard-empty {
  color: #b0b0b0;
}


/* Winning Modal Styles (aligned with wordle/style.css) */
.winning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.484);
    display: flex;
    justify-content: center;
    align-items: flex-start; /* position modal from top */
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .winning-overlay.show {
    opacity: 1;
    visibility: visible;
  }
  
  /* Modal box */
  .winning-modal {
    background: #2c2c2c; /* leaderboard background */
    border: 1px solid #444;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    max-width: 420px;
    width: 92%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.92);
    transition: transform 0.3s ease;
    font-family: 'Nunito', Arial, sans-serif; /* match leaderboard font */
  }
  .winning-modal * { font-family: inherit; }
  .winning-overlay.show .winning-modal {
    transform: scale(1);
  }
  /* Position winning modal 20% from top of the screen */
  .winning-overlay .winning-modal { margin-top: 15vh; }
  .winning-title {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
  }
  
  /* Single winner */
  .single-winner {
    display: none;
    flex-direction: column;
    align-items: center;
  }
  .winner-photo {
    width: 80%;
    /* height: 220px; */
    border-radius: 8px; /* square-ish corners */
    border: 2px solid #fff;
    margin-bottom: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    object-fit: cover;
    object-position: center;
  }
  .winner-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-top: 6px;
  }

  .winning-site {
    margin-top: 12px;
    color: #fff;
    font-size: 20px; /* match request */
    opacity: 0.9;
    font-weight: 600;
    color: #f7be57;
    background-color: #6b6562;
    width: fit-content;
    padding: 5px 10px;
    border-radius: 5px;
    margin: 12px auto 6px auto;
  }
  
  /* Multiple winners (mapped from wordle group-winners) */
  .multiple-winners {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
  }
  .multi-winner {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 80px;
  }
  .multi-winner-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #fff;
    margin-bottom: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    object-fit: cover;
  }
  .multi-winner-name {
    font-size: 0.9em;
    font-weight: 600;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    text-align: center;
    word-break: break-word;
  }
  @media (max-width: 600px) {
    .winning-modal { padding: 30px 20px; }
    .winning-title { font-size: 2em; }
    .winner-photo { width: 120px; height: 120px; }
    .multi-winner-photo { width: 50px; height: 50px; }
    .multiple-winners { gap: 12px; }
    .multi-winner { padding: 10px; min-width: 70px; }
    .multi-winner-name { font-size: 0.8em; }
  }
  



  


/* Instruction Popup (aligned with wordle/style.css) */
.instruction-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 350px;
  z-index: 999;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  opacity: 0;
}
.instruction-popup.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
.instruction-popup.slide-out {
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}
.instruction-popup-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.2);
}
.instruction-popup-text {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 15px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}
.instruction-popup-gif {
  width: 100%;
  max-width: 300px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Settings Panel Styles (from wordle/style.css) */
.settings-panel {
  position: fixed;
  font-family: 'Segoe UI', Arial, sans-serif;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100vh;
  background-color: #1c1c1c;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
  transition: right 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

.settings-panel.open {
  right: 0;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #3a3a3c;
}

.settings-header h2 {
  margin: 0;
  color: #ffffff;
  font-size: 24px;
}

.close-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.close-btn:hover {
  background-color: #3a3a3c;
}

.settings-section {
  border-bottom: 1px solid #3a3a3c;
}

.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.settings-section-header:hover {
  background-color: #2a2a2c;
}

.settings-section-header h3 {
  margin: 0;
  color: #ffffff;
  font-size: 18px;
}

.arrow {
  color: #ffffff;
  transition: transform 0.2s ease;
}

.settings-section-header.collapsed .arrow {
  transform: rotate(0deg);
}

.settings-section-header:not(.collapsed) .arrow {
  transform: rotate(180deg);
}

.settings-section-content {
  padding: 0 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.settings-section-header:not(.collapsed) + .settings-section-content {
  padding: 15px 20px;
  max-height: none;
}

.settings-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #1c1c1c;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, background-color 0.2s ease;
  z-index: 999;
}

.settings-toggle:hover {
  background-color: #2a2a2c;
  transform: scale(1.1);
}

.settings-toggle svg {
  width: 24px;
  height: 24px;
}

.settings-toggle.simulate-active {
  background-color: #2ecc40 !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(46,204,64,0.3);
}

.setting-item {
  margin: 15px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-item label {
  color: #ffffff;
  font-size: 16px;
}

.setting-select {
  background-color: #2a2a2c;
  color: #ffffff;
  border: 1px solid #3a3a3c;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.setting-select:hover {
  border-color: #4a4a4c;
}

.setting-select:focus {
  outline: none;
  border-color: #538d4e;
}

.number-input-container {
  display: flex;
  align-items: center;
  background-color: #2a2a2c;
  border: 1px solid #3a3a3c;
  border-radius: 4px;
  overflow: hidden;
}

.number-input-btn {
  background-color: #3a3a3c;
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.number-input-btn:hover {
  background-color: #4a4a4c;
}

.setting-input {
  background-color: #2a2a2c;
  color: #ffffff;
  border: none;
  width: 50px;
  height: 32px;
  text-align: center;
  font-size: 14px;
  appearance: textfield;
  -moz-appearance: textfield;
}

.setting-input::-webkit-outer-spin-button,
.setting-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.setting-input-wide {
  background-color: #2a2a2c;
  color: #ffffff;
  border: 1px solid #3a3a3c;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

.setting-input-wide:hover {
  border-color: #4a4a4c;
}

.setting-input-wide:focus {
  outline: none;
  border-color: #538d4e;
}

.test-btn {
  background-color: #b59f3b;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.2s ease;
  width: 100%;
}

.test-btn:hover {
  background-color: #a08f35;
}

.test-btn:active {
  transform: translateY(1px);
}

.setting-checkbox {
  width: 18px;
  height: 18px;
  accent-color: #538d4e;
  cursor: pointer;
}

.setting-checkbox:hover {
  transform: scale(1.1);
}

.setting-color {
  width: 44px;
  height: 32px;
  padding: 2px;
  border: 1px solid #3a3a3c;
  border-radius: 4px;
  background-color: #2a2a2c;
  cursor: pointer;
}

.setting-color:hover {
  border-color: #4a4a4c;
}

.setting-range {
  flex: 1;
  accent-color: #538d4e;
  cursor: pointer;
}

.bg-perf-warning {
  font-size: 11px;
  color: #b6b6b6;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid #3a3a3c;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.bg-presets-group { margin-bottom: 8px; }
.bg-presets-label { font-size: 11px; color: #888; margin-bottom: 4px; }
.bg-presets-row   { display: flex; gap: 6px; flex-wrap: wrap; }
.bg-preset-btn {
  font-size: 11px;
  padding: 4px 10px;
  background-color: #2a2a2c;
  color: #b6b6b6;
  border: 1px solid #3a3a3c;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.bg-preset-btn:hover { border-color: #538d4e; color: #ffffff; }

.setting-textarea {
  background-color: #2a2a2c;
  color: #ffffff;
  border: 1px solid #3a3a3c;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
  resize: vertical;
  font-family: inherit;
}

.setting-textarea:hover {
  border-color: #4a4a4c;
}

.setting-textarea:focus {
  outline: none;
  border-color: #538d4e;
}

/* Spanish / Portuguese word picker (custom listbox) */
.word-picker-listbox {
  width: 100%;
  box-sizing: border-box;
  max-height: 200px;
  overflow-y: auto;
  padding: 0;
  cursor: default;
}

.word-picker-listbox:focus {
  outline: none;
  border-color: #538d4e;
}

.word-picker-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
  color: #ffffff;
}

.word-picker-row:hover {
  background-color: #4a4a4c;
}

.word-picker-row.is-selected {
  background-color: #3d5a38;
}

.word-picker-row-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.word-picker-row-icon {
  flex-shrink: 0;
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: #b6b6b6;
  opacity: 0.9;
}

.word-picker-row-icon svg {
  display: block;
}

.word-picker-stats {
  font-size: 12px;
  color: #b6b6b6;
  margin-top: 4px;
  text-align: right;
  width: 100%;
  box-sizing: border-box;
}

  /* Settings Panel — Custom Game Creator overrides */
  .settings-panel .select-game-header {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
  }
  .settings-panel .custom-game-input {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .settings-panel .password-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .settings-panel #customWordInput {
    background-color: #2a2a2c;
    color: #ffffff;
    border: 1px solid #3a3a3c;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    flex: 1;
  }
  .settings-panel #customWordInput::placeholder {
    color: #b0b0b0;
  }
  .settings-panel #createCustomGame,
  .settings-panel #continueToGame,
  .settings-panel #acceptSimilarWord,
  .settings-panel #startAutomatedList,
  .settings-panel #playSelectedSpanishWord,
  .settings-panel #playSelectedPortugueseWord {
    background-color: #538d4e;
    color: #ffffff;
    border: none;
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    width: 100%;
  }
  .settings-panel #randomGame,
  .settings-panel #backToInput {
    background-color: #3a3a3c;
    color: #ffffff;
    border: 1px solid #4a4a4c;
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    width: 100%;
  }
  .settings-panel #createCustomGame:hover,
  .settings-panel #continueToGame:hover,
  .settings-panel #acceptSimilarWord:hover,
  .settings-panel #startAutomatedList:hover,
  .settings-panel #playSelectedSpanishWord:hover,
  .settings-panel #playSelectedPortugueseWord:hover {
    background-color: #4a7a44;
  }
  .settings-panel #randomGame:hover,
  .settings-panel #backToInput:hover {
    background-color: #4a4a4c;
  }
  .settings-panel #loadingGame {
    color: #ffffff;
  }
  .settings-panel .error-text {
    color: #f2c4c4;
    background: #3a1f1f;
    border: 1px solid #803333;
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 10px;
    font-size: 14px;
  }
  .settings-panel #wordCheckUI p {
    color: #ffffff;
    margin-bottom: 10px;
  }
  .settings-panel .word-check-buttons {
    display: flex;
    gap: 10px;
  }


  .settings-panel .success-message {
    color: #ffffff;
  }

  #gameCreationUI {
    display: block;
  }


/* Floating Leaderboard */
.floating-leaderboard {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 320px;
  background: #2c2c2c;
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 3000;
  font-family: 'Nunito', Arial, sans-serif;
  cursor: move;
  user-select: none;
}

.floating-leaderboard.opacity-50 {
  opacity: 0.8;
}

.floating-leaderboard-header {
  background: #333;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid #444;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: move;
}

.floating-leaderboard-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-leaderboard-toggle:hover {
  background: #444;
  border-radius: 3px;
}

.floating-leaderboard-body {
  padding: 8px;
  max-height: 290px;
  overflow-y: auto;
  display: block;
}

.leaderboard-height-toggle {
  position: sticky;
  bottom: 4px;
  left: 270px;
  background: transparent;
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  margin-top: 10px;
  margin-left: 210px;
}

.floating-leaderboard-body.collapsed {
  display: none;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #3a3a3a;
  border-radius: 4px;
  padding: 6px 10px;
  height: 36px;
}

.leaderboard-user {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.leaderboard-rank {
  color: #aaa;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
}

.leaderboard-img {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  object-fit: cover;
  background: #555;
  flex-shrink: 0;
}

.leaderboard-username {
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.leaderboard-points {
  color: #4285f4;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

.leaderboard-empty {
  color: #888;
  font-size: 0.8rem;
  text-align: center;
  padding: 20px;
  font-style: italic;
}

.leaderboard-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.leaderboard-nav-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: background 0.2s;
}

.leaderboard-nav-btn:hover:not(:disabled) {
  background: #444;
}

.leaderboard-nav-btn:disabled {
  color: #666;
  cursor: not-allowed;
}

.leaderboard-page-info {
  color: #ccc;
  font-size: 16px;
  min-width: 24px;
  text-align: center;
  margin: 0 2px;
}

/* Leaderboard Announcement Toast */
.leaderboard-toast {
  position: fixed;
  top: 20px;
  left: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px 30px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  max-width: 450px;
  width: auto;
  font-family: 'Nunito', sans-serif;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-500px);
  transition: all 0.4s ease;
}

.leaderboard-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.leaderboard-toast h3 {
  margin: 0 0 15px 0;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
}

.leaderboard-toast p {
  margin: 10px 0;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
}

.toast-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================================ */
/* 🎁 GIFT METER                                                */
/* ============================================================ */

/* Floating gift meter toggle button — below the settings gear */
.meter-toggle {
  position: fixed;
  top: 70px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #1c1c1c;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, background-color 0.2s ease;
  z-index: 999;
  line-height: 1;
}

.meter-toggle:hover {
  background-color: #2a2a2c;
  transform: scale(1.1);
}

/* Armed state (game in progress, meter queued for next round end) */
.meter-toggle.meter-armed {
  background-color: #2ecc40 !important;
  box-shadow: 0 2px 12px rgba(46, 204, 64, 0.5);
  animation: meter-pulse 1.4s ease-in-out infinite;
}

/* Active state (overlay currently showing) */
.meter-toggle.meter-active {
  background-color: #e74c3c !important;
  box-shadow: 0 2px 12px rgba(231, 76, 60, 0.5);
}

@keyframes meter-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* Overlay backdrop — sits over the game, not full-blackout */
.meter-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1050;
  align-items: center;
  justify-content: center;
}

.meter-overlay.show {
  display: flex;
}

/* Modal card — shifted 40px above center */
.meter-modal {
  background: #1e2732;
  border-radius: 14px;
  padding: 24px 28px 20px;
  width: min(380px, 90vw);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #ffffff;
  font-family: 'Nunito', sans-serif;
  transform: translateY(-100px);
}

.meter-title {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
  text-align: center;
}

.meter-subtitle {
  margin: 0;
  text-align: center;
  font-size: 16px;
  color: #aab8c2;
}

.meter-subtitle strong {
  color: #1d9bf0;
}

/* Progress bar */
.meter-bar-track {
  position: relative;
  background: #2d3741;
  border-radius: 8px;
  height: 22px;
  overflow: hidden;
  margin-top: 4px;
}

.meter-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #27ae60, #2ecc71);
  border-radius: 8px;
  transition: width 0.4s ease;
}

.meter-bar-pct {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* Coin count display */
.meter-count-display {
  text-align: center;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 1px;
}

.meter-remaining {
  margin: 0;
  text-align: center;
  font-size: 15px;
  color: #aab8c2;
}

/* Countdown timer */
.meter-countdown {
  text-align: center;
  font-size: 15px;
  color: #6b7c8c;
  font-weight: 600;
}

.meter-countdown.meter-countdown-urgent {
  color: #e74c3c;
}

/* Gifters list */
.meter-gifters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  margin-top: 2px;
}

.meter-gifter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 4px 8px;
}

.meter-gifter-photo {
  width: 26px;
  height: 26px;
  border-radius: 0;
  object-fit: cover;
  flex-shrink: 0;
}

.meter-gifter-name {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter-gifter-coins {
  font-size: 14px;
  color: #f0c040;
  font-weight: 700;
  white-space: nowrap;
}

/* Footer */
.meter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* Last gifter display in footer */
.meter-last-gifter {
  display: none;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: #aab8c2;
  max-width: 55%;
  overflow: hidden;
}

.meter-last-gifter.visible {
  display: flex;
}

.meter-last-gifter-photo {
  width: 24px;
  height: 24px;
  border-radius: 0;
  object-fit: cover;
  flex-shrink: 0;
}

.meter-last-gifter-info {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.meter-cancel-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #aab8c2;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.meter-cancel-btn:hover {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  border-color: rgba(231, 76, 60, 0.4);
}

/* Success state — overlay stays visible during success delay */
.meter-modal.meter-success .meter-title {
  color: #2ecc71;
}

.meter-modal.meter-success .meter-bar-fill {
  background: linear-gradient(90deg, #27ae60, #2ecc71);
}

/* Gift image on the meter overlay */
.meter-gift-img {
  display: block;
  margin: 0 auto;
  max-height: 90px;
  width: auto;
  border-radius: 8px;
  object-fit: contain;
}

/* Wrapper for the gift-name input + dropdown */
.meter-gift-name-wrapper {
  position: relative;
  width: 100%;
}

.meter-gift-name-wrapper .setting-input-wide {
  width: 100%;
  box-sizing: border-box;
}

/* Autocomplete dropdown */
.meter-gift-autocomplete {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  overflow: hidden;
}

.meter-gift-autocomplete:empty {
  display: none;
}

/* Individual suggestion row */
.meter-gift-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  color: #1c1c1c;
  transition: background 0.12s ease;
}

.meter-gift-suggestion:hover {
  background: #f0f4ff;
}

.meter-gift-suggestion-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}