:root {
  --ls-bg: #050712;
  --ls-panel: #141827;
  --ls-panel-soft: #1b2032;

  --ls-accent: #ffd743;
  --ls-accent-soft: #ffe58a;

  --ls-text-main: #f5f5f7;
  --ls-text-muted: #a2a7c2;
  --ls-border-subtle: #30364c;

  --ls-shadow-soft: 0 14px 40px rgba(0, 0, 0, 0.6);
  --ls-transition-fast: 0.16s ease-out;
  
  --ls-btn-text-size: 0.75rem; 
}

/* RESET */
*, *::before, *::after { box-sizing: border-box; }

html, body { 
  margin: 0; 
  padding: 0; 
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ls-text-main);
  background-color: #050712;
  
  /* --- CENTERING MAGIC --- */
  display: flex;
  flex-direction: column;
}

/* --- CENTER WRAPPER --- */
.center-wrapper {
  margin: auto; /* Centers vertically and horizontally */
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 8px;
  position: relative;
  z-index: 1;
}

/* --- FIXED BACKGROUND (Star Field) --- */
.fixed-background {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0; 
  background-color: #020205; /* Deep Black */
  overflow: hidden;
  pointer-events: none; 
}

/* Layer 1: Small stars (Continuous) */
.fixed-background::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 25px 5px, white 1px, transparent 1.5px),
    radial-gradient(circle at 50px 25px, rgba(255,255,255,0.8) 1px, transparent 1.5px),
    radial-gradient(circle at 125px 20px, white 1px, transparent 1.5px),
    radial-gradient(circle at 200px 65px, rgba(255,255,255,0.6) 1px, transparent 1.5px),
    radial-gradient(circle at 300px 10px, white 1px, transparent 1.5px),
    radial-gradient(circle at 360px 45px, rgba(255,255,255,0.9) 1px, transparent 1.5px);
  background-size: 400px 400px;
  opacity: 0.6; 
  animation: starIntro 25s linear infinite;
}

/* Layer 2: Brighter/Larger stars (Continuous) */
.fixed-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 75px 100px, white 1.5px, transparent 2.5px),
    radial-gradient(circle at 150px 250px, white 1px, transparent 2px),
    radial-gradient(circle at 320px 380px, white 1.5px, transparent 2.5px);
  background-size: 550px 550px; 
  opacity: 0.8; 
  animation: starIntroFast 22s linear infinite;
}

@keyframes starIntro {
  from { background-position: 0 0; }
  to { background-position: 0 400px; } 
}

@keyframes starIntroFast {
  from { background-position: 0 0; }
  to { background-position: 0 550px; } 
}

/* PAGE + SHELL */
.game-shell.ls-shell {
  width: 100%;
  max-width: 460px;
  padding: 18px 14px 22px;
  margin: 0;
  
  /* Glassmorphism Background */
  background: rgba(20, 24, 39, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  
  border-radius: 26px;
  position: relative;
  z-index: 1; /* Above stars */
  box-shadow: 0 0 0 1px rgba(255, 215, 67, 0.25), 0 0 18px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

/* CONFETTI CANVAS */
.ls-confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

.hidden { display: none !important; }

/* HEADER */
.ls-header { text-align: center; margin-bottom: 6px; }
.ls-header h1 { margin: 0 0 4px; letter-spacing: 0.22em; font-weight: 800; font-size: 1.6rem; }
.ls-tagline { margin: 0; font-size: 0.78rem; color: var(--ls-text-muted); }
.ls-howto-btn { margin-top: 6px; background: transparent; border: none; color: var(--ls-text-muted); font-size: 0.75rem; cursor: pointer; text-decoration: underline; padding: 0; }
.ls-howto-btn:hover { color: var(--ls-text-main); }
.ls-howto-tooltip { margin: 6px 0 10px; font-size: 0.75rem; background: rgba(10, 14, 26, 0.96); border-radius: 10px; padding: 8px 10px; border: 1px solid var(--ls-border-subtle); color: var(--ls-text-muted); text-align: center; }

/* Buttons */
.ls-btn, .mode-btn, .ls-ctrl-btn, .ls-bottom-btn, .ls-btn-mini {
  font-size: var(--ls-btn-text-size);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.ls-btn-mini {
  margin-top: 6px; padding: 4px 8px; border-radius: 999px;
  border: 1px solid rgba(255, 215, 67, 0.9);
  background: linear-gradient(135deg, #ffd743, #ffb833);
  color: #050712; cursor: pointer;
}

/* TOP BAR */
.top-bar.ls-top-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(9, 12, 24, 0.96); border-radius: 999px;
  padding: 6px 12px 6px 16px; border: 1px solid var(--ls-border-subtle);
  box-shadow: var(--ls-shadow-soft); margin-bottom: 10px; font-size: 0.7rem; gap: 8px;
}
.top-item { flex: 1; display: flex; flex-direction: column; align-items: center; }
.top-label { text-transform: uppercase; letter-spacing: 0.12em; color: var(--ls-text-muted); font-size: 0.6rem; }
.top-value { margin-top: 2px; font-weight: 600; font-size: 0.8rem; }

/* Sound Toggle */
.ls-sound-toggle {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--ls-border-subtle);
  color: var(--ls-text-muted); border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 1rem; transition: all 0.2s ease; margin-left: 4px; flex-shrink: 0;
}
.ls-sound-toggle:hover { background: rgba(255, 255, 255, 0.1); color: var(--ls-text-main); transform: scale(1.05); }
.ls-sound-toggle.muted { opacity: 0.6; color: #666; }

/* MODE SWITCH */
.mode-switch.ls-mode-switch {
  display: inline-flex; background: rgba(13, 17, 30, 0.9); border-radius: 999px;
  padding: 3px; border: 1px solid var(--ls-border-subtle); box-shadow: var(--ls-shadow-soft);
  margin: 0 auto 10px; position: relative; left: 50%; transform: translateX(-50%);
}
.mode-btn {
  border: none; background: transparent; color: var(--ls-text-muted); padding: 8px 14px;
  border-radius: 999px; cursor: pointer; transition: background 0.2s ease-out, color 0.2s ease-out, transform var(--ls-transition-fast);
}
.mode-btn.active { background: linear-gradient(135deg, #ffd743, #ffb833); color: #050712; font-weight: 600; transform: translateY(-0.5px); }

/* TRAINER */
.ls-trainer-lock { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 8px; font-size: 0.75rem; color: var(--ls-text-muted); }
.ls-trainer-label { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.64rem; }
.ls-trainer-pills { display: inline-flex; background: rgba(13, 17, 30, 0.9); border-radius: 999px; padding: 3px; border: 1px solid var(--ls-border-subtle); }
.ls-trainer-pill { border: none; background: transparent; color: var(--ls-text-muted); font-size: 0.72rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; transition: background 0.2s ease-out, color 0.2s ease-out; }
.ls-trainer-pill.active { background: linear-gradient(135deg, #ffd743, #ffb833); color: #050712; }

/* GRID SECTION */
.ls-grid-section { margin-top: 8px; background: radial-gradient(circle at top, #191f3a, #141827); padding: 12px 10px 10px; border-radius: 20px; box-shadow: var(--ls-shadow-soft); border: 1px solid rgba(80, 88, 120, 0.6); }
.ls-grid-wrapper { position: relative; width: 100%; max-width: 260px; aspect-ratio: 1 / 1; margin: 0 auto 10px; border-radius: 20px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55); transition: box-shadow 0.25s ease-out, transform 0.3s ease-out; }
.ls-grid-wrapper--flash { box-shadow: 0 0 28px rgba(255, 215, 67, 0.55); }

@keyframes ls-win-pulse {
  0% { transform: scale(1); box-shadow: 0 12px 30px rgba(0,0,0,0.55); }
  50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(255, 215, 67, 0.8); }
  100% { transform: scale(1); box-shadow: 0 12px 30px rgba(0,0,0,0.55); }
}
.ls-grid-wrapper.win-anim { animation: ls-win-pulse 0.6s ease-out; }

/* Grid */
.ls-grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 6px; padding: 10px; background: #101323; border-radius: 18px; border: 1px solid rgba(255, 255, 255, 0.04); }

/* Tiles */
.ls-tile { border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.08); background: #121525; position: relative; cursor: pointer; transition: background 0.12s ease-out, transform 0.12s ease-out, box-shadow 0.12s ease-out, border-color 0.12s ease-out; }
.ls-tile::before { content: ""; position: absolute; inset: 10%; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.06); opacity: 0; transition: opacity var(--ls-transition-fast); }
.ls-tile:hover::before { opacity: 1; }
.ls-tile.on { background: radial-gradient(circle at top, #ffe58a 0, var(--ls-accent) 35%, #f1b000 100%); box-shadow: 0 0 12px rgba(255, 215, 67, 0.75); border-color: rgba(255, 236, 167, 0.9); }
.ls-tile.hint { box-shadow: 0 0 0 2px rgba(255, 215, 67, 0.8), 0 10px 24px rgba(0, 0, 0, 0.85); border-color: rgba(255, 215, 67, 1); animation: ls-hint-pulse 1.1s infinite ease-in-out; }
@keyframes ls-hint-pulse {
  0% { transform: translateY(-1px) scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 67, 0.8), 0 10px 24px rgba(0, 0, 0, 0.85); }
  50% { transform: translateY(-2px) scale(1.03); box-shadow: 0 0 0 5px rgba(255, 215, 67, 0.35), 0 14px 30px rgba(0, 0, 0, 0.9); }
  100% { transform: translateY(-1px) scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 67, 0), 0 10px 24px rgba(0, 0, 0, 0.85); }
}

/* Grid Lines */
.ls-grid-lines { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.ls-line { position: absolute; background: rgba(255, 215, 67, 0.25); pointer-events: none; border-radius: 2px; transition: background 0.18s ease-out, box-shadow 0.18s ease-out, opacity 0.18s; }
.ls-line.h-line.h1 { top: 33.33%; left: 8%; width: 84%; height: 3px; }
.ls-line.h-line.h2 { top: 66.66%; left: 8%; width: 84%; height: 3px; }
.ls-line.v-line.v1 { left: 33.33%; top: 8%; height: 84%; width: 3px; }
.ls-line.v-line.v2 { left: 66.66%; top: 8%; height: 84%; width: 3px; }
.ls-grid-lines.flash .ls-line { background: var(--ls-accent); box-shadow: 0 0 12px rgba(255, 215, 67, 0.9); }
.ls-grid-lines.solved .ls-line { animation: ls-grid-solved 1.2s ease-out forwards; }
@keyframes ls-grid-solved { 0% { opacity: 0.8; } 20% { opacity: 1; } 40% { opacity: 0.4; } 60% { opacity: 1; } 80% { opacity: 0.2; } 100% { opacity: 0; } }

/* PATTERN OVERLAY & GHOST EFFECT */
.ls-pattern-overlay { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 3; transition: opacity 0.25s ease-out; }
.ls-pattern-overlay.visible { opacity: 1; }
.ls-pattern-overlay.flash-brief { opacity: 0.7; transition: opacity 0.1s ease-out; }

.ls-pattern-line { position: absolute; background: radial-gradient(circle, rgba(255, 215, 67, 0.9) 0, rgba(255, 215, 67, 0.15) 40%, transparent 100%); opacity: 0; border-radius: 999px; box-shadow: 0 0 18px rgba(255, 215, 67, 0.45); transition: opacity 0.18s ease-out; }
.plus-vertical { top: 8%; bottom: 8%; width: 6px; left: 50%; transform: translateX(-50%); }
.plus-horizontal { left: 8%; right: 8%; height: 6px; top: 50%; transform: translateY(-50%); }
.x-diag-1, .x-diag-2 { width: 150%; height: 5px; top: 50%; left: 50%; transform-origin: center; }
.x-diag-1 { transform: translate(-50%, -50%) rotate(45deg); }
.x-diag-2 { transform: translate(-50%, -50%) rotate(-45deg); }

.ls-pattern-dot { position: absolute; width: 22%; height: 22%; border-radius: 999px; background: radial-gradient(circle, rgba(255, 215, 67, 1) 0, rgba(255, 215, 67, 0.25) 45%, transparent 100%); opacity: 0; box-shadow: 0 0 16px rgba(255, 215, 67, 0.6); transition: opacity 0.18s ease-out; }
.diag-dot.tl { top: 16.5%; left: 16.5%; } .diag-dot.tr { top: 16.5%; right: 16.5%; } .diag-dot.bl { bottom: 16.5%; left: 16.5%; } .diag-dot.br { bottom: 16.5%; right: 16.5%; }

/* Pattern Visibility Logic */
.ls-pattern-overlay[data-pattern="plus"] .plus-vertical, .ls-pattern-overlay[data-pattern="plus"] .plus-horizontal { opacity: 0.85; }
.ls-pattern-overlay[data-pattern="x"] .x-diag-1, .ls-pattern-overlay[data-pattern="x"] .x-diag-2 { opacity: 0.85; }
.ls-pattern-overlay[data-pattern="diag"] .diag-dot { opacity: 0.95; }

/* TEXT & STATUS */
.ls-concept-text { margin: 10px 0 0; font-size: 0.76rem; color: var(--ls-text-muted); text-align: center; }
.ls-pattern-key { font-weight: 600; color: var(--ls-accent-soft); }
.ls-bottom { margin-top: 10px; padding: 8px 2px 0; }
.ls-status-bar { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 4px 6px; font-size: 0.8rem; color: var(--ls-text-muted); text-align: center; }
.ls-moves-text { font-size: 0.9rem; font-weight: 600; color: var(--ls-accent-soft); }
.ls-status-text { max-width: 100%; transition: color 0.2s ease, text-shadow 0.2s ease; }
.ls-status-text.highlight { color: #ffffff; font-weight: 600; text-shadow: 0 0 12px rgba(255, 255, 255, 0.25); }

/* CONTROLS */
.ls-controls { display: flex; gap: 8px; margin-top: 4px; }
.ls-ctrl-btn { flex: 1; border-radius: 16px; padding: 10px 12px; cursor: pointer; border: 1px solid rgba(255, 255, 255, 0.16); background: linear-gradient(145deg, #1b213b, #11152b); color: var(--ls-text-main); transition: background var(--ls-transition-fast), transform 0.1s ease-out, box-shadow 0.1s ease-out, border-color 0.1s ease-out; }
.ls-ctrl-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.7); border-color: rgba(255, 255, 255, 0.3); }
.ls-ctrl-btn--primary { background: linear-gradient(145deg, #ffd743, #ffb833); color: #050712; border-color: rgba(255, 215, 67, 0.95); }
.ls-ctrl-btn--primary:hover:not(:disabled) { box-shadow: 0 14px 30px rgba(255, 215, 67, 0.4); }
.ls-ctrl-btn--ghost { background: transparent; }
.ls-ctrl-btn--hint-active { box-shadow: 0 0 0 1px rgba(255, 215, 67, 0.9), 0 0 18px rgba(255, 215, 67, 0.6); }
.ls-ctrl-btn:disabled { opacity: 0.5; cursor: default; }

.ls-bottom-actions { display: flex; gap: 6px; margin-top: 8px; }
.ls-bottom-btn { flex: 1; border-radius: 999px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(14, 18, 35, 0.96); color: var(--ls-text-main); cursor: pointer; transition: background 0.16s ease-out, transform 0.1s ease-out, box-shadow 0.1s ease-out, border-color 0.1s ease-out, color 0.1s ease-out; }
.ls-bottom-btn:hover:enabled { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.7); border-color: rgba(255, 255, 255, 0.35); }
.ls-bottom-btn:disabled { opacity: 0.4; cursor: default; }
.ls-bottom-btn--share { background: radial-gradient(circle at top, #ffd743, #ffb833); color: #050712; }
.ls-bottom-btn.clicked { color: #ffffff !important; }

/* MODALS */
.ls-modal-overlay { position: fixed; inset: 0; background: rgba(1, 3, 10, 0.65); display: flex; align-items: center; justify-content: center; z-index: 20; }
.ls-modal { 
  position: relative; 
  width: min(420px, 92vw); 
  max-height: 80vh; 
  overflow: auto; 
  background: #050712; 
  border-radius: 20px; 
  border: 1px solid rgba(255, 215, 67, 0.45); 
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9); 
  padding: 32px 16px; /* Increased padding */
}
.ls-modal-title { margin: 0 0 8px; text-align: center; font-size: 1.1rem; }
.ls-modal-close { border: none; background: transparent; color: var(--ls-text-muted); position: absolute; right: 18px; top: 14px; font-size: 1.1rem; cursor: pointer; }
.ls-stats-section-title { 
  margin: 8px 0 4px; 
  font-size: 0.85rem; 
  color: var(--ls-accent-soft); 
  text-transform: uppercase; 
  letter-spacing: 0.12em; 
  text-align: center; 
}
.ls-stats-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.ls-stats-item { flex: 1 1 30%; background: #111525; border-radius: 12px; padding: 6px 8px; border: 1px solid rgba(255, 255, 255, 0.08); text-align: center; }
.ls-stats-label { display: block; font-size: 0.72rem; color: var(--ls-text-muted); }
.ls-stats-value { display: block; margin-top: 2px; font-size: 0.9rem; font-weight: 600; }

/* HEATMAP */
.ls-heatmap-container {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 8px;
}

.ls-heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #2a3044;
  border: 1px solid rgba(255,255,255,0.05);
}

/* Colors for Heatmap tiers */
.hm-green { background: #59FF84; box-shadow: 0 0 6px rgba(89, 255, 132, 0.4); } /* Normal (Diag) */
.hm-orange { background: #FF9F2E; box-shadow: 0 0 6px rgba(255, 159, 46, 0.4); } /* Hard (Plus) */
.hm-red { background: #FF4F70; box-shadow: 0 0 6px rgba(255, 79, 112, 0.4); } /* Hardest (X) */
.hm-grey { background: #2a3044; opacity: 0.3; }

/* FOOTER - Updated Spacing */
.ls-footer { 
  margin-top: 40px; 
  padding-top: 20px; 
  border-top: 1px solid var(--ls-border-subtle);
  text-align: center; 
  font-size: 0.8rem; 
  color: var(--ls-text-muted); 
  width: 100%;
  max-width: 600px;
  position: relative;
  z-index: 10;
}
.ls-footer-links { display: flex; justify-content: center; gap: 12px; margin-bottom: 4px; }
.ls-footer-link { color: var(--ls-accent-soft); text-decoration: none; font-size: 0.78rem; }
.ls-footer-link:hover { text-decoration: underline; }
.ls-footer-copy { margin: 6px 0 0; }

/* NEW CONTENT SECTION (Yellow Theme) */
.content-section {
  width: 100%;
  max-width: 600px;
  margin-top: 20px; /* MATCHED TO COLOURCROSS */
  padding: 0 14px;
  color: var(--ls-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
  z-index: 5;
  text-align: left;
}

.content-section h2 {
  color: var(--ls-text-main);
  font-size: 1.3rem;
  margin-bottom: 16px;
  margin-top: 10px; /* MATCHED TO COLOURCROSS */
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--ls-border-subtle);
  padding-bottom: 8px;
  text-align: center;
}

.content-section h3 {
  color: var(--ls-accent); /* Yellow */
  font-size: 1.1rem;
  margin-bottom: 10px;
  margin-top: 24px;
}

/* ADDED: Color for Step headings (h4) */
.content-section h4 {
  color: #ffffff;
  margin-top: 18px;
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 700;
}

.content-section p {
  margin-bottom: 16px;
}

.content-section ul {
  margin-bottom: 16px;
  padding-left: 0;
  list-style: none;
}

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

.content-section strong {
  color: var(--ls-text-main);
}

@media (max-width: 480px) {
  .game-shell.ls-shell { padding: 16px 10px 18px; }
  .ls-grid-wrapper { max-width: 240px; }
  .ls-header h1 { font-size: 1.4rem; }
}

/* --- COOL BACK NAV (YELLOW THEME) --- */
.arcade-return-nav {
  width: 100%;
  max-width: 460px;
  margin: 20px auto 10px;
  display: flex;
  justify-content: center;
  z-index: 5;
  position: relative;
}

.return-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  background: rgba(13, 17, 30, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 28px;
  border-radius: 999px;
  color: var(--ls-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* YELLOW HOVER STATE */
.return-link:hover {
  background: rgba(255, 215, 67, 0.12); /* Yellow tint */
  border-color: var(--ls-accent);
  color: #ffffff;
  box-shadow: 0 0 25px rgba(255, 215, 67, 0.25);
  transform: translateY(-2px);
}

.return-icon {
  font-size: 1.1em;
  transition: transform 0.3s ease;
}

.return-link:hover .return-icon {
  transform: translateX(-4px);
}

.return-link:active {
  transform: translateY(0) scale(0.98);
  opacity: 0.8;
}