@font-face {
  font-family: 'Rubik';
  src: url('assets/rubik/Rubik-Medium.ttf') format('truetype');
  font-weight: 500;
}
@font-face {
  font-family: 'Rubik';
  src: url('assets/rubik/Rubik-SemiBold.ttf') format('truetype');
  font-weight: 600;
}
@font-face {
  font-family: 'Rubik';
  src: url('assets/rubik/Rubik-Bold.ttf') format('truetype');
  font-weight: 700;
}
@font-face {
  font-family: 'Rubik';
  src: url('assets/rubik/Rubik-ExtraBold.ttf') format('truetype');
  font-weight: 800;
}

/* ===========================================
   COLOR VARIABLES
   Edit these to change your game's colors
   =========================================== */
:root {
  /* Snake & Primary Green */
  --snake-green: #5E8D5A;
  --snake-green-dark: #4f7a4c;
  --snake-green-darker: #4d7549;
  --color-snake-stroke: #5E8D5A;
  
  /* Pills & Buttons */
  --pill-bg: #fefefe;

  
  /* Letter Tiles */
  --tile-bg: #e7e2da;
  
  /* Text Colors */
  --text-dark: #1a1a1a;
  --text-medium: #666;
  --text-light: #999;
  --text-white: white;
  
  /* Status Colors */
  --color-bonus: #e9ba3a;
  --color-error: #e74c3c;
  --color-badge: #ef4444;
  
  /* Backgrounds */
  --bg-white: #fefefe;
  --bg-light: #f5f5f5;
  --bg-gray: #e8e8e8;
  --bg-green-light: #e8f5e9;
  --bg-green-highlight: #f0f8f0;
  --bg-modal: rgba(255, 255, 255, 0.63);
  
  /* Borders */
  --border-light: #e0e0e0;
  --border-medium: #ccc;
  
  /* Puzzle Status */
  --status-solved: #c8e6c9;
  --status-solved-text: #2e7d32;
  --status-partial: #fff3e0;
  --status-partial-text: #f57c00;
  --status-unsolved: #757575;
  
  /* Letter Backgrounds */
  --letter-bg: #e8eaed;
  --letter-light: #ece8e0;
  --current-puzzle: #e8f5e8;
  
  /* Rainbow Animation */
  --rainbow-1: #B84451;
  --rainbow-2: #D5713E;
  --rainbow-3: #E9AF34;
  --rainbow-4: #9FAD44;
  --rainbow-5: #8D4B86;
  
  /* Gray Shades */
  --gray-light: #f8f8f8;
  --gray-medium: #888;
  --gray-dark: #555;
  --gray-darker: #444;
  --gray-darkest: #333;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Rubik';
}

html {
  height: 100%;
}

body {
  height: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
  background: var(--bg-white);
  touch-action: none;
  opacity: 1;
  transition: opacity 0.3s ease-in;
  overscroll-behavior: none;
}

body.loading {
  opacity: 0;
}

.progress-bar-container {
  width: 100%;
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box;
  display: none;
}

.container {
  height: calc(100dvh - 74px);
  width: 100%;
  max-width: 500px;
  padding: 0 34px 0px 34px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
}

@media (min-width: 800px) {
  .container {
    max-width: 800px;
  }
}

.container.loaded {
  opacity: 1;
  visibility: visible;
}

.game-title-container {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 5px;
  margin-bottom: 10px;
  padding-top: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
}

.game-title-inner {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 5px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

@media (min-width: 800px) {
  .game-title-inner {
    max-width: 800px;
  }
}

.game-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

@media (min-width: 800px) {
  .game-title {
    font-size: 20px;
  }
  
  .game-title-pill {
    padding: 8px 16px;
  }
}

.game-title-pill {
  cursor: pointer;
  transition: opacity 0.2s ease;
  background: var(--pill-bg);
  padding: 10px 16px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  position: relative;
  overflow: hidden;
}

.game-title-pill:hover {
  opacity: 0.7;
}

.pill-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--tile-bg);
  transition: width 0.4s ease, background 0.5s ease;
  z-index: 0;
  pointer-events: none;
}

.game-title-pill.completed .pill-progress-fill {
  background: var(--color-snake-stroke);
}

.pill-hint-marker {
  position: absolute;
  top: 0;
  height: 100%;
  width: 2px;
  background: var(--tile-bg);
  z-index: 1;
  pointer-events: none;
  transition: left 0.4s ease, opacity 0.3s ease;
  display: none;
}

#pillHintMarker {
  left: 33.33%;
}

#pillHintMarker2 {
  left: 66.67%;
}

.game-title-pill.completed .pill-hint-marker {
  display: none;
}

#gameTitleWords {
  position: relative;
  z-index: 1;
  transition: color 0.4s ease;
}

.game-title-pill.completed #gameTitleWords {
  color: white;
}


.rotate-btn-desktop {
  display: none;
}

@media (min-width: 800px) {
  .rotate-btn-desktop {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pill-bg);
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity 0.2s ease;
  }

  .rotate-btn-desktop:hover {
    opacity: 0.7;
  }

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

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pill-bg);
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  transition: opacity 0.2s ease;
}

.menu-btn:hover {
  opacity: 0.7;
}

.menu-btn:active {
  transform: translateY(-50%) scale(0.95);
}

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

.rotate-btn-mobile {
  position: absolute;
  top: -82px;
  right: -30px;
  background: var(--pill-bg);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  color: var(--text-dark);
  transition: transform 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

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

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

@media (min-width: 800px) {
  .rotate-btn-mobile {
    display: none !important;
  }
}

.rotate-btn-desktop svg,
.rotate-btn-mobile svg {
  transition: transform 0.3s ease;
}

.rotate-btn-desktop.rotating svg,
.rotate-btn-mobile.rotating svg {
  animation: rotateIcon 0.6s ease-in-out;
}

@keyframes rotateIcon {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hint-badge-placeholder {
  display: none;
}

.game-content {
  display: flex;
  flex-direction: column;
  overflow: visible;
  margin-top: 24px;
}

@media (min-width: 800px) {
  .game-content {
    flex-direction: row;
    flex-wrap: wrap;
    column-gap: 60px;
    row-gap: 30px;
    position: relative;
  }
}

.words-column {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  order: 0;
  transition: transform 0.4s ease;
}

@media (min-width: 800px) {
  .words-column {
    flex: 1;
    min-width: 0;
    order: 1;
  }
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--tile-bg);
  border-radius: 0;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--snake-green), var(--snake-green-dark));
  border-radius: 0;
  width: 0%;
  transition: width 0.4s ease;
  position: absolute;
  top: 0;
  left: 0;
}

.wordlist-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  padding: 4px;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.wordlist-toggle-btn:hover {
  opacity: 0.7;
}

.wordlist-toggle-btn svg {
  width: 22px;
  height: 22px;
  transition: transform 0.3s ease;
  stroke: var(--text-dark);
}

.words-list {
  transition: height 0.4s ease, opacity 0.4s ease, margin-bottom 0.4s ease;
  overflow-x: visible;
  height: 180px;
  overflow: scroll;
  text-align: center;
  flex-shrink: 0;
  width: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin-bottom: 0;
}

.words-list::-webkit-scrollbar {
  display: none;
}

.words {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  width: 100%;
  justify-content: center;
}

@media (min-width: 800px) {
  .words-list {
    height: 330px;
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
  }
  
  .words-column.collapsed .words-list {
    height: 0 !important;
    opacity: 0;
    margin-bottom: 0 !important;
    overflow: hidden;
  }

  .words {
    justify-content: left;
  }
}



.words::-webkit-scrollbar {
  display: none;
}

.word { 
  display: block; 
  margin: 0; 
  padding: 10px;
  color: var(--letter-light);
  background: transparent;
  font-weight: 600;
  font-size: 22px;
  cursor: default;
  position: relative;
  border-radius: 50px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

.word.bonus { 
  display: none;
}

.word.found { 
  color: var(--text-dark);
  background: transparent;
  cursor: default;
}

.word.found.just-found {
  animation: word-found-celebration 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
}

@keyframes word-found-celebration {
  0% {
    transform: scale(0.3) rotateZ(-10deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotateZ(5deg);
  }
  100% {
    transform: scale(1) rotateZ(0deg);
    opacity: 1;
  }
}

.word.bonus.found {
  display: block;
  color: var(--color-bonus);
  background: transparent;
  cursor: default;
}

.word-letter-slot {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

.word-letter-dot {
  display: inline-block;
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  font-size: 32px;
  line-height: 1;
  vertical-align: baseline;
  position: relative;
  top: 5px;
  opacity: 1;
}

.word-letter-reveal {
  display: inline-block;
  margin: 0;
  padding: 0;
  color: var(--text-dark);
  opacity: 0;
  max-width: 0;
  overflow: hidden;
}

.word-letter-slot.revealed .word-letter-dot {
  opacity: 0;
  max-width: 0;
}

.word-letter-slot.revealed .word-letter-reveal {
  opacity: 1;
  max-width: 1em;
  color: var(--text-dark);
}

.word.found .word-letter-dot {
  opacity: 0;
  max-width: 0;
}

.word.found .word-letter-reveal {
  opacity: 1;
  max-width: 1em;
  color: var(--text-dark);
}

.word.bonus.found .word-letter-reveal {
  color: var(--snake-green);
}

.letters-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  align-items: center;
  transition: transform 0.4s ease;
  order: 2;
}

@media (max-width: 799px) {
  .letters-column.puzzle-completed {
    transform: translateY(-78px);
  }

  .letters-column.puzzle-completed .rotate-btn-mobile {
    opacity: 0;
    pointer-events: none;
  }
  
  .completion-section.show {
    margin-top: -48px;
  }

}

@media (min-width: 800px) {
  .letters-column {
    flex: 1;
    align-items: stretch;
  }

  .letters-column.puzzle-completed {
    transform: translateY(-76px);
  }

  .words-column.puzzle-completed {
    transform: translateY(-76px);
  }
}

.letters-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 0;
  width: 100%;
  max-width: 320px;
  padding: 10px;
  align-self: center;
}


@media (max-height: 700px) {
.letters-wrap {
  max-width: 260px;
}
}

@media (min-width: 800px) {
  .letters-wrap {
    flex: 1;
    justify-content: flex-start;
  }
}

.players-solved-text {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  margin-top: 80px;
  display: none;
}

.see-results-btn {
  background: var(--pill-bg);
  border: none;
  color: var(--text-dark);
  padding: 14px 24px;
  border-radius: 24px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
  margin-top: 16px;
  white-space: nowrap;
  width: fit-content;
  align-self: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  margin-top: -62px;
  z-index: 999;
}

.see-results-btn:hover {
  opacity: 0.7;
}

.see-results-btn:active {
  opacity: 0.5;
}

.completion-section {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 30px;
  padding-top: 20px;
  flex-shrink: 0;
  opacity: 0;
  animation: celebrateIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.completion-section.show {
  display: flex;
}

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

.completion-time {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  line-height: 1.3;
}

.completion-ranking {
  font-size: 26px;
  font-weight: 600;
  color: var(--snake-green);
  text-align: center;
  margin-top: 8px;
}

.more-puzzles-button {
  background: linear-gradient(135deg, var(--snake-green), var(--snake-green-dark));
  border: none;
  color: var(--text-white);
  padding: 14px 28px;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  max-width: 260px;
  text-transform: none;
  margin-top: 24px;
}

.more-puzzles-button:hover {
  background: linear-gradient(135deg, var(--snake-green-dark), var(--snake-green-dark));
  transform: translateY(-2px);
}

.more-puzzles-button:active {
  transform: translateY(0);
}

.feedback-wrap {
  font-size: 22px; 
  font-weight: 600;
  line-height: 1.5;
  min-height: 117px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dark);
  width: 100%;
  flex-shrink: 0;
  text-align: center;
  order: 1;
  padding-top:32px;
  padding-bottom: 32px;
  transition: opacity 0.3s ease;
}

.game-content.puzzle-completed .feedback-wrap {
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 800px) {
  .feedback-wrap {
    margin-bottom: 20px;
    min-height: 56px;
    height: 56px;
    order: 0;
    flex-basis: 100%;
    position: relative;
  }
}

#feedback-message {
  line-height: 1.5;
  color: var(--text-dark);
  white-space: normal;
  word-wrap: break-word;
}

#feedback-message.forming {
  color: var(--text-dark);
  display: inline-block;
  background: var(--pill-bg);
  padding: 10px;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}


#feedback-message.forming.tap-mode {
  cursor: pointer;
}

#feedback-message.forming.tap-mode:hover {
  transform: scale(1.05);
  opacity: 1;
}

#feedback-message.forming.tap-mode:active {
  transform: scale(0.95);
}

#feedback-message.success {
  color: var(--snake-green);
  animation: feedback-pop-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
  display: inline-block;
}

#feedback-message.bonus {
  color: var(--snake-green);
  animation: feedback-pop-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
  display: inline-block;
}

#feedback-message.error {
  color: var(--color-error);
  animation: error-shake 0.4s ease;
}

#feedback-message.perfect {
  background: linear-gradient(90deg, #f7c948, #f97316, #e74c9a, #8b5cf6, #3b82f6, #22c55e, #f7c948);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: feedback-pop-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), rainbow-scroll 1.5s linear infinite;
  transform-origin: center;
  display: inline-block;
  font-weight: bold;
}

@keyframes rainbow-scroll {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@keyframes success-pulse {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.15); }
  60% { transform: scale(0.95); }
}

@keyframes feedback-pop-in {
  0% {
    transform: scale(0.3) rotateZ(-10deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotateZ(5deg);
  }
  100% {
    transform: scale(1) rotateZ(0deg);
    opacity: 1;
  }
}

@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}


.letters-grid-wrap {
  flex: 1;
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 800px) {
  .letters-grid-wrap {
    align-items: flex-start;
  }
}

.snake-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.snake-svg #snake-head {
  display: none;
}

#snake-poly {
  transition: all 0.1s ease-out;
}

.letters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.letters.grid-4x4 {
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.letter {
  width: 100% !important;
  height: 0 !important;
  padding-bottom: 100%;
  font-size: 32px;
  position: relative;
  display: block !important;
  font-weight: 700;
  border-radius: 10px;
  transition: all 0.15s ease-out;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  color: var(--text-dark);
}

.letters.grid-4x4 .letter {
  font-size: 28px;
}

.letter::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--tile-bg);
  border-radius: 10px;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.letter-text {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 2;
  color: inherit;
}

.letter-counter {
  position: absolute;
  bottom: 7px;
  right: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-light);
  z-index: 3;
  pointer-events: none;
}

.letters.grid-4x4 .letter-counter {
  font-size: 14px;
  bottom: 4px;
  right: 6px;
}

.letter.selected .letter-text {
  color: var(--text-white);
}

.letter.completed-green::before {
  background: var(--snake-green);
}

.letter.completed-green .letter-text {
  color: var(--text-white);
}

.letter.anticipation-pulse {
  animation: anticipationPulse 0.4s ease-out;
}

@keyframes anticipationPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.letter.green-sweep::before {
  animation: greenSweep 0.3s ease-out forwards;
}

@keyframes greenSweep {
  0% { background: var(--letter-bg); }
  100% { background: var(--snake-green); }
}

.letter.wave-animate {
  animation: dramaticWave 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dramaticWave {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  40%, 60% {
    transform: translateY(-40px) scale(1.1);
  }
}

.letter.rainbow-animate::before {
  animation: rainbowBackgrounds 1.5s ease-in-out !important;
}

.letter.rainbow-animate .letter-text {
  color: var(--text-white);
}

@keyframes rainbowBackgrounds {
  0% { background: var(--rainbow-1); }
  20% { background: var(--rainbow-2); }
  40% { background: var(--rainbow-3); }
  60% { background: var(--rainbow-4); }
  80% { background: var(--rainbow-5); }
  100% { background: var(--snake-green); }
}

.letter.settle-pop {
  animation: settlePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes settlePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.letter.celebration-dance {
  animation: celebrationWiggle 0.9s ease-in-out both;
}

@keyframes celebrationWiggle {
  0%   { transform: rotate(0deg); }
  15%  { transform: rotate(-6deg); }
  35%  { transform: rotate(6deg); }
  55%  { transform: rotate(-4deg); }
  75%  { transform: rotate(4deg); }
  90%  { transform: rotate(-1deg); }
  100% { transform: rotate(0deg); }
}

.letters.grid-success-pulse {
  animation: gridSuccessPulse 0.5s ease;
}

@keyframes gridSuccessPulse {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.03); }
  60% { transform: scale(0.98); }
}

.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loader-overlay.show {
  opacity: 1;
  visibility: visible;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f0f0f0;
  border-top: 4px solid var(--snake-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-darkest);
  margin-bottom: 8px;
}

.loader-subtext {
  font-size: 14px;
  color: var(--text-medium);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 0;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-overlay::-webkit-scrollbar {
  display: none;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show .modal {
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 24px;
  max-width: 350px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transform: scale(0.8);
  text-align: left;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(60vh);
  margin: auto 20px;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal::-webkit-scrollbar {
  display: none;
}

.modal-header {
  margin-bottom: 24px;
  text-align: center;
  position: relative;
}

.modal-word {
  font-size: 24px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--gray-darkest);
}

.modal-close-x {
  position: absolute;
  top: 18px;
  right: 15px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-dark);
  font-size: 30px;
  font-weight: 600;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  border-radius: 8px;
  z-index: 3;
}

.modal-close-x:hover { 
  background: #f3f3f3; 
  color: var(--text-dark); 
}

.modal-close {
  background: linear-gradient(135deg, var(--snake-green), var(--snake-green-dark));
  border: none;
  color: var(--text-white);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
  width: 100%;
  margin-top: 20px;
}

.modal-close:hover {
  background: linear-gradient(135deg, var(--snake-green-dark), var(--snake-green-dark));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

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

.info-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 20px;
  text-align: center;
}

.info-content {
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-darker);
  text-align: left;
}

.info-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-darkest);
  margin: 20px 0 10px 0;
}

.info-content p {
  margin-bottom: 12px;
}

.info-content ul {
  margin: 12px 0;
  padding-left: 20px;
}

.info-content li {
  margin-bottom: 8px;
}

.info-content a {
  color: var(--snake-green);
  text-decoration: none;
  font-weight: 600;
}

.info-content a:hover {
  text-decoration: underline;
}

.info-highlight {
  background: var(--bg-green-highlight);
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid var(--snake-green);
  margin: 16px 0;
  font-weight: 500;
}

#results-overlay {
  padding-top: 120px;
  align-items: flex-start;
}

#results-overlay .modal {
  margin: 0 20px;
}

@media (max-width: 799px) {
  #results-overlay {
    padding-top: 120px;
    align-items: flex-start;
  }
}

.results-modal {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.results-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dark);
  margin-top: -8px;
  margin-bottom: 0px;
  line-height: 40px;
}

.results-time {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 20px;
  text-align: center;
}

.results-ranking {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 25px;
  text-align: center;
}

.results-share-button {
  background: var(--snake-green);
  border: none;
  color: var(--text-white);
  padding: 12px 32px;
  border-radius: 50px;
  font-size: 19px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: fit-content;
  text-transform: none;
  margin-bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.results-share-button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.results-share-button:hover {
  background: var(--snake-green-darker);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(94, 141, 90, 0.3);
}

.results-share-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(94, 141, 90, 0.3);
}

.results-change-puzzle-button {
  gap: 0;
}

.results-streak {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-dark);
  text-align: center;
  margin-bottom: 20px;
}

.results-stats {
  margin-bottom: 12px;
  width: 100%;
}


.results-try-master {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-dark);
  text-align: center;
  margin-top: 10px;
  cursor: pointer;
}

.results-try-master-link {
  text-decoration: underline;
}

.stat-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-dark);
  text-align: center;
  line-height: 1.3;
  max-width: 80px;
}


.puzzle-list-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.puzzle-tab {
  flex: 1;
  padding: 10px 16px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  background: var(--pill-bg);
  border-radius: 20px;
  text-decoration: none;
  transition: opacity 0.2s ease;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.puzzle-tab.active {
  background: var(--snake-green);
  color: var(--text-white);
}

.puzzle-list-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 16px;
}

.puzzle-list-note {
  font-size: 14px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 22px;
}

.puzzle-list {
  max-height: 270px;
  overflow-y: auto;
  margin-bottom: 20px;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.puzzle-list::-webkit-scrollbar {
  display: none;
}

.puzzle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-white);
}

.puzzle-item.current {
  background: var(--current-puzzle);
  border-color: var(--snake-green);
  border-width: 1px;
}

.puzzle-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.puzzle-number {
  font-weight: 600;
  font-size: 16px;
  color: var(--gray-darkest);
}

.puzzle-details {
  font-size: 14px;
  color: var(--text-medium);
  margin-top: 2px;
}

.puzzle-status {
  font-weight: 600;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
}

.puzzle-status.solved {
  background: var(--status-solved);
  color: var(--status-solved-text);
}

.puzzle-status.partial {
  background: var(--status-partial);
  color: var(--status-partial-text);
}

.puzzle-status.unsolved {
  background: var(--bg-light);
  color: var(--status-unsolved);
}

.first-letter-counter-modal,
.two-thirds-modal,
.first-drag-modal,
.first-bonus-modal {
  text-align: center;
}

.first-letter-counter-title,
.two-thirds-title,
.first-drag-title,
.first-bonus-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-dark);
}

.first-letter-counter-message,
.two-thirds-message,
.first-drag-message,
.first-bonus-message {
  font-size: 20px;
  line-height: 1.6;
  color: var(--text-medium);
  margin-top: 16px;
}

.first-drag-message-desktop {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .first-drag-message-mobile {
    display: none;
  }
  .first-drag-message-desktop {
    display: inline;
  }
}

.first-letter-counter-continue-button,
.two-thirds-continue-button,
.first-drag-continue-button,
.first-bonus-continue-button,
.continue-playing-button,
.feedback-button {
  background: linear-gradient(135deg, var(--snake-green), var(--snake-green-dark));
  border: none;
  color: var(--text-white);
  padding: 14px 28px;
  border-radius: 10px;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(76, 175, 80, 0.3);
  width: 100%;
  margin-top: 20px;
  text-transform: none;
}

.feedback-button {
  display: block;
  font-size: 18px;
  text-decoration: none;
  text-align: center;
}

.first-letter-counter-continue-button:hover,
.two-thirds-continue-button:hover,
.first-drag-continue-button:hover,
.first-bonus-continue-button:hover,
.continue-playing-button:hover,
.feedback-button:hover {
  background: linear-gradient(135deg, var(--snake-green-dark), var(--snake-green-dark));
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.first-letter-counter-continue-button:active,
.two-thirds-continue-button:active,
.first-drag-continue-button:active,
.first-bonus-continue-button:active,
.continue-playing-button:active,
.feedback-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.first-letter-counter-continue-button:disabled,
.two-thirds-continue-button:disabled,
.first-drag-continue-button:disabled,
.first-bonus-continue-button:disabled,
.continue-playing-button:disabled,
.feedback-button:disabled,
.first-letter-counter-continue-button.disabled,
.two-thirds-continue-button.disabled,
.first-drag-continue-button.disabled,
.first-bonus-continue-button.disabled,
.continue-playing-button.disabled,
.feedback-button.disabled {
  background: linear-gradient(135deg, #a5a5a5, #8c8c8c);
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  opacity: 0.7;
}

.menu-modal {
  text-align: left;
}

.menu-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  line-height: inherit;
}

.menu-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.menu-link {
  background: none;
  border: none;
  color: var(--gray-darkest);
  padding: 15px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.menu-link:hover {
  background: var(--bg-gray);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.menu-link:active {
  transform: translateY(0);
}

.how-to-play-modal,
.privacy-terms-modal {
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.how-to-play-modal::-webkit-scrollbar,
.privacy-terms-modal::-webkit-scrollbar {
  display: none;
}

/* ===========================================
   WELCOME MODAL
   =========================================== */
.welcome-overlay {
  align-items: center;
  padding: 20px;
}

.welcome-modal {
  text-align: center;
  max-height: none;
  padding: 32px 28px;
}


.welcome-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0;
}

.welcome-message {
  font-size: 21px;
  color: var(--text-medium);
  margin-bottom: 28px;
  line-height: 1.7;
}

.welcome-play-button {
  background: linear-gradient(135deg, var(--snake-green), var(--snake-green-dark));
  border: none;
  color: var(--text-white);
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(76, 175, 80, 0.35);
  width: 100%;
  letter-spacing: 0.3px;
}

.welcome-play-button:hover {
  background: linear-gradient(135deg, var(--snake-green-dark), var(--snake-green-darker));
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(76, 175, 80, 0.45);
}

.welcome-play-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* ─── Single Word Definition Modal ──────────────────────────────────────── */

.word-def-modal {
  text-align: left;
  padding-top: 20px;
}

.word-def-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  margin-top: 16px;
  line-height: 1;
}

.word-def-name.bonus {
  color: var(--snake-green);
}

.word-def-definition {
  font-size: 15px;
  color: var(--gray-darker);
  line-height: 1.55;
  margin: 0 0 8px 0;
}

.word-def-example {
  font-size: 14px;
  color: #999;
  font-style: italic;
  line-height: 1.45;
  margin: 0;
}

/* ─── Definitions Modal ──────────────────────────────────────────────────── */

.definitions-modal {
  max-height: calc(60vh);
  display: flex;
  flex-direction: column;
}

.definitions-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  text-align: center;
}

.definitions-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex: 1;
  margin-top: 4px;
}

.definitions-list::-webkit-scrollbar {
  display: none;
}

.definitions-word-entry {
  padding: 14px 0;
  border-bottom: 1px solid #ececec;
}

.definitions-word-entry:last-child {
  border-bottom: none;
}

.definitions-word-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.definitions-word-entry.bonus .definitions-word-name {
  color: var(--snake-green);
}

.definitions-word-definition {
  font-size: 14px;
  color: var(--gray-darker);
  line-height: 1.5;
  margin: 0 0 4px 0;
}

.definitions-word-example {
  font-size: 13px;
  color: #999;
  font-style: italic;
  line-height: 1.4;
  margin: 0;
}

.definitions-empty {
  font-size: 15px;
  color: var(--gray-dark);
  text-align: center;
  padding: 24px 0;
  margin: 0;
}

/* Make found words in the word list feel tappable */
.word.found,
.word.bonus.found {
  cursor: pointer;
}

.word.found:active,
.word.bonus.found:active {
  opacity: 0.7;
}

/* ===========================================
   DARK MODE
   =========================================== */
body.dark-mode {
  --pill-bg: #2a2a2a;
  --tile-bg: #2e2e2e;

  --text-dark: #efefef;
  --text-medium: #aaa;
  --text-light: #777;

  --bg-white: #1a1a1a;
  --bg-light: #222;
  --bg-gray: #333;
  --bg-green-light: #1e2f1e;
  --bg-green-highlight: #1b281b;
  --bg-modal: rgba(0, 0, 0, 0.72);

  --border-light: #383838;
  --border-medium: #444;

  --status-solved: #1e3d1e;
  --status-solved-text: #66bb6a;
  --status-partial: #3a2800;
  --status-partial-text: #ffb74d;
  --status-unsolved: #888;

  --letter-bg: #2e2e2e;
  --letter-light: #2a2a2a;
  --current-puzzle: #1e2f1e;

  --gray-light: #222;
  --gray-medium: #999;
  --gray-dark: #aaa;
  --gray-darker: #bbb;
  --gray-darkest: #dedede;
}

body.dark-mode .modal-close-x:hover {
  background: #333;
}

body.dark-mode .definitions-word-example {
  color: #777;
}

/* Dark mode toggle row */
.menu-dark-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: default;
}

.menu-dark-mode-row:hover {
  transform: none;
}

.dark-mode-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--bg-gray);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.25s ease;
  flex-shrink: 0;
  border: 2px solid var(--border-light);
}

.dark-mode-toggle.active {
  background: var(--snake-green);
  border-color: var(--snake-green);
}

.dark-mode-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.dark-mode-toggle.active .dark-mode-toggle-knob {
  transform: translateX(18px);
}

/* ── Confetti ──────────────────────────────────────────────────────────── */
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transform-origin: center;
  animation: confetti-burst ease-out forwards;
}

@keyframes confetti-burst {
  0%   { opacity: 1; transform: translate(0, 0)                       rotateZ(0deg)   scale(1); }
  60%  { opacity: 1; transform: translate(var(--ex), var(--ey))       rotateZ(240deg) scale(0.9); }
  100% { opacity: 0; transform: translate(var(--ex), calc(var(--ey) + 20px)) rotateZ(360deg) scale(0.5); }
}

