/* =========================================================
   THE LUXURY ASCENSION — UI chrome
   Sunset expedition palette: deep purple base → gold peak
   ========================================================= */

:root {
  --plum-950: #150b2e;
  --plum-900: #1d1038;
  --plum-800: #2a1a4a;
  --plum-700: #3b2364;
  --plum-600: #4b2f78;
  --plum-500: #6d4a9e;

  --gold: #e6b450;
  --gold-bright: #ffd985;
  --gold-deep: #c9a14e;
  --champagne: #f7e3b3;
  --snow: #fff6df;

  --ink: #1a1030;
  --text: #f3ecff;
  --text-2: #cfc2e8;
  --muted: #9d8fc0;
  --line: rgba(247, 227, 179, 0.18);

  --green: #2ec27e;
  --red: #e35d6a;

  --panel-bg: rgba(24, 13, 44, 0.9);
  --card-bg: rgba(32, 18, 58, 0.92);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --shadow: 0 10px 40px rgba(10, 4, 24, 0.5);
  --shadow-lg: 0 24px 80px rgba(10, 4, 24, 0.65);

  --font-display: "Playfair Display", Georgia, serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --t-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-mid: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--plum-950);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
em { color: var(--gold-bright); font-style: italic; }
::selection { background: rgba(230, 180, 80, 0.4); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), opacity var(--t-fast);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn--gold {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-deep));
  color: #2a1a0a;
  box-shadow: 0 6px 24px rgba(230, 180, 80, 0.35);
}
.btn--gold:hover { box-shadow: 0 8px 32px rgba(230, 180, 80, 0.55); transform: translateY(-1px); }
.btn--ghost {
  background: transparent;
  color: var(--champagne);
  border-color: var(--line);
}
.btn--ghost:hover { background: rgba(247, 227, 179, 0.08); }
.btn--sm { padding: 8px 18px; font-size: 0.85rem; }
.btn--lg { padding: 15px 32px; font-size: 1.05rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------------- HUD ---------------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(14px, 3vw, 28px);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(16, 8, 34, 0.85), rgba(16, 8, 34, 0));
}
.hud-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-mark { color: var(--gold-bright); font-size: 1.1rem; }
.hud-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.hud-alt { flex: 1; max-width: 420px; }
.hud-alt-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--champagne);
  margin-bottom: 4px;
}
.hud-rank { color: var(--muted); letter-spacing: 0.08em; font-weight: 600; }
.hud-alt-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(247, 227, 179, 0.15);
  overflow: hidden;
}
#hudAltFill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--plum-500), var(--gold-bright));
  transition: width 700ms cubic-bezier(0.16, 1, 0.3, 1);
}
.hud-actions { display: flex; gap: 8px; margin-left: auto; }
.hud-btn {
  background: rgba(24, 13, 44, 0.6);
  border: 1px solid var(--line);
  color: var(--champagne);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.hud-btn:hover { background: rgba(247, 227, 179, 0.12); }

@media (max-width: 620px) {
  .hud-title { display: none; }
}

/* ---------------- GATE (climbing permit) ---------------- */
#gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(120% 100% at 50% 100%, rgba(21, 11, 46, 0.55), rgba(21, 11, 46, 0.88));
  overflow-y: auto;
  transition: opacity 600ms ease, visibility 600ms;
}
#gate.gate--closed { opacity: 0; visibility: hidden; pointer-events: none; }
.gate-card {
  width: min(460px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 40px);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  margin: auto;
}
@supports not (backdrop-filter: blur(14px)) {
  .gate-card { background: #201238; }
}
.gate-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.gate-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.1rem, 7vw, 2.9rem);
  line-height: 1.06;
  margin: 0 0 14px;
  background: linear-gradient(180deg, var(--snow), var(--gold-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.gate-sub { color: var(--text-2); font-size: 0.95rem; margin: 0 0 24px; }
#gateForm { display: flex; flex-direction: column; gap: 14px; text-align: left; }
#gateForm label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
#gateForm input {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(21, 11, 46, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
#gateForm input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(230, 180, 80, 0.18);
}
.gate-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .gate-row { grid-template-columns: 1fr; } }
.gate-fine { font-size: 0.72rem; color: var(--muted); text-align: center; margin: 2px 0 0; }

/* ---------------- CAMP PANEL ---------------- */
#camp-panel {
  position: fixed;
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
@supports not (backdrop-filter: blur(14px)) {
  #camp-panel { background: #1c0f36; }
}

@media (min-width: 880px) {
  #camp-panel {
    top: 0; right: 0; bottom: 0;
    width: min(560px, 44vw);
    border-radius: 0;
    border-right: none;
    transform: translateX(103%);
    transition: transform var(--t-slow);
  }
  #camp-panel.open { transform: translateX(0); }
  .panel-grab { display: none; }
}
@media (max-width: 879px) {
  #camp-panel {
    left: 0; right: 0; bottom: 0;
    height: 82vh;
    height: 82dvh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    transform: translateY(104%);
    transition: transform var(--t-slow);
  }
  #camp-panel.open { transform: translateY(0); }
}
.panel-grab {
  display: flex;
  justify-content: center;
  padding: 10px 0 2px;
}
.panel-grab span {
  width: 44px; height: 4px;
  border-radius: 999px;
  background: rgba(247, 227, 179, 0.35);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px clamp(18px, 4vw, 30px) 14px;
  border-bottom: 1px solid var(--line);
}
.panel-eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.panel-title {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.4vw, 1.7rem);
  font-weight: 700;
  margin: 0;
  line-height: 1.15;
}
.panel-close {
  background: rgba(247, 227, 179, 0.08);
  border: 1px solid var(--line);
  color: var(--champagne);
  width: 34px; height: 34px;
  border-radius: 999px;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.panel-close:hover { background: rgba(247, 227, 179, 0.16); }
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px clamp(18px, 4vw, 30px) 40px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ---------------- Content blocks ---------------- */
.blk-hero {
  margin: 4px 0 18px;
}
.blk-hero .eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.blk-hero h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.25;
  margin: 0;
  color: var(--snow);
}
.panel-body p { color: var(--text-2); font-size: 0.94rem; margin: 0 0 14px; }
.panel-body h4 {
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--gold-bright);
  margin: 24px 0 10px;
}
.panel-body ul { margin: 0 0 16px; padding-left: 20px; color: var(--text-2); font-size: 0.93rem; }
.panel-body li { margin-bottom: 7px; }
.blk-callout {
  border: 1px solid rgba(230, 180, 80, 0.35);
  background: rgba(230, 180, 80, 0.08);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 16px;
}
.blk-callout strong { color: var(--gold-bright); display: block; margin-bottom: 4px; }
.blk-callout p { margin: 0; font-size: 0.9rem; }
.blk-fieldnote {
  position: relative;
  border-left: 3px solid var(--gold-deep);
  background: rgba(247, 227, 179, 0.05);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px 14px 18px;
  margin: 0 0 16px;
  font-style: italic;
}
.blk-fieldnote::before {
  content: "FIELD NOTE";
  display: block;
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--gold-deep);
  margin-bottom: 5px;
}
.blk-fieldnote p { margin: 0; color: var(--champagne); font-size: 0.9rem; }

/* ---------------- Quiz ---------------- */
.quiz {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(21, 11, 46, 0.55);
  padding: 18px;
  margin: 22px 0;
}
.quiz-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.quiz-eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}
.quiz-progress { font-size: 0.78rem; color: var(--muted); }
.quiz-question { font-weight: 600; font-size: 0.98rem; margin-bottom: 14px; color: var(--snow); }
.quiz-options { display: flex; flex-direction: column; gap: 9px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: rgba(247, 227, 179, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-2);
  padding: 11px 14px;
  font-size: 0.9rem;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.quiz-option:hover:not([disabled]) { background: rgba(247, 227, 179, 0.12); border-color: rgba(247, 227, 179, 0.4); }
.quiz-option[disabled] { cursor: default; }
.quiz-key {
  width: 26px; height: 26px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--champagne);
}
.quiz-option.correct { border-color: var(--green); background: rgba(46, 194, 126, 0.14); color: #d9f7e9; }
.quiz-option.correct .quiz-key { border-color: var(--green); color: var(--green); }
.quiz-option.wrong { border-color: var(--red); background: rgba(227, 93, 106, 0.14); color: #ffdfe3; }
.quiz-option.wrong .quiz-key { border-color: var(--red); color: var(--red); }
.quiz-feedback {
  margin-top: 12px;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.86rem;
  color: var(--text-2);
}
.quiz-feedback.correct { background: rgba(46, 194, 126, 0.1); border: 1px solid rgba(46, 194, 126, 0.4); }
.quiz-feedback.wrong { background: rgba(227, 93, 106, 0.1); border: 1px solid rgba(227, 93, 106, 0.4); }
.quiz-feedback strong { display: block; margin-bottom: 3px; color: var(--snow); }
.quiz-next { margin-top: 14px; text-align: right; }
.quiz-result { text-align: center; padding: 10px 0; }
.quiz-result-score {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--gold-bright);
}
.quiz-result-note { color: var(--muted); font-size: 0.9rem; margin: 6px 0 18px; }
.quiz-result .btn { margin: 0 5px; }

/* ---------------- Mission ---------------- */
.mission {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px dashed rgba(230, 180, 80, 0.5);
  border-radius: var(--radius-lg);
  background: rgba(230, 180, 80, 0.06);
  padding: 16px;
  margin: 18px 0;
}
.mission input[type="checkbox"] {
  width: 22px; height: 22px;
  margin-top: 2px;
  accent-color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}
.mission-label { cursor: pointer; }
.mission-eyebrow {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.mission-text { font-size: 0.92rem; color: var(--champagne); }
.mission.done { border-style: solid; background: rgba(46, 194, 126, 0.08); border-color: rgba(46, 194, 126, 0.5); }
.mission.done .mission-eyebrow { color: var(--green); }

/* camp completion strip */
.camp-status {
  display: flex;
  gap: 10px;
  margin: 4px 0 18px;
}
.camp-status .chip {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
}
.camp-status .chip.done { border-color: var(--green); color: var(--green); }

/* ---------------- Badge overlay + modal ---------------- */
#badgeOverlay, #badgesModal, #victory-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 6, 28, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.badge-card, .badges-card, .victory-card {
  background: var(--card-bg);
  border: 1px solid rgba(230, 180, 80, 0.4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  text-align: center;
  width: min(400px, 100%);
  animation: card-in 420ms cubic-bezier(0.16, 1, 0.3, 1);
}
.badges-card { width: min(520px, 100%); text-align: left; padding: 0 0 20px; max-height: 80vh; max-height: 80dvh; display: flex; flex-direction: column; }
#badgesGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 18px 24px; overflow-y: auto; }
.badge-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  opacity: 0.35;
}
.badge-tile.on { opacity: 1; border-color: rgba(230, 180, 80, 0.5); background: rgba(230, 180, 80, 0.07); }
.badges-foot {
  padding: 4px 24px 6px;
  text-align: right;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.badges-foot .btn { opacity: 0.75; }
.badges-foot .btn:hover { opacity: 1; border-color: rgba(227, 93, 106, 0.6); color: #ffdfe3; }
.badge-tile .i { font-size: 1.6rem; }
.badge-tile .n { font-size: 0.78rem; font-weight: 700; color: var(--champagne); margin-top: 6px; }
.badge-tile .d { font-size: 0.68rem; color: var(--muted); margin-top: 3px; }
.badge-icon { font-size: 3rem; }
.badge-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin: 10px 0 6px;
}
.badge-desc { color: var(--text-2); font-size: 0.9rem; margin-bottom: 20px; }

/* ---------------- Victory card ---------------- */
.victory-eyebrow {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: var(--gold);
  margin-bottom: 8px;
}
.victory-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  margin: 0 0 10px;
  background: linear-gradient(180deg, var(--snow), var(--gold-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.victory-sub { color: var(--text-2); font-size: 0.94rem; margin: 0 0 18px; }
.victory-stats {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin-bottom: 22px;
}
.victory-stats .stat .v {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold-bright);
}
.victory-stats .stat .k {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.victory-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

#victorySkip {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 72;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  z-index: 80;
  background: var(--card-bg);
  border: 1px solid var(--line);
  color: var(--champagne);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid), transform var(--t-mid);
  max-width: min(90vw, 480px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { border-color: rgba(46, 194, 126, 0.6); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---------------- Altitude gain pop ---------------- */
.alt-pop {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  right: 22px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  text-shadow: 0 2px 10px rgba(10, 4, 24, 0.8);
  animation: alt-pop 1.5s ease forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes alt-pop {
  0% { opacity: 0; transform: translateY(10px); }
  15% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-22px); }
}
@media (prefers-reduced-motion: reduce) {
  .alt-pop { animation-duration: 0.8s; }
}
