/* lightning-smoke-machine app-walkthrough design-system*/
/* ------------------- */
/* Accessibility utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------- */
/* Google fonts */

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@500;600;700&display=swap');


/* ------------------- */
/* Design tokens (CSS Variables) */

:root {
  /* Background */
  --color-bg-main: #FFFFFF;
  --color-bg-card: #F6EFE7;
  --color-bg-dark: #52514E;

  /* Text */
  --color-text-primary: #191817;
  --color-text-secondary: #62605C;
  --color-text-tertiary: #87837F;

  /* Action */
  --color-action: #F9A836;
  --color-action-text: #FFFFFF;
  --color-text-accent: #585858;

  /* Level accent colors (card backgrounds per level) */
  --color-level-00: #FFFFFF;
  --color-level-01: #BCEEB6;
  --color-level-02: #ADE4FF;
  --color-level-03: #E0BFDE;
  --color-level-04: #FFCC77;
  --color-safety: #FFFFFF; /* (I don't know yet) */

  /* Feedback */
  --color-success: #49C275;
  --color-warning: #FFC300;
  --color-error: #FC5057;

  /* Spacing scale */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 100px;

  /* Shadow */
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.08);
}


/* ------------------- */
/* Reset */

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ------------------- */
/* Keyboard focus indicator */

*:focus {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--color-text-primary);
  outline-offset: 3px;
}

/* Pill-shaped buttons get a rounded outline */
.btn-lang,
.btn-letsgo,
.btn-continue,
.btn-mark-read,
.btn-levelup-gotit,
.btn-map-startover,
.help-show-more,
.help-submit-btn {
  border-radius: var(--radius-pill);
}

.btn-lang:focus-visible,
.btn-letsgo:focus-visible,
.btn-continue:focus-visible,
.btn-mark-read:focus-visible,
.btn-levelup-gotit:focus-visible,
.btn-map-startover:focus-visible,
.help-show-more:focus-visible,
.help-submit-btn:focus-visible,
.help-send-btn:focus-visible {
  outline-offset: 4px;
  border-radius: var(--radius-pill);
}

/* Circular icon buttons */
.wb-icon-btn:focus-visible {
  outline-offset: 2px;
  border-radius: 50%;
}

/* Card-shaped elements */
.help-card:focus-visible {
  outline-offset: 2px;
  border-radius: var(--radius-md);
}

/* Input fields */
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-text-primary);
  outline-offset: 0;
}

img {
  display: block;
  max-width: 100%;
}

/* ------------------- */
/* Base typography */

body {
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  background: var(--color-bg-main);
  color: var(--color-text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}


/* ------------------- */
/* App container (mobile-first, centered on desktop for now) */

#app {
  position: relative;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--color-bg-main);
  overflow: hidden;
}

@media (min-width: 431px) {
  body {
    background: var(--color-bg-dark);
  }

  #app {
    min-height: 100vh;
    border-radius: 24px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  }
}


/* ------------------- */
/* Screen system (show/hide) */

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--space-lg) var(--space-md);
}

.screen.active {
  display: flex;
}


/* ------------------- */
/* Screen 1 - Language Select */

/* Grid override for this screen: 3 rows */
#screen-language.active {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  padding: 0 0 40px;
}

/* Row 1: background SVG + logo stacked */
.lang-hero {
  position: relative;
  line-height: 0;
  height: 65vh;
}

.lang-bg {
  --bg-scale: 0.9; /* augmente pour agrandir le background, ex: 1.3, 1.5 */
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform: scale(var(--bg-scale));
  transform-origin: center top;
  margin-top: -37px;
}

.lang-logo {
  position: absolute;
  top: 38%;
  left: 52.5%;
  transform: translate(-50%, -50%) scale(1.15) rotate(-10deg);
  width: 100%;
  filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.25));
}

/* Row 2: text block, pulled up over the background SVG */
.lang-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: -200px;
  position: relative;
  z-index: 2;
  padding: 0 var(--space-md);
}

.lang-tagline {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-primary);
  line-height: 1.35;
  text-align: center;
}

.lang-subtitle {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-align: center;
}

/* Row 3: buttons */
.lang-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: 0 var(--space-md) max(32px, env(safe-area-inset-bottom));
}

.btn-lang {
  width: 100%;
  min-height: 56px;
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1.125rem;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-lang:active {
  opacity: 0.85;
  transform: scale(0.97);
}

.btn-lang--primary {
  background: var(--color-action);
  color: var(--color-action-text);
}

.btn-lang--outline {
  background: #FFF8ED;
  color: var(--color-text-accent);
  border: 2px solid var(--color-text-accent);
}


/* ------------------- */
/* Screen 2a - Welcome (first visit) */

#screen-welcome.active {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  padding: 0;
}

/* Hero: halo + logo + caterpillar layered */
.welcome-hero {
  position: relative;
  height: 58vh;
  line-height: 0;
  margin-bottom: -1px;
}

.welcome-bg {
  --bg-scale: 1.1; /* increase to enlarge without moving */
  display: block;
  width: 100%;
  height: 95%;
  object-fit: fill;
  transform: scale(var(--bg-scale));
}

.welcome-logo {
  position: absolute;
  top: 36%;
  left: 48%;
  transform: translate(-50%, -50%) rotate(-15deg);
  width: 80%;
  filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.25));
  z-index: 1;
}

/* Caterpillar sits in front of logo, overflows into form zone */
.welcome-mascot {
  position: absolute;
  top: 32.5%;
  bottom: -90px;
  left: 61%;
  transform: translateX(-50%);
  width: 325px;
  height: 325px;
  object-fit: contain;
  z-index: 2;
}

/* Form zone */
.welcome-form {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: 100px var(--space-md) max(32px, env(safe-area-inset-bottom));
}

.pseudonym-input {
  position: absolute;
  top: 148px; /* change top to move up or down */
  left: var(--space-md);
  right: var(--space-md);
  width: auto;
  min-height: 56px;
  padding: 0 var(--space-md);
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  font-size: 1rem;
  color: var(--color-text-primary);
  background: #FFF8ED;
  border: 2px solid var(--color-action);
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  outline: none;
}

.pseudonym-input::placeholder {
  color: var(--color-text-tertiary);
}

/* LET'S GO button */
.btn-letsgo {
  width: 100%;
  min-height: 56px;
  margin-top: 120px; /* change to move button + info text up or down */
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1.125rem;
  background: var(--color-action);
  color: var(--color-action-text);
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: opacity 0.15s ease, transform 0.1s ease;
}

@media (max-height: 700px) {
  .welcome-hero {
    height: 45vh;
  }
  .welcome-mascot {
    width: 200px;
    height: 200px;
  }
  .welcome-form {
    padding-top: 70px;
    gap: 12px;
  }
  .pseudonym-input { top: 110px; }
  .btn-letsgo       { margin-top: 100px; }
}

@media (max-height: 600px) {
  .welcome-hero   { height: 38vh; }
  .welcome-mascot { width: 160px; height: 160px; }
  .welcome-form   { padding-top: 56px; gap: 8px; }
  .pseudonym-input { top: 80px; }
  .btn-letsgo       { margin-top: 76px; font-size: 1rem; min-height: 48px; }
}

.btn-letsgo:active {
  opacity: 0.85;
  transform: scale(0.97);
}

/* Input shake animation for empty submit */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

.pseudonym-input.shake {
  animation: shake 0.35s ease;
  border-color: #e05c2a;
}

/* Info text below button */
.welcome-info {
  font-size: 0.8rem;
  font-weight: 500;
  font-style: italic;
  color: var(--color-text-tertiary);
  text-align: center;
}


/* ------------------- */
/* Screen 2b - Welcome Back */

#screen-welcome-back.active {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
}

.wb-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-md) 0;
}

.wb-icon-btn {
  background: none;
  border: none;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wb-icon-btn:active {
  opacity: 0.6;
}

/* Hero: halo + logo + caterpillar */
.wb-hero {
  position: relative;
  height: 48vh;
  line-height: 0;
}

.wb-bg {
  --wb-bg-scale: 1.0; /* increase to enlarge background */
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform: scale(var(--wb-bg-scale));
  transform-origin: center top;
}

.wb-logo {
  position: absolute;
  top: 30%;
  left: 47%;
  transform: translate(-50%, -50%) rotate(-15deg);
  width: 65%;
  filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.35));
  z-index: 1;
}

.wb-mascot {
  position: absolute;
  top: 25%;
  left: 59%;
  transform: translateX(-50%);
  width: min(290px, 85vw);
  height: min(290px, 85vw);
  object-fit: contain;
  z-index: 2;
}

/* Bottom zone */
.wb-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) var(--space-md) max(32px, env(safe-area-inset-bottom));
  gap: var(--space-xs);
}

.wb-greeting {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: center;
}

.wb-progress-bar {
  width: 100%;
  height: 12px;
  background: var(--color-bg-card);
  border-radius: 100px;
  overflow: hidden;
  margin-top: var(--space-xs);
}

.wb-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--level-color, var(--color-action));
  border-radius: 100px;
  transition: width 0.4s ease, background 0.4s ease;
}

.wb-progress-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-align: center;
}

.wb-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: auto;
}

@media (max-height: 700px) {
  .wb-hero { height: 40vh; }
  .wb-mascot { width: 200px; height: 200px; }
}


/* ------------------- */
/* Screen 3 - Tutorial Map */

#screen-map.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  padding: 0;
}

/* Top bar */
.map-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  flex-shrink: 0;
}

.map-topbar::before {
  content: '';
  min-width: 44px;
}

.map-overall-bar {
  flex: 1;
  height: 10px;
  background: var(--color-bg-card);
  border-radius: 100px;
  overflow: hidden;
}

.map-overall-fill {
  height: 100%;
  width: 0%;
  background: var(--color-action);
  border-radius: 100px;
  transition: width 0.4s ease;
}

/* Title */
.map-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  padding: 0 var(--space-md) var(--space-xs);
  margin: 0;
  flex-shrink: 0;
}

/* Cards container: fills remaining height, no scroll */
.map-cards {
  --map-top-gap: 10px;      /* space between title and first card */
  --map-cards-gap: 20px;    /* space between cards (first card stays fixed, others move down) */
  --map-mascot-layout: 85px; /* space the mascot reserves in the card layout (controls card height) */
  --map-mascot-size: 120px;  /* visual size of the mascot image (can be bigger than layout, overflows) */
  --map-card-inner-gap: 6px; /* gap between name, steps text, and progress bar inside each card */
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--map-cards-gap);
  padding: var(--map-top-gap) 24px max(16px, env(safe-area-inset-bottom));
  overflow: visible;
  min-height: 0;
}

/* Base card */
.map-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  border-radius: 16px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 0;
}

/* Completed: white bg, amber border, no shadow */
.map-card--completed {
  background: white;
  border: 2px solid var(--color-action);
}

/* Current: white bg, amber border, pulsing glow */
.map-card--current {
  background: white;
  border: 2px solid var(--color-action);
  animation: pulseGlow 2s ease-in-out infinite;
}

/* Locked: gray bg */
.map-card--locked {
  background: #F5F5F5;
  border: 2px solid #ebebeb;
  cursor: default;
}

/* Glow animation for current card */
@keyframes pulseGlow {
  0%   { box-shadow: 0 0 8px rgba(249, 168, 54, 0.3); }
  50%  { box-shadow: 0 0 22px rgba(249, 168, 54, 0.85); }
  100% { box-shadow: 0 0 8px rgba(249, 168, 54, 0.3); }
}

/* Locked card shake (reuses same keyframes as screen 2a input) */
.map-card--locked.shake {
  animation: shake 0.35s ease;
}

/* Start Over row */
.map-startover-row {
  --startover-margin-top: 4px;   /* ← monter/descendre le bouton */
  display: flex;
  justify-content: center;
  padding: var(--startover-margin-top) 0 42px;
  flex-shrink: 0;
}
.btn-map-startover {
  background: none;
  border: none;
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: 12px;
  color: var(--color-text-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s ease;
}

/* Start Over confirming state */
.btn-lang--outline.startover--confirming {
  background: #FFF0F0;
  border-color: var(--color-error);
  color: var(--color-error);
  opacity: 1;
}

.btn-map-startover.startover--confirming {
  color: var(--color-error);
  text-decoration-color: var(--color-error);
}

/* Mascot image: scale() enlarges visually without affecting layout */
.map-card-mascot {
  width: var(--map-mascot-layout);
  height: var(--map-mascot-layout);
  flex-shrink: 0;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-card-mascot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(calc(var(--map-mascot-size) / var(--map-mascot-layout)));
  transform-origin: center center;
}

/* Locked placeholder: gray circle with ? */
.map-card-locked-icon {
  width: var(--map-mascot-layout);
  height: var(--map-mascot-layout);
  border-radius: 50%;
  background: #DEDEDE;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #ABABAB;
  flex-shrink: 0;
}

/* Card info column */
.map-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--map-card-inner-gap);
  min-width: 0;
}

.map-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.map-card-steps {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
}

/* Progress bar + fraction on same row */
.map-card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-card-bar {
  flex: 1;
  height: 8px;
  background: #E8E8E8;
  border-radius: 100px;
  overflow: hidden;
}

.map-card-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.4s ease;
}

/* Small color sliver at start of bar when level is current but not yet started */
.map-card--current .map-card-fill {
  min-width: 10px;
}

.map-card-fraction {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
}

/* Locked state: dim all text and bar */
.map-card--locked .map-card-name,
.map-card--locked .map-card-steps,
.map-card--locked .map-card-fraction {
  color: #C0C0C0;
  filter: blur(1px);
}

.map-card--locked .map-card-bar {
  background: #E0E0E0;
}

@media (max-height: 700px) {
  .map-card { padding: 6px 12px; gap: 10px; }
  .map-card-mascot,
  .map-card-locked-icon { width: 46px; height: 46px; }
  .map-cards { gap: 6px; }
}


/* ------------------- */
/* Screen 4 - Step Content */

#screen-step.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding: 0;
}

/* Sticky top bar */
.step-topbar,
.safety-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: white;

  flex-shrink: 0;
  z-index: 10;
}

.step-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-primary);
  cursor: pointer;
  white-space: nowrap;
  padding: 10px 0;
  min-height: 44px;
}

.step-topbar-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.step-counter {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-tertiary);
}

.step-topbar-bar {
  width: 100%;
  height: 6px;
  background: var(--color-bg-card);
  border-radius: 100px;
  overflow: hidden;
}

.step-topbar-fill {
  height: 100%;
  width: 0%;
  border-radius: 100px;
  transition: width 0.4s ease, background 0.4s ease;
}

/* Scrollable content zone */
.step-content {
  flex: 1;
  min-width: 0; /* prevent flex item from overflowing when pre/code has long unbreakable content */
  overflow-y: auto;
  padding: var(--space-md) var(--space-md) 0;
}

/* Content typography */
.step-content h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-sm);
  line-height: 1.3;
}

.step-content h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-accent);
  margin: var(--space-md) 0 var(--space-xs);
  line-height: 1.35;
}

.step-content p {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  line-height: 1.6;
  margin: 0 0 var(--space-sm);
}

.step-content ul,
.step-content ol {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  line-height: 1.6;
  margin: 0 0 var(--space-sm);
  padding-left: var(--space-md);
}

.step-content li {
  margin-bottom: 5px;
}

/* Image card */
.step-img-card {
  background: var(--color-bg-card);
  border-radius: 16px;
  padding: 12px;
  margin: var(--space-sm) 0;
}

.step-img-plain {
  margin: var(--space-sm) 0;
}

.step-img-card img,
.step-img-plain img {
  display: block;
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
}

/* Image skeleton while loading */
.step-img-card.img-skeleton,
.step-img-plain.img-skeleton {
  min-height: 180px;
  background: linear-gradient(90deg, #F0EDE8 25%, #E8E3DC 50%, #F0EDE8 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 12px;
}

.step-img-card.img-skeleton img,
.step-img-plain.img-skeleton img {
  opacity: 0;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Code block */
.step-content pre,
.step-content code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  background: #F5F3F0;
  border-radius: 8px;
}

.step-content pre {
  padding: var(--space-sm);
  margin: var(--space-xs) 0 var(--space-sm);
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-all;
}

.step-content code {
  padding: 2px 6px;
  overflow-wrap: break-word;
  word-break: break-all;
}

.step-content pre code {
  background: none;
  padding: 0;
}

/* Table */
.step-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  color: var(--color-text-tertiary);
  margin: var(--space-sm) 0;
}

.step-content th {
  background: var(--color-bg-card);
  font-weight: 700;
  color: var(--color-text-primary);
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #E8E3DC;
}

.step-content td {
  padding: 8px;
  border-bottom: 1px solid #F0EDE9;
  vertical-align: top;
}

/* Sticky bottom: gradient fade + button */
.step-bottom {
  flex-shrink: 0;
  padding: 0 var(--space-md) max(24px, env(safe-area-inset-bottom));
  padding-top: 8px;
  background: white;
  position: relative;
}

.step-bottom::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, transparent, white);
  pointer-events: none;
}

/* Mark as complete button */
.btn-mark-read {
  width: 100%;
  min-height: 56px;
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: var(--radius-pill);
  transition: opacity 0.15s ease, transform 0.1s ease, background 0.2s ease, color 0.2s ease;
}

.btn-mark-read--outline {
  background: #FFF8ED;
  border: 2px solid var(--color-text-accent);
  color: var(--color-text-accent);
  opacity: 0.5;
}

.btn-mark-read--filled {
  background: var(--color-action);
  border: 2px solid var(--color-action);
  color: white;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-mark-read--filled:active {
  opacity: 0.85;
  transform: scale(0.97);
}

.btn-mark-read--outline.shake {
  animation: shake 0.35s ease;
}

/* Links inside step content */
.step-content a {
  color: var(--color-text-secondary);
  font-style: italic;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: break-word;
}

/* Responsive tables: horizontal scroll wrapper */
.step-table-wrap {
  overflow-x: auto;
  margin: var(--space-sm) 0;
  border-radius: 8px;
}
.step-table-wrap table {
  margin: 0;
  min-width: 480px; /* forces scroll on small screens if needed */
}

/* Responsive step content */
@media (max-width: 374px) {
  /* Very small phones (< 375px) */
  .step-content h1 { font-size: 1.15rem; }
  .step-content h2 { font-size: 0.95rem; }
  .step-content p,
  .step-content ul,
  .step-content ol { font-size: 0.88rem; }
  .step-content pre,
  .step-content code { font-size: 0.75rem; }
  .step-content table { font-size: 0.75rem; }
  .step-content { padding: var(--space-sm) var(--space-sm) 0; }
}

@media (min-width: 768px) {
  /* Tablets */
  .step-content { padding: var(--space-md) var(--space-lg) 0; }
  .step-content h1 { font-size: 1.55rem; }
  .step-content h2 { font-size: 1.2rem; }
  .step-content p,
  .step-content ul,
  .step-content ol { font-size: 1.05rem; }
  .step-content pre,
  .step-content code { font-size: 0.92rem; }
  .step-content table { font-size: 0.95rem; }
  .step-table-wrap table { min-width: unset; }
  .btn-mark-read { font-size: 1.2rem; min-height: 60px; }
}

@media (min-width: 1024px) {
  /* Large tablets / desktop */
  .step-content { padding: var(--space-lg) calc(var(--space-lg) * 2) 0; max-width: 720px; margin: 0 auto; }
}

/* Zoomable image cursor hint */
.img-zoomable {
  cursor: zoom-in;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 2000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox.active {
  display: flex;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:focus-visible {
  outline-color: #fff;
  outline-offset: 3px;
  border-radius: 50%;
}
.lightbox-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.lightbox-img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}


/* ------------------- */
/* Screen 5 - Level Up */

#screen-levelup.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: clip;
  padding: 0;
  position: relative;
}

/* Confetti layer: covers whole screen, no pointer events */
.levelup-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}

.levelup-confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg);    opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(600deg); opacity: 0; }
}

/* Top hero zone
   Per-level tuning parameters (set via JS on #levelup-hero):
   --lu-color        : background color of the hero zone
   --lu-hero-height  : total height of the colored zone (default 68vh)
   --lu-mascot-top   : distance from hero top to mascot (px or %)
   --lu-mascot-size  : mascot height (px or %)
   --lu-mascot-x     : horizontal offset from center (px, positive = right)
*/
.levelup-hero {
  --lu-color:       #BCEEB6;
  --lu-hero-height: 82vh;
  --lu-mascot-top:  8%;
  --lu-mascot-size: 52%;
  --lu-mascot-x:    0px;
  --lu-text-bottom: 16px;
  --lu-text-x:      0px;

  height: var(--lu-hero-height);
  background: var(--lu-color);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.levelup-help-btn {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 2;
}

.levelup-mascot {
  position: absolute;
  top: var(--lu-mascot-top);
  left: 50%;
  transform: translateX(calc(-50% + var(--lu-mascot-x)));
  height: var(--lu-mascot-size);
  width: auto;
  max-width: none; /* preserve aspect ratio — overflow is clipped by .levelup-hero */
  z-index: 1;
}

/* Title: independently positioned on screen, bottom = from screen bottom
   Tunable via textBottom / textX in JS — fully independent of heroHeight */
.levelup-hero-text {
  position: absolute;
  bottom: 300px; /* default, overridden by JS textBottom */
  left: 0;
  right: 0;
  text-align: center;
  padding: 0 var(--space-md);
  z-index: 4;
}

/* Gradient fade: inside hero, pinned to its bottom edge — above the white zone */
.levelup-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 35px;
  background: linear-gradient(to bottom, transparent, white);
  z-index: 3;
  pointer-events: none;
}

/* Bottom white zone: button only, anchored to screen bottom */
.levelup-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) var(--space-md) max(32px, env(safe-area-inset-bottom));
  z-index: 2;
}

.levelup-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 6px;
  letter-spacing: 0.02em;
  paint-order: stroke fill; /* stroke drawn behind fill so textColor stays visible */
}

/* Desc: independently positioned in white zone, tunable via descBottom in JS */
.levelup-desc {
  position: absolute;
  bottom: 185px; /* default, overridden by JS descBottom */
  left: 0;
  right: 0;
  padding: 0 var(--space-md);
  font-size: 1.10rem;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.45;
  margin: 0;
  white-space: pre-line;
  text-align: center;
  z-index: 3;
}

/* Stats: independently positioned on the screen via statsBottom param in JS */
.levelup-stats {
  position: absolute;
  bottom: 110px;  /* default, overridden by JS statsBottom */
  left: 0;
  right: 0;
  padding: 0 var(--space-md);
  font-size: 1.0rem;
  font-weight: 600;
  font-style: italic;
  color: var(--color-text-tertiary);
  line-height: 1.55;
  margin: 0;
  white-space: pre-line;
  text-align: center;
  z-index: 3;
}

/* GOT IT button */
.btn-levelup-gotit {
  width: 100%;
  min-height: 56px;
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--color-action);
  color: white;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-levelup-gotit:active {
  opacity: 0.85;
  transform: scale(0.98);
}

/* Small screens: compress hero height and text */
@media (max-height: 700px) {
  .levelup-hero   { height: 48vh; }
  .levelup-fade   { height: 56px; margin-top: -56px; }
  .levelup-title  { font-size: 1.35rem; }
  .levelup-desc   { font-size: 0.88rem; }
  .levelup-stats  { font-size: 0.76rem; }
  .levelup-text   { gap: 7px; }
  .btn-levelup-gotit { min-height: 50px; font-size: 1rem; }
}

/* Very short screens (iPhone SE 1st gen 568px, older Androids) */
@media (max-height: 600px) {
  .levelup-hero   { height: 40vh; }
  .levelup-mascot { height: 80%; }
  .levelup-fade   { height: 40px; margin-top: -40px; }
  .levelup-title  { font-size: 1.2rem; }
  .levelup-desc   { font-size: 0.82rem; }
  .levelup-stats  { font-size: 0.72rem; }
  .levelup-text   { gap: 4px; }
  .btn-levelup-gotit { min-height: 44px; font-size: 0.95rem; }
}

/* ------------------- */
/* Screen 4a - Safety Warning */

#screen-safety.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding: 0;
}

/* Scrollable zone: hero + content scroll together */
.safety-scroll {
  flex: 1;
  overflow-y: auto;
}

/* Hero: halo + mascot, scrolls with content */
.safety-hero {
  --safety-hero-height: 300px;
  position: relative;
  height: var(--safety-hero-height);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.safety-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 340px;
  height: 340px;
  pointer-events: none;
}

.safety-mascot {
  position: relative;
  z-index: 1;
  height: 360px;
  width: auto;
  object-fit: contain;
}

/* Text content */
.safety-content {
  padding: var(--space-sm) var(--space-md) var(--space-lg);
}

.safety-title {
  font-size: 1.70rem;
  font-weight: 900;
  color: #E53935;
  text-align: center;
  margin: 0 0 var(--space-xs);
  line-height: 0.8;
}

.safety-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-align: center;
  margin: 0 0 var(--space-sm);
  line-height: 1.3;
}

.safety-p--danger {
  --safety-p--danger-gap: 1px;
  font-weight: 700;
  color: #E53935;
  text-align: center;
  margin: var(--safety-p--danger-gap) 0 var(--space-sm);
}

.safety-p {
  --safety-p-gap: 35px;
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  text-align: left;
  line-height: 1.6;
  margin: var(--safety-p-gap) 0 var(--space-sm);
}

.safety-label {
  --safety-label-gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  margin: var(--safety-label-gap) 0 var(--space-sm);
  padding-bottom: 3%;
}

/* Checkbox rows */
.safety-check {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: var(--space-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.safety-check-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.safety-check-box {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-action);
  border-radius: 6px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin-top: 1px;
}

.safety-check-box::after {
  content: '';
  display: block;
  width: 6px;
  height: 11px;
  border: 2.5px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 0.1s ease;
}

.safety-check-input:checked + .safety-check-box {
  background: var(--color-action);
  border-color: var(--color-action);
}

.safety-check-input:checked + .safety-check-box::after {
  opacity: 1;
}

.safety-check-text {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
}

/* Shake for unchecked checkbox rows */
.safety-check.shake {
  animation: shake 0.35s ease;
}


/* ------------------- */
/* Screen 6 - Help Center */

#screen-help.active {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.help-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--space-md) 8px;
  flex-shrink: 0;
}

.help-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-md) max(32px, env(safe-area-inset-bottom));
}

.help-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-lg);
}

/* Section */
.help-section {
  margin-bottom: var(--space-lg);
}

.help-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-accent);
  margin-bottom: var(--space-sm);
}

.help-section-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

/* Contact section box */
.help-contact-section {
  background: #FFF8ED;
  border: 2px solid var(--color-action);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

/* Textarea */
.help-textarea {
  width: 100%;
  min-height: 96px;
  padding: var(--space-sm);
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-text-primary);
  background: #FFFFFF;
  border: 1.5px solid #E8DDD0;
  border-radius: var(--radius-md);
  resize: none;
  outline: none;
  display: block;
  margin-bottom: var(--space-sm);
  transition: border-color 0.2s ease;
}

.help-textarea::placeholder {
  color: var(--color-text-tertiary);
}

.help-textarea:focus {
  border-color: var(--color-action);
}

.help-textarea.shake {
  animation: shake 0.35s ease;
  border-color: #e05c2a;
}

/* Send button */
.help-send-btn {
  width: 100%;
  min-height: 48px;
  background: var(--color-action);
  color: var(--color-action-text);
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-pill);
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.help-send-btn:active {
  opacity: 0.85;
  transform: scale(0.97);
}

/* Confirmation message */
.help-confirm {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--space-md) 0 4px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.help-confirm.visible {
  display: flex;
}

.help-confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-success);
  color: white;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Accordion card list */
.help-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Base card */
.help-card {
  background: var(--color-bg-card);
  border: 1.5px solid var(--color-action);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Extra cards hidden by default — must come after .help-card to override display:flex */
.help-card--extra {
  display: none;
}

.help-card--extra.expanded-visible {
  display: flex;
}

.help-card-question {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-primary);
  transition: color 0.3s ease;
  padding: 2px 0;
}

/* Answer: collapsed by default via max-height transition */
.help-card-answer {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  line-height: 1.55;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, margin-top 0.3s ease, color 0.3s ease;
  margin-top: 0;
}

/* Open state */
.help-card.open {
  background: var(--color-action);
}

.help-card.open .help-card-question {
  color: #FFFFFF;
}

.help-card.open .help-card-answer {
  color: #FFFFFF;
  max-height: 400px;
  margin-top: 8px;
}

/* Show more / Show less */
.help-show-more {
  display: block;
  width: 100%;
  text-align: center;
  color: var(--color-text-accent);
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: var(--space-sm) 0;
  min-height: 44px;
  background: none;
  border: none;
  cursor: pointer;
}

/* Links section */
.help-links-list {
  list-style: disc;
  padding-left: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-links-list li {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.help-links-list a {
  color: var(--color-text-accent);
  text-decoration: none;
  word-break: break-all;
}

.help-links-list a:hover {
  text-decoration: underline;
}

/* Bottom fade — absolute inside relative screen, zero viewport impact */
.help-bottom-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ffffff);
  pointer-events: none;
  z-index: 5;
}

/* ------------------- */
/* Toast notification */

.app-toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-bg-dark);
  color: #FFFFFF;
  font-family: 'Quicksand', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}