.compass-reference-frame {
  --compass-target-counter: 0deg;
  position: relative;
}

/*
 * The compass rose is oriented once from the absolute target bearing.
 * It does not follow live sensor updates. This keeps the target fixed at the
 * top while still showing where north/east/south/west lie around it.
 */
.compass-rotor {
  position: absolute;
  inset: 0;
  z-index: 1;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  transition: none;
}

.compass-dial-face {
  display: block;
  width: 100%;
  height: 100%;
}

.compass-cardinal {
  position: absolute;
  z-index: 2;
  display: block;
  color: #7c5a1b;
  font-family: var(--font-mincho);
  font-size: clamp(0.95rem, 4.6vw, 1.3rem);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 252, 244, 0.9);
}

.compass-cardinal > span {
  display: block;
  transform: rotate(var(--compass-target-counter));
}

.compass-cardinal--north {
  top: 14.5%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.compass-cardinal--east {
  top: 50%;
  right: 13.5%;
  transform: translate(50%, -50%);
}

.compass-cardinal--south {
  bottom: 12.8%;
  left: 50%;
  transform: translate(-50%, 50%);
}

.compass-cardinal--west {
  top: 50%;
  left: 13.5%;
  transform: translate(-50%, -50%);
}

.dial-center-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: grid;
  width: 24%;
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid var(--color-kin-light);
  border-radius: 50%;
  background: linear-gradient(145deg, #ba2a26, #851319);
  box-shadow:
    0 6px 16px rgba(127, 18, 23, 0.12),
    inset 0 0 0 2px rgba(255, 244, 215, 0.14);
  transform: translate(-50%, -50%);
}

.dial-center-seal .torii-glyph {
  transform: scale(0.78);
  transform-origin: 50% 50%;
}

/* The shrine destination never moves: it is always the top reference. */
.target-fixed-mark {
  position: absolute;
  top: -2.5%;
  left: 50%;
  z-index: 7;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.target-fixed-dot {
  position: relative;
  display: block;
  width: 1.6rem;
  height: 1.6rem;
  border: 3px solid #f0d58c;
  border-radius: 50%;
  background: linear-gradient(145deg, #d94135, var(--color-shu-dark));
  box-shadow:
    0 0 0 2px rgba(255, 252, 244, 0.84),
    0 4px 10px rgba(127, 18, 23, 0.2);
}

.target-fixed-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.44rem;
  height: 0.44rem;
  border-radius: 50%;
  background: #f0d58c;
  transform: translate(-50%, -50%);
}

.target-fixed-label {
  padding: 0.12rem 0.42rem;
  border: 1px solid rgba(166, 32, 32, 0.35);
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.96);
  color: var(--color-shu-dark);
  font-family: var(--font-mincho);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(96, 67, 15, 0.08);
}

/*
 * Only the current-heading pointer moves during guidance. The existing
 * AlignmentEngine delta is inverted in JS so the pointer describes the
 * phone's current direction in a target-up reference frame.
 */
.compass-reference-frame .direction-arrow,
.compass-reference-frame .aligned-needle {
  z-index: 5;
}

.compass-reference-frame .current-heading-arrow .arrow-stem {
  background: linear-gradient(180deg, #f1d894 0%, #c8a04a 58%, #8e6820 100%);
  box-shadow:
    0 0 0 1px rgba(255, 252, 244, 0.82),
    0 0 10px rgba(140, 101, 30, 0.2);
}

.compass-reference-frame .current-heading-arrow .arrow-head {
  top: -0.62rem;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 0.48rem solid transparent;
  border-bottom: 0.88rem solid #b98a2d;
  border-left: 0.48rem solid transparent;
  background: transparent;
  box-shadow: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 0 1px rgba(255, 252, 244, 0.95));
}

.compass-reference-frame .aligned-needle {
  top: 15%;
  bottom: 18%;
  background: linear-gradient(180deg, #f1d894 0 48%, #9d7427 49% 100%);
  box-shadow: 0 0 0 1px rgba(255, 252, 244, 0.82), 0 0 10px rgba(140, 101, 30, 0.16);
}

.compass-reference-frame .aligned-needle::before {
  top: -0.52rem;
  border-right: 0.46rem solid transparent;
  border-bottom: 0.85rem solid #b98a2d;
  border-left: 0.46rem solid transparent;
}

.target-bearing-primary {
  margin: 0.2rem 0 0.25rem;
  color: #7c5a1b;
  font-family: var(--font-mincho);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.front-reference-copy {
  display: grid;
  gap: 0.18rem;
  margin: 0.45rem 0 0.6rem;
  text-align: center;
}

.front-reference-copy strong {
  color: var(--color-shu-dark);
  font-family: var(--font-mincho);
  font-size: 0.82rem;
  font-weight: 700;
}

.front-reference-copy span {
  color: var(--color-muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.55;
}

.aligned-panel .front-reference-copy {
  margin-top: 0.3rem;
  margin-bottom: 0.45rem;
}

.aligned-panel .front-reference-copy strong {
  color: #7c5a1b;
}

.compass-reference-frame .direction-arrow {
  transition: transform 140ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .compass-reference-frame .direction-arrow {
    transition: none;
  }
}
