
:root {
  --secondary: #fbc02d;
  --text-secondary: #9aa0a6;
}

.scene {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  margin-bottom: 0;
  padding: 10px 0;
  min-height: 0;
  overflow: visible;
}

.shell {
  width: clamp(160px, 45vw, 220px);
  max-height: 30vh;
  position: relative;
  z-index: 10;
  transition: transform 0.3s;
  display: flex;
  justify-content: center;
}

.shell-img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: none;
}

.shell.shaking {
  animation: shake-shell 0.5s infinite;
}

@keyframes shake-shell {
  0% { transform: rotate(0deg) translate(0, 0); }
  25% { transform: rotate(-5deg) translate(-5px, 2px); }
  50% { transform: rotate(0deg) translate(0, -2px); }
  75% { transform: rotate(5deg) translate(5px, 2px); }
  100% { transform: rotate(0deg) translate(0, 0); }
}

.coins-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.coin {
  width: 50px;
  height: 50px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease-out, opacity 0.3s;
}

.coin-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s;
}

.coin-front, .coin-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 2px #bcaaa4, 0 2px 5px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Front: Yang (Characters) */
.coin-front {
  background: transparent;
  border: none;
}
.coin-front img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.coin-front::before { display: none; }
.coin-front::after { content: ""; }

/* Back: Yin (Flower/Manchu) */
.coin-back {
  background: transparent;
  border: none;
  transform: rotateY(180deg);
}
.coin-back img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.coin-back::before { display: none; }
.coin-back::after { content: ""; }

/* Fallback style if image fails */
.fallback-coin .coin-front {
  background: radial-gradient(circle at 30% 30%, #fff9c4, #fbc02d);
  border: 4px solid #f57f17;
}
.fallback-coin .coin-front::after {
  content: "字";
  font-weight: bold;
  color: #bf360c;
  font-family: "Kaiti", "STKaiti", serif;
  display: block;
}
.fallback-coin .coin-front::before {
    display: block;
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background: transparent;
    border: 2px solid #bf360c;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.fallback-coin .coin-back {
  background: radial-gradient(circle at 30% 30%, #d7ccc8, #8d6e63);
  border: 4px solid #5d4037;
}
.fallback-coin .coin-back::after {
  content: "花";
  font-weight: bold;
  color: #3e2723;
  font-family: "Kaiti", "STKaiti", serif;
  display: block;
}
.fallback-coin .coin-back::before {
    display: block;
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background: transparent;
    border: 2px solid #3e2723;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Animations for coins */
.coin.in-shell {
  transform: translateY(-100px) scale(0.5);
  opacity: 0;
}

.coin.toss-animation {
  /* This class is applied when coins are "thrown" out */
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-bottom: 0;
}

.lines-container {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  /* Removed fixed min-height */
  align-items: center;
}

.hex-line {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  position: relative;
  width: clamp(80px, 30vw, 120px);
}

.hex-line.yin::before, .hex-line.yin::after {
  content: "";
  width: 40%;
  height: 8px;
  background: var(--primary);
  display: block;
  position: absolute;
  border-radius: 4px;
}
.hex-line.yin::before { left: 0; }
.hex-line.yin::after { right: 0; }

.hex-line.yang::before {
  content: "";
  width: 100%;
  height: 8px;
  background: var(--primary);
  display: block;
  border-radius: 4px;
}

.hex-line.old-yin::before, .hex-line.old-yin::after {
  content: "";
  width: 40%;
  height: 8px;
  background: var(--secondary);
  display: block;
  position: absolute;
  border-radius: 4px;
}
.hex-line.old-yin::before { left: 0; }
.hex-line.old-yin::after { right: 0; }
.hex-line.old-yin .marker {
  position: absolute;
  color: var(--secondary);
  font-size: 14px;
  right: -12px;
  font-weight: bold;
}

.hex-line.old-yang::before {
  content: "";
  width: 100%;
  height: 8px;
  background: var(--secondary);
  display: block;
  border-radius: 4px;
}
.hex-line.old-yang .marker {
  position: absolute;
  color: var(--secondary);
  font-size: 14px;
  right: -12px;
  font-weight: bold;
}

.line-info {
  position: absolute;
  left: -76px;
  width: 72px;
  text-align: right;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.9em;
  text-align: center;
}

.result-card.compact {
  max-height: clamp(120px, 24vh, 220px);
}

.lines-container.compact {
  gap: 4px;
  padding: 6px;
}

.lines-container.compact .hex-line {
  height: 16px;
  width: clamp(70px, 26vw, 100px);
}

.lines-container.compact .hex-line.yin::before,
.lines-container.compact .hex-line.yin::after {
  height: 4px;
}

.lines-container.compact .hex-line.yang::before {
  height: 4px;
}

.lines-container.compact .line-info {
  font-size: 11px;
  left: -68px;
  width: 64px;
}
