/* SURMOUNT — night sanctuary theme */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1020;
  --bg-glow: #1a2142;
  --panel: #161b31;
  --panel-edge: rgba(255, 255, 255, 0.08);
  --text: #eef0ff;
  --muted: #9aa3c7;
  --gold: #f0c987;
  --ember: #e8965a;
  --accent-grad: linear-gradient(135deg, #f0c987, #e8965a);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}
[data-theme="light"] {
  --bg: #f4f2ec;
  --bg-glow: #e7e2d4;
  --panel: #ffffff;
  --panel-edge: rgba(30, 30, 60, 0.12);
  --text: #23263d;
  --muted: #6a7092;
  --shadow: 0 10px 24px rgba(40, 40, 80, 0.12);
}

body {
  font-family: "Avenir Next", "SF Pro Text", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 600px at 70% -10%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(108, 123, 255, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app { max-width: 1120px; margin: 0 auto; padding: 20px 24px 40px; color: var(--text); }

/* ---------- header ---------- */
#topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0 18px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 34px; filter: drop-shadow(0 0 12px rgba(240, 201, 135, 0.45)); }
.brand-text h1 { font-size: 26px; letter-spacing: 4px; font-weight: 700; }
.tagline { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  color: var(--text); border-radius: 999px; padding: 7px 14px; font-size: 13px;
}
.streak-chip .flame { filter: drop-shadow(0 0 6px rgba(255, 143, 94, 0.8)); }
.icon-chip { cursor: pointer; }
.icon-chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--gold) inset; }

/* ---------- tabs ---------- */
#tabs { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0 20px; }
.tab {
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--muted);
  padding: 9px 18px; border-radius: 12px; font-size: 14px; cursor: pointer; transition: all .18s ease;
}
.tab.active { color: var(--text); background: var(--accent-grad); border-color: transparent; color: #20160a; font-weight: 600; }
.tab.locked { opacity: 0.6; }
.tab .lock { font-size: 11px; }

/* ---------- panels & cards ---------- */
.panel { display: none; }
.panel.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.muted { color: var(--muted); font-size: 13px; }
.section-heading { margin: 26px 0 12px; font-size: 15px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }

.sanctum-grid { display: grid; grid-template-columns: 340px 1fr; gap: 18px; }
@media (max-width: 860px) { .sanctum-grid { grid-template-columns: 1fr; } }

/* avatar */
.avatar-card { text-align: center; }
#avatar-stage svg { width: 200px; height: 230px; }
.avatar-float { animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.identity { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 8px; }
.identity h2 { font-size: 20px; }
.level-badge {
  background: var(--accent-grad); color: #20160a; font-weight: 700;
  border-radius: 999px; padding: 7px 14px; font-size: 15px;
  box-shadow: 0 0 18px rgba(232, 150, 90, 0.4);
}
.title-line { color: var(--gold); font-size: 13px; letter-spacing: 1px; }
[data-theme="light"] .title-line, [data-theme="light"] .mantra-text, [data-theme="light"] .quest-title strong { color: #8a6a2f; }
[data-theme="light"] .overlay-card #levelup-title { color: #8a6a2f; }

.xp-block { margin-top: 16px; text-align: left; }
.xp-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.xp-nums { font-variant-numeric: tabular-nums; }
.xp-bar { height: 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; border: 1px solid var(--panel-edge); }
.xp-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: var(--accent-grad); transition: width .9s cubic-bezier(.22,1,.36,1);
  position: relative;
}
.xp-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%);
  animation: shimmer 2.4s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.xp-next { margin-top: 6px; font-size: 12px; color: var(--muted); }
.currencies { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* attributes */
.attr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; align-content: start; }
.attr-card { padding: 14px 16px; border-left: 3px solid transparent; transition: transform .15s ease; }
.attr-card:hover { transform: translateY(-2px); }
.attr-card.pulse { animation: pulse .8s ease; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--pulse-colour, #f0c987); } 100% { box-shadow: 0 0 0 14px transparent; } }
.attr-head { display: flex; justify-content: space-between; align-items: baseline; }
.attr-name { font-weight: 600; font-size: 14px; }
.attr-level { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.attr-blurb { color: var(--muted); font-size: 11px; margin: 6px 0 10px; line-height: 1.4; }
.attr-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; }
.attr-fill { height: 100%; border-radius: 999px; transition: width .8s cubic-bezier(.22,1,.36,1); }

/* worlds */
.worlds { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.world-card { position: relative; overflow: hidden; padding: 16px; min-height: 108px; }
.world-card h4 { font-size: 14px; margin-bottom: 4px; }
.world-card p { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.world-tint { position: absolute; inset: 0; opacity: var(--tint, .2); pointer-events: none; transition: opacity 1s ease; }
.world-level { position: absolute; top: 10px; right: 12px; font-size: 11px; color: var(--muted); }
.world-tier { position: absolute; bottom: 10px; right: 12px; font-size: 11px; color: var(--gold); }
.next-unlock { margin-top: 12px; padding: 12px 16px; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.next-unlock.hidden { display: none; }
.next-unlock .unlock-chip { color: var(--gold); border-color: rgba(240, 201, 135, .5); }
[data-theme="light"] .next-unlock .unlock-chip { color: #8a6a2f; border-color: rgba(138, 106, 47, .5); }

/* mantra */
.mantra { margin-top: 26px; text-align: center; padding: 26px; }
.mantra-label { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.mantra-text { font-size: 20px; font-style: italic; color: var(--gold); }

/* forging teasers */
.forging-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.teaser { opacity: .75; }
.teaser-icon { font-size: 22px; display: block; margin-bottom: 8px; }
.teaser p { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.45; }

/* ---------- quests ---------- */
.quests-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.quests-header h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.done-chip { font-variant-numeric: tabular-nums; }
.sync-block { text-align: right; }
.sync-block .muted { margin-top: 6px; }

.btn {
  border: none; border-radius: 12px; padding: 10px 18px; font-size: 14px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease; font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent-grad); color: #20160a; font-weight: 700; box-shadow: 0 6px 18px rgba(232, 150, 90, 0.35); }
.btn.ghost { background: transparent; border: 1px solid var(--panel-edge); color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

.quest-list { display: grid; gap: 10px; }
.quest-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 14px; padding: 14px 16px;
}
.quest-main { flex: 1; min-width: 0; }
.quest-side { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.quest-side .btn { padding: 6px 12px; font-size: 12px; }
.focus-card { border-color: rgba(240, 201, 135, .55); box-shadow: 0 0 16px rgba(240, 201, 135, .18); }
.focus-badge { color: var(--gold); font-size: 11.5px; letter-spacing: 1px; font-weight: 700; margin-bottom: 4px; }
.quest-card .seal-btn { align-self: stretch; }

.quest-title {
  font-size: 14px; line-height: 1.45; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.quest-title strong { color: var(--gold); font-weight: 600; }
.wikilink { color: var(--muted); border-bottom: 1px dotted var(--panel-edge); }
.quest-meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.qchip { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--panel-edge); color: var(--muted); }
.qchip.due-today { color: var(--gold); border-color: rgba(240, 201, 135, .5); }
.qchip.overdue { color: #ff7b7b; border-color: rgba(255, 123, 123, .5); }
.quest-card.sealed { opacity: .55; }
.seal-note { color: var(--gold); font-size: 13px; }
.empty-state { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 14px; }

.locked-panel .locked-card { text-align: center; max-width: 560px; margin: 40px auto; padding: 40px; }
.locked-card h2 { margin: 10px 0; }
.locked-card p { color: var(--muted); line-height: 1.6; }

/* skills */
.skill-trees { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.skill-tree { border-top: 3px solid #7b8cff; display: flex; flex-direction: column; gap: 8px; }
.skill-tree-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.skill-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--panel-edge); border-radius: 12px; padding: 10px 12px;
}
.skill-row.learned { border-color: rgba(240, 201, 135, 0.45); background: rgba(240, 201, 135, 0.06); }
.skill-main { flex: 1; min-width: 0; }
.skill-name { font-size: 13.5px; font-weight: 600; }
.skill-flavour { color: var(--muted); font-size: 11.5px; margin-top: 3px; font-style: italic; line-height: 1.4; }
.skill-side { flex-shrink: 0; }
.learn-btn { padding: 7px 14px; font-size: 13px; }

/* collection */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.companion { padding: 14px 16px; border-left: 3px solid var(--muted); }
.companion.owned { border-left-color: var(--gold); }
.companion.unowned { opacity: .55; }
.companion.rare { border-left-color: #64c7ff; }
.companion.epic { border-left-color: #b18cff; }
.companion.legendary { border-left-color: var(--gold); box-shadow: 0 0 22px rgba(240, 201, 135, .25); }
.companion-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.companion-icon { font-size: 26px; }
.companion-name { font-weight: 600; font-size: 13.5px; }
.companion-flavour { color: var(--muted); font-size: 11.5px; font-style: italic; line-height: 1.45; }
.affinity { margin-top: 8px; color: var(--gold); font-size: 12px; }
.rarity-legendary { color: var(--gold); border-color: rgba(240, 201, 135, .5); }
.rarity-epic { color: #b18cff; border-color: rgba(177, 140, 255, .5); }
.rarity-rare { color: #64c7ff; border-color: rgba(100, 199, 255, .5); }

/* keep */
.keep-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.room-card { border-top: 3px solid #7b8cff; }
.room-head { display: flex; justify-content: space-between; align-items: baseline; }
.room-actions { display: flex; flex-direction: column; gap: 8px; }
.room-staff {
  background: var(--panel); color: var(--text); border: 1px solid var(--panel-edge);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; font-family: inherit;
}

/* chronicle */
.chronicle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .chronicle-grid { grid-template-columns: 1fr; } }
.arc-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.arc-form label { font-size: 12px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.arc-form input, .arc-form textarea {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-edge); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
.arc-form input:focus, .arc-form textarea:focus { outline: 2px solid var(--gold); }
.arc-form .btn { align-self: flex-start; }
.arc-list { display: grid; gap: 10px; }
.arc-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.arc-row.arc-done { opacity: .7; }
.week-card { margin-bottom: 12px; }
.week-text { font-size: 13.5px; line-height: 1.6; margin: 8px 0 12px; }
.feed-card { max-height: 520px; overflow-y: auto; }
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-today {
  font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 4px;
  border: 1px solid rgba(240, 201, 135, .35); background: rgba(240, 201, 135, .06); color: var(--text);
}
[data-theme="light"] .feed-today { border-color: rgba(138, 106, 47, .4); background: rgba(240, 201, 135, .12); }
.feed-row { display: flex; align-items: baseline; gap: 10px; font-size: 13px; line-height: 1.45; }
.feed-icon { flex-shrink: 0; }
.feed-text { flex: 1; }
.feed-time { flex-shrink: 0; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

/* worlds map */
.map-card { padding: 8px; }
#world-map { display: block; width: 100%; height: auto; border-radius: 12px; }
.map-node { cursor: pointer; transition: transform .15s ease; }
.map-node:hover { transform: scale(1.06); }
.map-node:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.world-detail { margin-top: 14px; }
.world-detail.hidden { display: none; }
.world-detail h3 { font-size: 18px; margin-bottom: 4px; }
.world-facts { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.world-quests { margin: 10px 0 0 18px; display: grid; gap: 6px; font-size: 13px; line-height: 1.45; }
.world-quests li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quest-link { padding: 4px 10px; font-size: 11.5px; white-space: nowrap; }
.quest-card.highlight { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240, 201, 135, .4); }

/* tour */
.tour-overlay { position: fixed; inset: 0; z-index: 80; }
.tour-overlay.hidden { display: none; }
.tour-highlight {
  position: fixed; border-radius: 16px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(8, 10, 22, 0.82), 0 0 0 3px var(--gold);
  transition: all .35s cubic-bezier(.22,1,.36,1);
}
.tour-bubble {
  position: fixed; width: 360px; max-width: calc(100vw - 24px);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 16px;
  padding: 18px 20px; box-shadow: var(--shadow); z-index: 81;
}
.tour-step-count { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.tour-bubble h3 { margin: 6px 0; font-size: 17px; }
.tour-bubble p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.tour-buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.tour-buttons .btn { padding: 8px 14px; font-size: 13px; }

/* ---------- overlay & toast ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 22, .78); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.overlay.hidden, .toast.hidden { display: none; }
.overlay-card {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 22px;
  padding: 44px 52px; text-align: center; box-shadow: var(--shadow);
  animation: pop .45s cubic-bezier(.22,1.4,.36,1);
}
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.overlay-kicker { letter-spacing: 4px; text-transform: uppercase; font-size: 12px; color: var(--muted); }
#levelup-title { font-size: 44px; margin: 8px 0 2px; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.overlay-quote { color: var(--muted); font-size: 13px; margin: 14px 0 22px; font-style: italic; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-edge); color: var(--text);
  border-radius: 12px; padding: 12px 20px; font-size: 14px; box-shadow: var(--shadow); z-index: 60;
}

/* floating xp popups */
.xp-popup {
  position: fixed; z-index: 70; font-weight: 700; font-size: 16px; pointer-events: none;
  animation: rise 1.2s ease forwards; text-shadow: 0 2px 10px rgba(0,0,0,.5);
}
@keyframes rise { from { opacity: 0; transform: translateY(6px);} 15% { opacity: 1; } to { opacity: 0; transform: translateY(-46px);} }

.confetti-bit { position: fixed; width: 8px; height: 8px; z-index: 65; pointer-events: none; animation: fall 1.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(60vh) rotate(300deg); opacity: 0; } }

#footer { margin-top: 40px; color: var(--muted); font-size: 12px; text-align: center; }

/* focus visibility */
button:focus-visible, .tab:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .xp-fill::after, .avatar-float { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* weekly challenges */
.challenge-list { display: grid; gap: 10px; margin-bottom: 8px; }
.challenge-card { display: flex; align-items: center; gap: 14px; }
.challenge-card.claimed { opacity: .65; }
.challenge-card .attr-fill { transition: width .8s cubic-bezier(.22,1,.36,1); }

/* bonding */
.companion-bond { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.companion-bond .bond-btn { padding: 4px 10px; font-size: 11.5px; }

/* living companions — dialogue bubble */
.companion-bubble {
  display: none; position: relative; margin: 8px 0; padding: 10px 12px;
  background: rgba(240, 201, 135, .1); border: 1px solid rgba(240, 201, 135, .35);
  border-radius: 12px; font-size: 12px; font-style: italic; line-height: 1.5; color: var(--text);
}
.companion-bubble.visible { display: block; }
[data-theme="light"] .companion-bubble { background: rgba(240, 201, 135, .18); }
.companion-bubble::before {
  content: ""; position: absolute; top: -6px; left: 18px;
  border: 5px solid transparent; border-bottom-color: rgba(240, 201, 135, .5);
}
.bond-actions { display: flex; gap: 6px; }
.bond-actions .btn { flex: 1; padding: 5px 8px; font-size: 11px; white-space: nowrap; }

/* mobile layout — play from anywhere */
@media (max-width: 700px) {
  #app { padding: 14px 14px 30px; }
  #topbar { flex-wrap: wrap; gap: 10px; }
  .brand-text h1 { font-size: 20px; letter-spacing: 3px; }
  #tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
  .tab { flex-shrink: 0; padding: 8px 14px; font-size: 13px; }
  .sanctum-grid { grid-template-columns: 1fr; }
  .attr-grid { grid-template-columns: repeat(2, 1fr); }
  .worlds { grid-template-columns: repeat(2, 1fr); }
  .forge-grid, .forging-grid { grid-template-columns: 1fr; }
  .quest-card { flex-direction: column; align-items: stretch; }
  .quest-card .seal-btn, .quest-side { width: 100%; }
  .quest-side { flex-direction: row; }
  .challenge-card { flex-direction: column; align-items: stretch; }
  .keep-rooms { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .chronicle-grid { grid-template-columns: 1fr; }
  .map-card { padding: 4px; }
  .overlay-card { padding: 28px 24px; margin: 0 12px; }
  .tour-bubble { width: calc(100vw - 32px); left: 16px !important; right: 16px; }
  .companion-bubble::before { left: 24px; }
}
