/**
 * Quest OS — RPG progressive guidance (範山道令-inspired)
 * One quest · one door · no full dump
 * v=quest-os-v1
 */

:root {
  --qo-void: #07050f;
  --qo-panel: rgba(18, 10, 34, 0.94);
  --qo-violet: #a78bfa;
  --qo-gold: #f0c14b;
  --qo-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* When quest map owns the screen */
body.qo-map-open {
  overflow: hidden;
}
body.qo-map-open .mw-command,
body.qo-map-open .mw-context,
body.qo-map-open .mw-tab-shell,
body.qo-map-open .mw-dock,
body.qo-map-open .mw-fab-coord,
body.qo-map-open .main-container {
  visibility: hidden !important;
  pointer-events: none !important;
}
/* Keep navbar accessible for logout/lang? Hide main only — navbar stays */
body.qo-map-open .main-container {
  opacity: 0;
}

.qo-root {
  position: fixed;
  inset: 0;
  z-index: 100050;
  display: none;
  flex-direction: column;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(167, 139, 250, 0.2), transparent 55%),
    radial-gradient(circle at 80% 90%, rgba(240, 193, 75, 0.06), transparent 40%),
    var(--qo-void);
  color: #f5f3ff;
  font-family: "Noto Serif TC", serif;
  padding: calc(72px + env(safe-area-inset-top, 0px)) 16px
    calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.qo-root.show {
  display: flex;
  animation: qo-fade 0.45s var(--qo-ease) both;
}
@keyframes qo-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.qo-inner {
  width: min(720px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Player HUD */
.qo-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: linear-gradient(145deg, rgba(42, 16, 54, 0.9), rgba(10, 5, 18, 0.95));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), 0 0 40px rgba(167, 139, 250, 0.1);
}
.qo-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 900;
  background: linear-gradient(145deg, #a78bfa, #6d28d9);
  color: #07050f;
  box-shadow: 0 0 24px rgba(167, 139, 250, 0.45);
  font-family: Cinzel, serif;
}
.qo-hud-meta {
  flex: 1;
  min-width: 140px;
}
.qo-hud-meta .eyebrow {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--qo-violet);
  font-weight: 800;
  margin-bottom: 0.2rem;
}
.qo-hud-meta h2 {
  font-size: 1.05rem;
  font-weight: 900;
  margin: 0 0 0.35rem;
  font-family: Cinzel, "Noto Serif TC", serif;
  letter-spacing: 0.04em;
}
.qo-exp-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.qo-exp-bar {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.qo-exp-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #f0c14b);
  border-radius: 99px;
  transition: width 0.5s var(--qo-ease);
}
.qo-lv {
  font-size: 10px;
  font-weight: 900;
  color: var(--qo-gold);
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.qo-hud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.qo-chip-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(245, 243, 255, 0.75);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  font-family: inherit;
  min-height: 40px;
  transition: all 0.2s;
}
.qo-chip-btn:hover {
  border-color: rgba(167, 139, 250, 0.5);
  color: #fff;
}
.qo-chip-btn.gold {
  border-color: rgba(240, 193, 75, 0.4);
  color: var(--qo-gold);
  background: rgba(240, 193, 75, 0.08);
}
.qo-chip-btn.primary {
  background: linear-gradient(135deg, #a78bfa, #c4b5fd);
  color: #07050f;
  border: none;
}

/* Sifu intro */
.qo-sifu {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  background: rgba(167, 139, 250, 0.07);
  font-size: 12px;
  line-height: 1.65;
  color: rgba(245, 243, 255, 0.72);
}
.qo-sifu b {
  display: block;
  color: var(--qo-violet);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

/* Quest board */
.qo-board-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.55);
  margin: 0.25rem 0 0;
}
.qo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
@media (min-width: 560px) {
  .qo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.qo-card {
  position: relative;
  text-align: left;
  padding: 1rem 0.9rem 0.85rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: all 0.28s var(--qo-ease);
  min-height: 128px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: hidden;
}
.qo-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--qc, #a78bfa) 22%, transparent), transparent 55%);
  pointer-events: none;
  opacity: 0.85;
}
.qo-card > * {
  position: relative;
  z-index: 1;
}
.qo-card:hover,
.qo-card:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--qc, #a78bfa) 55%, transparent);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35), 0 0 24px color-mix(in srgb, var(--qc, #a78bfa) 18%, transparent);
  outline: none;
}
.qo-card.done {
  border-color: rgba(16, 185, 129, 0.35);
}
.qo-card.done .qo-badge-done {
  display: inline-flex;
}
.qo-card-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--qc, #a78bfa) 22%, transparent);
  color: var(--qc, #a78bfa);
  font-size: 0.95rem;
}
.qo-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
}
.qo-card p {
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.45);
  flex: 1;
}
.qo-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--qc, #a78bfa);
}
.qo-badge-done {
  display: none;
  align-items: center;
  gap: 0.25rem;
  color: #34d399;
  font-size: 9px;
}
.qo-xp {
  color: var(--qo-gold);
}

/* Sealed action strip */
.qo-seal-strip {
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px dashed rgba(240, 193, 75, 0.35);
  background: rgba(240, 193, 75, 0.06);
  font-size: 12px;
  line-height: 1.5;
}
.qo-seal-strip strong {
  display: block;
  color: var(--qo-gold);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.qo-seal-strip.empty {
  opacity: 0.55;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

/* ─── Active quest runner ───────────────────────────────── */
.qo-run {
  position: fixed;
  inset: 0;
  z-index: 100070;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.qo-run.show {
  display: flex;
}
.qo-run-bd {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 10, 0.88);
  backdrop-filter: blur(12px);
}
.qo-run-shell {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(92vh, 780px);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: linear-gradient(168deg, rgba(28, 12, 42, 0.99), rgba(8, 4, 14, 0.99));
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65), 0 0 60px rgba(167, 139, 250, 0.12);
  overflow: hidden;
  animation: qo-rise 0.4s var(--qo-ease) both;
}
@keyframes qo-rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.qo-run-prog {
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
}
.qo-run-prog i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #f0c14b);
  transition: width 0.35s var(--qo-ease);
}
.qo-run-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.65);
}
.qo-run-head button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
}
.qo-lanterns {
  display: flex;
  gap: 6px;
  padding: 0.5rem 1rem 0;
  justify-content: center;
}
.qo-lanterns span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: all 0.25s;
}
.qo-lanterns span.on {
  background: #a78bfa;
  box-shadow: 0 0 10px #a78bfa;
}
.qo-lanterns span.done {
  background: #f0c14b;
}
.qo-run-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem 1.2rem 0.5rem;
  text-align: center;
}
.qo-run-main .glyph {
  font-size: 3rem;
  font-weight: 900;
  font-family: Cinzel, serif;
  color: var(--qo-violet);
  text-shadow: 0 0 30px rgba(167, 139, 250, 0.5);
  margin: 0.35rem 0 0.75rem;
  line-height: 1;
}
.qo-run-main .ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.75rem;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(167, 139, 250, 0.15);
  color: var(--qo-violet);
  font-size: 1.25rem;
}
.qo-run-main h1 {
  font-size: 1.25rem;
  font-weight: 900;
  margin: 0 0 0.65rem;
  line-height: 1.3;
  font-family: Cinzel, "Noto Serif TC", serif;
}
.qo-sifu-box {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.2);
  margin-bottom: 0.85rem;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(245, 243, 255, 0.75);
}
.qo-sifu-box .tag {
  display: block;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--qo-violet);
  margin-bottom: 0.3rem;
}
.qo-lines {
  text-align: left;
  font-size: 12px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.62);
  margin-bottom: 0.75rem;
}
.qo-lines p {
  margin: 0 0 0.45rem;
}
.qo-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.75rem 0;
}
.qo-choice {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  text-align: left;
  transition: all 0.2s;
  min-height: 52px;
}
.qo-choice i {
  color: var(--qc, #a78bfa);
  width: 1.2rem;
  text-align: center;
}
.qo-choice.on {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(167, 139, 250, 0.15);
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.12);
}
.qo-commit {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(240, 193, 75, 0.3);
  background: rgba(240, 193, 75, 0.07);
  text-align: left;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  margin: 0.5rem 0;
}
.qo-commit input {
  margin-top: 3px;
  accent-color: #f0c14b;
}
.qo-commit strong {
  display: block;
  color: var(--qo-gold);
  margin-bottom: 0.2rem;
  font-size: 11px;
}
.qo-run-foot {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.qo-run-foot button {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  font-family: inherit;
}
.qo-btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
}
.qo-btn-primary {
  border: none;
  background: linear-gradient(135deg, #a78bfa, #c4b5fd);
  color: #07050f;
}
.qo-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* XP toast */
.qo-xp-toast {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 100100;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  background: rgba(7, 5, 15, 0.95);
  border: 1px solid rgba(240, 193, 75, 0.5);
  color: #f0c14b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s var(--qo-ease);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.qo-xp-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Hide journey FAB when map open (map has own CTA) */
body.qo-map-open .mystic-journey-fab {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .qo-root,
  .qo-run-shell,
  .qo-card {
    animation: none !important;
    transition: none !important;
  }
}
