/*
 * Word Snake.
 *
 * Everything is scoped under .game-wordsnake so the game can share a document
 * with the platform chrome (and, in principle, another game). The PZL games
 * overrides at the foot of the file were the page's inline <style> block; they
 * sat after the stylesheet originally and must stay last.
 */

/* ===========================================
   COLOR VARIABLES — PZL games / Zanagrams palette
   =========================================== */
.game-wordsnake {
  /* Center game UI here — never on body (that was centering drawer brand). */
  text-align: center;

  /* CTAs — brand blue; snake path uses --color-snake-stroke */
  --snake-green: #4169f1;
  --snake-green-dark: #2f50d8;
  --snake-green-darker: #2744b8;
  --color-snake-stroke: #E56B4A;
  --green: #2e9e5b;
  --green-dark: #278a4f;

  /* Pills & Buttons */
  --pill-bg: #ffffff;

  /* Letter Tiles */
  --tile-bg: #d9d5c8;

  /* Text Colors */
  --text-dark: #1c1c1e;
  --text-medium: #616162;
  --text-light: #b8b8b4;
  --text-white: white;

  /* Status Colors */
  --color-bonus: #f59e0b;
  --color-error: #e0524a;
  --color-badge: #e0524a;
  --hint-bg: #F5D0C4;
  --blue: #4169f1;
  --orange: #f59e0b;

  /* Backgrounds */
  --bg-white: #ffffff;
  --bg-light: #f0efe9;
  --bg-gray: #e8e6dd;
  --bg-green-light: #e6ecff;
  --bg-green-highlight: #eef2ff;
  --bg-modal: #ffffff;

  /* Borders */
  --border-light: #ece9e0;
  --border-medium: #d8d5c9;

  /* Puzzle Status */
  --status-solved: #dff3e6;
  --status-solved-text: #2e9e5b;
  --status-partial: #fdebcf;
  --status-partial-text: #c47d10;
  --status-unsolved: #b8b8b4;

  /* Letter Backgrounds */
  --letter-bg: #e8e6dd;
  --letter-light: #e8e6dd;
  --current-puzzle: #e6ecff;

  /* Rainbow Animation */
  --rainbow-1: #B84451;
  --rainbow-2: #D5713E;
  --rainbow-3: #E9AF34;
  --rainbow-4: #9FAD44;
  --rainbow-5: #8D4B86;

  /* Gray Shades */
  --gray-light: #f0efe9;
  --gray-medium: #b8b8b4;
  --gray-dark: #616162;
  --gray-darker: #444;
  --gray-darkest: #1c1c1e;

  /* Completed tiles use success green (not the blue snake) */
  --tile-complete: #2e9e5b;
}

/* ===========================================
   BASE RESET
   =========================================== */
.game-wordsnake * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Baloo 2", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

html:has(.game-wordsnake) {
  height: 100%;
}

body:has(.game-wordsnake) {
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  position: fixed;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  touch-action: none;
  opacity: 1;
  transition: opacity 0.3s ease-in;
  overscroll-behavior: none;
}

/* ===========================================
   LAYOUT
   =========================================== */
.game-wordsnake .container {
  height: 100dvh;
  width: 100%;
  max-width: 440px;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 0px 20px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
}

.game-wordsnake .container.loaded {
  opacity: 1;
  visibility: visible;
}

/* ===========================================
   HEADER BUTTONS (Menu + Rotate)
   =========================================== */
.game-wordsnake .rotate-btn, .game-wordsnake .help-btn, .game-wordsnake .hint-btn,
.game-wordsnake .grid-tool-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  border-radius: 8px;
  padding: 0;
  width: 38px;
  height: 38px;
  box-shadow: none;
  transition: color 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
  text-decoration: none;
}

.game-wordsnake .rotate-btn:hover, .game-wordsnake .help-btn:hover, .game-wordsnake .hint-btn:hover,
.game-wordsnake .grid-tool-btn:hover:not(:disabled) {
  color: var(--snake-green);
  opacity: 1;
}

.game-wordsnake .rotate-btn svg, .game-wordsnake .help-btn svg, .game-wordsnake .hint-btn svg,
.game-wordsnake .grid-tool-btn svg {
  width: 30px;
  height: 30px;
  display: block;
}

.game-wordsnake .grid-tool-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.game-wordsnake .hint-badge,
body:has(.game-wordsnake) #pd-chrome-tools .hint-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--color-snake-stroke, #E56B4A);
  color: #fff;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  pointer-events: none;
}

/* Hide lightbulb on welcome/tutorial/completion */
body:has(.game-wordsnake.is-welcome) #pd-chrome-tools .hint-btn,
body:has(.game-wordsnake.is-tutorial) #pd-chrome-tools .hint-btn,
body:has(.game-wordsnake.is-done) #pd-chrome-tools .hint-btn {
  display: none !important;
}

.game-wordsnake .hint-btn.shake {
  animation:wordsnake-iconShake .35s ease;
}

@keyframes wordsnake-iconShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.game-wordsnake .rotate-btn svg {
  transition: transform 0.3s ease;
}

.game-wordsnake .rotate-btn.rotating svg {
  animation:wordsnake-spin 0.6s ease-in-out;
}

/* ===========================================
   GAME LAYOUT — same on mobile + desktop
   Pager above centered letter grid
   =========================================== */
.game-wordsnake .game-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  margin: 16px auto 0;
  overflow: visible;
}

/* ===========================================
   WORD PAGER (one missing word at a time)
   =========================================== */
.game-wordsnake .word-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 380px;
  margin: 0 0 20px;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.game-wordsnake .word-pager.is-complete {
  opacity: 0.55;
  pointer-events: none;
}

.game-wordsnake.is-done .word-pager,
.game-wordsnake .word-pager.puzzle-completed {
  visibility: hidden;
}

.game-wordsnake .word-pager-stage {
  width: 100%;
  min-width: 0;
  text-align: center;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.game-wordsnake .word-pager-clue-slot {
  --pager-font: clamp(28px, 8vw, 36px);
  position: relative;
  width: 100%;
  height: calc(var(--pager-font) * 1.25);
  flex-shrink: 0;
}

.game-wordsnake .word-pager-clue {
  /* Slot wide enough for M/W; tight gap so letters don't look spaced out */
  --pager-slot: 0.7em;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 8vw, 36px);
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--text-dark, #1c1c1e);
  width: 100%;
  height: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: content-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.04em;
}

/* Status overlays the clue — never changes document flow */
.game-wordsnake .word-pager-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 8px;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(22px, 6vw, 28px);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--color-error);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-sizing: border-box;
}

.game-wordsnake .word-pager-status[hidden] {
  display: none !important;
}

.game-wordsnake .word-pager-clue-slot.is-showing-status .word-pager-clue {
  visibility: hidden;
}

/* Fixed slots so wide letters (N/M/W) never reflow the row */
.game-wordsnake .word-pager-clue .pager-letter,
.game-wordsnake .word-pager-clue .pager-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--pager-slot);
  min-width: var(--pager-slot);
  max-width: var(--pager-slot);
  flex: 0 0 var(--pager-slot);
  margin: 0;
  padding: 0;
  box-sizing: content-box;
  text-align: center;
}

.game-wordsnake .word-pager-clue .pager-letter {
  color: inherit;
}

/* Tiny nudge on the clue's first letter when the player starts wrong */
.game-wordsnake .word-pager-clue .pager-letter.is-nudge {
  animation: wordsnake-clueLetterNudge 0.36s ease;
}

@keyframes wordsnake-clueLetterNudge {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-3px); }
  40%      { transform: translateX(3px); }
  60%      { transform: translateX(-2px); }
  80%      { transform: translateX(2px); }
}

.game-wordsnake .word-pager-clue .pager-blank {
  color: inherit;
}

/* Typed letters fill into the clue blanks */
.game-wordsnake .word-pager-clue .pager-letter.is-typed {
  color: var(--color-snake-stroke, #2e9e5b);
}

/* Letters revealed by the hint lightbulb — no flash */
.game-wordsnake .word-pager-clue .pager-letter.is-hinted {
  color: var(--blue, #3b6ef5);
}

/* 18 Words-style toast */
.game-wordsnake .ws-toast {
  position: fixed;
  left: 50%;
  bottom: calc(40px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  background: #1c1c1e;
  color: #f5f5f7;
  padding: 13px 22px;
  border-radius: 999px;
  font-family: var(--pd-font-ui);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2000;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.game-wordsnake .ws-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.game-wordsnake .word-pager-clue.is-found,
.game-wordsnake .word-pager-clue.is-solved {
  color: var(--green, #2e9e5b);
}

.game-wordsnake .word-pager-clue.is-solved {
  animation: wordsnake-wordPop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Bonus finds that fit the clue use the same green solved pulse (no gold) */
.game-wordsnake .word-pager-clue.is-solved.is-bonus {
  color: var(--green, #2e9e5b);
}

.game-wordsnake .word-pager-clue.is-solved .pager-letter {
  color: inherit;
}

.game-wordsnake .word-pager-clue.is-shake {
  /* Transform-only shake on the clue box (doesn't affect layout) */
  animation: wordsnake-error-shake 0.4s ease;
  color: var(--color-error);
}

.game-wordsnake .word-pager-status.is-shake {
  animation: wordsnake-error-shake 0.4s ease;
}

.game-wordsnake .word-pager-meta {
  margin: 0;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(14px, 3.6vw, 17px);
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: var(--text-dark, #1c1c1e);
}

.game-wordsnake .pd-c-score.is-resigned {
  font-variant-numeric: normal;
}
.game-wordsnake.is-resigned .pd-c-share {
  display: none !important;
}

/* Hidden word store — keep for game logic only */
.game-wordsnake #modal-words {
  display: none !important;
}

.game-wordsnake .word.bonus {
  display: none;
}

.game-wordsnake .word.found.already-found-shake {
  animation: wordsnake-error-shake 0.4s ease;
}

/* ===========================================
   FEEDBACK BAR (removed — kept in DOM for JS only)
   =========================================== */
.game-wordsnake .feedback-wrap,
.game-wordsnake #feedback-message,
.game-wordsnake #feedback-message.forming,
.game-wordsnake #feedback-message.success,
.game-wordsnake #feedback-message.bonus,
.game-wordsnake #feedback-message.error,
.game-wordsnake #feedback-message.perfect,
.game-wordsnake #feedback-message.words-left {
  display: none !important;
  margin: 0 !important;
  min-height: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Scale-only pulse — same beat as Zanagrams forming.res-good */
@keyframes wordsnake-wordPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ===========================================
   LETTERS COLUMN
   =========================================== */
.game-wordsnake .letters-column {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  align-items: center;
  flex: 0 0 auto;
  transition: transform 0.4s ease;
}

.game-wordsnake .letters-column.puzzle-completed {
  transform: translateY(-64px);
}

.game-wordsnake .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: 360px;
  padding: 10px;
  align-self: center;
  padding-bottom: 12px;
  gap: 4px;
}

/* Skip + rotate row — hidden for now */
.game-wordsnake .letters-tools {
  display: none !important;
}

@media (max-width: 799px) {
  .game-wordsnake .letters-wrap {
    width: 92%;
    max-width: 360px;
  }
}

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

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

/* ===========================================
   SNAKE SVG
   =========================================== */
.game-wordsnake .snake-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

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

.game-wordsnake #snake-poly {
  transition: stroke 0.12s ease-out;
}

.game-wordsnake #snake-poly.res-good {
  stroke: var(--green) !important;
}
.game-wordsnake #snake-poly.res-bonus {
  stroke: var(--orange) !important;
}

.game-wordsnake .letter.res-good::before {
  background: var(--green);
}
.game-wordsnake .letter.res-good .letter-text {
  color: #fff;
}
.game-wordsnake .letter.res-bonus::before {
  background: var(--orange);
}
.game-wordsnake .letter.res-bonus .letter-text {
  color: #fff;
}

/* Subtle path glow along the found word — then settles */
.game-wordsnake .letter.word-found-glow,
.game-wordsnake .letter.word-found-glow-bonus {
  z-index: 4;
}
.game-wordsnake .letter.word-found-glow::before,
.game-wordsnake .letter.word-found-glow-bonus::before {
  animation: wordsnake-foundGlow 1.05s ease-in-out both;
  animation-delay: var(--found-delay, 0ms);
}
.game-wordsnake .letter.word-found-glow-bonus::before {
  animation-name: wordsnake-foundGlowBonus;
}
@keyframes wordsnake-foundGlow {
  0%   { background: var(--tile-bg); }
  45%  { background: #e6f1eb; }
  100% { background: var(--tile-bg); }
}
@keyframes wordsnake-foundGlowBonus {
  0%   { background: var(--tile-bg); }
  45%  { background: #f7eee6; }
  100% { background: var(--tile-bg); }
}

/* ===========================================
   LETTER TILES
   =========================================== */
.game-wordsnake .letters {
  display: grid;
  grid-template-columns: repeat(var(--ws-cols, 4), 1fr);
  gap: 7px;
  width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

/* Soft diagonal sheen — quiet, slow, polished glide with the clue pulse */
.game-wordsnake .letters.word-shine::after,
.game-wordsnake .letters.word-shine-bonus::after {
  content: '';
  position: absolute;
  inset: -35%;
  z-index: 30;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 28%,
    rgba(255, 255, 255, 0.02) 40%,
    rgba(255, 255, 255, 0.1) 48%,
    rgba(255, 255, 255, 0.16) 50%,
    rgba(255, 255, 255, 0.1) 52%,
    rgba(255, 255, 255, 0.02) 60%,
    transparent 72%
  );
  transform: translateX(-120%) skewX(-10deg);
  animation: wordsnake-gridShine 0.95s cubic-bezier(0.4, 0.05, 0.2, 1) both;
}
.game-wordsnake .letters.word-shine-bonus::after {
  background: linear-gradient(
    115deg,
    transparent 28%,
    rgba(255, 240, 220, 0.03) 40%,
    rgba(255, 255, 255, 0.1) 48%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 248, 235, 0.09) 52%,
    rgba(255, 236, 214, 0.03) 60%,
    transparent 72%
  );
}
@keyframes wordsnake-gridShine {
  to { transform: translateX(120%) skewX(-10deg); }
}

.game-wordsnake .letter {
  width: 100% !important;
  height: 0 !important;
  padding-bottom: 100%;
  font-size: clamp(26px, 7.2vw, 34px);
  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);
}

/* Older 3×3 puzzle files keep a slightly larger letter size */
.game-wordsnake .letters[data-cols="3"] {
  --ws-cols: 3;
  gap: 8px;
}
.game-wordsnake .letters[data-cols="3"] .letter {
  font-size: clamp(30px, 8vw, 40px);
}

.game-wordsnake .letter::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--tile-bg);
  border-radius: 10px;
  z-index: 2;
  box-shadow: none;
}

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

.game-wordsnake .letter-counter {
  display: none !important;
}

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

.game-wordsnake .letter.hint-letter::before {
  background: var(--hint-bg);
}
.game-wordsnake .letter.hint-letter .letter-text {
  color: #8B3F2C;
}

/* Hint pulses disabled — reveal is quiet (clue slot + path lock only) */
.game-wordsnake .letter.hint-pulse,
.game-wordsnake .letter.hint-pulse-lit {
  animation: none !important;
}
.game-wordsnake .letter.hint-pulse::before,
.game-wordsnake .letter.hint-pulse-lit::before {
  animation: none !important;
}

.game-wordsnake .letter.completed-green::before {
  background: var(--tile-complete, var(--snake-green));
}

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

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

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

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

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

/* ===========================================
   MODALS — BASE
   =========================================== */
.game-wordsnake .modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

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

.game-wordsnake .modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.game-wordsnake .modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px 16px 22px;
  max-width: 400px;
  width: 100%;
  border: 2px solid #2B2B2B;
  box-shadow: none;
  transform: scale(0.8);
  text-align: left;
  position: relative;
  overflow: hidden;
  overscroll-behavior: none;
  max-height: min(58dvh, calc(100dvh - 96px));
  margin: auto 0;
  flex-shrink: 0;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body:has(.game-wordsnake):has(.modal-overlay.show) {
  overflow: hidden !important;
  overscroll-behavior: none;
}

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

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

.game-wordsnake .modal-close-x {
  position: absolute;
  top: 25px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: #2B2B2B;
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  border-radius: 8px;
  z-index: 3;
  padding: 0;
}

.game-wordsnake .modal-close-x:hover {
  background: rgba(0, 0, 0, .06);
  color: #2B2B2B;
}

.game-wordsnake .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;
}

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

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

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

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

/* ===========================================
   MILESTONE MODALS
   (first-letter-counter, two-thirds, first-drag, first-bonus)
   =========================================== */
.game-wordsnake .first-letter-counter-modal, .game-wordsnake .two-thirds-modal, .game-wordsnake .first-bonus-modal {
  text-align: center;
}

.game-wordsnake .first-letter-counter-title, .game-wordsnake .two-thirds-title, .game-wordsnake .first-bonus-title, .game-wordsnake .hint-title {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dark);
  padding: 0 28px;
}

.game-wordsnake .first-bonus-title.bonus-title {
  color: var(--orange);
}

.game-wordsnake .first-letter-counter-message, .game-wordsnake .two-thirds-message, .game-wordsnake .first-bonus-message, .game-wordsnake .hint-body {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-medium);
  margin-top: 12px;
}

.game-wordsnake .first-bonus-message.bonus-body {
  font-size: 19px;
  color: var(--text-dark);
  max-width: 300px;
  margin: 12px auto 0;
  text-align: center;
}
.game-wordsnake .first-bonus-message.bonus-body p {
  margin: 0 0 14px;
}
.game-wordsnake .first-bonus-message.bonus-body p:last-child {
  margin-bottom: 0;
}

.game-wordsnake .btn-bonus {
  background: var(--orange) !important;
  box-shadow: 0 8px 18px rgba(245, 158, 11, .38) !important;
}
.game-wordsnake .btn-bonus:hover {
  filter: brightness(.97);
  background: var(--orange) !important;
}

.game-wordsnake .modal-hint {
  text-align: center;
  max-width: 400px;
}
.game-wordsnake .hint-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.game-wordsnake .hint-actions .btn {
  flex: 1;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 800;
  font-size: 17px;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  padding: 14px 18px;
  touch-action: manipulation;
}
.game-wordsnake .hint-actions .btn-primary {
  background: var(--blue);
  color: #fff;
}
.game-wordsnake .hint-actions .btn-secondary {
  background: transparent;
  color: var(--text-dark);
  border: 3px solid var(--text-dark);
}

.game-wordsnake .first-letter-counter-continue-button, .game-wordsnake .two-thirds-continue-button, .game-wordsnake .first-bonus-continue-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: none;
  width: 100%;
  margin-top: 20px;
  text-transform: none;
}

.game-wordsnake .first-letter-counter-continue-button:hover, .game-wordsnake .two-thirds-continue-button:hover, .game-wordsnake .first-bonus-continue-button:hover {
  background: linear-gradient(135deg, var(--snake-green-dark), var(--snake-green-dark));
  transform: translateY(-2px);
  box-shadow: none;
}

.game-wordsnake .first-letter-counter-continue-button:active, .game-wordsnake .two-thirds-continue-button:active, .game-wordsnake .first-bonus-continue-button:active {
  transform: translateY(0);
  box-shadow: none;
}

.game-wordsnake .first-letter-counter-continue-button:disabled, .game-wordsnake .two-thirds-continue-button:disabled, .game-wordsnake .first-bonus-continue-button:disabled, .game-wordsnake .first-letter-counter-continue-button.disabled, .game-wordsnake .two-thirds-continue-button.disabled, .game-wordsnake .first-bonus-continue-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;
}

/* ===========================================
   WORD DEFINITION MODAL (single word)
   =========================================== */
.game-wordsnake .word-def-modal {
  text-align: left;
  padding-top: 20px;
}

.game-wordsnake .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;
}

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

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

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

/* ===========================================
   WORD LIST MODAL (progress pill)
   =========================================== */
.game-wordsnake .definitions-modal {
  max-height: min(70vh, 560px);
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
}

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

.game-wordsnake .definitions-modal .words-list {
  height: auto !important;
  max-height: none;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0 0;
  text-align: center;
  scroll-snap-type: none;
}

.game-wordsnake .definitions-modal .words {
  justify-content: center;
  padding-bottom: 8px;
}

/* ===========================================
   DARK MODE (site-wide via html[data-theme])
   =========================================== */
html[data-theme="dark"] .game-wordsnake {
  --pill-bg: #1c1c19;
  --tile-bg: #2e2c28;

  --text-dark: #dddace;
  --text-medium: #8e8e86;
  --text-light: #6b6b66;

  --bg-white: #141412;
  --bg-light: #1c1c19;
  --bg-gray: #2a2a26;
  --bg-green-light: #1e2a22;
  --bg-green-highlight: #243028;
  --bg-modal: #1c1c19;

  --border-light: #3a3a35;
  --border-medium: #4a4a44;

  --status-solved: #1e3d2a;
  --status-solved-text: #3cb87a;
  --status-partial: #3a2800;
  --status-partial-text: #ffb74d;
  --status-unsolved: #888;

  --letter-bg: #2e2c28;
  --letter-light: #2a2a26;
  --current-puzzle: #1e2a22;

  --gray-light: #1c1c19;
  --gray-medium: #9a9a92;
  --gray-dark: #b8b8b0;
  --gray-darker: #c4c2b6;
  --gray-darkest: #dddace;
}

html[data-theme="dark"] .game-wordsnake .modal-close-x:hover {
  background: #2a2a26;
}

/* ===========================================
   KEYFRAME ANIMATIONS
   =========================================== */
@keyframes wordsnake-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes wordsnake-letterRevealPop {
  0%   { opacity: 0; transform: scale(0.3) translateY(6px); }
  65%  { opacity: 1; transform: scale(1.2) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

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

@keyframes wordsnake-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 wordsnake-error-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

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

@keyframes wordsnake-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(--tile-complete, var(--snake-green)); }
}

@keyframes wordsnake-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); }
}

/* --------------------------------------------------------------------------
   PZL games page overrides. These came from the page's inline <style>,
   which sat after the stylesheet, so they stay last to keep winning.
   -------------------------------------------------------------------------- */

/* PZL games shell — cream page, header/footer chrome, game in the middle */
html:has(.game-wordsnake) {
  height: auto;
  min-height: 100%;
}
body:has(.game-wordsnake) {
  position: relative !important;
  width: 100% !important;
  height: auto !important;
  min-height: 100dvh !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  background: transparent !important;
  touch-action: manipulation;
  opacity: 1 !important;
}
.game-wordsnake .content {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: 1403px;
  min-height: 700px;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  background: transparent;
  line-height: normal;
  box-sizing: border-box;
}
.game-wordsnake .game-shell {
  width: 100%;
  max-width: 440px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  line-height: normal;
  padding: 0 16px;
  box-sizing: border-box;
}
.game-wordsnake .container {
  height: auto !important;
  min-height: 700px;
  max-width: 100% !important;
  padding: 12px 4px 0 !important;
}
@media (max-width: 768px) {
  html:has(.game-wordsnake), body:has(.game-wordsnake) {
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  .game-wordsnake .content {
    min-height: 0 !important;
  }
  .game-wordsnake .game-shell, .game-wordsnake .container {
    min-height: 0 !important;
    height: 100% !important;
  }
  .game-wordsnake .container {
    display: flex !important;
    flex-direction: column !important;
  }
  .game-wordsnake .game-content {
    margin-top: 8px !important;
  }

  /* Done: unlock page scroll so the completion screen (defs etc.) can move. */
  html:has(.game-wordsnake.is-done),
  body:has(.game-wordsnake.is-done) {
    height: auto !important;
    max-height: none !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
  .game-wordsnake.is-done .content,
  .game-wordsnake.is-done .game-shell {
    min-height: auto !important;
    height: auto !important;
  }
}
/* Display type — match Zanagrams / 18 Words */
.game-wordsnake .definitions-title, .game-wordsnake .first-letter-counter-title, .game-wordsnake .two-thirds-title, .game-wordsnake .first-bonus-title, .game-wordsnake .letter, .game-wordsnake .letter-text, .game-wordsnake .first-letter-counter-continue-button, .game-wordsnake .two-thirds-continue-button, .game-wordsnake .first-bonus-continue-button, .game-wordsnake .results-share-button {
  font-family: 'Baloo 2', system-ui, sans-serif !important;
}

/* Modal shell — shared tokens (see shared/css/modals.css) */
.game-wordsnake .modal {
  background: var(--pd-colour-surface, #fff) !important;
  border: var(--pd-modal-border) !important;
  border-radius: var(--pd-modal-radius, 22px) !important;
  box-shadow: var(--pd-shadow-modal) !important;
  color: var(--pd-colour-text);
}
.game-wordsnake .modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  background: transparent !important;
  align-items: center !important;
  padding: 20px !important;
  z-index: 1000 !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}
/* Hide the whole puzzle (clue + tools + grid) while paused — no peeking */
.game-wordsnake.is-paused .game-content {
  visibility: hidden;
}
.game-wordsnake.is-done .feedback-wrap {
  display: none !important;
}
.game-wordsnake.is-done .container {
  height: auto !important;
  min-height: 0 !important;
  overflow: visible;
  flex: none;
  padding-bottom: 8px;
}
.game-wordsnake.is-done .game-shell {
  flex: none;
  height: auto !important;
}
.game-wordsnake.is-done #wsBackBtn {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 1001 !important;
}
/* Back icon lives in the chrome row */
.game-wordsnake #wsBackBtn {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin: 0;
  transform: none;
  pointer-events: auto !important;
}

/* Under-board completion — staged reveal like The Middle.
   Negative top margin offsets the empty space left by
   .letters-column.puzzle-completed { transform: translateY(-64px) }. */
.game-wordsnake #completeScreen.pd-complete-panel {
  margin-top: -28px;
  padding-left: 0;
  padding-right: 0;
  opacity: 1;
  transform: none;
  transition: none;
}
.game-wordsnake #completeScreen.pd-complete-panel:not(.is-shown) {
  visibility: hidden;
  pointer-events: none;
}
.game-wordsnake #completeScreen.pd-complete-panel.is-shown {
  visibility: visible;
  pointer-events: auto;
}
.game-wordsnake #completeScreen.pd-complete-panel.is-instant .ws-c-stage {
  transition: none;
}
.game-wordsnake .ws-c-stage {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.45s cubic-bezier(.22, 1, .36, 1), transform 0.45s cubic-bezier(.22, 1, .36, 1);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.game-wordsnake .ws-c-stage.is-in {
  opacity: 1;
  transform: none;
}
.game-wordsnake .ws-c-score-block {
  width: 100%;
}
.game-wordsnake #completeScreen .pd-c-score {
  font-variant-numeric: tabular-nums;
}
.game-wordsnake .pd-c-word-list .def-item {
  grid-template-columns: minmax(0, 1fr) auto;
}
.game-wordsnake .pd-c-word-list .def-word.bonus {
  color: #f59e0b;
}
.game-wordsnake .pd-c-word-list .pd-c-bonus-head {
  margin: 28px 0 8px;
  font-family: var(--pd-font-body, 'Baloo 2', system-ui, sans-serif);
  font-size: 16px;
  font-weight: 800;
  color: #616162;
}

/* ===========================================
   FIRST-RUN TUTORIAL (in normal play column)
   =========================================== */
.game-wordsnake .ws-tut-panel[hidden] {
  display: none !important;
}

body:has(.game-wordsnake.is-tutorial) #pd-chrome-tools {
  display: none;
}

/* Daily board must fully leave the layout during tutorial.
   `.container { display:flex }` otherwise overrides the [hidden] attribute. */
.game-wordsnake.is-tutorial #wsGameContainer,
.game-wordsnake.is-tutorial #wsGameContainer.loaded {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.game-wordsnake .ws-tut-panel {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 28px 12px 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-sizing: border-box;
  color: var(--pd-colour-text, #1c1c1e);
  touch-action: none;
  /* Sit in the same centered play slot as .container */
  flex: 0 1 auto;
  align-self: center;
}

body.pd-game:not(.pd-welcome):not(.pd-done):not(:has(.is-done)) .game-wordsnake .pd-play-area > .ws-tut-panel:not([hidden]) {
  flex: 0 1 auto !important;
  height: auto !important;
  max-height: 100%;
  min-height: 0;
  width: min(440px, 100%);
}

.game-wordsnake .ws-tut-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.game-wordsnake .ws-tut-text {
  margin: 4px 8px 0;
  text-align: center;
  font-family: var(--pd-font-ui);
  font-weight: 800;
  font-size: clamp(17px, 4.6vw, 22px);
  line-height: 1.45;
  color: var(--text-dark, #1c1c1e);
}

.game-wordsnake .ws-tut-clue {
  --tut-slot: 0.7em;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.04em;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 8vw, 36px);
  line-height: 1.25;
  color: var(--text-dark, #1c1c1e);
}

.game-wordsnake .ws-tut-clue .pager-letter,
.game-wordsnake .ws-tut-clue .pager-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tut-slot);
  min-width: var(--tut-slot);
  max-width: var(--tut-slot);
  flex: 0 0 var(--tut-slot);
}

.game-wordsnake .ws-tut-clue .pager-letter.is-typed {
  color: var(--color-snake-stroke, #2e9e5b);
}

.game-wordsnake .ws-tut-clue .pager-letter.is-nudge {
  animation: wordsnake-clueLetterNudge 0.36s ease;
}

.game-wordsnake .ws-tut-clue.is-solved {
  color: var(--green, #2e9e5b);
  animation: wordsnake-wordPop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.game-wordsnake .ws-tut-clue.is-solved .pager-letter {
  color: inherit;
}

/* Tutorial board — same tile size / font / padding as the daily grid */
.game-wordsnake .ws-tut-board {
  width: 100%;
  max-width: 360px;
  margin: 14px auto 0;
}

@media (max-width: 799px) {
  .game-wordsnake .ws-tut-board {
    width: 92%;
  }
}

.game-wordsnake .ws-tut-board .ws-tut-letters-wrap {
  width: 100%;
  max-width: 360px;
  padding: 10px;
  padding-bottom: 12px;
  margin: 0;
  align-self: center;
}

.game-wordsnake .ws-tut-board .letters-grid-wrap {
  width: 100%;
}

.game-wordsnake .ws-tut-board .letters {
  --ws-cols: 4;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.game-wordsnake .ws-tut-board .letter {
  font-size: clamp(26px, 7.2vw, 34px);
  cursor: pointer;
}

.game-wordsnake .ws-tut-board .snake-svg #wsTutHead {
  display: none;
}

.game-wordsnake .ws-tut-skip {
  display: block;
  align-self: center;
  margin: 20px auto 0;
  padding: 10px 22px;
  border: 2px solid var(--text-dark, #2b2b2b);
  border-radius: 999px;
  background: var(--bg-modal, var(--pd-colour-surface, #fff));
  color: var(--text-dark, #1c1c1e);
  font-family: var(--pd-font-ui);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.game-wordsnake .ws-tut-skip.tut-skip-play {
  background: var(--text-dark, #1a1a1a);
  border-color: var(--text-dark, #1a1a1a);
  color: var(--bg-white, #fff);
}

html[data-theme="dark"] .game-wordsnake .ws-tut-skip.tut-skip-play {
  background: var(--text-dark);
  border-color: var(--text-dark);
  color: var(--bg-white);
}

.game-wordsnake .ws-tut-panel.tut-done .ws-tut-text {
  margin: 8px 4px 0;
  font-size: clamp(22px, 5.2vw, 26px);
  line-height: 1.3;
}

.game-wordsnake .ws-tut-panel.tut-done .ws-tut-clue {
  margin-top: 12px;
}

