/* ============================================================
   KNIGHT'S CREST — STYLES
   Layered medieval chamber · forged-metal HUD · mobile-first
   ============================================================ */

:root {
  --graphite: #101114;
  --steel: #1c1f24;
  --steel-light: #2e3239;
  --steel-edge: #41454d;
  --silver: #c6c8ca;
  --silver-dim: #9a9ea5;
  --gold: #b58a3c;
  --gold-bright: #d9ae5f;
  --cream: #efe6d2;
  --burgundy: #5d2430;
  --font-display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --px: 0;  /* parallax x, set by JS, range -1..1 */
  --py: 0;  /* parallax y */
  --qb-h: 72px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Mirrors the fixed layer-bg base gradient so overscroll and any
     visual-viewport offset of the fixed layers never expose a seam */
  background: linear-gradient(180deg, #16181c 0%, #101114 55%, #0a0b0d 100%) fixed var(--graphite);
  color: var(--cream);
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; overflow-x: hidden; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 200;
  background: var(--gold); color: var(--graphite);
  padding: 10px 16px; border-radius: 6px; font-weight: 700;
  text-decoration: none; transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

/* ============================================================
   WORLD — layered 2.5D chamber
   ============================================================ */
.world {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  perspective: 900px;
}

.layer { position: fixed; inset: 0; pointer-events: none; }

/* Distant stone hall */
.layer-bg {
  z-index: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, #2a2d33 0%, transparent 60%),
    radial-gradient(80% 60% at 15% 105%, rgba(181,138,60,.10) 0%, transparent 55%),
    radial-gradient(80% 60% at 85% 105%, rgba(181,138,60,.10) 0%, transparent 55%),
    linear-gradient(180deg, #16181c 0%, #101114 55%, #0a0b0d 100%);
  transform: translate3d(calc(var(--px) * -6px), calc(var(--py) * -4px), 0);
}
/* faint stone blocks */
.layer-bg::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 140px 70px, 140px 70px;
  mask-image: radial-gradient(90% 80% at 50% 30%, #000 0%, transparent 85%);
  -webkit-mask-image: radial-gradient(90% 80% at 50% 30%, #000 0%, transparent 85%);
}

/* Midground arches + torches */
.layer-mid {
  z-index: 1;
  transform: translate3d(calc(var(--px) * -14px), calc(var(--py) * -9px), 0);
}
.arch {
  position: absolute; bottom: -4%; width: 26vw; max-width: 240px; height: 70vh;
  border: 2px solid rgba(198,200,202,.07);
  border-bottom: none;
  border-radius: 50% 50% 0 0 / 28% 28% 0 0;
  background: linear-gradient(180deg, rgba(46,50,57,.25), transparent 70%);
}
.arch-l { left: -8vw; }
.arch-r { right: -8vw; }

.torch { position: absolute; top: 16%; width: 10px; height: 44px; }
.torch-l { left: 6%; }
.torch-r { right: 6%; }
.torch::before {
  content: ""; position: absolute; inset: 14px 3px 0;
  background: linear-gradient(180deg, #41454d, #23262b);
  border-radius: 2px;
}
.flame {
  position: absolute; top: -2px; left: 50%; width: 14px; height: 18px;
  transform: translateX(-50%);
  background: radial-gradient(50% 60% at 50% 70%, #d9ae5f 0%, rgba(181,138,60,.55) 55%, transparent 100%);
  border-radius: 50% 50% 45% 45%;
  filter: blur(1px);
  animation: flicker 2.8s ease-in-out infinite;
}
.torch::after {
  content: ""; position: absolute; top: -30px; left: 50%; width: 130px; height: 130px;
  transform: translate(-50%, -20%);
  background: radial-gradient(50% 50% at 50% 50%, rgba(217,174,95,.13) 0%, transparent 70%);
  pointer-events: none;
}
@keyframes flicker {
  0%, 100% { opacity: .85; transform: translateX(-50%) scale(1); }
  30% { opacity: 1; transform: translateX(-52%) scale(1.08, 1.14); }
  60% { opacity: .75; transform: translateX(-48%) scale(.94, .9); }
}

.particles { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

/* ============================================================
   SCENE CONTENT
   ============================================================ */
.scene {
  position: relative; z-index: 3;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px) clamp(14px, 4vw, 28px) calc(var(--qb-h) + 28px);
  display: flex; flex-direction: column; align-items: center;
}

/* ---------- Identity ---------- */
.identity { text-align: center; margin-top: 8px; }

.crest-wrap {
  background: none; border: none; padding: 0; cursor: pointer;
  border-radius: 18px;
  -webkit-tap-highlight-color: transparent;
  transition: transform .25s ease;
}
.crest-wrap:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 6px; }

/* Discovery affordance: restrained hover lift (hover-capable devices only) */
@media (hover: hover) {
  .crest-wrap:hover { transform: translateY(-2px); }
  .crest-wrap:hover .crest { filter: drop-shadow(0 18px 32px rgba(0,0,0,.6)) brightness(1.04); }
}
/* Touch/press compression */
.crest-wrap:active { transform: translateY(0) scale(.985); }

/* Occasional idle lift (scheduled by JS until first activation) */
.crest-wrap.crest-hint-lift { animation: crest-lift 1.05s ease; }
@keyframes crest-lift {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-2px) scale(1.012); }
}

.crest {
  width: clamp(190px, 52vw, 250px);
  display: block;
  filter: drop-shadow(0 14px 28px rgba(0,0,0,.55));
  transform:
    rotateY(calc(var(--px) * 2deg))
    rotateX(calc(var(--py) * -1.5deg));
  transition: transform .18s ease-out, filter .25s ease;
  animation: crest-idle 7s ease-in-out infinite;
}
@keyframes crest-idle {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}
.crest.crest-tapped { animation: crest-knock .45s ease; }
@keyframes crest-knock {
  0% { rotate: 0deg; } 30% { rotate: -2.4deg; } 65% { rotate: 1.6deg; } 100% { rotate: 0deg; }
}

.crest-initials {
  font-family: var(--font-display);
  font-size: 54px; font-weight: 700; letter-spacing: 2px;
  fill: var(--cream);
}
.crest-motto { font-family: var(--font-ui); font-size: 11px; letter-spacing: 1.6px; fill: var(--cream); }
.seal-text { font-family: var(--font-display); font-size: 30px; fill: var(--cream); letter-spacing: 1px; }

.crest-sweep.sweep-run {
  opacity: 1;
  stroke-dasharray: 90 640;
  stroke-dashoffset: 730;
  animation: sweep 1.1s ease-out forwards;
}
@keyframes sweep { to { stroke-dashoffset: 0; opacity: 0; } }

/* Discovery glint: a narrow, low-opacity light pass along the forged
   inner edge — like light briefly catching metal. ~800 ms, no flash. */
.crest-glint.glint-run {
  opacity: .35;
  stroke-dasharray: 60 670;
  stroke-dashoffset: 730;
  animation: glint .85s ease-in-out forwards;
}
@keyframes glint { to { stroke-dashoffset: 210; opacity: 0; } }

.name {
  font-family: var(--font-display);
  font-size: clamp(30px, 8vw, 42px);
  letter-spacing: 3px; text-transform: uppercase;
  margin: 14px 0 2px;
  color: var(--silver);
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
.sword-divider {
  display: block;
  width: clamp(200px, 58vw, 300px);
  margin: 6px auto 8px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}
.diamond-divider {
  display: block;
  width: clamp(120px, 34vw, 170px);
  margin: 10px auto 0;
}
.title {
  margin: 0;
  font-size: clamp(14px, 3.6vw, 17px);
  letter-spacing: 4px; text-transform: uppercase;
  color: var(--gold-bright);
}
.renown-plaque {
  display: inline-block;
  margin: 12px 0 0;
  padding: 6px 16px;
  font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--silver);
  background: linear-gradient(180deg, #2e3239, #1c1f24);
  border: 1px solid var(--steel-edge);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.renown-plaque b { color: var(--gold-bright); font-weight: 700; }

/* ---------- Interactive objects ---------- */
.objects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
  margin-top: clamp(22px, 5vw, 36px);
}

.obj {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: 16px 10px 14px;
  min-height: 132px;
  background:
    linear-gradient(180deg, rgba(46,50,57,.6), rgba(22,24,28,.85));
  border: 1px solid var(--steel-edge);
  border-radius: 14px;
  color: var(--cream);
  font-family: var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.obj:hover, .obj:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 10px 22px rgba(0,0,0,.45), 0 0 0 1px rgba(181,138,60,.35), inset 0 1px 0 rgba(255,255,255,.07);
  transform: translateY(-3px);
}
.obj:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
.obj:active { transform: translateY(1px) scale(.98); }

.obj-art { width: 62px; height: 62px; }
.obj-art svg { width: 100%; height: 100%; }
.obj-name {
  font-family: var(--font-display);
  font-size: 17px; letter-spacing: 1px; color: var(--silver);
}
.obj-action { font-size: 13px; color: var(--gold-bright); letter-spacing: .4px; }

/* object reaction animations */
.obj.fx-raven .raven { animation: raven-flap .6s ease; transform-origin: 50% 60%; }
@keyframes raven-flap {
  0% { transform: rotate(0); } 25% { transform: rotate(-7deg) translateY(-2px); }
  55% { transform: rotate(4deg); } 100% { transform: rotate(0); }
}
.obj.fx-raven .raven-wing { animation: wing .6s ease; transform-origin: 40% 60%; }
@keyframes wing { 30% { transform: rotate(-16deg); } 60% { transform: rotate(8deg); } }

.obj.fx-scroll .scrollg { animation: unroll .7s ease; transform-origin: 50% 50%; }
@keyframes unroll { 0% { transform: scaleY(.55); } 60% { transform: scaleY(1.08); } 100% { transform: scaleY(1); } }
.obj.fx-scroll .seal { animation: seal-stamp .5s ease .45s forwards; }
@keyframes seal-stamp { 0% { opacity: 0; transform: scale(2.2); } 70% { opacity: 1; transform: scale(.9); } 100% { opacity: 1; transform: scale(1); } }

.obj.fx-sword .swordg { animation: sword-flash .55s ease; transform-origin: 50% 80%; }
@keyframes sword-flash {
  0% { transform: rotate(0) translateY(0); }
  35% { transform: rotate(-14deg) translateY(-4px); }
  65% { transform: rotate(10deg) translateY(-2px); }
  100% { transform: rotate(0) translateY(0); }
}

.obj.fx-gate .gate-bars { animation: gate-rise .4s ease; }
@keyframes gate-rise { 40% { transform: translateY(-5px); } 100% { transform: translateY(0); } }

.obj.fx-chest .chest-lid { animation: lid-open .6s ease; transform-origin: 12px 30px; }
@keyframes lid-open { 40% { transform: rotate(-14deg); } 100% { transform: rotate(0); } }
.obj.fx-chest .chest-glow { animation: glow-pop .6s ease; }
@keyframes glow-pop { 30% { opacity: 1; } 100% { opacity: 0; } }

.obj.fx-anvil .anvil-body { animation: anvil-jolt .35s ease; }
@keyframes anvil-jolt {
  0% { transform: translateY(0); } 25% { transform: translateY(2px); }
  60% { transform: translateY(-1px); } 100% { transform: translateY(0); }
}
.obj.fx-anvil .anvil-glow { animation: glow-pop .55s ease; }
.obj.fx-anvil .spark { animation: spark-fly .5s ease-out; }
.obj.fx-anvil .spark.s2 { animation-delay: .04s; }
.obj.fx-anvil .spark.s3 { animation-delay: .08s; }
@keyframes spark-fly {
  0% { opacity: 0; transform: translate(0, 0); }
  15% { opacity: .9; }
  100% { opacity: 0; transform: translate(-3px, -12px); }
}
.obj.fx-anvil .spark.s2 { --sx: 1px; }
@keyframes spark-fly-2 { 0% { opacity: 0; } 15% { opacity: .9; } 100% { opacity: 0; transform: translate(2px, -14px); } }
.obj.fx-anvil .spark.s2 { animation-name: spark-fly-2; }
@keyframes spark-fly-3 { 0% { opacity: 0; } 15% { opacity: .9; } 100% { opacity: 0; transform: translate(6px, -11px); } }
.obj.fx-anvil .spark.s3 { animation-name: spark-fly-3; }

/* ---------- Deeds of Renown (collapsible) ---------- */
.achievements { width: 100%; margin-top: clamp(26px, 6vw, 40px); text-align: center; }
.sec-heading {
  font-family: var(--font-display);
  font-size: 15px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--silver-dim);
  margin: 0 0 12px;
}

.deeds-toggle {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 4px 12px;
  width: 100%;
  padding: 13px 16px;
  background: linear-gradient(180deg, rgba(46,50,57,.55), rgba(22,24,28,.85));
  border: 1px solid var(--steel-edge);
  border-radius: 14px;
  color: var(--cream);
  cursor: pointer;
  font-family: var(--font-ui);
}
.deeds-toggle:hover { border-color: var(--gold); }
.deeds-toggle:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.deeds-title {
  font-family: var(--font-display);
  font-size: 15px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--silver-dim);
}
.deeds-summary { font-size: 13.5px; color: var(--gold-bright); letter-spacing: .4px; }
.deeds-caret {
  width: 16px; height: 16px; color: var(--silver-dim);
  transition: transform .2s ease;
}
.deeds-toggle[aria-expanded="true"] .deeds-caret { transform: rotate(180deg); }

.deeds-body { padding-top: 14px; animation: fade-in .2s ease; }
.deeds-progress { margin: 0 0 12px; font-size: 13px; color: var(--silver-dim); letter-spacing: .4px; }
.deeds-filter { margin-top: 14px; font-size: 13px; padding: 8px 18px; }
.deeds-filter[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-bright); }

.renown-note { margin: 14px auto 0; max-width: 420px; text-align: left; }
.renown-note summary {
  cursor: pointer; font-size: 12.5px; color: var(--silver-dim);
  letter-spacing: .5px; text-align: center; list-style-position: inside;
}
.renown-note summary:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; border-radius: 4px; }
.renown-note p { font-size: 12.5px; color: var(--silver-dim); line-height: 1.6; margin: 8px 0 0; text-align: center; }

/* ---------- Tier identity (color is never the only indicator —
   tier names appear on tabs and in card aria-labels) ---------- */
:root {
  --tier-bronze: #b0773f;
  --tier-silver: #c6c8ca;
  --tier-gold: #d9ae5f;
  --tier-platinum: #e4e8eb;
  --tier-diamond: #b8d8e8;
  --tier-knight: #cfd3d8;
  --tier-king: #e6c15c;
}

/* Collapsed-summary rank progress bar */
.deeds-summary { display: block; width: 100%; }
.deeds-count { display: block; width: 100%; font-size: 12.5px; color: var(--silver-dim); }
.deeds-rankbar {
  display: block; width: min(100%, 260px); height: 4px;
  margin-top: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 2px; overflow: hidden;
}
.deeds-rankbar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  border-radius: 2px;
  transition: width .4s ease;
}
.deeds-toggle { flex-direction: column; gap: 3px; position: relative; }
.deeds-toggle .deeds-caret { position: absolute; right: 14px; top: 16px; }

/* ---------- Rank tabs ---------- */
.rank-tabs {
  display: flex; gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin-bottom: 8px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.rank-tab {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--steel-edge);
  border-radius: 999px;
  color: var(--silver-dim);
  font-size: 12.5px; letter-spacing: .5px;
  cursor: pointer;
  white-space: nowrap;
}
.rank-tab .tier-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--tier-c, var(--gold));
  box-shadow: 0 0 0 1px rgba(0,0,0,.4) inset;
}
.rank-tab[aria-selected="true"] {
  color: var(--cream);
  border-color: var(--tier-c, var(--gold));
  background: rgba(255,255,255,.07);
}
.rank-tab:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.rank-tab .tab-current {
  font-size: 10px; color: var(--gold-bright); letter-spacing: .8px; text-transform: uppercase;
}

/* ---------- Filter bar ---------- */
.deeds-filterbar {
  display: flex; justify-content: center; gap: 6px;
  margin-bottom: 12px;
}
.filter-btn {
  padding: 6px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--steel-edge);
  border-radius: 999px;
  color: var(--silver-dim);
  font-size: 12.5px; cursor: pointer;
}
.filter-btn[aria-pressed="true"] {
  color: var(--gold-bright); border-color: var(--gold);
  background: rgba(181,138,60,.1);
}
.filter-btn:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }

/* ---------- Deed cards ---------- */
.badges { flex-direction: column; align-items: stretch; gap: 8px; }
.deed {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(46,50,57,.45), rgba(22,24,28,.85));
  border: 1px solid var(--steel-edge);
  border-left: 3px solid var(--tier-c, var(--steel-edge));
  border-radius: 12px;
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
  font-family: var(--font-ui);
}
.deed:hover { border-color: var(--tier-c, var(--gold)); border-left-width: 3px; }
.deed:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.deed.badge-pop { animation: badge-pop .5s ease; }
.deed.deed-locked { opacity: .55; filter: saturate(.6); }
.deed-emblem { flex: 0 0 auto; width: 34px; height: 40px; margin-top: 2px; }
.deed-emblem svg { width: 100%; height: 100%; }
.deed-main { flex: 1 1 auto; min-width: 0; }
.deed-main b {
  display: block;
  font-family: var(--font-display);
  font-size: 14.5px; letter-spacing: .6px;
  color: var(--cream);
  overflow-wrap: break-word;
}
.deed.deed-locked .deed-main b { color: var(--silver-dim); }
.deed-main .deed-desc {
  display: block; font-size: 12.5px; color: var(--silver-dim);
  line-height: 1.45; margin-top: 1px;
}
.deed-meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  margin-top: 6px;
  font-size: 11.5px; color: var(--silver-dim); letter-spacing: .3px;
}
.deed-meta .deed-reward { color: var(--gold-bright); }
.deed-meta .deed-tier { text-transform: capitalize; color: var(--tier-c, var(--silver-dim)); }
.deed-bar {
  width: 100%; height: 3px; margin-top: 7px;
  background: rgba(255,255,255,.08);
  border-radius: 2px; overflow: hidden;
}
.deed-bar i {
  display: block; height: 100%;
  background: var(--tier-c, var(--gold));
  border-radius: 2px;
}
.deeds-empty { font-size: 13px; color: var(--silver-dim); padding: 14px 0; }

/* "+N Renown" — restrained forged-metal chip that drifts up and fades
   when the database awards points. Decorative only (aria-hidden). */
.renown-float {
  position: fixed; z-index: 125;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: linear-gradient(180deg, #2e3239, #1a1c21);
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 13px; letter-spacing: 1px;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
  animation: renown-drift 1.6s ease-out forwards;
}
@keyframes renown-drift {
  0% { opacity: 0; translate: 0 6px; }
  18% { opacity: 1; translate: 0 0; }
  75% { opacity: 1; translate: 0 -16px; }
  100% { opacity: 0; translate: 0 -24px; }
}
@media (prefers-reduced-motion: reduce) {
  .renown-float { animation: renown-fade 1.4s ease forwards; }
  @keyframes renown-fade { 0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
}

/* ---------- Rank-up ceremony overlay ---------- */
.rankup {
  position: fixed; inset: 0; z-index: 140;
  display: flex; align-items: center; justify-content: center;
}
/* display:flex would otherwise defeat the hidden attribute */
.rankup[hidden] { display: none; }
.rankup {
  background: rgba(8, 9, 11, .78);
  backdrop-filter: blur(4px);
  animation: fade-in .25s ease;
  padding: 20px;
}
.rankup-card {
  box-sizing: border-box;
  width: min(92vw, 380px);
  padding: clamp(20px, 5vw, 30px);
  text-align: center;
  background: linear-gradient(180deg, #2e3239 0%, #16181c 60%, #101114 100%);
  border: 1px solid var(--tier-c, var(--gold));
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.7), 0 0 40px -18px var(--tier-c, var(--gold));
  animation: rankup-in .5s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes rankup-in {
  from { transform: translateY(22px) scale(.94); opacity: 0; }
}
.ru-kicker {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 13px; letter-spacing: 4px; text-transform: uppercase;
  color: var(--silver-dim);
}
.ru-badges {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 12px;
}
.ru-badge { width: 56px; height: 66px; display: inline-block; }
.ru-badge-old { opacity: .45; transform: scale(.82); }
.ru-badge-new { animation: badge-reveal .7s ease .15s backwards; }
@keyframes badge-reveal {
  from { transform: scale(.5) rotate(-6deg); opacity: 0; }
}
.ru-badge svg { width: 100%; height: 100%; }
.ru-arrow { color: var(--silver-dim); font-size: 18px; }
.ru-names {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 21px; letter-spacing: 1px;
  color: var(--cream);
}
.ru-names .ru-new-name { color: var(--tier-c, var(--gold-bright)); }
.ru-msg {
  margin: 0 0 18px;
  font-size: 14px; font-style: italic; line-height: 1.5;
  color: var(--silver-dim);
}
.ru-close { margin-top: 0; }
/* King gets the most ceremonial (still tasteful) treatment */
.rankup-card.t-king .ru-kicker { color: var(--tier-king); }
.rankup-card.t-king .ru-names { letter-spacing: 2px; text-transform: uppercase; font-size: 19px; }
.badges {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
}
.badge {
  position: relative;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, rgba(181,138,60,.16), rgba(22,24,28,.9));
  color: var(--cream);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 118px;
  transition: transform .18s ease;
}
.badge b { font-family: var(--font-display); letter-spacing: .8px; font-size: 13.5px; color: var(--gold-bright); }
.badge span { color: var(--silver-dim); font-size: 12.5px; }
.badge:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.badge.badge-locked {
  border-color: var(--steel-edge); opacity: .45; filter: grayscale(.6);
}
.badge.badge-pop { animation: badge-pop .5s ease; }
@keyframes badge-pop { 35% { transform: translateY(-6px) rotate(-2deg) scale(1.05); } 100% { transform: none; } }

.colophon { margin: 34px 0 8px; font-size: 12.5px; color: var(--silver-dim); letter-spacing: .5px; text-align: center; line-height: 1.7; }
.colophon-sub { font-size: 11.5px; opacity: .75; font-style: italic; }

/* ---------- Abilities panel ---------- */
.ab-sub {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 13px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--silver-dim);
}
.ability-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.ability {
  border: 1px solid var(--steel-edge);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  overflow: hidden;
}
.ability-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: none; border: none;
  color: var(--cream);
  font-family: var(--font-ui); font-size: 14.5px; text-align: left;
  cursor: pointer;
}
.ability-head:hover { color: var(--gold-bright); }
.ability-head:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: -3px; border-radius: 10px; }
.ability-head .ability-caret {
  width: 14px; height: 14px; flex: none;
  color: var(--silver-dim);
  transition: transform .2s ease;
}
.ability-head[aria-expanded="true"] { color: var(--gold-bright); }
.ability-head[aria-expanded="true"] .ability-caret { transform: rotate(180deg); }
.ability-desc {
  margin: 0; padding: 0 14px 12px;
  font-size: 13.5px; line-height: 1.55; color: var(--silver-dim);
  animation: fade-in .18s ease;
}
.ab-secondary { display: block; text-align: center; text-decoration: none; margin-top: 10px; }

/* ============================================================
   SCENE CONTROLS (sound / ambience)
   ============================================================ */
.scene-controls {
  position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; z-index: 60;
  display: flex; gap: 8px;
}
.ctl {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 52px; padding: 7px 9px 5px;
  background: rgba(22, 24, 28, .82);
  border: 1px solid var(--steel-edge);
  border-radius: 10px;
  color: var(--silver-dim);
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.ctl svg { width: 21px; height: 21px; }
.ctl-label { font-size: 10.5px; letter-spacing: .6px; }
.ctl[aria-pressed="true"] { color: var(--gold-bright); border-color: var(--gold); }
.ctl[aria-pressed="true"] .spk-mute { display: none; }
.ctl[aria-pressed="false"] .spk-wave { display: none; }
.ctl:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }

/* ============================================================
   QUICK ACTION BAR — forged-metal HUD
   ============================================================ */
.quickbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  padding: 8px max(10px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #23262b 0%, #14161a 100%);
  border-top: 1px solid var(--steel-edge);
  box-shadow: 0 -8px 24px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05);
}
.qb {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px 5px;
  background: none; border: none; border-radius: 10px;
  color: var(--cream); font-family: var(--font-ui);
  font-size: 12px; letter-spacing: .3px;
  text-decoration: none; cursor: pointer;
  transition: background .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.qb svg { width: 23px; height: 23px; color: var(--gold-bright); }
.qb:hover { background: rgba(181,138,60,.12); }
.qb:active { transform: scale(.94); }
.qb:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: -2px; }

/* ============================================================
   PANELS
   ============================================================ */
.backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 9, 11, .68);
  backdrop-filter: blur(3px);
  animation: fade-in .18s ease;
}
@keyframes fade-in { from { opacity: 0; } }

.panel {
  position: fixed; z-index: 90;
  left: 50%; bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  box-sizing: border-box;
  width: min(92vw, 520px);
  max-width: 100%;
  max-height: min(84dvh, 660px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background:
    linear-gradient(180deg, #2e3239 0%, #1a1c21 14%, #16181c 100%);
  border: 1px solid var(--steel-edge);
  border-radius: 18px;
  box-shadow: 0 -14px 40px rgba(0,0,0,.6);
  animation: panel-up .24s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes panel-up { from { transform: translate(-50%, 40px); opacity: 0; } }

/* Page behind a panel must not scroll (JS adds .panel-open) */
body.panel-open { overflow: hidden; }

.panel-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: clamp(13px, 3.5vw, 16px) clamp(14px, 4vw, 18px) 12px;
  background: linear-gradient(180deg, #2e3239, #22252a);
  border-bottom: 1px solid rgba(181,138,60,.35);
}
.panel-head h2 {
  margin: 0;
  min-width: 0;                 /* allow the title to wrap, never clip */
  flex: 1 1 auto;
  font-family: var(--font-display);
  font-size: clamp(17px, 4.6vw, 20px);
  line-height: 1.25;
  letter-spacing: clamp(.4px, .3vw, 1.5px);
  overflow-wrap: break-word;
  color: var(--gold-bright);
}
.panel-close {
  flex: 0 0 auto;               /* never overlapped by the title */
  background: rgba(255,255,255,.06);
  border: 1px solid var(--steel-edge);
  color: var(--silver);
  width: 38px; height: 38px; border-radius: 10px;
  font-size: 16px; cursor: pointer;
}
.panel-close:hover { border-color: var(--gold); color: var(--gold-bright); }
.panel-close:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }

.panel-body {
  padding: clamp(14px, 4vw, 18px) clamp(14px, 4vw, 18px)
           calc(clamp(16px, 4vw, 20px) + env(safe-area-inset-bottom));
}
.panel-body > * { max-width: 100%; }

.panel-link {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--steel-edge);
  border-radius: 12px;
  color: var(--cream);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.panel-link:hover, .panel-link:focus-visible { border-color: var(--gold); background: rgba(181,138,60,.08); }
.panel-link:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.panel-link strong { color: var(--gold-bright); font-weight: 600; letter-spacing: .3px; }
.panel-link span { color: var(--silver-dim); font-size: 13.5px; }
.panel-link.as-btn { font: inherit; }

.pp-subtitle { margin: 0 0 6px; color: var(--silver); font-size: 13.5px; letter-spacing: 2.5px; text-transform: uppercase; }
.pp-rank { margin: 0 0 10px; color: var(--gold-bright); font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }
.pp-bio { margin: 0 0 14px; line-height: 1.55; color: var(--cream); font-size: 15px; }
.pp-sub {
  font-family: var(--font-display);
  font-size: 13px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--silver-dim); margin: 16px 0 8px;
}
.pp-services { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.pp-services li {
  padding: 6px 12px; font-size: 13.5px;
  border: 1px solid var(--steel-edge); border-radius: 999px;
  color: var(--silver); background: rgba(255,255,255,.03);
}
.pp-social { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-social a {
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--steel-edge);
  color: var(--cream); text-decoration: none; font-size: 14px;
  background: rgba(255,255,255,.04);
}
.pp-social a:hover, .pp-social a:focus-visible { border-color: var(--gold); }
.pp-extra { margin-top: 14px; }

.btn-gold {
  display: block; width: 100%;
  margin-top: 16px; padding: 14px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #17130a; font-weight: 700; font-size: 15px; letter-spacing: .5px;
  border: none; border-radius: 12px;
  text-align: center; text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(181,138,60,.3), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-gold:active { transform: translateY(1px); }
.btn-gold:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }

.btn-ghost {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--steel-edge);
  color: var(--cream);
  padding: 10px 22px; border-radius: 10px;
  font-size: 14px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--gold); }
.btn-ghost:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }

/* ============================================================
   INTRO
   ============================================================ */
.intro {
  position: fixed; inset: 0; z-index: 150;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(110% 90% at 50% 20%, #1c1f24 0%, #0a0b0d 75%);
  opacity: 1;
  transition: opacity .35s ease;
}
.intro.intro-done { opacity: 0; pointer-events: none; }
.intro[hidden] { display: none; }

.intro-stage { position: relative; display: flex; flex-direction: column; align-items: center; }
.intro-sword {
  width: 34px; height: 190px;
  opacity: 0;
  animation: intro-sword .7s ease-out .1s forwards;
}
.i-blade { fill: var(--silver); }
.i-gold { fill: var(--gold); }
.i-grip { fill: #4a3722; }
@keyframes intro-sword {
  from { opacity: 0; transform: translateY(-36px); }
  to { opacity: 1; transform: translateY(0); }
}
.intro-ring {
  position: absolute; top: 46%; left: 50%;
  width: 150px; height: 150px;
  transform: translate(-50%, -50%) scale(.6);
  border: 2px solid var(--gold);
  border-radius: 50%;
  opacity: 0;
  animation: intro-ring .6s ease-out .55s forwards;
}
@keyframes intro-ring {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  to { opacity: .8; transform: translate(-50%, -50%) scale(1); }
}
.intro-name {
  margin: 26px 0 0;
  font-family: var(--font-display);
  font-size: 22px; letter-spacing: 5px; text-transform: uppercase;
  color: var(--silver);
  opacity: 0;
  animation: intro-name .5s ease .85s forwards;
}
@keyframes intro-name { to { opacity: 1; } }

.intro-controls {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.intro-pref { font-size: 13px; color: var(--silver-dim); display: flex; align-items: center; gap: 7px; cursor: pointer; }
.intro-pref input { accent-color: var(--gold); width: 16px; height: 16px; }

/* ============================================================
   FEEDBACK — wax seal + toast
   ============================================================ */
.seal-fx {
  position: fixed; z-index: 120;
  left: 50%; top: 42%;
  width: 110px; height: 110px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.5));
}
.seal-fx.seal-run { animation: seal-slam .9s cubic-bezier(.2, .9, .3, 1.15) forwards; }
@keyframes seal-slam {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.4) rotate(-14deg); }
  40% { opacity: 1; transform: translate(-50%, -50%) scale(.92) rotate(2deg); }
  55% { transform: translate(-50%, -50%) scale(1.02) rotate(0); }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

.toast {
  position: fixed; z-index: 130;
  left: 50%; bottom: calc(var(--qb-h) + 18px);
  transform: translateX(-50%) translateY(16px);
  max-width: min(92vw, 420px);
  padding: 12px 20px;
  background: linear-gradient(180deg, #2e3239, #1a1c21);
  border: 1px solid var(--gold);
  border-radius: 12px;
  color: var(--cream);
  font-size: 14.5px; text-align: center; letter-spacing: .3px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- noscript ---------- */
.noscript {
  position: relative; z-index: 160;
  margin: 16px; padding: 18px;
  background: #1c1f24; border: 1px solid var(--gold); border-radius: 12px;
  text-align: center; line-height: 1.7;
}
.noscript a { color: var(--gold-bright); }

/* ============================================================
   WIDER SCREENS
   ============================================================ */
@media (min-width: 700px) {
  /* six objects → balanced 3×2 composition */
  .objects { grid-template-columns: repeat(3, 1fr); }
  .quickbar {
    left: 50%; right: auto; bottom: 14px;
    transform: translateX(-50%);
    width: 520px;
    border: 1px solid var(--steel-edge);
    border-radius: 16px;
    padding: 8px 10px;
  }
  .panel {
    bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 18px; border-bottom: 1px solid var(--steel-edge);
  }
  @keyframes panel-up { from { transform: translate(-50%, calc(-50% + 26px)); opacity: 0; } }
}

/* ============================================================
   REDUCED MOTION — short fades only, all function intact
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .1s !important;
  }
  .crest { animation: none; transform: none; }
  .layer-bg, .layer-mid { transform: none; }
  .flame { animation: none; opacity: .85; }
  .particles { display: none; }
}
body.reduced-motion .crest { animation: none; transform: none; }
body.reduced-motion .layer-bg,
body.reduced-motion .layer-mid { transform: none; }
body.reduced-motion .particles { display: none; }
/* Static actionable affordance for the crest when motion is off:
   a slightly stronger gold-tinged shadow instead of shimmer/lift */
body.reduced-motion .crest,
.reduced-motion-static .crest {
  filter: drop-shadow(0 14px 28px rgba(0,0,0,.55)) drop-shadow(0 0 12px rgba(181,138,60,.22));
}
@media (prefers-reduced-motion: reduce) {
  .crest { filter: drop-shadow(0 14px 28px rgba(0,0,0,.55)) drop-shadow(0 0 12px rgba(181,138,60,.22)); }
  .crest-wrap.crest-hint-lift { animation: none; }
  .crest-glint.glint-run { animation: none; opacity: 0; }
}
