:root {
  /* Dark blue foundation with warm artwork accents */
  --bg: #0d1620;
  --panel: #d6f4ab;        /* Green boxes */
  --panel-2: #c4ee90;      /* Slightly darker green for nested fields */
  --text: #0b1d3a;         /* Very dark blue text */
  --muted: #2f4e66;        /* Muted dark blue for secondary text */
  --accent: #86d63c;       /* Vibrant Lime Green */
  --accent-2: #28aadc;     /* Sky Blue */
  --danger: #e24968;       /* Warm Salmon Pink / Red */
  --ok: #34bc71;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  position: relative; /* containing block for the background wall + scrim */
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Views sit above the background wall/scrim (z-index 0/1). */
.view {
  position: relative;
  z-index: 2;
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.view.hidden { display: none; }

/* --- Background wall (landing / config / complete; never the runner) --------
   A two-wide, seamless tiled wall of reference images, warming the "chrome"
   screens. Absolute + inset:0 so it spans the full document height and repeats
   down however far the page scrolls; surplus tiles are clipped. Built by app.js.
   Hidden while a session runs so nothing competes with the pose. */
.bg-wall {
  position: absolute; inset: 0; z-index: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  gap: 0;
  overflow: hidden;
}
.bg-tile {
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
}
/* Dark scrim overlay */
.bg-scrim {
  position: absolute; inset: 0; z-index: 1;
  background:
    radial-gradient(ellipse 60% 45% at 50% 30%, rgba(13,22,32,.35), rgba(13,22,32,.88)),
    linear-gradient(rgba(13,22,32,.55), rgba(13,22,32,.75));
}
/* While the runner is active, the pose owns the screen — no wall behind it. */
body.running .bg-wall,
body.running .bg-scrim { display: none; }

.muted { color: var(--muted); }
.center { text-align: center; }

.app-header h1 { margin: 0 0 4px; font-size: 1.6rem; color: #f0f4f8; }

/* Landing — full-width so the wall shows around the centred content. */
.landing { max-width: none; padding: 0; }

/* Hero: the folder-picker card, centred in the first viewport. */
.landing-hero {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

/* Card with green fill and pink outline */
.card {
  background: rgba(214, 244, 171, .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 26px 24px;
  width: 100%;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .4);
}
.card.intro { max-width: 460px; text-align: center; }
.card.intro h1 { margin: 0 0 6px; font-size: 2rem; color: var(--text); }
.tagline { margin: 0 0 18px; color: var(--muted); }
.cta {
  background: var(--danger); color: #ffffff; border: 0;
  padding: 15px 18px; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 1.05rem; font-weight: 700; width: 100%;
}
.cta:hover { background: #f25877; }
.cta:disabled { background: #b0caa2; color: #5f7057; cursor: not-allowed; }
.hint { margin: 12px 0 0; font-size: .85rem; color: var(--muted); }
.scroll-cue { margin: 22px 0 0; font-size: .8rem; color: var(--muted); }

/* Help / guidance column below the hero. */
.info {
  max-width: 640px; margin: 0 auto;
  padding: 4px 20px 90px;
  display: flex; flex-direction: column; gap: 16px;
}
.info .card { text-align: left; }
.info h2 { margin: 0 0 12px; font-size: 1.2rem; color: var(--text); }
.info p { margin: 0 0 10px; line-height: 1.55; }
.info p:last-child { margin-bottom: 0; }
.info ol, .info ul { margin: 0; padding-left: 1.2em; line-height: 1.55; }
.info li { margin-bottom: 8px; }
.info li:last-child { margin-bottom: 0; }

/* Timing-guidance rows with a coloured length chip. */
.guidance { list-style: none; padding-left: 0; }
.guidance li { margin-bottom: 14px; }
.len {
  display: inline-block; margin-right: 8px;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  color: #ffffff; background: var(--accent-2);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.privacy .lock { color: var(--danger); }

/* Small, unobtrusive maker credit at the foot of the landing column. */
.credit { text-align: center; font-size: .82rem; color: #a2b8cc; padding: 4px 0 8px; }
.credit a { color: var(--accent-2); text-decoration: none; font-weight: 600; }
.credit a:hover { text-decoration: underline; }

.panel {
  background: var(--panel);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
}
.panel h2 { margin: 0 0 12px; font-size: 1rem; color: var(--muted); font-weight: 700; }

/* Presets */
.preset-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.preset {
  background: var(--panel-2);
  border: 1.5px solid var(--danger);
  border-radius: 10px;
  padding: 14px 12px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, transform .05s, background-color .15s;
}
.preset:hover { background: #b8e280; }
.preset:active { transform: scale(.98); }
.preset.active { border-color: var(--danger); background: var(--accent-2); color: #ffffff; }
.preset.active .sub { color: #d0f2ff; }
.preset .label { font-weight: 600; }
.preset .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* Custom tile inputs — revealed below the preset grid when "Custom" is selected. */
.custom-fields {
  margin-top: 12px;
  padding: 14px;
  background: var(--panel-2);
  border: 1.5px solid var(--danger);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.custom-fields.hidden { display: none; }
.custom-fields .field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .9rem;
}
.custom-fields .field input {
  width: 96px;
  background: var(--panel);
  color: var(--text);
  border: 1.5px solid var(--danger);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-weight: 600;
  text-align: right;
}
.custom-fields .field input:focus {
  outline: none;
  border-color: var(--accent-2);
}
.custom-fields #custom-summary { margin: 0; font-size: .8rem; }

/* Segmented toggle */
.segmented { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 4px; border: 1.5px solid var(--danger); }
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: .9rem; font-weight: 700;
}
.segmented button.active { background: var(--danger); color: #ffffff; }

/* Buttons */
button { font: inherit; }
.primary {
  background: var(--danger); color: #ffffff; border: 0; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
}
.primary:hover { background: #f25877; }
.primary:disabled { background: #b0caa2; color: #5f7057; cursor: not-allowed; }
.big { width: 100%; padding: 16px; font-size: 1.05rem; margin-top: 8px; }
.secondary {
  background: var(--panel-2); color: var(--text); border: 1.5px solid var(--danger);
  padding: 10px 18px; border-radius: 10px; cursor: pointer; font-weight: 600;
}
.secondary:hover { background: #b8e280; }
.controls { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); padding: 10px 18px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.danger:hover { background: rgba(226, 73, 104, .15); }

/* Runner — dark stage for clear image viewing */
#runner-view { position: relative; height: 100vh; width: 100vw; max-width: none; padding: 0; overflow: hidden; }
.stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #080e14;
  touch-action: none;
}
#stage-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  transition: transform .15s ease;
  user-select: none; -webkit-user-drag: none;
}

/* Grid overlay */
.grid-overlay {
  position: absolute; inset: 0; pointer-events: none;
  display: grid;
  --grid-color: rgba(40, 170, 220, .65);
  border-top: 1px solid var(--grid-color);
  border-left: 1px solid var(--grid-color);
}
.grid-overlay.hidden { display: none; }
.grid-cell {
  border-right: 1px solid var(--grid-color);
  border-bottom: 1px solid var(--grid-color);
  box-sizing: border-box;
}

.stage.zoomed { cursor: grab; }
.stage.panning { cursor: grabbing; }
.stage.panning #stage-img { transition: none; }

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(13, 22, 32, .88); gap: 6px;
}
.overlay.hidden { display: none; }
.overlay-label { color: #a2b8cc; font-size: 1.1rem; }
.overlay-count { font-size: 5rem; font-weight: 700; color: var(--accent); line-height: 1; }

/* Floating HUD pill styled with green background & pink outline */
.hud {
  position: absolute; top: 16px; left: 16px;
  z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(214, 244, 171, .45);
  border: 2px solid var(--danger);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  opacity: .32; transition: opacity .2s ease;
  cursor: grab; touch-action: none; user-select: none;
}
/* :focus-visible, not :focus-within — a mouse-clicked button keeps focus and
   would otherwise pin the HUD bright after Skip/Pause. */
.hud:hover, .hud:has(:focus-visible) { opacity: 1; }
.hud.dragging { opacity: 1; cursor: grabbing; transition: none; }
.hud .hud-btn { cursor: pointer; }
.hud-grip { color: var(--muted); font-size: 1rem; line-height: 1; padding-right: 2px; }

.hud .phase {
  font-size: .65rem; letter-spacing: .08em; font-weight: 700;
  padding: 3px 8px; border-radius: 6px; background: var(--accent-2); color: #ffffff;
}
.hud .phase.transition { background: var(--danger); color: #ffffff; }
.hud .time { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4ch; text-align: center; color: var(--text); }
.hud .step { font-size: .8rem; color: var(--muted); }
.hud-sep { width: 1px; align-self: stretch; background: var(--danger); margin: 2px 2px; }

.hud-btn {
  background: rgba(11, 29, 58, .08); color: var(--text); border: 0;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: .85rem; font-weight: 600;
}
.hud-btn:hover { background: rgba(11, 29, 58, .16); }
.hud-btn.danger { color: var(--danger); background: rgba(226, 73, 104, .15); }
.hud-btn.danger:hover { background: rgba(226, 73, 104, .28); }

.hud-btn:disabled { opacity: .4; cursor: default; }

/* Zoom controls */
.hud-zoom { display: flex; align-items: center; gap: 4px; }
.hud-zoom .hud-btn { min-width: 2.4ch; padding: 7px 10px; font-size: 1rem; line-height: 1; }

/* Grid controls */
.hud-grid { display: flex; align-items: center; gap: 4px; }
#grid-size-btn { min-width: 5.5ch; text-align: center; }
.hud-btn.grid-color-btn { width: 22px; height: 22px; padding: 0; border: 1px solid var(--danger); }

/* Progress line pinned to bottom */
.progress { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; height: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent-2); transition: width .9s linear; }