/*
 * Golden Temple v6 enhancement layer.
 * The selectors intentionally outrank the embedded legacy stylesheet.
 */
html:root {
  color-scheme: dark;
  --bg: #070706;
  --surface: rgba(20, 18, 12, 0.78);
  --solid: rgba(29, 25, 15, 0.9);
  --sep: rgba(244, 205, 105, 0.2);
  --label: #fff8dd;
  --label2: #e9debd;
  --sec: #c7b98f;
  --ter: #827657;
  --tint: #f0c95d;
  --yellow: #ffd86b;
  --r: 22px;
  --blur: blur(24px) saturate(140%);
}

html body {
  background:
    radial-gradient(900px 680px at 50% -10%, rgba(244, 196, 73, 0.13), transparent 64%),
    radial-gradient(720px 620px at 4% 76%, rgba(115, 79, 190, 0.11), transparent 68%),
    radial-gradient(680px 560px at 96% 86%, rgba(18, 132, 126, 0.1), transparent 66%),
    #070706;
  color: var(--label);
}

html body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(255, 219, 124, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 219, 124, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0, transparent 72%);
  mask-image: radial-gradient(circle at 50% 30%, #000 0, transparent 72%);
}

body header.hero .eyebrow,
body header.hero .formula,
body .cap,
body .note,
body .mini .tag,
body .kv span,
body .facet .fh,
body .facet .fs,
body .stat .lab,
body footer {
  color: var(--sec);
}

body header.hero .sub,
body .mini p,
body .rule p,
body .bardo ol,
body .flow p,
body .bpm .st {
  color: var(--label2);
}

body header.hero h1 .grad {
  background: linear-gradient(100deg, #fff9e6 0%, #f4cd68 43%, #fff1b2 70%, #c99436 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body nav.tabs,
body .card,
body .mini,
body .stat,
body .log,
body .facet,
body .flow,
body .bardo,
body .deck {
  background: linear-gradient(145deg, rgba(35, 31, 20, 0.86), rgba(13, 12, 9, 0.76));
  border-color: rgba(244, 205, 105, 0.2);
  box-shadow:
    inset 0 1px rgba(255, 247, 213, 0.055),
    0 20px 54px rgba(0, 0, 0, 0.24);
}

body nav.tabs button {
  color: var(--label2);
}

body nav.tabs button.on {
  color: #1a1408;
  background: linear-gradient(135deg, #fff1b2, #d9a93e);
  box-shadow: 0 7px 22px rgba(230, 181, 67, 0.2);
}

body .btn.pri {
  color: #1a1408;
  background: linear-gradient(135deg, #fff0a8, #c8902e);
  box-shadow: 0 7px 22px rgba(230, 181, 67, 0.24);
}

body .btn.ghost,
body .die {
  color: var(--label);
  background: rgba(255, 249, 224, 0.07);
  border-color: var(--sep);
}

body .sheet {
  color: var(--label);
  background:
    radial-gradient(560px 260px at 50% 0, rgba(232, 187, 70, 0.12), transparent),
    rgba(10, 9, 7, 0.965);
  border: 1px solid rgba(244, 205, 105, 0.24);
  border-bottom: 0;
  box-shadow: 0 -24px 80px rgba(0, 0, 0, 0.68);
}

body .grab {
  background: linear-gradient(90deg, transparent, #d8b45a, transparent);
}

body .overlay {
  background: rgba(0, 0, 0, 0.76);
}

body svg text {
  paint-order: stroke;
  stroke: rgba(8, 7, 5, 0.55);
  stroke-width: 0.45px;
}

/* Compact state toolbar */
.v6-toolbar {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 82;
  width: min(680px, calc(100vw - 20px));
  color: #fff8dd;
  border: 1px solid rgba(247, 211, 117, 0.34);
  border-radius: 17px;
  background: rgba(12, 11, 8, 0.86);
  box-shadow: 0 16px 52px rgba(0, 0, 0, 0.5), inset 0 1px rgba(255, 245, 207, 0.08);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  backdrop-filter: blur(22px) saturate(130%);
}

.v6-toolbar__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px;
}

.v6-toolbar__age {
  display: flex;
  flex: 1 1 180px;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.v6-toolbar label {
  flex: 0 0 auto;
  color: #d9c996;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.v6-toolbar input[type="number"] {
  width: 64px;
  min-height: 34px;
  color: #fff8dd;
  border: 1px solid rgba(247, 211, 117, 0.28);
  border-radius: 10px;
  outline: 0;
  background: rgba(255, 248, 218, 0.075);
  font: 700 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.v6-toolbar button,
.v6-toolbar__import-label {
  display: inline-flex;
  min-width: 34px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  color: #f6e8ba;
  border: 1px solid rgba(247, 211, 117, 0.2);
  border-radius: 10px;
  background: rgba(255, 248, 218, 0.075);
  font: 750 11px/1 system-ui, sans-serif;
  cursor: pointer;
}

.v6-toolbar button[data-v6="age-go"] {
  color: #1a1408;
  border-color: #e8bc50;
  background: linear-gradient(135deg, #ffe797, #c68c27);
}

.v6-toolbar__range {
  min-width: 70px;
  color: #aa9c73;
  font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.v6-toolbar__tools {
  display: flex;
  gap: 5px;
}

.v6-toolbar__status {
  position: absolute;
  right: 8px;
  bottom: calc(100% + 7px);
  max-width: min(360px, calc(100vw - 30px));
  padding: 7px 10px;
  color: #fff3c7;
  border: 1px solid rgba(247, 211, 117, 0.24);
  border-radius: 10px;
  background: rgba(10, 9, 6, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: 0.2s ease;
}

.v6-toolbar__status.is-visible {
  opacity: 1;
  transform: none;
}

/* Cell focus and resonance */
body .scell,
body .cell,
body .fcell,
body .ofield,
body .tfield {
  outline: none;
}

body .ofield,
body .tfield {
  cursor: pointer;
}

body .scell:focus-visible,
body .cell:focus-visible,
body .fcell:focus-visible,
body .ofield:focus-visible,
body .tfield:focus-visible,
body button:focus-visible,
body input:focus-visible,
body .v6-toolbar__import-label:focus-visible {
  outline: 3px solid #ffe58c;
  outline-offset: 3px;
}

body.v6-focus-mode .scell,
body.v6-focus-mode .cell,
body.v6-focus-mode .fcell,
body.v6-focus-mode .ofield,
body.v6-focus-mode .tfield {
  opacity: 0.1;
  filter: saturate(0.28);
  transition: opacity 0.24s ease, filter 0.24s ease;
}

body.v6-focus-mode #starSvg > :not(.scell):not(.ofield):not(.tfield):not(.source-node),
body.v6-focus-mode #flowerSvg > :not(.fcell) {
  opacity: 0.035;
  transition: opacity 0.24s ease;
}

body.v6-focus-mode .scell.v6-resonant,
body.v6-focus-mode .cell.v6-resonant,
body.v6-focus-mode .fcell.v6-resonant,
body.v6-focus-mode .ofield.v6-resonant,
body.v6-focus-mode .tfield.v6-resonant {
  opacity: 1;
  filter: saturate(1.18) drop-shadow(0 0 8px rgba(255, 221, 123, 0.9));
}

body.v6-focus-mode .scell.v6-resonant > circle,
body.v6-focus-mode .fcell.v6-resonant,
body.v6-focus-mode .ofield.v6-resonant,
body.v6-focus-mode .tfield.v6-resonant {
  stroke: #fff1a6;
  stroke-width: 3px;
}

/* Optional, explicitly non-canonical afterlife route tracker */
.v6-bardo-route {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(244, 205, 105, 0.18);
}

.v6-bardo-route__head,
.v6-bardo-route__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.v6-bardo-route__head b {
  color: #f0d47d;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.v6-bardo-route__head span {
  color: #c6b98e;
  font: 650 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
}

.v6-bardo-route progress {
  display: block;
  width: 100%;
  height: 7px;
  margin: 8px 0 9px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: rgba(255, 247, 214, 0.08);
}

.v6-bardo-route progress::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(255, 247, 214, 0.08);
}

.v6-bardo-route progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #b7852c, #ffe38d);
}

.v6-bardo-route progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, #b7852c, #ffe38d);
}

.v6-bardo-route__actions button {
  min-height: 32px;
  flex: 1 1 0;
  padding: 0 9px;
  color: #f6e8ba;
  border: 1px solid rgba(247, 211, 117, 0.22);
  border-radius: 9px;
  background: rgba(255, 248, 218, 0.07);
  font: 700 10px/1.15 system-ui, sans-serif;
  cursor: pointer;
}

.v6-bardo-route__actions button:first-child {
  color: #1a1408;
  border-color: #d6a945;
  background: linear-gradient(135deg, #ffe797, #c68c27);
}

.v6-bardo-route__actions button:disabled {
  cursor: default;
  opacity: 0.42;
}

.v6-bardo-route > p {
  margin-top: 7px;
  color: #998c68;
  font-size: 9.5px;
  line-height: 1.35;
}

/* Inserted authored record */
.v6-cell-context {
  margin: 12px 0 10px;
}

.v6-cell-context__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 8px;
}

.v6-cell-context__head h3 {
  margin: 0;
  color: #fff3c2;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.v6-cell-context__ordinal {
  color: #c9b77c;
  font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.v6-cell-context__lines {
  display: grid;
  gap: 6px;
  list-style: none;
}

.v6-cell-context__lines li {
  position: relative;
  padding-left: 14px;
  color: #eee3bf;
  font-size: 13px;
  line-height: 1.52;
}

.v6-cell-context__lines li::before {
  position: absolute;
  top: 0.58em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  content: "";
  background: #e4ba51;
  box-shadow: 0 0 8px rgba(228, 186, 81, 0.55);
}

.v6-cell-context__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.v6-cell-context__panel {
  padding: 10px 11px;
  border: 1px solid rgba(244, 205, 105, 0.16);
  border-radius: 12px;
  background: rgba(255, 248, 218, 0.045);
}

.v6-cell-context__panel b {
  display: block;
  margin-bottom: 3px;
  color: #d3bd78;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.v6-cell-context__panel p,
.v6-cell-context__panel li {
  color: #eee4c4;
  font-size: 12px;
  line-height: 1.45;
}

.v6-books {
  grid-column: 1 / -1;
}

.v6-books ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.v6-books li::before {
  margin-right: 6px;
  color: #e7bd52;
  content: "▤";
}

/* Sacred relation map */
.v6-sacred {
  position: relative;
  margin: 11px 0 13px;
  overflow: hidden;
  border: 1px solid rgba(245, 207, 105, 0.23);
  border-radius: 17px;
  background:
    radial-gradient(circle at 50% 50%, rgba(225, 181, 67, 0.1), transparent 50%),
    rgba(255, 248, 218, 0.025);
}

.v6-sacred__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 10px;
  padding: 9px 12px 0;
  color: #cdbb84;
  font: 650 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.v6-sacred svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 230px;
}

.v6-sacred .v6-edge {
  fill: none;
  stroke: rgba(231, 190, 83, 0.44);
  stroke-width: 1.6;
}

.v6-sacred .v6-edge--fine {
  stroke: rgba(255, 244, 202, 0.24);
  stroke-width: 1;
}

.v6-sacred .v6-node {
  fill: rgba(15, 13, 8, 0.94);
  stroke: #c59a37;
  stroke-width: 1.7;
}

.v6-sacred .v6-node--active {
  fill: rgba(219, 171, 52, 0.19);
  stroke: #ffe18a;
  stroke-width: 2.4;
}

.v6-sacred .v6-node-label {
  fill: #fff2c2;
  stroke: none;
  font: 700 11px/1 system-ui, sans-serif;
  text-anchor: middle;
}

.v6-sacred .v6-node-sub {
  fill: #c8b681;
  stroke: none;
  font: 600 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-anchor: middle;
}

.v6-sacred .v6-sigil-line {
  fill: rgba(229, 184, 69, 0.09);
  stroke: #e1b64d;
  stroke-width: 1.3;
}

.v6-sacred .v6-sigil-bit {
  fill: #6d5c30;
  stroke: #ae8a31;
  stroke-width: 0.8;
}

.v6-sacred .v6-sigil-bit.is-on {
  fill: #ffe08a;
  filter: drop-shadow(0 0 3px rgba(255, 215, 103, 0.82));
}

.v6-sacred__note {
  padding: 0 12px 10px;
  color: #958761;
  font-size: 10px;
}

/* Player-cell passport: six semantic layers on a tactile CSS 3D cube. */
.v6-player-cube {
  --cube-size: 248px;
  position: fixed;
  top: 50%;
  left: max(14px, env(safe-area-inset-left));
  z-index: 108;
  width: 364px;
  max-height: calc(100vh - 28px);
  padding: 14px 14px 12px;
  overflow: auto;
  color: #fff5cf;
  border: 1px solid rgba(255, 220, 126, 0.35);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 35%, rgba(241, 191, 61, 0.13), transparent 44%),
    rgba(8, 7, 5, 0.94);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.72), inset 0 1px rgba(255, 246, 210, 0.09);
  -webkit-backdrop-filter: blur(26px) saturate(130%);
  backdrop-filter: blur(26px) saturate(130%);
  transform: translateY(-50%);
  animation: v6-cube-panel-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes v6-cube-panel-in {
  from { opacity: 0; transform: translate(-18px, -50%); }
  to { opacity: 1; transform: translate(0, -50%); }
}

.v6-player-cube__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.v6-player-cube__head span {
  display: block;
  color: #d9b855;
  font: 800 9px/1.25 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.11em;
}

.v6-player-cube__head h2 {
  margin: 4px 0 0;
  color: #fff4c9;
  font-size: 16px;
  line-height: 1.2;
}

.v6-player-cube__head button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  color: #e6d6a4;
  border: 1px solid rgba(255, 222, 128, 0.2);
  border-radius: 50%;
  background: rgba(255, 249, 224, 0.06);
  font: 400 22px/1 system-ui, sans-serif;
  cursor: pointer;
}

.v6-cell-cube__scene {
  width: var(--cube-size);
  height: var(--cube-size);
  margin: 28px auto 25px;
  outline: none;
  perspective: 760px;
  touch-action: pan-y;
  cursor: grab;
}

.v6-cell-cube__scene.is-dragging {
  cursor: grabbing;
}

.v6-cell-cube__scene:focus-visible {
  outline: 3px solid #ffe58c;
  outline-offset: 9px;
  border-radius: 18px;
}

.v6-cell-cube {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotateX(-8deg) rotateY(0deg);
  transform-style: preserve-3d;
  transition: transform 0.58s cubic-bezier(0.2, 0.78, 0.24, 1);
}

.v6-cell-cube__scene.is-dragging .v6-cell-cube {
  transition: none;
}

.v6-cell-cube__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 11px 10px;
  overflow: hidden;
  color: #fff5d1;
  border: 1px solid rgba(255, 221, 126, 0.55);
  border-radius: 17px;
  background:
    linear-gradient(145deg, rgba(49, 40, 19, 0.96), rgba(13, 11, 7, 0.975)),
    rgba(12, 10, 7, 0.96);
  box-shadow: inset 0 0 32px rgba(226, 177, 49, 0.08), 0 0 26px rgba(0, 0, 0, 0.44);
  backface-visibility: hidden;
  pointer-events: none;
}

.v6-cell-cube__face.is-active {
  pointer-events: auto;
}

.v6-cell-cube__face--front { transform: translateZ(calc(var(--cube-size) / 2)); }
.v6-cell-cube__face--right { transform: rotateY(90deg) translateZ(calc(var(--cube-size) / 2)); }
.v6-cell-cube__face--back { transform: rotateY(180deg) translateZ(calc(var(--cube-size) / 2)); }
.v6-cell-cube__face--left { transform: rotateY(-90deg) translateZ(calc(var(--cube-size) / 2)); }
.v6-cell-cube__face--top { transform: rotateX(90deg) translateZ(calc(var(--cube-size) / 2)); }
.v6-cell-cube__face--bottom { transform: rotateX(-90deg) translateZ(calc(var(--cube-size) / 2)); }

.v6-cell-cube__face header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255, 220, 122, 0.18);
}

.v6-cell-cube__face header span {
  color: #d8ad43;
  font: 750 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.v6-cell-cube__face header b {
  color: #ffecac;
  font: 800 10px/1 system-ui, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.v6-cell-cube__face ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 8px 3px 5px 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 191, 84, 0.45) transparent;
  list-style: none;
}

.v6-cell-cube__face li {
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 231, 161, 0.09);
}

.v6-cell-cube__face li:last-child {
  border-bottom: 0;
}

.v6-cell-cube__face li b,
.v6-cell-cube__face li span,
.v6-cell-cube__face li small {
  display: block;
}

.v6-cell-cube__face li b {
  color: #d7b95f;
  font-size: 8px;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.v6-cell-cube__face li span {
  margin-top: 2px;
  color: #fff6d6;
  font-size: 9.5px;
  line-height: 1.35;
}

.v6-cell-cube__face li small {
  margin-top: 2px;
  color: #bcae82;
  font-size: 8px;
  line-height: 1.32;
}

.v6-cell-cube__nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.v6-cell-cube__nav button {
  min-height: 30px;
  padding: 4px 5px;
  color: #c8b98b;
  border: 1px solid rgba(247, 211, 117, 0.16);
  border-radius: 9px;
  background: rgba(255, 248, 218, 0.045);
  font: 720 9px/1.1 system-ui, sans-serif;
  cursor: pointer;
}

.v6-cell-cube__nav button[aria-current="true"] {
  color: #181206;
  border-color: #e0b447;
  background: linear-gradient(135deg, #ffe999, #c88f29);
}

.v6-player-cube__hint {
  margin: 8px 2px 0;
  color: #94865e;
  font-size: 9px;
  line-height: 1.35;
  text-align: center;
}

@media (min-width: 1181px) {
  body .overlay.v6-player-cell .sheet {
    margin-left: 390px;
  }
}

@media (max-width: 1180px) {
  .v6-player-cube {
    --cube-size: 210px;
    top: max(8px, env(safe-area-inset-top));
    left: 50%;
    width: min(350px, calc(100vw - 18px));
    max-height: 47vh;
    padding: 11px;
    transform: translateX(-50%);
  }

  @keyframes v6-cube-panel-in {
    from { opacity: 0; transform: translate(-50%, -14px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }

  .v6-cell-cube__scene {
    margin-top: 22px;
    margin-bottom: 20px;
  }

  body .overlay.v6-player-cell .sheet {
    max-height: 50vh;
  }
}

@media (max-width: 720px) {
  .v6-toolbar__row {
    flex-wrap: wrap;
  }

  .v6-toolbar__age {
    flex: 1 1 100%;
  }

  .v6-toolbar__tools {
    width: 100%;
  }

  .v6-toolbar__tools > * {
    flex: 1 1 auto;
  }

  .v6-cell-context__grid {
    grid-template-columns: 1fr;
  }

  .v6-books {
    grid-column: auto;
  }

  .v6-sacred svg {
    min-height: 190px;
  }

  .v6-player-cube {
    --cube-size: 182px;
    max-height: 48vh;
  }

  .v6-player-cube__head h2 {
    max-width: 240px;
    font-size: 14px;
  }

  .v6-cell-cube__scene {
    margin-top: 18px;
    margin-bottom: 16px;
  }

  .v6-cell-cube__face {
    padding: 9px 8px 7px;
  }

  .v6-cell-cube__face li span {
    font-size: 8.5px;
  }

  body .overlay.v6-player-cell .sheet {
    max-height: 49vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
