.fortune-geomancy {
  padding: clamp(12px, 2.5vw, 28px);
  border: 1px solid #cfe3d7;
  border-radius: 16px;
  background: #fbfffd;
}

.fortune-geomancy #experience,
.geomancy-reading {
  max-width: 60rem;
  margin-inline: auto;
}

.fortune-geomancy :is(#geomancy-error, #journal-note, #fortune-audio-notice):empty,
.geomancy-sources:empty {
  display: none;
}

.fortune-geomancy #geomancy-error {
  color: #932e28;
}

.geomancy-sand {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 2vw, 16px);
  padding: clamp(8px, 2vw, 18px);
  border: 1px solid #d9b988;
  border-radius: 12px;
  background: #f5e1bb;
  box-shadow: inset 0 1px 12px #9e714b22;
}

.geomancy-sand-tray {
  display: grid;
  grid-template-rows: repeat(4, 14px);
  align-content: center;
  min-height: 82px;
  padding: 3px;
  border-bottom: 1px solid #cda879;
}

.geomancy-sand-row {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  align-items: center;
  gap: 1px;
}

.geomancy-sand-row i {
  width: min(100%, 5px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #714c28;
  box-shadow: 0 1px 1px #fff2ce;
}

.geomancy-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 14px;
  margin-top: 14px;
}

.geomancy-toolbar #action,
.geomancy-audio summary,
.geomancy-source {
  min-height: 44px;
}

.geomancy-audio {
  max-width: 100%;
}

.geomancy-audio summary {
  cursor: pointer;
  align-content: center;
}

.geomancy-audio > div {
  display: grid;
  grid-template-columns: auto minmax(4rem, 7rem);
  gap: 4px 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #cfe3d7;
  border-radius: 8px;
}

.geomancy-audio input[type="range"] {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.geomancy-audio label:last-of-type,
.geomancy-audio #fortune-audio-notice {
  grid-column: 1 / -1;
}

.geomancy-reading {
  overflow-wrap: anywhere;
}

.geomancy-reading :is(h3, h4, h5, p) {
  margin: 0 0 8px;
}

.geomancy-hint {
  color: #466252;
}

.geomancy-result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.geomancy-board {
  display: grid;
  gap: 5px;
  padding: clamp(6px, 1vw, 12px);
  border: 1px solid #d9b988;
  border-radius: 14px 14px 28% 28% / 14px 14px 15% 15%;
  background: #fbf0d8;
}

.geomancy-top {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  direction: rtl;
  gap: 5px;
}

.geomancy-tier {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  direction: rtl;
  gap: 4px;
}

.geomancy-nieces {
  width: min(78%, 26rem);
  justify-self: center;
}

.geomancy-witnesses {
  width: min(58%, 17rem);
  justify-self: center;
}

.geomancy-judge,
.geomancy-reconciler {
  width: min(36%, 10rem);
  justify-self: center;
}

.geomancy-reconciler {
  margin-block: 4px;
}

.geomancy-board .geomancy-card {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 48px;
  padding: 2px;
  border: 1px solid #c8a976;
  border-radius: 6px;
  background: #fffaf0;
  color: #553c20;
  direction: ltr;
  font: inherit;
  cursor: pointer;
}

.geomancy-board .geomancy-card.is-source {
  border: 1px dashed #377b63;
  background: #e2f3e9;
  color: #245b48;
}

.geomancy-board .geomancy-card[aria-pressed="true"] {
  border-color: #8b5c28;
  background: #f4d49e;
  box-shadow: inset 0 0 0 1px #8b5c28;
}

.geomancy-role {
  font-size: .75rem;
  line-height: 1.2;
}

.geomancy-figure-dots {
  display: grid;
  gap: 2px;
}

.geomancy-figure-dots span {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.geomancy-figure-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.geomancy-detail {
  min-width: 0;
  padding: clamp(9px, 2vw, 16px);
  border: 1px solid #cfe3d7;
  border-radius: 10px;
  background: #f3faf5;
  scroll-margin-top: 8px;
}

.geomancy-detail .geomancy-back-to-board {
  display: none;
}

.geomancy-detail h5 {
  margin-top: 12px;
  font-size: 1rem;
}

.geomancy-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-block: 8px;
}

.geomancy-sources .geomancy-source {
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid #77a590;
  border-radius: 6px;
  background: #e2f3e9;
  color: #245b48;
  font: inherit;
  cursor: pointer;
}

.geomancy-parity {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 0;
  margin: 8px 0;
  list-style: none;
}

.geomancy-parity li {
  padding: 3px 5px;
  border-radius: 4px;
  background: #e7f1eb;
  font-size: .86rem;
}

.geomancy-reading button:focus-visible {
  outline: 2px solid #245e91;
  outline-offset: 1px;
}

.geomancy-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.fortune-frame[data-geomancy-reading] {
  height: auto !important;
  min-height: 0;
  overflow: visible;
}

.fortune-frame[data-geomancy-reading] :is(#fortune-canvas, #canvas-access, #fortune-state) {
  display: none;
}

.geomancy-journal-detail {
  min-width: 0;
  padding: clamp(2px, 1vw, 10px);
}

@media (max-width: 760px) {
  .geomancy-result-layout,
  .geomancy-top {
    grid-template-columns: minmax(0, 1fr);
  }

  .geomancy-sand {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .geomancy-detail .geomancy-back-to-board {
    display: inline-block;
    min-height: 44px;
    margin-bottom: 8px;
    padding: 3px 8px;
    border: 0;
    background: transparent;
    color: #245b48;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .geomancy-sand-row i {
    animation: geomancy-dot 140ms var(--drop-delay) both;
  }
}

@keyframes geomancy-dot {
  from { opacity: 0; transform: scale(1.7); }
  to { opacity: 1; transform: scale(1); }
}
