/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── Mobile: prevent browser swipe/scroll gestures hijacking touch events ─── */
/* game.js installs its own touch handlers with e.preventDefault(), but the
   browser still needs touch-action: none on the root to allow that on iOS. */
@media (pointer: coarse) {
  html, body {
    touch-action: none;
    overscroll-behavior: none;
  }
}

/* ── Body ──────────────────────────────────────────────────────────────────── */
body {
  font-family: 'Sen', sans-serif;
  background-image: url('../assets/images/ui/felt-texture.webp');
  background-repeat: repeat;
  background-size: 1024px 1024px;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  user-select: none;
}

/* ── Scale wrapper ─────────────────────────────────────────────────────────── */
#scale-wrapper {
  transform-origin: top center;
  flex-shrink: 0;
  line-height: 0;
}

/* ── Game stage (felt playing surface) ────────────────────────────────────── */
/* Background comes entirely from the body — one unified felt texture at one
   scale.  Giving the stage its own background-image caused a visible seam
   because the stage is CSS-transformed (scaled) while the body background
   is not, making the two tile sizes diverge at every zoom level. */
#game-stage {
  position: relative;
  width: 4000px;
  height: 2400px;
}

/* ── Logo (in the top holding area above the board) ──────────────────────── */
/* Board at left:1125, width:1750 → centre = 1125+875 = 2000; board top = 320.
   Logo centred horizontally at 2000 and vertically in the 0–320 band (midpoint 160). */
#puzzle-logo {
  position: absolute;
  width: 1150px;
  max-height: 290px;
  height: auto;
  left: 2000px;
  top: 160px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* -- drop shadow for board ---- */
#board-shadow {
  position: absolute;
  left: 1125px;
  top: 320px;
  width: 1750px;
  height: 1400px;
  pointer-events: none;
  z-index: 0;
  border-radius: 6px;
  box-shadow: 0 20px 60px 16px rgba(0, 0, 0, 0.65);
}

/* ── Board frame — textured border sits behind #board-inset ────────────────── */
/* 48 px larger on every side than #board — the outer 24px ring (beyond
   #board-inset's own footprint below) is what's actually visible as wood. */
#board-frame {
  position: absolute;
  left: 1077px;   /* 1125 - 48 */
  top: 272px;     /* 320  - 48 */
  width: 1846px;  /* 1750 + 96 */
  height: 1496px; /* 1400 + 96 */
  background: url('../assets/images/background/board-background.jpg') center / cover no-repeat;
  border-radius: 32px;
  pointer-events: none;
}

/* ── Board inset — parchment mat between the wood frame and the play area ─── */
/* Same footprint the wood frame used to have (24px larger than #board on
   every side) — the wood frame above is now sized to extend a further 24px
   ring beyond this, so wood stays fully visible outside the mat rather than
   being covered by it. Flat color, no shadow/bevel. */
#board-inset {
  position: absolute;
  left: 1101px;   /* 1125 - 24 */
  top: 296px;     /* 320  - 24 */
  width: 1798px;  /* 1750 + 48 */
  height: 1448px; /* 1400 + 48 */
  background: #e8dcc0;
  border-radius: 20px;
  pointer-events: none;
}

/* ── Board (reference container for the grid overlay) ─────────────────────── */
#board {
  position: absolute;
  left: 1125px;
  top: 320px;
  width: 1750px;
  height: 1400px;
  background: #ffffff;
  pointer-events: none;
  border-radius: 6px;
}

/* ── Grid SVG (drawn programmatically by game.js) ─────────────────────────── */
#grid-svg {
  position: absolute;
  left: 1125px;
  top: 320px;
  pointer-events: none;
  z-index: 2;
}

/* ── Clue hover targets — invisible zones at each empty snap position ──────── */
.clue-target {
  position: absolute;
  pointer-events: all;
  z-index: 5;   /* above board grid (z-index:2), below loose pieces (z-index:10) */
}

/* ── Puzzle pieces ─────────────────────────────────────────────────────────── */
.puzzle-piece {
  position: absolute;
  display: block;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 10;
}


.puzzle-piece.dragging {
  cursor: grabbing;
  z-index: 1000;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
  /* Force Safari to promote the dragging piece to its own compositor layer.
     Without this Safari leaves a black smear where the piece was on each frame. */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: left, top;
}

.puzzle-piece.snapped {
  cursor: default;
  pointer-events: none;
  /* JS sets inline z-index: 3 on snap so placed pieces sink below loose ones.
     z-index: 3 here as a fallback (preview mode pieces have no inline override). */
  z-index: 3;
  transition: left 0.15s ease-out, top 0.15s ease-out;
}

/* ── Taskbar — wood grain strip fixed at the bottom ──────────────────────── */
#ui-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  height: 58px;
  z-index: 500;
  pointer-events: none;
  background-image: url('../assets/images/ui/wood.webp');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: center;
  border-top: 1px solid rgba(0, 0, 0, 0.70);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.55);
}

#ui-bar > * {
  pointer-events: auto;
}

#taskbar-logo {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  height: clamp(20px, 2.2vw, 32px);
  width: auto;
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.8)) drop-shadow(0 0 6px rgba(0,0,0,0.5));
}

/* ── Taskbar buttons — white text, no chrome ──────────────────────────────── */
#reset-btn, #pause-btn, #hint-btn, #undo-btn, #buy-vowel-btn,
#music-btn, #theme-taskbar-btn, #zoom-fit-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.78);
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 10px;
  transition: color 0.15s, transform 0.12s;
  white-space: nowrap;
  line-height: 1;
}
#reset-btn:hover, #pause-btn:hover, #hint-btn:hover, #undo-btn:hover, #buy-vowel-btn:hover,
#music-btn:hover, #theme-taskbar-btn:hover, #zoom-fit-btn:hover {
  color: rgba(255, 255, 255, 1);
  transform: scale(1.12);
}
#reset-btn:active, #pause-btn:active, #hint-btn:active, #undo-btn:active, #buy-vowel-btn:active,
#music-btn:active, #theme-taskbar-btn:active, #zoom-fit-btn:active {
  transform: scale(0.93);
}

/* ── Peek button — corner thumbnail card ─────────────────────────────────── */
#peek-btn {
  position: fixed;
  bottom: 70px;
  right: 14px;
  z-index: 3500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 5px 5px 7px;
  background: rgba(8, 4, 0, 0.90);
  border: 1px solid rgba(255, 220, 120, 0.38);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}
#peek-btn:hover,
#peek-btn:focus-visible {
  border-color: rgba(255, 220, 120, 0.72);
  box-shadow: 0 0 14px rgba(255, 200, 60, 0.28);
  transform: translateY(-3px);
}
#peek-btn:active {
  transform: translateY(-1px);
  box-shadow: none;
}
#peek-thumbnail {
  display: block;
  width: 84px;
  height: 63px;
  object-fit: cover;
  border-radius: 3px;
  pointer-events: none;
}
.peek-label {
  font-family: 'Sen', sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 240, 200, 0.65);
  pointer-events: none;
  transition: color 0.15s;
}
#peek-btn:hover .peek-label {
  color: rgba(255, 240, 200, 1.0);
}

#start-btn {
  padding: 7px 24px;
  border: 1px solid rgba(255, 220, 120, 0.75);
  background: rgba(255, 200, 80, 0.18);
  color: rgba(255, 240, 180, 0.96);
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 200, 80, 0.18);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.12s;
}
#start-btn:hover {
  background: rgba(255, 200, 80, 0.34);
  border-color: rgba(255, 230, 130, 1.0);
  box-shadow: 0 0 24px rgba(255, 200, 80, 0.40);
}
#start-btn:active { transform: scale(0.96); }


/* Start overlay — difficulty card anchored above UI bar by JS (bottom/left/transform) */
#start-overlay {
  position: fixed;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
  background: rgba(8, 4, 0, 0.78);
  border: 1px solid rgba(255, 220, 120, 0.18);
  border-radius: 6px;
  backdrop-filter: blur(6px);
}

#piece-counter {
  font-family: 'Sen', sans-serif;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.80);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.06em;
}

/* ── Completion overlay ────────────────────────────────────────────────────── */
#celebration {
  display: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 35%, rgba(100, 60, 5, 0.45) 0%, transparent 70%),
    rgba(8, 4, 0, 0.95);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 24px 28px;
}

#celebration::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 15%, rgba(255, 200, 60, 0.07) 0%, transparent 55%);
  pointer-events: none;
}

#celebration.show {
  display: flex;
  animation: fadeInOverlay 1.4s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
}

/* Word overlay layer — behind board & content */
#celeb-word-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

/* Floating word + definition cards */
.celeb-word-float {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  max-width: 240px;
  transform: translateX(-50%);
  pointer-events: none;
  animation: wordFloat 13s ease-in-out forwards;
}

.celeb-word-name {
  font-family: 'Sen', sans-serif;
  font-style: italic;
  font-size: 1.05rem;
  color: rgba(255, 240, 200, 0.82);
  letter-spacing: 0.06em;
}

.celeb-word-def {
  font-family: 'Sen', sans-serif;
  font-size: 0.67rem;
  color: rgba(255, 225, 170, 0.48);
  letter-spacing: 0.02em;
  line-height: 1.55;
}

@keyframes wordFloat {
  0%   { opacity: 0; transform: translateX(-50%) translateY(14px); }
  8%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; transform: translateX(-50%) translateY(-12px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-22px); }
}

/* Scaled board render — flex child, sits above the text */
#celebration-board-bg {
  flex-shrink: 0;
  pointer-events: none;
  filter: drop-shadow(0 10px 40px rgba(0, 0, 0, 0.7));
  margin-bottom: 10px;
  position: relative;
  z-index: 2;
  /* width / height set by JS */
}

#celebration-board-stage {
  position: relative;
  width: 1750px;
  height: 1400px;
  transform-origin: top left;
  background: #ffffff;
  overflow: hidden;
  border-radius: 4px;
  box-shadow:
    0 0 0 3px rgba(255, 200, 80, 0.25),
    0 12px 60px rgba(0, 0, 0, 0.7);
}

/* Text + buttons sit below the board */
#celebration-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  animation: celebContentIn 1.1s 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

/* Gold accent rule */
.celebration-rule {
  width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 200, 80, 0.55), transparent);
  margin: 4px 0;
  flex-shrink: 0;
}

#celebration-title {
  font-family: 'Sen', sans-serif;
  font-style: italic;
  font-size: 2.6rem;
  color: #fff8e8;
  text-align: center;
  text-shadow:
    0 0 60px rgba(255, 200, 60, 0.50),
    0 0 20px rgba(255, 160, 0, 0.30),
    0 4px 16px rgba(0, 0, 0, 0.60);
  letter-spacing: 0.03em;
  line-height: 1.2;
  margin: 6px 0 2px;
}

#celebration-sub {
  font-family: 'Sen', sans-serif;
  font-size: 0.95rem;
  font-style: italic;
  color: rgba(255, 240, 200, 0.70);
  text-align: center;
  max-width: 420px;
  line-height: 1.65;
  letter-spacing: 0.04em;
}

#celebration-time {
  font-family: 'Sen', sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 210, 80, 0.75);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  min-height: 1.2em;
}

#celebration-best {
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  color: rgba(255, 220, 100, 0.80);
  letter-spacing: 0.12em;
  text-align: center;
}

#celebration-best.new-record {
  color: rgba(255, 220, 80, 1.0);
  text-shadow: 0 0 12px rgba(255, 200, 60, 0.6);
}

/* ── Celebration button row (Begin Again + Rise) ─────────────────────────── */
#celebration-btns-row {
  display: flex;
  flex-direction: row;
  gap: 12px;
  margin-top: 6px;
}

#celebration-btn,
#level-up-btn {
  flex: 1 1 0;
  min-width: 0;
}

#celebration-btn {
  padding: 10px 26px;
  border: 1px solid rgba(255, 220, 120, 0.40);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 240, 200, 0.80);
  font-family: 'Sen', sans-serif;
  font-size: 0.80rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}

#celebration-btn:hover {
  background: rgba(255, 200, 80, 0.12);
  border-color: rgba(255, 220, 120, 0.65);
  color: rgba(255, 245, 210, 1.0);
}

/* ── Level-up button — shown when a harder difficulty is available ────────── */
#level-up-btn {
  padding: 10px 26px;
  border: 1px solid rgba(255, 220, 120, 0.70);
  background: rgba(255, 200, 80, 0.14);
  color: rgba(255, 240, 180, 0.95);
  font-family: 'Sen', sans-serif;
  font-size: 0.80rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 200, 80, 0.15), inset 0 1px 0 rgba(255, 240, 160, 0.12);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

#level-up-btn:hover {
  background: rgba(255, 200, 80, 0.26);
  border-color: rgba(255, 230, 130, 0.95);
  box-shadow: 0 0 28px rgba(255, 200, 80, 0.35), inset 0 1px 0 rgba(255, 240, 160, 0.18);
}

#level-up-btn:active { transform: scale(0.97); }

/* ── Celebration secondary row (Save Score + Share) ──────────────────────── */
#celebration-secondary-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

/* ── Confetti canvas ───────────────────────────────────────────────────────── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
}

/* ── Keyframe animations ───────────────────────────────────────────────────── */
@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Snap glow — cloned img overlay, NOT on the piece itself ─────────────── */
/* Animating filter directly on the snapped piece creates a CSS stacking
   context that hoists the piece above its assigned z-index.  Instead we
   clone the piece image, place it at z-index 100 for 0.55 s, animate the
   glow on the clone, then remove it. The real piece is never touched. */
@keyframes snapGlow {
  0%   { filter: drop-shadow(0 0  0px rgba(255, 220,  80, 0.0)); opacity: 1; }
  18%  { filter: drop-shadow(0 0 22px rgba(255, 220,  80, 1.0))
                 drop-shadow(0 0 48px rgba(255, 160,   0, 0.75));  opacity: 1; }
  100% { filter: drop-shadow(0 0  2px rgba(255, 220,  80, 0.0)); opacity: 0; }
}

.snap-glow {
  position: absolute;
  pointer-events: none;
  z-index: 100;
  animation: snapGlow 0.55s ease-out forwards;
}

/* ── Hold-to-peek reference overlay ──────────────────────────────────────── */
#peek-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
}

/* Wrapper has the exact scaled board dimensions so overflow is hidden */
#peek-wrapper {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 220, 120, 0.25);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}

/* Inner board — 1750 × 1400, scaled by JS to fit the viewport */
#peek-stage {
  position: relative;
  width: 1750px;
  height: 1400px;
  transform-origin: top left;
  background: #ffffff;
}

#peek-label {
  font-family: 'Sen', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 240, 200, 0.6);
  text-align: center;
  margin: 0;
}

/* pulseTitle removed — celebration title is calm, no animation */

/* ── Difficulty selector ──────────────────────────────────────────────────── */
#diff-label {
  font-family: 'Sen', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 240, 200, 0.45);
  margin-bottom: 2px;
}

#difficulty-selector {
  display: flex;
  gap: 8px;
  width: 100%;
}

.diff-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-transform: none;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 220, 120, 0.25);
  color: rgba(255, 240, 200, 0.65);
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  padding: 5px 16px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
}

.diff-btn:hover {
  background: rgba(255, 200, 80, 0.12);
  border-color: rgba(255, 220, 120, 0.55);
  color: rgba(255, 240, 200, 0.92);
}

.diff-btn.active {
  background: rgba(255, 200, 80, 0.18);
  border-color: rgba(255, 220, 120, 0.85);
  color: #fff8e8;
  box-shadow: 0 0 10px rgba(255, 200, 80, 0.2);
}

/* Expert button — same style as other difficulty buttons */

/* ── Timer + Sound toggles (start overlay) ───────────────────────────────── */
#option-toggles {
  display: flex;
  gap: 16px;
  align-items: center;
}

.option-toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: rgba(255, 240, 200, 0.55);
  cursor: pointer;
  user-select: none;
}

.option-toggle-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: rgba(255, 200, 80, 0.85);
  width: 13px;
  height: 13px;
}

/* ── Stats strip — floats centred just above the taskbar ─────────────────── */
#stats-strip {
  position: fixed;
  bottom: 58px;   /* sits flush on top of the taskbar */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 20px 6px;
  background: rgba(6, 3, 0, 0.72);
  border: 1px solid rgba(255, 220, 120, 0.14);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  pointer-events: none;
  z-index: 499;
}

#stats-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* ── Timer display ────────────────────────────────────────────────────────── */
#timer-display {
  font-family: 'Sen', sans-serif;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.80);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.08em;
  text-align: center;
}

/* ── In-game How to Play link ─────────────────────────────────────────────── */
#ingame-howto-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  color: rgba(255, 220, 120, 0.65);
  letter-spacing: 0.06em;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.15s;
}
#ingame-howto-btn:hover {
  color: rgba(255, 220, 120, 1);
}

/* ── Hint button — styled by unified taskbar rule; count is inline ────────── */
#hint-count {
  color: rgba(255, 220, 100, 0.90);
  font-size: 0.66rem;
  margin-left: 3px;
  font-weight: 700;
}

/* ── Hint ghost — piece silhouette shown at its snap position ─────────────── */
/* A copy of the piece image rendered at z-index 50, golden-tinted, that fades
   in and out over 5 s.  Uses filter (safe here — it's a temporary overlay, not
   the real piece, so the stacking context it creates does no harm). */
.hint-ghost {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  filter: sepia(1) saturate(4) hue-rotate(8deg) brightness(1.35)
          drop-shadow(0 0 18px rgba(255, 200, 80, 0.75));
  animation: hintGhostPulse 2s ease-in-out infinite;
}

@keyframes hintGhostPulse {
  0%   { opacity: 0.35; }
  50%  { opacity: 0.70; }
  100% { opacity: 0.35; }
}

/* ── Hint flash — red glow on icon when no eligible piece is held ──────────── */
.hint-flash img.hint-icon {
  animation: hintFlash 0.55s ease-out forwards !important;
}

@keyframes hintFlash {
  0%   { filter: drop-shadow(0 0 14px rgba(255, 90, 60, 1.0))
                 drop-shadow(0 2px 10px rgba(0,0,0,0.55)); }
  55%  { filter: drop-shadow(0 0 7px rgba(255, 140, 80, 0.55))
                 drop-shadow(0 2px 10px rgba(0,0,0,0.55)); }
  100% { filter: drop-shadow(0 2px 10px rgba(0,0,0,0.55)); }
}

/* ── Theme button (in start overlay) ─────────────────────────────────────── */
#theme-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

#start-audio-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 220, 120, 0.28);
  color: rgba(255, 240, 200, 0.60);
  font-family: 'Sen', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 5px 18px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#start-audio-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.55);
}

#theme-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 220, 120, 0.28);
  color: rgba(255, 240, 200, 0.60);
  font-family: 'Sen', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: none;
  padding: 5px 18px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#theme-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.55);
}
#theme-btn.has-theme {
  border-color: rgba(240, 192, 64, 0.75);
  color: rgba(255, 240, 200, 0.90);
}

/* Small colour dot shown when a theme is active */
#theme-btn-dot {
  display: none;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 220, 120, 0.40);
  flex-shrink: 0;
}
#theme-btn.has-theme #theme-btn-dot {
  display: inline-block;
}

/* ── Theme panel ──────────────────────────────────────────────────────────── */
#theme-panel {
  position: fixed;
  z-index: 4001;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 8px;
  background: rgba(8, 4, 0, 0.97);
  border: 1px solid rgba(255, 220, 120, 0.20);
  border-radius: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  min-width: 200px;
}
#theme-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#theme-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 5px;
  padding: 2px 0;
  max-height: 220px;
  overflow-y: auto;
}

.theme-swatch {
  width: 44px;
  height: 44px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  object-fit: cover;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-swatch:hover {
  border-color: rgba(255, 220, 120, 0.50);
}
.theme-swatch.active {
  border-color: rgba(240, 192, 64, 0.95);
  box-shadow: 0 0 6px rgba(240, 192, 64, 0.50);
}

/* Custom-color swatch — opens the native color picker; the swatch itself
   always shows whatever color is currently picked. Firefox's color input
   keeps its own native border/padding unless -moz-appearance is reset, and
   sizes its internal swatch independently of the input's own box — both
   are reset explicitly below so it matches the other flush 44x44 swatches. */
.ts-custom-color {
  display: block;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}
#custom-color-input {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  box-sizing: border-box;
  cursor: pointer;
  background: none;
  display: block;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
#custom-color-input::-webkit-color-swatch-wrapper { padding: 0; }
#custom-color-input::-webkit-color-swatch         { border: none; border-radius: 3px; }
#custom-color-input::-moz-color-swatch {
  border: none;
  border-radius: 3px;
  width: 100%;
  height: 100%;
}
#custom-color-input::-moz-focus-inner {
  border: 0;
  padding: 0;
}

/* Photo-upload label inside the theme panel */
.theme-photo-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 5px 10px;
  line-height: 1;
}
.theme-photo-label input[type="file"] {
  display: none;
}
.theme-photo-label:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.50);
}

#photo-preview {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 5px;
  border: 2px solid rgba(240, 192, 64, 0.80);
  align-self: center;
  margin-top: 2px;
}

/* ── Faint photo guide — full photo at low opacity so users see target placement */
#photo-guide {
  position: absolute;
  left: 1125px;
  top: 320px;
  width: 1750px;
  height: 1400px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.38;
  pointer-events: none;
  z-index: 1;
  display: none;
}

/* ── Invisible hover target over the 53-logo (bottom-right corner of board) */
#logo-hover-target {
  position: absolute;
  left: 2815px;   /* BOARD_X(1125) + logo offset(1690) */
  top:  1660px;   /* BOARD_Y(320) + logo offset(1340) */
  width: 60px;
  height: 60px;
  z-index: 10;
  cursor: help;
  display: none;
}

/* ── Center emblem ─────────────────────────────────────────────────────────── */
/* Sits in the one 50x50 cell Freedom, Hope, Eternal and Harmony all cross
   around but never actually occupy (board-local 850,450) — which is already
   rendered as a solid yellow square by the "outside" mosaic art underneath.
   No background of its own: the icon overlays directly onto that existing
   yellow square rather than covering it with a badge. A little clickable
   extra — cycles its icon on click. Shown only on the default theme; see
   applyTheme() in game.js, which toggles display. */
#center-icon-btn {
  position: absolute;
  left: 1979px;   /* BOARD_X(1125) + 850 + 4px centering margin */
  top:  774px;    /* BOARD_Y(320)  + 450 + 4px centering margin */
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #3a2a12;
  cursor: pointer;
  z-index: 4;
  transition: transform 150ms ease, background 150ms ease;
}
#center-icon-btn:hover  { background: rgba(58,42,18,0.1); transform: scale(1.08); }
#center-icon-btn:active { transform: scale(0.94); }
/* Icons are inlined as <svg> (see _renderCenterIcon), with <img> kept as a
   fallback when the fetch fails — both are sized here. */
#center-icon-btn img,
#center-icon-btn svg    { width: 30px; height: 30px; display: block; pointer-events: none; }

/* ── Center emblem icon animations ────────────────────────────────────────
   Simple looping animation per icon, keyed by filename (see slug logic in
   _renderCenterIcon() in game.js). Icons with no matching class below just
   render static — dropping a new SVG into square-icons/ never requires a
   code change, only a class here if you want it to move.

   Selectors are element-agnostic so they match the inlined <svg> and the
   <img> fallback alike. */
#center-icon-btn .icon-anim-star {
  animation: iconTwinkle 2.2s ease-in-out infinite;
}
#center-icon-btn .icon-anim-sun {
  animation: iconGlowPulse 2.8s ease-in-out infinite;
}
#center-icon-btn .icon-anim-gull {
  animation: iconWingTilt 3.2s ease-in-out infinite;
}

/* ── Fibonacci: draws itself outward, then retracts back in, on a loop ────
   The artwork is a single closed outline that runs from the centre out to its
   farthest point at ~48% of its length, then back in — so simply revealing it
   in its natural direction reads as a spiral drawing itself.

   pathLength="1" is set on the path in JS, which is what lets dasharray and
   dashoffset be expressed as a plain 0..1 fraction here.

   The !important flags override the inline style="" Adobe Illustrator exports
   on the path itself; inline styles otherwise beat every selector. Only the
   stroke weight and joins are overridden — the colour stays as authored. */
#center-icon-btn .icon-anim-fibonacci-sequence path {
  fill: none;                       /* not inline in the file, so no flag needed */
  stroke-width: 1.6 !important;     /* 0.75 in a 50-unit box renders ~0.45px at 30px — too faint to read as a line */
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: fibDraw 8s linear infinite;
}

@keyframes fibDraw {
  /* Draws in, holds, then erases back out along the same route.

     At offset `o` the visible run is [0, 1-o], so sliding the offset back to 1
     retracts the line from its outer tip inward — the reverse of how it was
     drawn, rather than a second erasing pass in the same direction.

     Both ends of the cycle sit at offset 1 (fully empty), so the loop closes
     seamlessly with no flash or jump between repeats.

     0-44%    3.5s   draw, centre spiralling outward
     44-56%   1.0s   hold the completed spiral
     56-100%  3.5s   erase, retracting back to the centre               */
  0%   { stroke-dashoffset: 1; animation-timing-function: ease-in-out; }
  44%  { stroke-dashoffset: 0; }
  56%  { stroke-dashoffset: 0; animation-timing-function: ease-in-out; }
  100% { stroke-dashoffset: 1; }
}

/* Anyone who has asked for less motion gets the finished spiral, not a loop. */
@media (prefers-reduced-motion: reduce) {
  #center-icon-btn .icon-anim-fibonacci-sequence path {
    animation: none;
    stroke-dashoffset: 0;
  }
  #center-icon-btn .icon-anim-star,
  #center-icon-btn .icon-anim-sun,
  #center-icon-btn .icon-anim-gull { animation: none; }
}

@keyframes iconSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes iconTwinkle {
  0%, 100% { opacity: 1;    transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.88); }
}
@keyframes iconGlowPulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 0 rgba(255, 200, 80, 0)); }
  50%      { transform: scale(1.12); filter: drop-shadow(0 0 6px rgba(255, 200, 80, 0.65)); }
}
@keyframes iconWingTilt {
  0%, 100% { transform: rotate(-8deg); }
  50%      { transform: rotate(8deg); }
}

/* ── Word description toast ───────────────────────────────────────────────── */
#word-toast {
  position: fixed;
  bottom: 0;  /* overridden by JS to float just above the stats-strip */
  left: 50%;
  transform: translateX(-50%);
  z-index: 4500;
  background: rgba(8, 4, 0, 0.84);
  border: 1px solid rgba(255, 220, 120, 0.18);
  border-radius: 6px;
  padding: 6px 18px 8px;
  max-width: min(88vw, 1100px);
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}

#word-toast.visible {
  opacity: 1;
}

#word-toast-name {
  font-family: 'Sen', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: rgba(255, 220, 100, 0.95);
  text-transform: uppercase;
  flex-shrink: 0;
}

#word-toast-def {
  font-family: 'Sen', sans-serif;
  font-size: 0.74rem;
  line-height: 1.5;
  color: rgba(255, 240, 200, 0.72);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* #reset-btn is now in the taskbar — styled by the unified taskbar button rule */

/* ── Out-of-hints toast ───────────────────────────────────────────────────── */
#out-of-hints-toast {
  position: fixed;
  top: calc(50% - 60px);      /* slightly above centre */
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  background: rgba(8, 4, 0, 0.90);
  border: 1px solid rgba(255, 110, 70, 0.45);
  border-radius: 6px;
  padding: 14px 30px;
  font-family: 'Sen', sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.07em;
  color: rgba(255, 200, 160, 0.95);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#out-of-hints-toast.visible {
  opacity: 1;
}

/* ── Buy-a-vowel toast ───────────────────────────────────────────────────── */
#buy-vowel-toast {
  position: fixed;
  bottom: 145px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  background: rgba(8, 4, 0, 0.90);
  border: 1px solid rgba(255, 220, 120, 0.45);
  border-radius: 6px;
  padding: 10px 22px;
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 240, 180, 0.95);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#buy-vowel-toast.visible {
  opacity: 1;
}

/* ── Buy-a-vowel slot highlights (pick mode) ────────────────────────────── */
.vowel-slot-highlight {
  position: absolute;
  z-index: 12;
  border-radius: 3px;
  cursor: crosshair;
  box-sizing: border-box;
  animation: vowelSlotPulse 0.8s ease-in-out infinite;
}
.vowel-slot-highlight:hover {
  animation: none;
  background: #c4e2ff;
  border: 3px solid #35b6ff;
  box-shadow: 0 0 12px rgba(53, 182, 255, 0.9), 0 0 28px rgba(53, 182, 255, 0.6);
}
@keyframes vowelSlotPulse {
  0%, 100% {
    background: rgba(120, 200, 255, 0.20);
    border: 3px solid rgba(120, 200, 255, 0.70);
    box-shadow: 0 0 8px rgba(53, 182, 255, 0.55), 0 0 18px rgba(53, 182, 255, 0.30);
  }
  50% {
    background: rgba(120, 200, 255, 0.42);
    border: 3px solid rgba(53, 182, 255, 1);
    box-shadow: 0 0 16px rgba(53, 182, 255, 1), 0 0 36px rgba(53, 182, 255, 0.70);
  }
}

/* Button active state while in pick mode */
#buy-vowel-btn.vowel-pick-active {
  color: #c4e2ff !important;
  transform: scale(1.08);
}

/* ── Buy-a-vowel pick-mode instruction prompt ────────────────────────────── */
#vowel-pick-prompt {
  position: fixed;
  bottom: 145px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5500;
  background: rgba(30, 20, 5, 0.82);
  border: 1px solid rgba(255, 220, 80, 0.55);
  color: rgba(255, 230, 140, 0.95);
  font-family: 'Sen', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  padding: 6px 14px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#vowel-pick-prompt.visible {
  opacity: 1;
}

/* ── Buy-a-vowel hover tooltip ───────────────────────────────────────────── */
#vowel-cost-tip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5500;
  background: rgba(8, 4, 0, 0.88);
  border: 1px solid rgba(255, 220, 120, 0.35);
  border-radius: 5px;
  padding: 5px 14px;
  font-family: 'Sen', sans-serif;
  font-size: 0.64rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(255, 220, 120, 0.90);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s ease;
  bottom: 145px;
}
#vowel-cost-tip.visible {
  opacity: 1;
}

/* ── Stray-piece pulse — unsnapped piece dropped inside the board ─────────── */
/* A slow gold breathing glow that makes the piece easy to spot against the
   placed puzzle pieces.  Applied directly to the img (not a clone) because
   the piece is loose (z-index 10) so the filter stacking context is harmless.
   Cleared the moment the piece is lifted or snaps into place. */
@keyframes strayPulse {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(0,0,0,0.90))
                     drop-shadow(0 0 1px rgba(0,0,0,0.75))
                     drop-shadow(0 0  0px rgba(220, 40, 40, 0.00)); }
  50%      { filter: drop-shadow(0 0 2px rgba(0,0,0,0.90))
                     drop-shadow(0 0 1px rgba(0,0,0,0.75))
                     drop-shadow(0 0 20px rgba(220,  40,  40, 1.0))
                     drop-shadow(0 0 40px rgba(180,  20,  20, 0.85))
                     drop-shadow(0 0 64px rgba(140,   0,   0, 0.45)); }
}

.puzzle-piece.on-board-stray {
  animation: strayPulse 1.6s ease-in-out infinite;
}

/* ── Snapped word pieces — re-enable hover for definition reveal ──────────── */
/* startDrag already guards against dragging snapped pieces, so pointer-events
   auto here is safe; it only enables mouseenter / mouseleave for the tooltip.
   The layered drop-shadow creates a dark outline so text reads clearly on the
   white board (stacking-context promotion is harmless at z-index 3). */
.puzzle-piece.snapped.word-snapped {
  pointer-events: auto;
  cursor: default;
}


/* #zoom-fit-btn is now in the taskbar — styled by the unified taskbar button rule */

/* ── Timer toggle (start overlay) ──────────────────────────────────────── */
#timer-toggle-row,
#grid-toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}

#grid-toggle-row {
  padding: 5px 10px;
}

#timer-toggle-row span,
#grid-toggle-row span {
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255, 240, 200, 0.70);
  transition: color 0.15s;
}

#timer-toggle-row:hover span,
#grid-toggle-row:hover span {
  color: rgba(255, 240, 200, 0.95);
}

#timer-toggle,
#grid-toggle {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 220, 120, 0.50);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

#timer-toggle:checked,
#grid-toggle:checked {
  background: rgba(255, 200, 80, 0.30);
  border-color: rgba(255, 220, 120, 0.85);
}

#timer-toggle:checked::after,
#grid-toggle:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 4px;
  border-left: 2px solid rgba(255, 240, 200, 0.95);
  border-bottom: 2px solid rgba(255, 240, 200, 0.95);
  transform: translate(-50%, -65%) rotate(-45deg);
}

/* ── Instructions button (start overlay) ────────────────────────────────── */
#start-text-btns {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
}

#instructions-btn,
#tutorial-replay-btn {
  background: none;
  border: none;
  color: rgba(255, 240, 200, 0.75);
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 0 0;
  transition: color 0.18s;
}
#instructions-btn:hover,
#tutorial-replay-btn:hover { color: rgba(255, 240, 200, 1); }

/* ── Instructions modal ──────────────────────────────────────────────────── */
#instructions-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}

#instructions-panel {
  position: relative;
  background: rgba(8, 4, 0, 0.94);
  border: 1px solid rgba(255, 220, 120, 0.22);
  border-radius: 8px;
  padding: 30px 36px 26px;
  max-width: 860px;
  width: 92vw;
  backdrop-filter: blur(8px);
}

#instructions-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 40px;
}

#instructions-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: rgba(255, 240, 200, 0.45);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s;
}
#instructions-close:hover { color: rgba(255, 240, 200, 0.90); }

#instructions-panel h2 {
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 220, 100, 0.85);
  text-align: center;
  margin-bottom: 18px;
}

.instr-item {
  margin-bottom: 12px;
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: rgba(255, 240, 200, 0.65);
}
.instr-item:last-child { margin-bottom: 0; }

.instr-diff-list {
  list-style: disc;
  padding-left: 1.2em;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#replay-tutorial-from-modal {
  display: block;
  margin: 16px auto 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 220, 120, 0.28);
  color: rgba(255, 240, 200, 0.60);
  font-family: 'Sen', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 5px 18px;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#replay-tutorial-from-modal:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.55);
}

.instr-label {
  display: block;
  font-size: 0.70rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255, 220, 100, 0.75);
  margin-bottom: 2px;
}

/* ── Instructions pagination ─────────────────────────────────────────────── */
.instr-page { display: none; }
.instr-page.active { display: block; }

.instructions-columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 40px;
}

#instr-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

#instr-dots {
  display: flex;
  gap: 8px;
}

.instr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 220, 100, 0.45);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, border-color 0.2s;
}
.instr-dot.active {
  background: rgba(255, 220, 100, 0.75);
  border-color: rgba(255, 220, 100, 0.75);
}

.instr-nav-btn {
  background: none;
  border: none;
  color: rgba(255, 240, 200, 0.45);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  transition: color 0.15s;
  line-height: 1;
}
.instr-nav-btn:hover:not(:disabled) { color: rgba(255, 240, 200, 0.90); }
.instr-nav-btn:disabled { opacity: 0.2; cursor: default; }

/* #theme-taskbar-btn is now in the taskbar — styled by the unified taskbar button rule */

/* #music-btn is now in the taskbar — styled by the unified taskbar button rule */

/* ── Music options panel — two-column side-by-side layout ────────────────── */
#music-panel {
  position: fixed;
  z-index: 4001;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
  padding: 10px 10px;
  background: rgba(8, 4, 0, 0.97);
  border: 1px solid rgba(255, 220, 120, 0.20);
  border-radius: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}
#music-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Column wrappers */
#music-col, #click-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 108px;
}

/* Vertical divider between columns */
.music-panel-divider-vert {
  width: 1px;
  background: rgba(255, 220, 120, 0.15);
  align-self: stretch;
  margin: 0 8px;
}

/* Volume row — High / Low / Pause in a single line */
#music-vol-row {
  display: flex;
  gap: 4px;
}
#music-vol-row .music-vol-btn {
  flex: 1;
  padding: 5px 4px;
}
#music-pause-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Track arrows row */
#music-track-btns {
  display: flex;
  gap: 4px;
}
#music-prev-btn, #music-next-btn {
  flex: 1;
}

/* Click sound 2×2 grid */
#click-snd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

/* Shared button base */
.music-vol-btn, .click-snd-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 220, 120, 0.20);
  color: rgba(255, 240, 200, 0.55);
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.08em;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.music-vol-btn:hover, .click-snd-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.50);
}
.music-vol-btn.active, .click-snd-btn.active {
  background: rgba(255, 200, 80, 0.16);
  border-color: rgba(255, 220, 120, 0.75);
  color: #fff8e8;
}

.music-panel-label {
  font-family: 'Sen', sans-serif;
  font-size: 0.60rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 240, 200, 0.35);
  margin: 0;
  text-align: center;
}

/* Keep old horizontal divider class in case anything else uses it */
.music-panel-divider {
  height: 1px;
  background: rgba(255, 220, 120, 0.15);
  margin: 3px 0;
}

/* Border buttons row inside the theme panel */
#theme-border-btns {
  display: flex;
  gap: 5px;
  width: 100%;
}

/* Border style buttons — share music-vol-btn sizing */
.border-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 220, 120, 0.20);
  color: rgba(255, 240, 200, 0.55);
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.08em;
  padding: 5px 0;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.border-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.50);
}
.border-btn.active {
  background: rgba(255, 200, 80, 0.16);
  border-color: rgba(255, 220, 120, 0.75);
  color: #fff8e8;
}

/* Border colour buttons — same style as border-btn */
#theme-border-color-btns {
  display: flex;
  gap: 5px;
  width: 100%;
  margin-top: 4px;
}
.border-color-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 220, 120, 0.20);
  color: rgba(255, 240, 200, 0.55);
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.08em;
  padding: 5px 0;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.border-color-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.50);
}
.border-color-btn.active {
  background: rgba(255, 200, 80, 0.16);
  border-color: rgba(255, 220, 120, 0.75);
  color: #fff8e8;
}

/* Hide in-game-only items when panel is opened from start overlay */
#music-panel.from-start .music-ingame-only,
#music-panel.from-start #music-pause-btn,
#music-panel.from-start #change-track-label,
#music-panel.from-start #music-track-btns { display: none; }

#mute-all-btn, #mute-music-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 100, 100, 0.30);
  color: rgba(255, 180, 180, 0.65);
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.08em;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  width: 100%;
}
#mute-all-btn:hover, #mute-music-btn:hover {
  background: rgba(220, 60, 60, 0.12);
  border-color: rgba(255, 100, 100, 0.60);
  color: rgba(255, 200, 200, 0.95);
}
#mute-all-btn.active, #mute-music-btn.active {
  background: rgba(200, 50, 50, 0.20);
  border-color: rgba(255, 100, 100, 0.90);
  color: #ffe8e8;
}

/* ── Now-playing track name ──────────────────────────────────────────────── */
#now-playing {
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  color: rgba(255, 220, 120, 0.85);
  letter-spacing: 0.09em;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
  line-height: 1.2;
}
#now-playing.visible {
  opacity: 1;
}

/* ── Music track arrow buttons ───────────────────────────────────────────── */
#music-prev-btn,
#music-next-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 220, 120, 0.25);
  color: rgba(255, 220, 120, 0.70);
  font-size: 0.65rem;
  padding: 4px 0;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#music-prev-btn:hover,
#music-next-btn:hover {
  background: rgba(255, 220, 120, 0.10);
  border-color: rgba(255, 220, 120, 0.60);
  color: rgba(255, 220, 120, 1);
}

/* ── Easy-mode first-letter guides ──────────────────────────────────────────── */
.easy-letter-guide {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  opacity: 0.45;
}

/* ── Hint piece flash — glows on the actual piece when hint is triggered ───── */
@keyframes hintPieceFlash {
  0%   { filter: drop-shadow(0 0  8px rgba(255, 220, 80, 0.40))
                 drop-shadow(0 0 20px rgba(255, 160,  0, 0.25)); }
  50%  { filter: drop-shadow(0 0 22px rgba(255, 220, 80, 1.0))
                 drop-shadow(0 0 44px rgba(255, 160,  0, 0.80)); }
  100% { filter: drop-shadow(0 0  8px rgba(255, 220, 80, 0.40))
                 drop-shadow(0 0 20px rgba(255, 160,  0, 0.25)); }
}

.hint-piece-flash {
  animation: hintPieceFlash 1.6s ease-in-out infinite !important;
}

/* ── Click-to-place: selected piece glow ────────────────────────────────── */
.piece-cp-selected {
  box-shadow: 0 0 0 3px rgba(255, 220, 80, 0.90),
              0 0 22px rgba(255, 180, 0, 0.55) !important;
  z-index: 500 !important;
}

/* ── Click-to-place: wrong-guess zone overlay ───────────────────────────── */
.cp-wrong-zone {
  position: absolute;
  background: rgba(255, 50, 50, 0.18);
  border: 2px solid rgba(255, 60, 60, 0.85);
  border-radius: 3px;
  pointer-events: none;
  z-index: 200;
  animation: cpWrongFade 0.75s ease forwards;
}
@keyframes cpWrongFade {
  0%   { opacity: 1; }
  60%  { opacity: 0.6; }
  100% { opacity: 0; }
}

/* ── Magnetic near-snap glow ─────────────────────────────────────────────── */
.puzzle-piece.near-snap {
  filter: drop-shadow(0 0 12px rgba(255, 220, 80, 0.80))
          drop-shadow(0 0 28px rgba(255, 160, 20, 0.45))
          drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
}

/* ── Counter bounce on snap ──────────────────────────────────────────────── */
@keyframes counterBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(0.88); }
  100% { transform: scale(1); }
}
#piece-counter.snap-bounce {
  display: inline-block;
  animation: counterBounce 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

/* ── Best time on celebration ────────────────────────────────────────────── */
#celebration-best {
  font-family: 'Sen', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.10em;
  color: rgba(255, 220, 100, 0.60);
  text-align: center;
  min-height: 1.2em;
}
#celebration-best.new-record {
  color: rgba(255, 220, 100, 0.95);
  animation: recordPulse 0.55s ease-out forwards;
}
@keyframes recordPulse {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.10); }
  100% { transform: scale(1); }
}

/* ── Save score modal ────────────────────────────────────────────────────── */
#save-score-modal {
  position: fixed;
  inset: 0;
  z-index: 10100;
  background: rgba(0, 0, 0, 0.70);
  display: flex;
  align-items: center;
  justify-content: center;
}

#save-score-panel {
  position: relative;
  background: rgba(18, 12, 4, 0.97);
  border: 1px solid rgba(255, 220, 120, 0.30);
  border-radius: 8px;
  padding: 28px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(420px, 90vw);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.7);
}

#save-score-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: rgba(255, 240, 200, 0.50);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
#save-score-close:hover { color: rgba(255, 240, 200, 0.90); }

#save-score-title {
  font-family: 'Sen', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 220, 100, 0.60);
  margin: 0;
}

#score-email-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: stretch;
}

#score-email {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 220, 120, 0.28);
  border-radius: 4px;
  padding: 8px 12px;
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  color: rgba(255, 240, 200, 0.90);
  outline: none;
  transition: border-color 0.18s;
}
#score-email::placeholder { color: rgba(255, 240, 200, 0.30); }
#score-email:focus { border-color: rgba(255, 220, 120, 0.65); }

#score-email-btn {
  padding: 8px 18px;
  border: 1px solid rgba(255, 220, 120, 0.40);
  background: rgba(255, 200, 80, 0.12);
  color: rgba(255, 240, 200, 0.85);
  font-family: 'Sen', sans-serif;
  font-size: 0.80rem;
  letter-spacing: 0.06em;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s;
}
#score-email-btn:hover {
  background: rgba(255, 200, 80, 0.24);
  border-color: rgba(255, 220, 120, 0.75);
}

#score-save-status {
  font-family: 'Sen', sans-serif;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: rgba(255, 220, 100, 0.75);
  margin: 0;
  min-height: 1.1em;
  text-align: center;
}

/* ── Show Solution confirmation (timed games only) ─────────────────────── */
#reveal-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 10200;
  background: rgba(0, 0, 0, 0.70);
  display: flex;
  align-items: center;
  justify-content: center;
}
#reveal-confirm-panel {
  background: rgba(18, 12, 4, 0.97);
  border: 1px solid rgba(255, 220, 120, 0.30);
  border-radius: 8px;
  padding: 28px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(380px, 90vw);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.7);
  text-align: center;
}
#reveal-confirm-title {
  font-family: 'Sen', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 220, 100, 0.60);
  margin: 0;
}
#reveal-confirm-text {
  font-family: 'Sen', sans-serif;
  font-size: 0.86rem;
  line-height: 1.5;
  color: rgba(255, 240, 200, 0.90);
  margin: 0;
}
#reveal-confirm-btns {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
#reveal-confirm-cancel, #reveal-confirm-go {
  padding: 8px 18px;
  border-radius: 4px;
  font-family: 'Sen', sans-serif;
  font-size: 0.80rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s;
}
#reveal-confirm-cancel {
  border: 1px solid rgba(255, 240, 200, 0.28);
  background: none;
  color: rgba(255, 240, 200, 0.75);
}
#reveal-confirm-cancel:hover { background: rgba(255, 240, 200, 0.08); }
#reveal-confirm-go {
  border: 1px solid rgba(255, 220, 120, 0.40);
  background: rgba(255, 200, 80, 0.12);
  color: rgba(255, 240, 200, 0.85);
}
#reveal-confirm-go:hover {
  background: rgba(255, 200, 80, 0.24);
  border-color: rgba(255, 220, 120, 0.75);
}

/* ── Print group (size selector + print button) ──────────────────────────── */
#print-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

#print-size-row {
  display: flex;
  gap: 4px;
}

.print-size-btn {
  padding: 3px 8px;
  border: 1px solid rgba(255, 220, 120, 0.25);
  background: rgba(255, 200, 80, 0.05);
  color: rgba(255, 240, 200, 0.50);
  font-family: 'Sen', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.print-size-btn:hover {
  background: rgba(255, 200, 80, 0.12);
  border-color: rgba(255, 220, 120, 0.50);
  color: rgba(255, 240, 200, 0.85);
}
.print-size-btn.active {
  background: rgba(255, 200, 80, 0.18);
  border-color: rgba(255, 220, 120, 0.70);
  color: rgba(255, 240, 200, 1.0);
}

/* ── Secondary celebration buttons (Save Score, Share, Print) ────────────── */
#save-score-btn,
#share-btn,
#print-btn {
  padding: 8px 20px;
  border: 1px solid rgba(255, 220, 120, 0.32);
  background: rgba(255, 200, 80, 0.07);
  color: rgba(255, 240, 200, 0.75);
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
#save-score-btn:hover,
#share-btn:hover,
#print-btn:hover {
  background: rgba(255, 200, 80, 0.18);
  border-color: rgba(255, 220, 120, 0.65);
  color: rgba(255, 240, 200, 0.95);
}

/* ── Share modal ─────────────────────────────────────────────────────────── */
#share-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}

#share-modal-panel {
  position: relative;
  background: rgba(8, 4, 0, 0.96);
  border: 1px solid rgba(255, 220, 120, 0.25);
  border-radius: 8px;
  padding: 30px 36px 26px;
  text-align: center;
  backdrop-filter: blur(8px);
  min-width: 260px;
}

#share-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: rgba(255, 240, 200, 0.45);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s;
}
#share-modal-close:hover { color: rgba(255, 240, 200, 0.90); }

#share-modal-title {
  font-family: 'Sen', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 220, 100, 0.70);
  margin-bottom: 20px;
}

#share-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-link {
  display: block;
  padding: 10px 24px;
  border: 1px solid rgba(255, 220, 120, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 240, 200, 0.80);
  font-family: 'Sen', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.share-link:hover {
  background: rgba(255, 200, 80, 0.14);
  border-color: rgba(255, 220, 120, 0.60);
  color: #fff8e8;
}

#share-instagram-note {
  font-family: 'Sen', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: rgba(255, 220, 100, 0.70);
  margin-top: 12px;
  margin-bottom: 0;
}

/* ── Keyboard-selected piece ─────────────────────────────────────────────── */
.puzzle-piece.kb-selected {
  filter: drop-shadow(0 0 10px rgba(120, 200, 255, 0.90))
          drop-shadow(0 0 24px rgba(60, 150, 255, 0.50));
  z-index: 900 !important;
}

/* Wrong-slot shake */
.puzzle-piece.kb-wrong {
  animation: kbWrongShake 0.45s ease-out forwards;
}
@keyframes kbWrongShake {
  0%        { transform: translateX(0); }
  15%       { transform: translateX(-10px); }
  35%       { transform: translateX(9px); }
  55%       { transform: translateX(-7px); }
  75%       { transform: translateX(5px); }
  90%       { transform: translateX(-3px); }
  100%      { transform: translateX(0); }
}

/* ── Keyboard placement target highlights ────────────────────────────────── */
.kb-target-highlight {
  border: 3px dashed rgba(120, 200, 255, 0.85);
  background: rgba(120, 200, 255, 0.16);
  border-radius: 3px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.kb-target-highlight.focused {
  border: 3px solid #35b6ff;
  background: #c4e2ff;
  box-shadow: 0 0 16px rgba(53, 182, 255, 0.95), 0 0 38px rgba(53, 182, 255, 0.55);
  animation: kb-target-pulse 1s ease-in-out infinite;
}
@keyframes kb-target-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(53, 182, 255, 0.85), 0 0 30px rgba(53, 182, 255, 0.45); }
  50%      { box-shadow: 0 0 24px rgba(53, 182, 255, 1),    0 0 48px rgba(53, 182, 255, 0.70); }
}

/* ── Mobile-version prompt — dismissible card offering the touch build ────── */
#mobile-version-prompt {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 99999;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(88vw, 420px);
  padding: 24px 22px;
  background: rgba(8, 4, 0, 0.94);
  border: 1px solid rgba(255, 220, 120, 0.30);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  text-align: center;
}

#mobile-version-prompt p {
  font-family: 'Sen', sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 240, 200, 0.90);
  letter-spacing: 0.02em;
  margin: 0;
  max-width: 480px;
}

#mobile-version-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

#mobile-version-link {
  font-family: 'Sen', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  color: #1a1108;
  background: rgba(255, 220, 120, 0.92);
  border-radius: 6px;
  padding: 7px 16px;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: background 0.15s;
}
#mobile-version-link:hover {
  background: rgba(255, 220, 120, 1);
}

#mobile-version-dismiss {
  background: none;
  border: none;
  color: rgba(255, 240, 200, 0.55);
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 6px 4px;
  text-decoration: underline;
}
#mobile-version-dismiss:hover {
  color: rgba(255, 240, 200, 0.9);
}

/* Small persistent pill left behind after the prompt is dismissed, so "No
   thanks" is recoverable. Top-left keeps it clear of the reference thumbnail
   and taskbar in the bottom corners. 44px tall to stay a valid touch target. */
#mobile-version-reopen {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: calc(10px + env(safe-area-inset-left, 0px));
  z-index: 99998;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(255, 220, 120, 0.35);
  border-radius: 999px;
  background: rgba(8, 4, 0, 0.90);
  color: rgba(255, 220, 120, 0.95);
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  opacity: 0.85;
}
#mobile-version-reopen:active { transform: scale(0.96); }

/* Pulses briefly when it first appears, so an accidental "No thanks" is
   obviously undoable rather than silently gone. */
#mobile-version-reopen.just-dismissed {
  animation: mobileReopenPulse 900ms ease-out 3;
}
@keyframes mobileReopenPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 220, 120, 0); opacity: 0.85; }
  50%      { box-shadow: 0 0 0 5px rgba(255, 220, 120, 0.30); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #mobile-version-reopen.just-dismissed { animation: none; opacity: 1; }
}

/* #pause-btn is now in the taskbar — styled by the unified taskbar button rule */

/* ── Pause overlay ───────────────────────────────────────────────────────── */
#pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  backdrop-filter: blur(14px) brightness(0.55);
  -webkit-backdrop-filter: blur(14px) brightness(0.55);
  background: rgba(4, 2, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInOverlay 0.35s ease;
}

#pause-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: rgba(8, 4, 0, 0.88);
  border: 1px solid rgba(255, 220, 120, 0.22);
  border-radius: 10px;
  padding: 28px 36px 24px;
  max-width: min(420px, 90vw);
  text-align: center;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7);
}

#pause-label {
  font-family: 'Sen', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 220, 100, 0.55);
  margin: 0;
}

#pause-quote-box {
  border-top: 1px solid rgba(255, 220, 120, 0.12);
  border-bottom: 1px solid rgba(255, 220, 120, 0.12);
  padding: 12px 0;
  width: 100%;
}

#pause-quote {
  font-family: 'Sen', sans-serif;
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.7;
  color: rgba(255, 240, 200, 0.82);
  letter-spacing: 0.02em;
  margin: 0 0 12px;
}

#pause-quote-author {
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  font-style: normal;
  letter-spacing: 0.10em;
  color: rgba(255, 220, 100, 0.65);
  margin: 0;
  text-align: center;
}

#pause-resume-btn {
  padding: 7px 48px;
  border: 1px solid rgba(255, 220, 120, 0.75);
  background: rgba(255, 200, 80, 0.18);
  color: rgba(255, 240, 180, 0.96);
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 200, 80, 0.18);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.12s;
}
#pause-resume-btn:hover {
  background: rgba(255, 200, 80, 0.34);
  border-color: rgba(255, 230, 130, 1.0);
  box-shadow: 0 0 24px rgba(255, 200, 80, 0.40);
}
#pause-resume-btn:active { transform: scale(0.96); }

#pause-btns-row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

#pause-howto-btn,
#pause-reset-btn {
  padding: 7px 22px;
  border: 1px solid rgba(255, 220, 120, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 240, 200, 0.60);
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
#pause-howto-btn:hover,
#pause-reset-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.55);
}
#pause-howto-btn:active,
#pause-reset-btn:active { transform: scale(0.96); }

#pause-music-credit {
  margin-top: 14px;
  font-size: 0.62rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255, 240, 200, 0.22);
}

/* ── Fullscreen button (shared style for theme panel + pause card) ────────── */
.fullscreen-btn {
  padding: 7px 22px;
  border: 1px solid rgba(255, 220, 120, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 240, 200, 0.65);
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
  width: 100%;
}
.fullscreen-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.55);
}
.fullscreen-btn:active { transform: scale(0.96); }

/* ── Auto Complete in pause card ─────────────────────────────────────────── */
#pause-card #auto-btn {
  padding: 7px 22px;
  border: 1px solid rgba(255, 220, 120, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 240, 200, 0.60);
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
#pause-card #auto-btn:hover {
  background: rgba(255, 200, 80, 0.10);
  color: rgba(255, 240, 200, 0.90);
  border-color: rgba(255, 220, 120, 0.55);
}
#pause-card #auto-btn:active { transform: scale(0.96); }
#pause-card #auto-btn[disabled] {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

#now-playing.muted {
  color: rgba(255, 255, 255, 0.30);
  font-style: italic;
  letter-spacing: 0.12em;
}

/* ── Tutorial overlay ────────────────────────────────────────────────────── */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 7000;
  pointer-events: none;  /* transparent — live board animates behind */
  display: flex;
  align-items: center;
  justify-content: center;
}

#tutorial-card {
  position: relative;
  background: rgba(8, 4, 0, 0.94);
  border: 1px solid rgba(255, 220, 120, 0.32);
  border-radius: 8px;
  padding: 20px 26px 18px;
  max-width: 360px;
  width: 90vw;
  text-align: center;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  animation: tutorialSlideUp 0.32s ease-out;
}

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

#tutorial-step-indicator {
  font-family: 'Sen', sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 220, 100, 0.48);
  margin-bottom: 9px;
}

#tutorial-text {
  font-family: 'Sen', sans-serif;
  font-size: 0.82rem;
  line-height: 1.65;
  color: rgba(255, 240, 200, 0.85);
  letter-spacing: 0.02em;
  margin: 0 0 16px;
  white-space: pre-line;
}

#tutorial-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

#tutorial-back,
#tutorial-skip {
  background: none;
  border: none;
  color: rgba(255, 240, 200, 0.32);
  font-family: 'Sen', sans-serif;
  font-size: 0.70rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.15s;
}
#tutorial-back:hover,
#tutorial-skip:hover { color: rgba(255, 240, 200, 0.65); }

#tutorial-next {
  background: rgba(255, 200, 80, 0.12);
  border: 1px solid rgba(255, 220, 120, 0.50);
  color: rgba(255, 240, 200, 0.92);
  font-family: 'Sen', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 7px 22px;
  border-radius: 3px;
  transition: background 0.15s, border-color 0.15s;
}
#tutorial-next:hover {
  background: rgba(255, 200, 80, 0.24);
  border-color: rgba(255, 220, 120, 0.82);
}

/* Target cell pulse used during tutorial hint demo */
@keyframes tutTargetPulse {
  0%,100% { border-color: rgba(255,220,80,0.85); box-shadow: 0 0 14px rgba(255,200,60,0.55); }
  50%     { border-color: rgba(255,220,80,0.35); box-shadow: 0 0 4px rgba(255,200,60,0.15); }
}

/* Pulsing highlight applied to UI elements during tutorial steps */
.tutorial-highlight {
  animation: tutorialPulse 1.1s ease-in-out infinite !important;
}
@keyframes tutorialPulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(255, 220, 80, 0.0); }
  50%       { box-shadow: 0 0 0 5px rgba(255, 220, 80, 0.7),
                           0 0 22px  rgba(255, 180, 0,  0.4); }
}

/* ── Mobile: slightly increase tap target padding in taskbar ─────────────── */
@media (pointer: coarse) {
  #ui-bar {
    gap: 14px;
    padding: 0 16px;
  }
  #reset-btn, #pause-btn, #hint-btn, #buy-vowel-btn,
  #music-btn, #theme-taskbar-btn, #zoom-fit-btn {
    padding: 8px 8px;
  }
}

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  /* Hide everything … */
  body > * { display: none !important; }
  /* … except the dedicated print canvas */
  #print-canvas {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw  !important;
    height: 100vh !important;
    object-fit: contain !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY — WCAG 2.1 AA
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Focus indicators ────────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid rgba(255, 220, 80, 0.95);
  outline-offset: 3px;
}

button:focus-visible,
.diff-btn:focus-visible,
.theme-swatch:focus-visible,
.music-vol-btn:focus-visible,
.click-snd-btn:focus-visible,
.border-btn:focus-visible,
.border-color-btn:focus-visible,
.print-size-btn:focus-visible,
.share-link:focus-visible {
  outline: 3px solid rgba(255, 220, 80, 0.95);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(255, 180, 0, 0.25);
}

input:focus-visible {
  outline: 3px solid rgba(255, 220, 80, 0.95);
  outline-offset: 2px;
}

/* Keyboard-selected puzzle piece */
.puzzle-piece.kb-selected {
  outline: 7px solid rgba(255, 220, 80, 1);
  outline-offset: 3px;
  box-shadow: 0 0 0 11px rgba(255, 180, 0, 0.35), 0 8px 24px rgba(0,0,0,0.5);
  z-index: 1001 !important;
  cursor: grabbing;
}

/* ── Color contrast — raise opacity on muted gold text to meet 4.5:1 ─────── */
.music-vol-btn,
.click-snd-btn {
  color: rgba(255, 240, 200, 0.85);
}
#change-track-label,
.music-panel-label {
  color: rgba(255, 240, 200, 0.85);
}
#music-prev-btn,
#music-next-btn,
#mute-music-btn,
#mute-all-btn {
  color: rgba(255, 240, 200, 0.85);
}
#ui-bar button {
  color: rgba(255, 240, 200, 0.90);
}
#timer-display,
#piece-counter {
  color: rgba(255, 240, 200, 0.92);
}

/* ── prefers-reduced-motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .vowel-slot-highlight {
    animation: none !important;
    background: rgba(120, 200, 255, 0.42) !important;
    border: 3px solid rgba(53, 182, 255, 1) !important;
  }
  .puzzle-piece.snapped {
    transition: none !important;
  }
  #celeb-word-layer * {
    animation: none !important;
    opacity: 1 !important;
  }
  .hint-piece-flash {
    animation: none !important;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Skip-to-content link ────────────────────────────────────────────────── */
#skip-to-game {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  background: rgba(30, 20, 5, 0.97);
  color: rgba(255, 220, 80, 1);
  border: 2px solid rgba(255, 220, 80, 0.9);
  padding: 10px 22px;
  border-radius: 4px;
  font-family: 'Sen', sans-serif;
  font-size: 0.9rem;
  text-decoration: none;
  transition: top 0.15s ease;
}
#skip-to-game:focus {
  top: 12px;
}

/* Screen-reader-only utility (visually hidden, still announced) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Current track name shown in the audio options menu */
#music-track-name {
  font-family: 'Sen', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: #fff8e8;
  margin: 3px 0 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
#music-panel.from-start #music-track-name { display: none; }

/* ── Guided mode: click-a-box placement ─────────────────────────────────── */
/* Word stays hidden at its slot until its box is clicked */
.puzzle-piece.guided-pending {
  opacity: 0;
  pointer-events: none;
}
/* Clickable empty-box affordance over each word slot */
.clue-target.clue-target--guided {
  cursor: pointer;
  border: 3px dashed transparent;
  border-radius: 3px;
  background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.clue-target.clue-target--guided:hover {
  background: rgba(120, 200, 255, 0.42);
  border-color: #35b6ff;
}
/* Word pops in when placed via a Guided click */
@keyframes guidedAppear {
  0%   { opacity: 0; transform: scale(0.6); }
  60%  { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}
.puzzle-piece.guided-appear {
  animation: guidedAppear 0.4s ease-out;
}
