/* Gypsy bamboo oracle — 2D half-circle fan, one-card reveal, mobile-first */
.gypsy-page {
  max-width: 640px;
  margin: 0 auto;
  touch-action: manipulation;
}

.gypsy-page h1 {
  margin: 0.15rem 0 0.35rem;
}

.gypsy-stage,
.gypsy-stage.bezel,
#bezel.gypsy-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.08;
  max-height: min(72dvh, 560px);
  margin: 0.85rem 0 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-silver);
  background: radial-gradient(ellipse at 50% 28%, #243056 0%, #0b1026 72%);
  box-shadow: var(--shadow-glow);
  touch-action: manipulation;
}

.gypsy-fan {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 0;
  height: 0;
  z-index: 1;
  --fan-step: 11deg;
}

.gypsy-fan[hidden] {
  display: none;
}

.gypsy-card {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  width: clamp(48px, 17vw, 72px);
  height: clamp(72px, 25.5vw, 108px);
  min-width: 44px;
  min-height: 66px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 145%;
  --fan: calc((var(--i) - 3) * var(--fan-step));
  transform: translate(-50%, -78%) rotate(var(--fan));
  z-index: calc(4 + var(--i));
  animation: gypsy-deal 0.48s ease both;
  animation-delay: calc(var(--i) * 45ms);
}

.gypsy-card.is-open {
  z-index: 16;
}

.gypsy-card.is-selected {
  z-index: 18;
  filter: drop-shadow(0 0 10px rgba(232, 197, 71, 0.55));
}

.gypsy-card-inner {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--gold-deep);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
  background: #1a1408;
}

.gypsy-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: cover;
  pointer-events: none;
}

.gypsy-card-face {
  opacity: 0;
}

.gypsy-card.is-open .gypsy-card-face {
  opacity: 1;
}

.gypsy-card.is-open .gypsy-card-back {
  opacity: 0;
}

.gypsy-card.is-opening .gypsy-card-inner {
  animation: gypsy-open 0.36s ease;
}

@keyframes gypsy-deal {
  from {
    opacity: 0;
    transform: translate(-50%, -30%) rotate(0deg);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -78%) rotate(var(--fan));
  }
}

@keyframes gypsy-open {
  0% { transform: scaleX(1); }
  45% { transform: scaleX(0.08); }
  100% { transform: scaleX(1); }
}

.gypsy-fx,
.gypsy-stage .dice-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.gypsy-fx[hidden],
.gypsy-stage .dice-fx[hidden] {
  display: none;
}

.gypsy-overlay {
  position: absolute;
  left: 50%;
  top: 0.55rem;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
  width: min(92%, 360px);
  text-align: center;
  padding: 0.45rem 0.55rem 0.5rem;
  border-radius: 14px;
  background: rgba(8, 12, 28, 0.92);
  border: 1px solid var(--gold-deep);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(232, 197, 71, 0.28);
}

.gypsy-overlay[hidden] {
  display: none;
}

.gypsy-overlay-faces {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.28rem 0.4rem;
}

.gypsy-overlay-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.05rem, 4.8vw, 1.35rem);
  line-height: 1.25;
  color: var(--gold);
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(232, 197, 71, 0.4);
  padding: 0.12rem 0.4rem;
}

.gypsy-overlay-line {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--gold-soft);
}

.gypsy-draw {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 22;
  box-sizing: border-box;
  min-height: 80px;
  height: auto;
  width: min(82%, 300px);
  min-width: min(82%, 220px);
  padding: 0.85rem 1.1rem;
  margin: 0;
  border: 3px solid #ffd6d6;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff5a5a 0%, #e11d1d 48%, #b10d0d 100%);
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(1.28rem, 5.8vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-shadow: 0 1px 0 rgba(80, 0, 0, 0.45);
  box-shadow:
    0 10px 28px rgba(140, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.38);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.gypsy-draw:hover,
.gypsy-draw:focus-visible {
  background: linear-gradient(180deg, #ff6e6e 0%, #ef2424 48%, #c10f0f 100%);
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.gypsy-draw:active {
  transform: translate(-50%, -50%) scale(0.98);
}

.gypsy-draw[hidden] {
  display: none !important;
}

.gypsy-stage.is-dealt .gypsy-draw,
.gypsy-stage.is-revealed .gypsy-draw {
  top: auto;
  bottom: 0.45rem;
  transform: translateX(-50%);
  min-height: 68px;
  width: min(86%, 300px);
  font-size: clamp(1.12rem, 4.8vw, 1.4rem);
}

.gypsy-stage.is-dealt .gypsy-draw:active,
.gypsy-stage.is-revealed .gypsy-draw:active {
  transform: translateX(-50%) scale(0.98);
}

.gypsy-actions {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  justify-content: flex-end;
}

.gypsy-mute {
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.85rem;
}

.gypsy-result {
  margin-top: 1rem;
  padding: 1rem 1.05rem 1.1rem;
  border-radius: var(--radius);
  background: var(--texture-wood);
  border: 1px solid var(--line);
}

.gypsy-result[hidden] {
  display: none;
}

.gypsy-faces {
  display: flex;
  gap: 0.45rem;
  margin: 0.35rem 0 0.75rem;
  flex-wrap: wrap;
}

.gypsy-face-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--gold-deep);
  background: rgba(11, 16, 38, 0.45);
  color: var(--gold-soft);
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
}

.gypsy-face-chip:disabled {
  opacity: 0.45;
  cursor: default;
}

.gypsy-face-chip.is-open.is-selected,
.gypsy-face-chip.is-selected {
  background: rgba(232, 197, 71, 0.18);
  color: var(--gold);
}

.gypsy-result h2,
.gypsy-card-heading {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
}

.gypsy-card-heading {
  margin-top: 1.1rem;
  color: var(--gold);
}

.gypsy-areas {
  margin: 0.85rem 0 0;
  display: grid;
  gap: 0.55rem;
}

.gypsy-areas div {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(11, 16, 38, 0.28);
}

.gypsy-areas dt {
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--gold);
  margin: 0 0 0.15rem;
}

.gypsy-areas dd {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.gypsy-disclaimer {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.gypsy-how {
  margin: 1rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-muted);
}

html.gypsy-modal-open,
body.gypsy-modal-open {
  overflow: hidden;
}

.gypsy-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding:
    max(0.5rem, env(safe-area-inset-top, 0px))
    max(0.5rem, env(safe-area-inset-right, 0px))
    max(0.5rem, env(safe-area-inset-bottom, 0px))
    max(0.5rem, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.gypsy-modal[hidden] {
  display: none !important;
}

.gypsy-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 18, 0.84);
  touch-action: none;
}

.gypsy-modal-sheet {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 520px);
  height: min(100%, 760px);
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  box-sizing: border-box;
  padding: 0;
  border-radius: 16px;
  border: 1px solid var(--gold-deep);
  background: var(--texture-wood, #1a1408);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.gypsy-modal-sticky {
  position: sticky;
  top: 0;
  z-index: 8;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    max(0.45rem, env(safe-area-inset-top, 0px))
    max(0.9rem, env(safe-area-inset-right, 0px))
    0.4rem
    max(0.9rem, env(safe-area-inset-left, 0px));
  background: var(--texture-wood, #1a1408);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
  touch-action: pan-y;
}

.gypsy-modal-close,
.gypsy-modal-prev,
.gypsy-modal-next {
  min-height: 44px;
  min-width: 44px;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--gold-deep);
  background: rgba(11, 16, 38, 0.92);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
}

.gypsy-modal-close {
  position: sticky;
  top: max(0.45rem, env(safe-area-inset-top, 0px));
  align-self: flex-end;
  z-index: 9;
  margin: 0 0 0.35rem;
}

.gypsy-modal-close:focus-visible,
.gypsy-modal-prev:focus-visible,
.gypsy-modal-next:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.gypsy-modal-art {
  display: block;
  width: 100%;
  max-width: min(100%, 360px);
  height: auto;
  max-height: clamp(140px, 36dvh, 360px);
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
  border: 2px solid var(--gold-deep);
  background: #0b1026;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.gypsy-modal-scroll {
  flex: 1 1 0;
  min-height: 0;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 0.4rem max(0.9rem, env(safe-area-inset-right, 0px)) 0.55rem max(0.9rem, env(safe-area-inset-left, 0px));
}

.gypsy-modal-sheet h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.15rem, 5vw, 1.45rem);
  color: var(--gold);
}

.gypsy-modal-sheet p {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
}

.gypsy-modal-nav {
  position: sticky;
  bottom: 0;
  z-index: 8;
  flex: 0 0 auto;
  display: flex;
  gap: 0.65rem;
  justify-content: space-between;
  margin: 0;
  padding: 0.65rem max(0.9rem, env(safe-area-inset-right, 0px)) max(0.85rem, env(safe-area-inset-bottom, 0px)) max(0.9rem, env(safe-area-inset-left, 0px));
  background: var(--texture-wood, #1a1408);
  box-shadow: 0 -8px 16px rgba(0, 0, 0, 0.22);
}

.gypsy-modal-prev,
.gypsy-modal-next {
  flex: 1;
}

@media (max-width: 600px) {
  .gypsy-modal {
    padding: 0;
    align-items: stretch;
  }

  .gypsy-modal-sheet {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    border-radius: 0;
    padding: 0;
    overflow: hidden;
  }

  .gypsy-modal-art {
    max-width: 100%;
    max-height: clamp(128px, 32dvh, 300px);
  }
}

@media (max-width: 400px) {
  .gypsy-overlay-chip {
    font-size: 1.05rem;
  }

  .gypsy-draw {
    min-height: 84px;
    width: min(88%, 320px);
  }

  .gypsy-stage.is-dealt .gypsy-draw,
  .gypsy-stage.is-revealed .gypsy-draw {
    min-height: 64px;
  }

  .gypsy-fan {
    top: 44%;
    --fan-step: 10deg;
  }
}

@media (min-width: 400px) {
  .gypsy-fan {
    --fan-step: 13deg;
  }
}

@media (min-width: 600px) {
  .gypsy-stage {
    aspect-ratio: 5 / 4;
  }

  .gypsy-fan {
    --fan-step: 16deg;
    top: 48%;
  }

  .gypsy-modal {
    align-items: center;
    padding: 1.25rem;
  }

  .gypsy-modal-sheet {
    height: min(92dvh, 760px);
    min-height: 0;
    max-height: min(92dvh, 760px);
    overflow: hidden;
  }

  .gypsy-modal-art {
    max-height: clamp(160px, 38dvh, 400px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gypsy-result,
  .gypsy-draw,
  .gypsy-overlay,
  .gypsy-card,
  .gypsy-card-inner,
  .gypsy-modal,
  .gypsy-modal-sheet,
  .gypsy-modal-sticky,
  .gypsy-modal-scroll,
  .gypsy-modal-art {
    animation: none;
    transition: none;
  }

  .anim-fade-up {
    animation: none;
  }

  .gypsy-fx,
  .gypsy-stage .dice-fx {
    display: none;
  }
}
