/* ============================================================
   SoulFrame: Rebirth Protocol — page styles
   Scoped under .sf-* — does not touch the rest of the site.
   ============================================================ */

.sf-body { background: #07071a; color: #e6e6f4; }
.sf       { color: #e6e6f4; }

/* The hero/stage/editor/result sections set their own display rule below
   (flex / block), which has higher specificity than the UA `[hidden]`
   rule — without this override, toggling `el.hidden = true` does not
   actually hide them and the menu sticks on screen. */
.sf [hidden] { display: none !important; }

/* Atmospheric background that bleeds behind the hero/page */
.sf::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 60% at 18% 0%,  rgba(255,95,191,.16), transparent 60%),
    radial-gradient(50% 60% at 90% 12%, rgba(123,108,255,.14), transparent 65%),
    radial-gradient(70% 80% at 50% 100%,rgba(60, 220, 255,.10), transparent 70%),
    linear-gradient(180deg, #07071a 0%, #0b0a26 60%, #07071a 100%);
}

/* ----------------- Hero / mode select ----------------- */
.sf-hero {
  position: relative;
  min-height: 86svh;
  padding: clamp(56px, 8vw, 110px) 18px 80px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.sf-hero-inner { position: relative; z-index: 2; max-width: 1080px; width: 100%; text-align: center; }

.sf-hero-bg { position: absolute; inset: 0; pointer-events: none; }
.sf-hero-orb {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: .55; mix-blend-mode: screen;
  animation: sfDrift 18s ease-in-out infinite;
}
.sf-hero-orb.a { width: 540px; height: 540px; left: -120px; top: -120px;
  background: radial-gradient(circle, #ff5fbf 0%, transparent 70%); }
.sf-hero-orb.b { width: 600px; height: 600px; right: -180px; top: 5%;
  background: radial-gradient(circle, #6c6cff 0%, transparent 70%);
  animation-delay: -6s; }
.sf-hero-orb.c { width: 480px; height: 480px; left: 30%; bottom: -180px;
  background: radial-gradient(circle, #2cdcff 0%, transparent 70%);
  animation-delay: -12s; }
@keyframes sfDrift {
  0%,100% { transform: translate3d(0,0,0) scale(1); }
  50%     { transform: translate3d(40px,-30px,0) scale(1.06); }
}
.sf-hero-grid {
  position: absolute; inset: -1px;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(closest-side, #000 30%, transparent 78%);
}
.sf-hero-glyph {
  position: absolute; right: -40px; top: 8%;
  width: clamp(180px, 28vw, 360px); opacity: .65;
  animation: sfSpin 60s linear infinite;
}
@keyframes sfSpin { to { transform: rotate(360deg); } }

.sf-eyebrow {
  display: inline-block;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  color: #ff8edc; padding: 6px 12px;
  border: 1px solid rgba(255,142,220,.45);
  background: rgba(255,95,191,.06);
  border-radius: 999px; margin-bottom: 22px;
}
.sf-title {
  margin: 0 0 18px;
  font-size: clamp(40px, 7.4vw, 88px);
  line-height: 1.02; letter-spacing: -.02em;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff 0%, #ffd6f0 60%, #ff8edc 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sf-title span {
  background: linear-gradient(90deg, #b9a5ff, #ff8edc 60%, #ffd980);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sf-sub {
  max-width: 720px; margin: 0 auto 36px;
  font-size: clamp(15px, 1.4vw, 18px); line-height: 1.65;
  color: #c3c3dc;
}
.sf-sub strong { color: #ffe0f3; font-weight: 700; }

.sf-cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Buttons */
.sf-btn, .sf-btn-ghost {
  cursor: pointer;
  font: inherit; font-weight: 700; letter-spacing: .02em;
  padding: 12px 22px; border-radius: 12px;
  border: 1px solid transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.sf-btn-primary {
  color: #110a1c;
  background: linear-gradient(135deg, #ffb6e0 0%, #ff6cb6 50%, #b07bff 100%);
  box-shadow: 0 8px 30px rgba(255, 110, 188, .28), inset 0 1px 0 rgba(255,255,255,.4);
}
.sf-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 38px rgba(255, 110, 188, .42); }
.sf-btn-ghost {
  color: #e6e6f4;
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.14);
}
.sf-btn-ghost:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); }

/* Mode tiles */
.sf-mode-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  max-width: 920px; margin: 8px auto 28px;
  text-align: left;
}
.sf-mode {
  cursor: pointer; position: relative;
  background: linear-gradient(160deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  padding: 18px 18px 22px;
  color: inherit; text-align: left;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
  overflow: hidden;
}
.sf-mode::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(60% 90% at 100% 0%, var(--sfm-glow, rgba(255,142,220,.25)), transparent 70%);
  pointer-events: none; opacity: .6;
}
.sf-mode:hover { transform: translateY(-3px); border-color: rgba(255,142,220,.55); }
.sf-mode-tag {
  display: inline-block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--sfm-tag, #ff8edc);
  border: 1px solid color-mix(in srgb, var(--sfm-tag, #ff8edc) 50%, transparent);
  padding: 3px 8px; border-radius: 999px;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--sfm-tag, #ff8edc) 12%, transparent);
}
.sf-mode h3 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.01em; }
.sf-mode p  { margin: 0; color: #b3b3cc; line-height: 1.5; font-size: 14px; }
.sf-mode-go {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px; font-weight: 700; color: #ffd6f0;
}
.sf-mode-tut   { --sfm-tag: #2cdcff; --sfm-glow: rgba(44,220,255,.20); }
.sf-mode-arena { --sfm-tag: #ff8edc; --sfm-glow: rgba(255,142,220,.22); }
.sf-mode-boss  { --sfm-tag: #ffae45; --sfm-glow: rgba(255,174,69,.22); }
.sf-mode-edit  { --sfm-tag: #b9a5ff; --sfm-glow: rgba(185,165,255,.22); }

/* Stat pill row */
.sf-progress-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 10px;
}
.sf-stat-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; color: #c3c3dc;
}
.sf-stat-pill .lbl { color: #8d90a6; text-transform: uppercase; letter-spacing: .14em; font-size: 10px; }
.sf-stat-pill strong { color: #ffe0f3; font-weight: 700; }

/* ----------------- Stage / canvas ----------------- */
.sf-stage {
  position: relative;
  width: 100%; min-height: 100svh;
  background: #04040d;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.sf-canvas {
  display: block;
  width: 100%; height: 100svh;
  max-width: 100vw;
  background: #06061a;
  touch-action: none;
}

/* HUD overlay */
.sf-hud {
  position: absolute; inset: 0;
  pointer-events: none;
  font-size: 14px;
}
.sf-hud > * { pointer-events: auto; }

.sf-hud-top {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; justify-content: space-between; gap: 14px;
  align-items: flex-start;
  pointer-events: none;
}

.sf-hud-bars {
  display: flex; flex-direction: column; gap: 8px;
  width: min(38vw, 320px);
}

.sf-bar {
  position: relative;
  height: 14px; border-radius: 6px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.10);
  overflow: hidden;
  box-shadow: 0 6px 22px rgba(0,0,0,.45);
}
.sf-bar-fill {
  position: absolute; inset: 0;
  width: 100%;
  border-radius: inherit;
  transition: width .25s ease;
}
.sf-bar-hp .sf-bar-fill {
  background: linear-gradient(90deg, #ff5577, #ffb1c1);
  box-shadow: 0 0 18px rgba(255,85,119,.55);
}
.sf-bar-stam .sf-bar-fill {
  background: linear-gradient(90deg, #2cdcff, #b9a5ff);
  box-shadow: 0 0 14px rgba(44,220,255,.55);
}
.sf-bar-lbl {
  position: absolute; inset: 0;
  display: flex; align-items: center;
  justify-content: flex-start; padding: 0 8px;
  font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: #ffe6f5;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
.sf-bar-lbl em { font-style: normal; margin-left: auto; font-weight: 700; }

.sf-hud-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
}
.sf-meta {
  background: rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.10);
  padding: 6px 10px; border-radius: 8px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: #b3b3cc;
}
.sf-meta strong { color: #ffe6f5; margin-left: 6px; font-weight: 700; }

/* Boss bar */
.sf-boss-bar {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  width: min(78vw, 640px);
  background: rgba(8,4,18,.72);
  border: 1px solid rgba(255,142,220,.40);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 0 30px rgba(255,95,191,.25);
}
.sf-boss-name {
  font-weight: 800; letter-spacing: .04em;
  font-size: 14px; color: #ffd6f0;
}
.sf-boss-phase {
  float: right; font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: #ffae45;
}
.sf-boss-track {
  position: relative; height: 10px; margin-top: 6px;
  background: rgba(0,0,0,.5);
  border-radius: 4px; overflow: hidden;
}
.sf-boss-fill {
  position: absolute; inset: 0; width: 100%;
  background: linear-gradient(90deg, #ffae45, #ff5577 60%, #b07bff);
  transition: width .35s ease;
}

/* Skill slots */
.sf-skills {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; gap: 10px;
}
.sf-skill {
  position: relative;
  width: 76px; height: 76px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(0,0,0,.5));
  border: 1px solid rgba(255,142,220,.45);
  color: #ffe6f5;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1.1;
  text-align: center; padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  overflow: hidden;
  transition: transform .18s ease, border-color .18s ease;
}
.sf-skill:active { transform: scale(.96); }
.sf-skill-key {
  position: absolute; top: 4px; left: 6px;
  font-size: 10px; letter-spacing: .18em;
  color: #ff8edc;
}
.sf-skill-name { font-weight: 700; padding: 12px 4px 0; }
.sf-skill-cd {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.sf-skill[data-cd] .sf-skill-cd { opacity: 1; }

/* Pause */
.sf-pause {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.18);
  color: #ffe6f5; cursor: pointer;
  font-weight: 800;
  display: none; /* shown via JS on desktop too */
}
.sf-stage:not([hidden]) .sf-pause { display: inline-flex; align-items: center; justify-content: center; }

/* Pause / dead overlay */
.sf-overlay {
  position: absolute; inset: 0;
  background: rgba(4,4,12,.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.sf-overlay-card {
  max-width: 420px; width: 90%;
  padding: 28px;
  background: linear-gradient(160deg, rgba(40,20,60,.75), rgba(20,10,30,.85));
  border: 1px solid rgba(255,142,220,.35);
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.sf-overlay-card h2 { margin: 0 0 6px; font-size: 28px; }
.sf-overlay-card p  { margin: 0 0 20px; color: #c3c3dc; }
.sf-overlay-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* Mobile controls */
.sf-mobile {
  position: absolute; left: 14px; bottom: 14px; right: 14px;
  display: none;
  pointer-events: none;
}
.sf-stick {
  position: relative; pointer-events: auto;
  width: 130px; height: 130px;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  touch-action: none;
}
.sf-stick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 50px; height: 50px; border-radius: 50%;
  margin: -25px 0 0 -25px;
  background: linear-gradient(135deg, #ff8edc, #b07bff);
  box-shadow: 0 6px 20px rgba(255,95,191,.4);
  transform: translate(0,0);
  pointer-events: none;
}
.sf-actions {
  position: absolute; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  pointer-events: auto;
}
.sf-act {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #ffe6f5;
  border: 1px solid rgba(255,142,220,.35);
  font-size: 22px; font-weight: 800; cursor: pointer;
}
.sf-act-attack { border-color: rgba(255,85,119,.5); }
.sf-act-dodge  { border-color: rgba(44,220,255,.5); }
.sf-act-q, .sf-act-e { border-color: rgba(185,165,255,.5); font-size: 16px; }

/* Show mobile UI on touch / narrow viewports */
@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .sf-mobile { display: block; }
  .sf-skills { bottom: 102px; }
}

/* ----------------- Build editor ----------------- */
.sf-editor {
  min-height: 100svh;
  padding: 28px 18px 80px;
  background:
    radial-gradient(60% 80% at 80% 0%, rgba(185,165,255,.16), transparent 70%),
    radial-gradient(60% 80% at 10% 50%, rgba(255,95,191,.12), transparent 70%),
    #07071a;
}
.sf-editor-shell {
  max-width: 1240px; margin: 0 auto;
}
.sf-editor-head {
  display: flex; gap: 16px; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 22px;
}
.sf-editor-head h2 { margin: 6px 0 0; font-size: clamp(26px, 3vw, 36px); }
.sf-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sf-editor-actions input {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.14);
  color: #e6e6f4; border-radius: 10px;
  padding: 10px 14px; min-width: 220px;
  font: inherit;
}
.sf-editor-actions input:focus {
  outline: none; border-color: rgba(255,142,220,.7);
  background: rgba(255,142,220,.06);
}

.sf-editor-grid {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 18px;
  align-items: flex-start;
}
@media (max-width: 1080px) {
  .sf-editor-grid { grid-template-columns: 1fr 1fr; }
  .sf-editor-summary { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .sf-editor-grid { grid-template-columns: 1fr; }
}

.sf-editor-list, .sf-editor-summary {
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 16px;
}
.sf-editor-list h3, .sf-editor-summary h3 {
  margin: 0 0 12px; font-size: 15px;
  letter-spacing: .12em; text-transform: uppercase;
  color: #ff8edc;
}

.sf-build-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.sf-build-row {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  cursor: pointer; transition: all .15s ease;
  font-size: 14px;
}
.sf-build-row:hover { background: rgba(255,142,220,.08); border-color: rgba(255,142,220,.35); }
.sf-build-row.is-active {
  background: rgba(185,165,255,.10);
  border-color: rgba(185,165,255,.55);
}
.sf-build-row .sf-br-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-build-row .sf-br-tag {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: #b9a5ff;
}
.sf-build-row .sf-br-del {
  background: none; border: none; color: #8d90a6; cursor: pointer;
  font-size: 16px; padding: 2px 6px; border-radius: 6px;
}
.sf-build-row .sf-br-del:hover { color: #ff5577; background: rgba(255,85,119,.08); }
.sf-w-full { width: 100%; }

.sf-editor-main {
  display: flex; flex-direction: column; gap: 16px;
}
.sf-edit-section {
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 16px;
}
.sf-edit-section h4 {
  margin: 0 0 12px; font-size: 14px;
  letter-spacing: .12em; text-transform: uppercase;
  color: #ffd6f0;
  display: flex; align-items: baseline; gap: 8px;
}
.sf-edit-hint { color: #8d90a6; font-size: 11px; letter-spacing: .04em; text-transform: none; font-weight: 400; }

.sf-atom-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.sf-atom {
  position: relative;
  padding: 10px 12px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  cursor: pointer; user-select: none;
  transition: all .15s ease;
  font-size: 13px;
  color: #c3c3dc;
}
.sf-atom:hover { background: rgba(255,142,220,.08); border-color: rgba(255,142,220,.4); color: #fff; }
.sf-atom.is-on  {
  background: linear-gradient(160deg, rgba(255,142,220,.18), rgba(185,165,255,.10));
  border-color: rgba(255,142,220,.65);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255,142,220,.35) inset, 0 4px 18px rgba(255,95,191,.18);
}
.sf-atom.is-locked {
  opacity: .5; cursor: not-allowed;
  background: rgba(0,0,0,.35);
  color: #8d90a6;
}
.sf-atom.is-locked::after {
  content: "🔒"; position: absolute; top: 6px; right: 8px; font-size: 11px;
}
.sf-atom-name { font-weight: 700; color: #fff; display: block; margin-bottom: 2px; }
.sf-atom-desc { color: #a0a0b8; font-size: 12px; line-height: 1.4; }
.sf-atom.is-on .sf-atom-desc { color: #ffd6f0; }

/* Logic editor rows */
.sf-logic-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.sf-logic-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 8px; align-items: center;
}
.sf-logic-row select {
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  color: #e6e6f4; padding: 8px 10px;
  font: inherit; min-width: 0;
}
.sf-logic-row select:focus { outline: none; border-color: rgba(255,142,220,.7); }
.sf-logic-arrow { color: #ff8edc; font-weight: 800; }
.sf-logic-rm {
  background: none; border: 1px solid rgba(255,85,119,.4);
  color: #ff5577; border-radius: 8px; cursor: pointer;
  width: 28px; height: 28px; font-size: 14px;
}
.sf-logic-rm:hover { background: rgba(255,85,119,.12); }

/* Loadout preview */
.sf-preview {
  display: flex; flex-direction: column; gap: 10px;
  font-size: 13px;
}
.sf-preview-section { display: flex; flex-direction: column; gap: 4px; }
.sf-preview-label {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: #8d90a6;
}
.sf-preview-chip {
  display: inline-block; padding: 4px 10px;
  border-radius: 999px;
  background: rgba(185,165,255,.10);
  border: 1px solid rgba(185,165,255,.35);
  color: #ffd6f0; font-size: 12px;
  margin: 2px 4px 2px 0;
}
.sf-preview-rule {
  background: rgba(0,0,0,.3);
  border-left: 2px solid #ff8edc;
  padding: 6px 10px;
  border-radius: 4px;
  color: #c3c3dc; font-size: 12px;
  margin-bottom: 4px;
}
.sf-preview-note {
  margin-top: 14px;
  font-size: 11px; line-height: 1.5;
  color: #8d90a6; font-style: italic;
}

/* ----------------- Result screen ----------------- */
.sf-result {
  min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 60px 18px;
}
.sf-result-card {
  max-width: 520px; width: 100%;
  padding: 36px;
  background: linear-gradient(160deg, rgba(40,20,60,.75), rgba(20,10,30,.85));
  border: 1px solid rgba(255,142,220,.35);
  border-radius: 22px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.sf-result-eyebrow {
  display: inline-block;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: #ff8edc; padding: 5px 10px;
  border: 1px solid rgba(255,142,220,.45);
  border-radius: 999px; margin-bottom: 14px;
}
.sf-result-card h2 { margin: 0 0 18px; font-size: 32px; }
.sf-result-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 26px; text-align: left;
}
.sf-result-stat {
  padding: 10px 12px; border-radius: 10px;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.08);
}
.sf-result-stat .lbl {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: #8d90a6; display: block; margin-bottom: 4px;
}
.sf-result-stat .val { font-size: 18px; font-weight: 800; color: #ffe6f5; }
.sf-result-stat.pos .val { color: #b9ffb1; }
.sf-result-stat.neg .val { color: #ffb1c1; }
.sf-result-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ----------------- Floating toast for unlock notices ----------------- */
.sf-unlock-toast {
  position: fixed; left: 50%; bottom: 32px;
  transform: translateX(-50%);
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(255,142,220,.92), rgba(185,165,255,.92));
  color: #110a1c; font-weight: 700;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(255,95,191,.4);
  z-index: 1000;
  animation: sfToast 3.4s ease forwards;
}
@keyframes sfToast {
  0%   { opacity: 0; transform: translate(-50%, 24px); }
  10%  { opacity: 1; transform: translate(-50%, 0); }
  85%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* Mobile tweaks */
@media (max-width: 600px) {
  .sf-hud-meta { display: none; }
  .sf-hud-bars { width: 60vw; }
  .sf-skill { width: 64px; height: 64px; }
  .sf-act   { width: 56px; height: 56px; font-size: 18px; }
  .sf-stick { width: 110px; height: 110px; }
  .sf-stick-knob { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
}

/* ============================================================
   WORLD MAP
   ============================================================ */
.sf-mode-hero {
  grid-column: 1 / -1;
  background: linear-gradient(160deg, rgba(255,142,220,.18), rgba(108,108,255,.10) 50%, rgba(44,220,255,.08));
  border: 1px solid rgba(255,142,220,.55);
  box-shadow: 0 14px 50px rgba(255,95,191,.18);
}
.sf-mode-hero h3 { font-size: 28px; }
.sf-mode-hero p  { font-size: 15px; color: #d8d8e8; }
.sf-mode-hero .sf-mode-tag { background: rgba(255,142,220,.18); color: #ffe6f5; border-color: rgba(255,142,220,.65); }

.sf-world {
  min-height: 100svh;
  padding: 32px 18px 80px;
  background:
    radial-gradient(60% 80% at 80% 0%, rgba(255,142,220,.16), transparent 70%),
    radial-gradient(60% 80% at 10% 50%, rgba(108,108,255,.14), transparent 70%),
    #07071a;
}
.sf-world-shell { max-width: 1240px; margin: 0 auto; }
.sf-world-head {
  display: flex; gap: 18px; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 28px;
}
.sf-world-title { margin: 6px 0 8px; font-size: clamp(28px, 3.6vw, 42px); }
.sf-world-sub  { max-width: 700px; color: #b3b3cc; line-height: 1.6; margin: 0; font-size: 14px; }

.sf-world-grid {
  display: grid; grid-template-columns: 1fr 380px;
  gap: 22px; align-items: stretch;
}
@media (max-width: 980px) { .sf-world-grid { grid-template-columns: 1fr; } }

.sf-world-map {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 22px; overflow: hidden;
  background:
    radial-gradient(60% 80% at 25% 75%, rgba(120,200,140,.18), transparent 70%),
    radial-gradient(50% 60% at 50% 50%, rgba(255,170,90,.15), transparent 70%),
    radial-gradient(50% 60% at 70% 30%, rgba(140,180,255,.18), transparent 70%),
    radial-gradient(50% 60% at 88% 55%, rgba(255,142,220,.20), transparent 70%),
    linear-gradient(180deg, #0c0a26 0%, #07071a 100%);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 0 80px rgba(0,0,0,.4);
}
.sf-world-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sf-world-nodes { position: absolute; inset: 0; }
.sf-world-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  background: none; border: none;
  color: inherit; font: inherit;
}
.sf-world-node:disabled { cursor: not-allowed; opacity: .55; }
.sf-world-node-orb {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 2px solid var(--sfwn-color, #ff8edc);
  background: radial-gradient(circle, color-mix(in srgb, var(--sfwn-color, #ff8edc) 30%, transparent) 0%, transparent 70%),
              rgba(0,0,0,.5);
  box-shadow: 0 0 32px color-mix(in srgb, var(--sfwn-color, #ff8edc) 35%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
}
.sf-world-node:hover:not(:disabled) .sf-world-node-orb {
  transform: scale(1.08);
  box-shadow: 0 0 44px color-mix(in srgb, var(--sfwn-color, #ff8edc) 60%, transparent);
}
.sf-world-node-name {
  margin-top: 8px;
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: #e6e6f4; white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
}
.sf-world-node-prog {
  position: absolute; top: -8px; right: -8px;
  background: rgba(0,0,0,.85);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  font-size: 10px; padding: 2px 6px;
  border-radius: 999px;
  font-weight: 700;
}
.sf-world-node.is-cleared .sf-world-node-orb {
  background: radial-gradient(circle, rgba(180,255,180,.4) 0%, transparent 70%), rgba(0,30,0,.5);
  border-color: #80ff9b;
}
.sf-world-node.is-cleared .sf-world-node-orb::after {
  content: '★'; color: #ffd980;
  position: absolute; right: -3px; bottom: -3px;
  font-size: 14px;
}
.sf-world-node.is-current .sf-world-node-orb { animation: sfWorldPulse 1.6s ease-in-out infinite; }
@keyframes sfWorldPulse {
  0%, 100% { box-shadow: 0 0 32px color-mix(in srgb, var(--sfwn-color, #ff8edc) 35%, transparent); }
  50%      { box-shadow: 0 0 64px color-mix(in srgb, var(--sfwn-color, #ff8edc) 75%, transparent); }
}

.sf-world-detail {
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 22px;
  padding: 22px;
  display: flex; flex-direction: column; gap: 16px;
  min-height: 360px;
}
.sf-world-zone-head h3 { margin: 6px 0 6px; font-size: 22px; }
.sf-world-zone-head p { margin: 0; color: #b3b3cc; font-size: 13px; line-height: 1.55; }

.sf-mission-list { display: flex; flex-direction: column; gap: 10px; }
.sf-mission-row {
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all .15s ease;
}
.sf-mission-row:hover { background: rgba(255,142,220,.10); border-color: rgba(255,142,220,.45); }
.sf-mission-row.is-locked { opacity: .55; cursor: not-allowed; }
.sf-mission-row.is-cleared {
  border-color: rgba(120,255,155,.35);
  background: rgba(40,80,40,.18);
}
.sf-mission-row-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.sf-mission-name { font-weight: 700; color: #ffe6f5; flex: 1; }
.sf-mission-tag {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,142,220,.15); color: #ffd6f0;
  border: 1px solid rgba(255,142,220,.4);
}
.sf-mission-row.is-cleared .sf-mission-tag {
  background: rgba(120,255,155,.15); color: #80ff9b; border-color: rgba(120,255,155,.5);
}
.sf-mission-row.is-locked .sf-mission-tag {
  background: rgba(255,255,255,.06); color: #8d90a6; border-color: rgba(255,255,255,.15);
}
.sf-mission-flavor { font-size: 12px; color: #a0a0b8; line-height: 1.5; }
.sf-mission-obj {
  margin-top: 8px;
  font-size: 11px; color: #b9a5ff;
  letter-spacing: .04em;
}
.sf-mission-rwd {
  font-size: 11px; color: #ffae45;
  margin-top: 4px;
}

/* Pre-run lore card */
.sf-lore {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4,4,12,.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  animation: sfLoreFade .25s ease both;
}
@keyframes sfLoreFade { from { opacity: 0; } to { opacity: 1; } }
.sf-lore-card {
  max-width: 480px; width: 100%;
  background: linear-gradient(160deg, rgba(40,20,60,.85), rgba(20,10,30,.92));
  border: 1px solid rgba(255,142,220,.45);
  border-radius: 22px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
}
.sf-lore-eyebrow {
  display: inline-block;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: #ff8edc; padding: 5px 10px;
  border: 1px solid rgba(255,142,220,.45);
  border-radius: 999px; margin-bottom: 14px;
}
.sf-lore-card h2 { margin: 0 0 10px; font-size: 28px; letter-spacing: -.01em; }
.sf-lore-card p  { margin: 0 0 20px; color: #d8d8e8; line-height: 1.6; font-size: 14px; font-style: italic; }
.sf-lore-obj {
  background: rgba(0,0,0,.4);
  border-left: 3px solid #ffae45;
  padding: 10px 14px; border-radius: 4px;
  text-align: left;
  margin-bottom: 22px;
}
.sf-lore-obj-lbl {
  display: block;
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: #ffae45; margin-bottom: 4px;
}
.sf-lore-obj strong { color: #ffe6f5; font-weight: 600; }
.sf-lore-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* HUD: Mission objective tracker */
.sf-objective {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(8,4,18,.72);
  border: 1px solid rgba(255,174,69,.40);
  border-radius: 999px;
  padding: 6px 16px;
  box-shadow: 0 0 30px rgba(255,174,69,.18);
  display: inline-flex; align-items: center; gap: 8px;
}
.sf-objective-lbl {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: #ffae45;
}
.sf-objective-val { color: #ffe6f5; font-size: 14px; font-weight: 700; }

/* ============================================================
   OVERWORLD — walkable Glade
   ============================================================ */
.sf-overworld {
  position: fixed; inset: 0;
  background: #050811;
  z-index: 60;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.sf-ow-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Top-left quest tracker */
.sf-ow-hud {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
  z-index: 2;
}
.sf-ow-quest {
  pointer-events: auto;
  background: rgba(8,12,20,0.78);
  border: 1px solid rgba(255,180,90,0.35);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 240px;
  max-width: 360px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}
.sf-ow-quest-step {
  display: block;
  font-size: 9px; letter-spacing: .26em; text-transform: uppercase;
  color: #ffae45; margin-bottom: 2px;
}
.sf-ow-quest-title {
  display: block;
  font-size: 15px; font-weight: 700; color: #ffe6f5;
  margin-bottom: 3px;
  font-family: inherit;
}
.sf-ow-quest-hint {
  display: block;
  font-size: 12px; color: rgba(255,255,255,0.78);
  line-height: 1.35;
}
.sf-ow-quest-prog {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 9px;
  background: rgba(255,180,90,0.18);
  border: 1px solid rgba(255,180,90,0.45);
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  color: #ffe9a3;
  letter-spacing: .04em;
}
.sf-ow-meta {
  pointer-events: auto;
  display: flex; gap: 8px;
  align-items: center;
}
.sf-ow-gold {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(8,12,20,0.78);
  border: 1px solid rgba(255,208,106,0.45);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  color: #ffe9a3;
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
.sf-ow-gold-coin {
  width: 16px; height: 16px;
  filter: drop-shadow(0 0 4px rgba(255,208,106,0.55));
}
.sf-ow-meta-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(8,12,20,0.78);
  color: #ffe6f5;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
}
.sf-ow-meta-btn:hover { background: rgba(20,28,40,0.88); }

/* Interaction prompt */
.sf-ow-prompt {
  position: absolute;
  left: 50%; bottom: 26%;
  transform: translateX(-50%);
  background: rgba(8,12,20,0.88);
  border: 1px solid rgba(255,142,220,0.45);
  border-radius: 999px;
  padding: 8px 16px;
  display: flex; gap: 12px; align-items: center;
  font-size: 13px;
  color: #ffe6f5;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  animation: sfowPromptIn .18s ease-out;
}
.sf-ow-prompt strong { font-weight: 700; }
.sf-ow-prompt-key { color: rgba(255,255,255,0.7); font-size: 11px; }
.sf-ow-prompt-key kbd {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, monospace;
  font-size: 10px;
}
@keyframes sfowPromptIn {
  from { transform: translate(-50%, 6px); opacity: 0; }
  to   { transform: translate(-50%, 0);   opacity: 1; }
}

/* Quest direction arrow (Blox-Fruits-style) */
.sf-ow-arrow {
  position: absolute;
  width: 56px; height: 56px;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 0 10px rgba(255,233,163,0.55));
}
.sf-ow-arrow svg {
  width: 100%; height: 100%;
  display: block;
  animation: sfowBob 1.1s ease-in-out infinite alternate;
}
.sf-ow-arrow-lbl {
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  background: rgba(8,12,20,0.86);
  border: 1px solid rgba(255,233,163,0.45);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 10px; font-weight: 700;
  color: #ffe9a3;
  white-space: nowrap;
}
@keyframes sfowBob {
  from { transform: translateY(-2px) scale(0.96); }
  to   { transform: translateY( 2px) scale(1.04); }
}

/* Mobile controls */
.sf-ow-mobile {
  position: absolute;
  inset: auto 0 16px 0;
  display: none;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
  z-index: 3;
}
.sf-ow-stick {
  pointer-events: auto;
  position: relative;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.14);
  touch-action: none;
}
.sf-ow-stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255,142,220,0.55);
  border: 1.5px solid rgba(255,255,255,0.55);
  transition: transform .04s linear;
}
.sf-ow-act {
  pointer-events: auto;
  width: 78px; height: 78px;
  margin-top: 30px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff8edc, #c66bb0);
  border: 2px solid rgba(255,255,255,0.7);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
@media (hover: none) and (pointer: coarse) {
  .sf-ow-mobile { display: flex; }
}

/* Dialogue overlay — only laid out when not [hidden]; otherwise the
   author display:flex would override the UA [hidden]{display:none}
   and the modal would sit visible over the world from page load. */
.sf-ow-dialog[hidden] { display: none !important; }
.sf-ow-dialog {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 32px;
  z-index: 5;
}
.sf-ow-dialog-card {
  background: linear-gradient(180deg, rgba(20,12,30,0.94), rgba(8,5,12,0.96));
  border: 1px solid rgba(255,142,220,0.45);
  border-radius: 14px;
  padding: 18px 22px;
  width: min(640px, 92vw);
  box-shadow: 0 18px 48px rgba(0,0,0,0.6);
}
.sf-ow-dialog-speaker {
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: #ffae45;
  margin-bottom: 6px;
  min-height: 14px;
}
.sf-ow-dialog-text {
  font-size: 16px; line-height: 1.5;
  color: #ffe6f5;
  margin-bottom: 14px;
  min-height: 50px;
}
.sf-ow-dialog-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
}

/* Engage confirm — see note above; the [hidden] override is required. */
.sf-ow-engage[hidden] { display: none !important; }
.sf-ow-engage {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.sf-ow-engage-card {
  background: linear-gradient(180deg, rgba(30,12,40,0.96), rgba(10,5,18,0.98));
  border: 1px solid rgba(255,142,220,0.55);
  border-radius: 14px;
  padding: 20px 28px;
  text-align: center;
  width: min(380px, 86vw);
  box-shadow: 0 18px 48px rgba(0,0,0,0.65);
}
.sf-ow-engage-eye {
  font-size: 10px; letter-spacing: .26em; text-transform: uppercase;
  color: #ff8edc;
  margin-bottom: 6px;
}
.sf-ow-engage-card h2 {
  font-size: 22px; color: #ffe6f5;
  margin: 0 0 4px 0;
}
.sf-ow-engage-card p {
  font-size: 13px; color: rgba(255,255,255,0.72);
  margin: 0 0 18px 0;
}
.sf-ow-engage-actions {
  display: flex; gap: 10px; justify-content: center;
}

/* Hide site header inside overworld so the canvas fills the screen */
body:has(.sf-overworld:not([hidden])) header { opacity: 0; pointer-events: none; }

