/** @format */

.timeline-flex-spacer {
  flex: 1;
}

/* Design tokens */
:root {
  --imperial-gold: #ffd700;
  --shadow-purple: #b478ff;
}
/** @format */

/* Timeline layout: single consolidated rule */
.timeline-flex-row {
  display: flex;
  justify-content: flex-start; /* keep content left-aligned; button will be absolutely centered */
  align-items: center;
  gap: 2.5em;
  margin-bottom: 20px;

  margin-right: 30px;
  margin-left: 20px;
  width: 100%;
  position: relative; /* establish containing block for absolute centering */
}

.timeline-btn-center {
  display: flex;
  justify-content: center;
  align-items: center;
  width: max-content;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
 
}

/* Double-size yarrow button image */
#yarrow-btn-img {
  width: 240px;
  height: 240px;
  object-fit: contain;
}

/* Square cast button */
.cast-hexagram-btn {
  width: 240px;
  height: 240px;
  border: none;
  background: none;
  padding: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#coin-flip-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

#quantum-serial-seal {
  display: none; /* default hidden; visibility toggled by .visible class */
  text-align: left;
  margin: 2.5em 0 1.2em 0.2em; /* merged from inline style */
  margin-top: 2.5em !important;
  font-weight: bold;
  font-size: 1.13em;
  letter-spacing: 0.04em;
  font-family: "OCR A Std", "OCR-A", "Consolas", "Courier New", monospace;
  color: #19ff19;
  z-index: 1;
}

/* Toggle visibility via class to avoid inline styles */
#quantum-serial-seal.visible {
  display: block;
}

/* Quantum Serial / Forged Seal text pieces (migrated from inline styles) */
.quantum-seal-prefix {
  display: inline-block;
  font-size: 0.665em;
  color: #0f0;
  margin-bottom: 0.1em;
  vertical-align: middle;
}
.quantum-seal-subtext {
  display: inline-block;
  font-size: 0.59em;
  color: gray;
  margin-bottom: 0.3em;
}
.quantum-seal-digit {
  font-size: 0.96em;
  color: #19ff19;
  vertical-align: middle;
}
.quantum-seal-letter {
  font-size: 0.96em;
  color: #fff;
}
.quantum-seal-tilde {
  font-size: 0.96em;
  color: #19ff19;
}
.quantum-seal-digit-power {
  font-size: 1.22em;
  color: #ff2a2a;
  vertical-align: middle;
  font-weight: bold;
}

/* Imperial Wisdom title card (migrated from inline styles) */
.iching-title-card {
  text-align: center;
  padding: 20px;
  margin: -10px -10px 20px -10px;
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.15),
    rgba(255, 165, 0, 0.1)
  );
  border: 2px solid rgba(255, 215, 0, 0.4);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(
      135deg,
      rgba(255, 215, 0, 0.15),
      rgba(255, 165, 0, 0.1)
    ),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 20px,
      rgba(255, 215, 0, 0.05) 20px,
      rgba(255, 215, 0, 0.05) 40px
    );
}
.iching-title-heading {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  letter-spacing: 2px;
}
.iching-title-sub {
  font-size: 24px;
  margin-top: 5px;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6));
}

/* Hexagram card and visual components */
.hexagram-card {
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.hexagram-card.primary {
  background: linear-gradient(
    135deg,
    rgba(30, 30, 60, 0.9),
    rgba(60, 30, 90, 0.7)
  );
  border: 2px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 8px 32px rgba(255, 215, 0, 0.2);
}
.hexagram-card-header {
  background: linear-gradient(
    90deg,
    rgba(255, 215, 0, 0.1),
    rgba(255, 165, 0, 0.05)
  );
  margin: -10px -10px 15px -10px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}
.hexagram-card-title {
  color: var(--imperial-gold, #ffd700);
  margin: 0;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}
.hexagram-card-subtitle {
  color: #ddd;
  font-size: 16px;
  margin-top: 5px;
}
.hexagram-visual {
  display: flex;
  justify-content: center;
  margin: 15px 0;
}
.hexagram-visual .placeholder {
  width: 180px;
  height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.4));
  border: 3px solid var(--imperial-gold, #ffd700);
  border-radius: 12px;
  box-shadow: rgba(255, 215, 0, 0.25) 0 0 25px,
    rgba(255, 255, 255, 0.1) 0 1px 0 inset;
  padding: 15px;
  position: relative;
  transition: 0.3s;
  cursor: default;
}
.hexagram-visual-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: bold;
  color: var(--imperial-gold, #ffd700);
  text-shadow: var(--imperial-gold, #ffd700) 0 0 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
}
.hexagram-visual-caption {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: bold;
  color: var(--imperial-gold, #ffd700);
  text-shadow: 0 0 15px var(--imperial-gold, #ffd700);
}
.hexagram-section {
  margin: 15px 0;
}
.hexagram-section-body.italic {
  font-style: italic;
}
/* Grid layout for the primary/shadow hexagram cards */
.iching-wisdom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 20px 0;
}

@media (max-width: 768px) {
  .iching-wisdom-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}

.hexagram-section-title {
  color: var(--imperial-gold, #ffd700);
  font-weight: bold;
  margin-bottom: 8px;
}
/* Shadow hexagram card styles (migrated from inline styles) */
.hexagram-card.shadow {
  background: linear-gradient(
    135deg,
    rgba(60, 30, 60, 0.9),
    rgba(90, 30, 60, 0.7)
  );
  border: 2px solid rgba(180, 120, 255, 0.4);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(180, 120, 255, 0.2);
  position: relative;
  overflow: hidden;
}
.hexagram-card.shadow .hexagram-card-header {
  background: linear-gradient(
    90deg,
    rgba(180, 120, 255, 0.1),
    rgba(160, 100, 255, 0.05)
  );
  margin: -10px -10px 15px -10px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}
.hexagram-card.shadow .hexagram-card-header h3 {
  color: #b478ff;
  margin: 0;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(180, 120, 255, 0.8);
}
.hexagram-card.shadow .hexagram-card-subtitle {
  color: #ddd;
  font-size: 16px;
  margin-top: 5px;
}
.hexagram-visual.shadow {
  display: flex;
  justify-content: center;
  margin: 15px 0;
}

/* Override styles for the dynamically-generated shadow hexagram visual.
   These use stronger rules to ensure visual parity even if the generator
   writes inline styles. */
#shadow-hexagram-visual > div {
  width: 180px !important;
  height: 180px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.6),
    rgba(0, 0, 0, 0.4)
  ) !important;
  border: 3px solid var(--shadow-purple, #b478ff) !important;
  border-radius: 12px !important;
  box-shadow: rgba(180, 120, 255, 0.25) 0 0 25px,
    rgba(255, 255, 255, 0.1) 0 1px 0 inset !important;
  padding: 15px !important;
  position: relative !important;
  transition: 0.3s !important;
  cursor: default !important;
  transform: scale(1) !important;
}

/* Hover effect parity with primary hexagram visual. Use strong specificity
   and !important to override any inline styles the generator may add. */
#shadow-hexagram-visual > div:hover {
  transform: scale(1.03) !important;
  box-shadow: rgba(180, 120, 255, 0.35) 0 0 32px,
    rgba(255, 255, 255, 0.12) 0 1px 0 inset !important;
}

#shadow-hexagram-visual .hexagram-visual-badge,
#shadow-hexagram-visual > div > div:first-child {
  position: absolute !important;
  top: 8px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-size: 14px !important;
  font-weight: bold !important;
  color: var(--shadow-purple, #b478ff) !important;
  text-shadow: var(--shadow-purple, #b478ff) 0 0 12px !important;
  background: rgba(0, 0, 0, 0.3) !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
}

#shadow-hexagram-visual .hexagram-visual-caption,
#shadow-hexagram-visual > div > div:last-child {
  position: absolute !important;
  bottom: 6px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-size: 15px !important;
  font-weight: bold !important;
  color: var(--shadow-purple, #b478ff) !important;
  text-shadow: var(--shadow-purple, #b478ff) 0 0 15px !important;
}

/* Primary hexagram visual overrides to restore mouseover parity with the shadow */
#primary-hexagram-visual > div {
  width: 180px !important;
  height: 180px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.6),
    rgba(0, 0, 0, 0.4)
  ) !important;
  border: 3px solid var(--imperial-gold, #ffd700) !important;
  border-radius: 12px !important;
  box-shadow: rgba(255, 215, 0, 0.25) 0 0 25px,
    rgba(255, 255, 255, 0.1) 0 1px 0 inset !important;
  padding: 15px !important;
  position: relative !important;
  transition: 0.3s !important;
  cursor: default !important;
}

#primary-hexagram-visual > div:hover {
  transform: scale(1.03) !important;
  box-shadow: rgba(255, 215, 0, 0.35) 0 0 32px,
    rgba(255, 255, 255, 0.12) 0 1px 0 inset !important;
}

#primary-hexagram-visual .hexagram-visual-badge,
#primary-hexagram-visual > div > div:first-child {
  position: absolute !important;
  top: 8px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-size: 14px !important;
  font-weight: bold !important;
  color: var(--imperial-gold, #ffd700) !important;
  text-shadow: var(--imperial-gold, #ffd700) 0 0 12px !important;
  background: rgba(0, 0, 0, 0.3) !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
}

#primary-hexagram-visual .hexagram-visual-caption,
#primary-hexagram-visual > div > div:last-child {
  position: absolute !important;
  bottom: 6px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-size: 15px !important;
  font-weight: bold !important;
  color: var(--imperial-gold, #ffd700) !important;
  text-shadow: var(--imperial-gold, #ffd700) 0 0 15px !important;
}
.hexagram-section-body {
  color: #ccc;
  font-size: 14px;
  line-height: 1.4;
}
.mystic-window {
  color: #e6e6e6;
  font-size: 14px;
  line-height: 1.5;
  font-style: italic;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 6px;
  border-left: 3px solid var(--imperial-gold, #ffd700);
}

/* Cosmic Synthesis card migrated from inline styles in JS */
.synthesis-card {
  background: linear-gradient(
    135deg,
    rgba(139, 69, 19, 0.3),
    rgba(160, 82, 45, 0.2)
  );
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  text-align: center;
}
.synthesis-title {
  color: #ffd700;
  margin: 0 0 15px 0;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}
.synthesis-body {
  color: #ddd;
  font-size: 15px;
  line-height: 1.6;
  font-style: italic;
  max-width: 800px;
  margin: 0 auto;
}

/* Wrapper previously emitted with inline styles in JS */
.enhanced-wisdom-shell {
  margin: 20px 0;
  padding: 25px;
  background: linear-gradient(
    135deg,
    rgba(139, 69, 19, 0.15),
    rgba(160, 82, 45, 0.15)
  );
  border: 3px solid rgba(218, 165, 32, 0.6);
  border-radius: 15px;
  color: #daa520;
  font-family: "Courier New", monospace;
  box-shadow: 0 0 25px rgba(218, 165, 32, 0.4);
  position: relative;
  overflow: hidden;
}

/* Responsive helpers moved from inline template in thefortunetimeline.js */
.yarrow-bar {
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: pre-line;
  min-width: 0;
  line-height: 1.1;
}

@media (max-width: 768px) {
  /* Ensure wisdom grid collapses to a single column on small screens */
  .iching-wisdom-display > div:first-child > div:nth-child(2) {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }
  .yarrow-bar {
    min-width: 0 !important;
    font-size: 0.9em !important;
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    white-space: pre-line !important;
    line-height: 1.1 !important;
  }
}

/* Round details expand/collapse (migrated from inline JS display toggles) */
.round-details-content {
  display: none;
}
.round-details-content.open {
  display: block;
}
/* Styling for the round details containers and toggle button (migrated from inline styles) */
.round-details-container {
  margin: 10px 0;
  border-radius: 12px;
  background: linear-gradient(90deg, #181c24 0%, #3a2d22 60%, #6a4fb6 100%);
  box-shadow: 0 2px 12px 0 #0ff2, 0 2px 8px #ffd70022;
  border: 2px solid #ffd70033;
}
.round-details-toggle {
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: bold;
  background: linear-gradient(90deg, #ffd70022, #6a4fb622);
  color: #4a90e2;
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: 12px 12px 0 0;
  transition: background 0.2s;
  box-shadow: 0 1px 6px #ffd70022;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.round-details-toggle:focus {
  box-shadow: 0 0 0 3px rgba(130, 87, 255, 0.12);
}
.round-details-content {
  padding: 12px 18px 16px 18px;
  background: linear-gradient(90deg, #181818 60%, #222 100%);
  border-radius: 0 0 12px 12px;
}

/* Toggle button internal layout pieces to replace previous inline spans */
.round-details-toggle .toggle-left,
.round-details-toggle .toggle-center,
.round-details-toggle .toggle-right {
  flex: 1;
}
.round-details-toggle .toggle-left {
  text-align: left;
}
.round-details-toggle .toggle-center {
  text-align: center;
}
.round-details-toggle .toggle-right {
  text-align: right;
  color: #aaa;
  font-weight: normal;
}
.meta-silver {
  color: silver;
}

/* Yarrow Stalk Hexagram Diagnostic styles (migrated from inline templates) */
.yarrow-diagnostic {
  margin: 20px 0;
  padding: 20px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 2px solid #ffd70055;
  border-radius: 12px;
}
.yarrow-title {
  color: #ff0000;
  text-align: center;
  margin: 0 0 20px 0;
  font-size: 1.4em;
  text-shadow: 0 0 5px #000;
}
.yarrow-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.yarrow-list li {
  margin-bottom: 0.5em;
  list-style: none;
}

.line-panel {
  padding: 15px;
  background: #1a1a2e;
  border-radius: 8px;
  margin: 10px 0;
}
.line-header {
  margin-bottom: 15px;
  padding: 10px;
  background: rgba(255, 215, 0, 0.1);
  border-radius: 6px;
  border-left: 3px solid #ffd700;
}
.line-value-title {
  color: #ffd700;
  font-weight: bold;
  font-size: 16px;
}
.division-block {
  margin: 15px 0;
  padding: 12px;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 6px;
}
.division-block.completed {
  border-left: 3px solid #4caf50;
}
.division-block.inprogress {
  border-left: 3px solid #ff9800;
}
.division-note {
  color: #ff69b4;
  margin: 8px 0;
  font-size: 14px;
}
.random-division {
  margin: 10px 0;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}
.pile-columns {
  display: flex;
  gap: 20px;
  margin: 8px 0;
}
.pile {
  flex: 1;
}
.pile .pile-count {
  color: #aaa;
  margin-left: 10px;
}
.stalks-process {
  margin: 10px 0;
  padding: 8px;
  background: rgba(25, 255, 25, 0.1);
  border-radius: 4px;
}
.stalks-process .stalks-text {
  color: #ccc;
  font-size: 13px;
  line-height: 1.4;
}
.stalks-removed {
  margin: 10px 0;
  padding: 8px;
  background: rgba(255, 215, 0, 0.1);
  border-radius: 4px;
}
.stalks-removed .stalks-removed-text {
  color: #ffd700;
  font-weight: bold;
}

/* Side-specific yarrow bar color helpers (used by generatePileVisual) */
.yarrow-left {
  color: #19ff19;
  font-family: monospace;
}
.yarrow-right {
  color: #4a90e2;
  font-family: monospace;
}

/* Hexagram Alchemy container replacements for inline styles */
.hexagram-alchemy-container {
  max-width: 800px;
  width: 90%;
  margin: 20px auto;
  padding: 15px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 255, 0, 0.3);
  border-radius: 8px;
  font-family: "Courier New", monospace;
  color: #0f0;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.imperial-hexagram-container {
  order: 1;
  margin-bottom: 20px;
}
.active-work-area {
  order: 2;
  margin-bottom: 15px;
}
.completed-container {
  order: 3;
}

/* Hexagram Alchemy: status indicator and titles */
.alchemizing-text {
  font-weight: bold;
  color: #ff4444;
  text-align: center;
}
.cosmic-status-indicator {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #ff4444;
  padding: 15px;
  margin-bottom: 15px;
  background: linear-gradient(
    135deg,
    rgba(255, 68, 68, 0.15),
    rgba(139, 69, 19, 0.15)
  );
  border: 2px solid rgba(255, 68, 68, 0.6);
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
}
.cosmic-status-indicator.complete {
  color: #9370db;
  background: linear-gradient(
    135deg,
    rgba(147, 112, 219, 0.25),
    rgba(72, 61, 139, 0.25)
  );
  border: 2px solid rgba(147, 112, 219, 0.8);
  text-shadow: 0 0 15px rgba(147, 112, 219, 1);
}
.cosmic-progress-wrapper {
  margin-top: 10px;
  font-size: 14px;
  color: #ff6666;
}
.cosmic-progress-bar-outer {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  height: 8px;
  margin: 8px 20px;
  overflow: hidden;
}
.cosmic-progress-bar-inner {
  height: 100%;
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 10px;
  background: linear-gradient(90deg, #ff4444, #ff6666);
}
.cosmic-progress-bar-inner.progress-glow {
  box-shadow: 0 0 12px rgba(255, 102, 102, 0.6);
}
.cosmic-progress-subtext {
  font-size: 12px;
  opacity: 0.8;
}

.stat-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #dda0dd;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.alchemy-title {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 15px;
  color: #9370db;
  text-shadow: 0 0 12px rgba(147, 112, 219, 0.6);
}
.hexagram-alchemy-overview {
  background: rgba(147, 112, 219, 0.1);
  border: 1px solid rgba(147, 112, 219, 0.3);
  border-radius: 6px;
  padding: 12px;
  margin: 10px 0;
  color: #9370db;
  font-size: 12px;
}

.hex-alchemy-active-title {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: #19ff19;
  margin-bottom: 8px;
}
.hex-line-container {
  background: rgba(0, 0, 0, 0.25);
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.active-division-area {
  padding: 8px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
}
.completed-divisions-container {
  padding: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
}
.line-result {
  padding: 10px;
  background: rgba(25, 255, 25, 0.04);
  border-radius: 6px;
}
.completed-line-container {
  padding: 10px;
  background: rgba(0, 0, 0, 0.16);
  border-radius: 6px;
}
.completed-header {
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 6px;
}
.completed-division {
  padding: 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.12);
  margin-bottom: 6px;
}
.completed-indicator {
  color: #4caf50;
  font-weight: bold;
}
.division-header {
  font-weight: bold;
  margin-bottom: 6px;
}
.preparation-display {
  padding: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
}
.result-display {
  padding: 8px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 6px;
}
.entropy-div {
  padding: 8px;
  background: rgba(255, 215, 0, 0.04);
  border-radius: 6px;
}
.hex-display {
  padding: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
}

.division-container {
  margin: 10px 0;
  padding: 12px;
  background: rgba(74, 169, 155, 0.08);
  border: 2px solid rgba(74, 169, 155, 0.4);
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(74, 169, 155, 0.3);
}
.division-header {
  font-weight: bold;
  color: #4a9;
  margin-bottom: 8px;
  text-align: center;
  text-shadow: 0 0 8px rgba(74, 169, 155, 0.6);
}
.preparation-display {
  margin: 6px 0;
  padding: 4px;
  background: rgba(0, 255, 255, 0.05);
  border: 1px dashed rgba(0, 255, 255, 0.2);
  border-radius: 3px;
  font-size: 11px;
  color: #0ff;
  text-align: center;
}
.division-display-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin: 8px 0;
}
.result-display {
  margin-top: 8px;
  padding: 6px;
  background: rgba(170, 85, 255, 0.1);
  color: #a5f;
  border-left: 3px solid #a5f;
  font-size: 12px;
}
.entropy-div {
  background: rgba(255, 255, 0, 0.1);
  padding: 6px;
  margin: 4px 0;
  border-radius: 3px;
  font-size: 11px;
  color: #ff0;
}
.division-completed {
  opacity: 1;
}

/* Stalk rendering and counting visuals (migrated from inline styles) */
.stalk-label {
  color: #ddd;
  font-size: 12px;
  margin-bottom: 4px;
  font-weight: bold;
  text-align: center;
}
.stalk-row {
  margin: 1px 0;
  line-height: 1.2;
  min-height: 14px;
  text-align: center;
}
.stalk-more {
  font-size: 10px;
  opacity: 0.7;
  text-align: center;
}
.stalk-char {
  margin: 0 1px;
  opacity: 0;
  transition: opacity 0.12s ease-in;
  font-family: monospace;
}
.stalk-char.visible {
  opacity: 1;
}
.stalk-left {
  color: #4a9;
}
.stalk-right {
  color: #a94;
}
.stalk-removed {
  color: #f44;
  font-weight: bold;
}
.stalks-wrapper {
  text-align: center;
  padding: 4px;
}

.counting-display {
  margin: 8px 0;
  padding: 6px;
  background: rgba(255, 0, 255, 0.1);
  border-radius: 3px;
  font-size: 11px;
}
.counting-title {
  color: #f0f;
  font-weight: bold;
  margin-bottom: 4px;
}
.counting-line-left {
  color: #4a9;
}
.counting-line-right {
  color: #a94;
}
.counting-result {
  color: #f44;
  font-weight: bold;
  padding: 4px;
  background: rgba(255, 68, 68, 0.1);
  border-radius: 3px;
  border-left: 3px solid #f44;
}
.hexagram-lines-display {
  font-size: 16px;
  line-height: 1.6;
  margin: 15px 0;
  color: #dda0dd;
  min-height: 200px;
}
.hexagram-line {
  margin: 4px 0;
  padding: 6px;
  background: rgba(221, 160, 221, 0.05);
  border: 1px dashed rgba(221, 160, 221, 0.2);
  border-radius: 4px;
  font-family: "Courier New", monospace;
  color: #666;
  transition: all 0.3s ease;
}
.hexagram-line.awaiting-revelation {
  /* subtle glow reserved for when lines reveal — non-intrusive by default */
  background: rgba(221, 160, 221, 0.08);
  box-shadow: 0 0 10px rgba(221, 160, 221, 0.18);
  transition: box-shadow 260ms ease, background 260ms ease;
}
.imperial-hexagram-display {
  padding: 20px;
  background: linear-gradient(
    135deg,
    rgba(25, 25, 112, 0.3),
    rgba(72, 61, 139, 0.3)
  );
  border: 2px solid rgba(138, 43, 226, 0.6);
  border-radius: 10px;
  text-align: center;
}
.hexagram-shadow-display {
  margin-top: 15px;
  padding: 15px;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.5),
    rgba(25, 25, 25, 0.5)
  );
  border: 2px solid rgba(85, 85, 85, 0.6);
  border-radius: 8px;
  text-align: center;
}
.shadow-lines-display {
  font-size: 14px;
  line-height: 1.4;
  margin: 10px 0;
  color: #555;
  min-height: 140px;
}
.shadow-line {
  margin: 3px 0;
  padding: 4px;
  background: rgba(85, 85, 85, 0.1);
  border: 1px dashed rgba(85, 85, 85, 0.2);
  border-radius: 3px;
  font-family: "Courier New", monospace;
  color: #444;
  font-size: 12px;
}
.shadow-line.updated {
  background: rgba(85, 85, 85, 0.2);
  border: 1px solid rgba(85, 85, 85, 0.4);
  color: #888;
  box-shadow: 0 0 5px rgba(85, 85, 85, 0.3);
}
.hexagram-metadata {
  margin-top: 12px;
  font-size: 12px;
  color: #9370db;
  border-top: 1px solid rgba(147, 112, 219, 0.3);
  padding-top: 10px;
}
.imperial-table-building {
  margin-top: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #9370db;
  border-radius: 8px;
  color: #9370db;
  font-size: 13px;
  font-family: "Courier New", monospace;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.imperial-table-building .imperial-table-title {
  font-weight: bold;
  margin-bottom: 6px;
}
.imperial-table-building table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.imperial-table-building th {
  border-bottom: 1px solid #9370db;
}
.imperial-table-building td {
  text-align: center;
}

/* HexagramAlchemy helper classes */
.progress-subtext {
  font-size: 12px;
  opacity: 0.8;
}
.hexagram-line-dim {
  color: #888;
}
.hexagram-line.revealed {
  margin: 4px 0;
  padding: 6px;
  background: rgba(221, 160, 221, 0.15);
  border: 1px solid rgba(221, 160, 221, 0.4);
  border-radius: 4px;
  font-family: "Courier New", monospace;
  color: #dda0dd;
  box-shadow: 0 0 8px rgba(221, 160, 221, 0.3);
  transition: all 0.5s ease;
}
.imperial-hexagram-title {
  font-size: 18px;
  font-weight: bold;
  color: #9370db;
  margin-bottom: 15px;
  text-shadow: 0 0 15px rgba(147, 112, 219, 0.8);
}
.hexagram-stat-overview {
  background: rgba(147, 112, 219, 0.1);
  border: 1px solid rgba(147, 112, 219, 0.3);
  border-radius: 6px;
  padding: 12px;
  margin: 10px 0;
  color: #9370db;
  font-size: 12px;
}
.active-division-area {
  order: 1;
  margin-bottom: 10px;
}
.completed-divisions-container {
  order: 2;
}
.division-container {
  margin: 10px 0;
  padding: 12px;
  background: rgba(74, 169, 155, 0.08);
  border: 2px solid rgba(74, 169, 155, 0.4);
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(74, 169, 155, 0.3);
}
.division-header {
  font-weight: bold;
  color: #4a9;
  margin-bottom: 8px;
  text-align: center;
  text-shadow: 0 0 8px rgba(74, 169, 155, 0.6);
}
.preparation-display {
  margin: 6px 0;
  padding: 4px;
  background: rgba(0, 255, 255, 0.05);
  border: 1px dashed rgba(0, 255, 255, 0.2);
  border-radius: 3px;
  font-size: 11px;
  color: #0ff;
  text-align: center;
}
.division-result-display {
  margin-top: 8px;
  padding: 6px;
  background: rgba(170, 85, 255, 0.1);
  color: #a5f;
  border-left: 3px solid #a5f;
  font-size: 12px;
}
.entropy-display {
  background: rgba(255, 255, 0, 0.1);
  padding: 6px;
  margin: 4px 0;
  border-radius: 3px;
  font-size: 11px;
  color: #ff0;
}
.imperial-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.imperial-table th {
  border-bottom: 1px solid #9370db;
}

.status-complete {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #9370db;
  padding: 15px;
  margin-bottom: 15px;
  background: linear-gradient(
    135deg,
    rgba(147, 112, 219, 0.25),
    rgba(72, 61, 139, 0.25)
  );
  border: 2px solid rgba(147, 112, 219, 0.8);
  border-radius: 10px;
  text-shadow: 0 0 15px rgba(147, 112, 219, 1);
  box-shadow: 0 0 20px rgba(147, 112, 219, 0.5);
}
.shadow-line.updated {
  background: rgba(85, 85, 85, 0.2);
  border: 1px solid rgba(85, 85, 85, 0.4);
  box-shadow: 0 0 5px rgba(85, 85, 85, 0.3);
  color: #888;
  padding: 4px;
  margin: 3px 0;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  font-size: 12px;
}
.shadow-metadata {
  margin-top: 8px;
  font-size: 11px;
  color: #666;
  border-top: 1px solid rgba(85, 85, 85, 0.3);
  padding-top: 8px;
}
.hexagram-metadata {
  margin-top: 12px;
  font-size: 12px;
  color: #9370db;
  border-top: 1px solid rgba(147, 112, 219, 0.3);
  padding-top: 10px;
}

.division-status {
  color: #4caf50;
  font-weight: bold;
  margin-bottom: 8px;
}
.division-number {
  color: #ffd700;
  font-weight: bold;
  margin-bottom: 8px;
}
.division-block.inprogress .division-status {
  color: #ff9800;
}
.pile-title {
  color: #19ff19;
  font-size: 14px;
  margin-bottom: 4px;
}
.pile-body {
  margin-left: 10px;
}
.pile-count {
  color: #aaa;
  margin-left: 10px;
}
.random-title {
  color: #ffd700;
  font-weight: bold;
  margin-bottom: 6px;
}
.stalks-process .stalks-text,
.stalks-process .stalks-text + .stalks-text {
  color: #ccc;
  font-size: 13px;
  line-height: 1.4;
}
/* Align coin to the right of the button - consolidated above (removed nested/invalid rules) */
/* Coin Flip 3D Styles (matches original CoinFlip app) */
.coin-flip-scene {
  width: 175px;
  height: 175px;
  perspective: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(ellipse at 60% 65%, #0005 0%, #0000 70%);
  box-shadow: 0 0 16px 0 #0006;
}
.coin-flip-coin3d {
  width: 175px;
  height: 175px;
  position: relative;
  transform-style: preserve-3d;
  transition: box-shadow 0.2s;
  box-shadow: 0 2px 12px #0006;
  border-radius: 50%;
}
.coin-flip-face {
  position: absolute;
  width: 175px;
  height: 175px;
  border-radius: 50%;
  backface-visibility: hidden;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 2px #fff2, 0 1px 8px #0005;
}
.coin-flip-heads {
  background-image: url("images/CoinHEADS.png");
  z-index: 2;
}
.coin-flip-tails {
  background-image: url("images/CoinTails.png");
  transform: rotateY(180deg);
  z-index: 1;
}

/* iChing Wisdom styles */
@keyframes goldShimmer {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}
.iching-wisdom-title {
  margin: 20px 0;
  padding: 25px;
  background: linear-gradient(
    135deg,
    rgba(139, 69, 19, 0.15),
    rgba(160, 82, 45, 0.15)
  );
  border: 3px solid rgba(218, 165, 32, 0.6);
  border-radius: 15px;
  color: #daa520;
  font-family: "Courier New", monospace;
  box-shadow: 0 0 25px rgba(218, 165, 32, 0.4);
}
.iching-wisdom-heading {
  text-align: center;
  padding: 20px;
  margin: -10px -10px 20px -10px;
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.15),
    rgba(255, 165, 0, 0.1)
  );
  border: 2px solid rgba(255, 215, 0, 0.4);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 200% 100%;
  animation: goldShimmer 3s ease-in-out infinite;
  letter-spacing: 2px;
}
.iching-wisdom-dragon {
  text-align: center;
  font-size: 24px;
  margin-top: 5px;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6));
}
.iching-single-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 15px 0;
}

/* iChing header and content layout */
.iching-header-section {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 25px;
  align-items: start;
}
@media (max-width: 768px) {
  .iching-header-section {
    grid-template-columns: 1fr;
    gap: 15px;
    text-align: center;
  }
}
.iching-header-text {
  /* small layout defaults for header text area */
  display: block;
  color: inherit;
  margin-bottom: 6px;
}
.iching-trigram-block {
  margin-bottom: 15px;
}
.iching-trigram-title {
  font-weight: bold;
  margin-bottom: 6px;
  font-size: 14px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
}
.iching-trigram-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 6px;
}
.iching-trigram-cell {
  color: #ddd;
}
.iching-musing-block {
  padding: 12px;
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.1),
    rgba(255, 215, 0, 0.05)
  );
  border-left: 4px solid #ffd700;
  border-radius: 6px;
}
.iching-musing-title {
  font-weight: bold;
  margin-bottom: 6px;
  font-size: 14px;
}
.iching-musing-body {
  font-style: italic;
  color: #f5f5dc;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
}
.iching-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 5px;
}
@media (max-width: 768px) {
  .iching-cards-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}
.hexagram-title-visual {
  margin-left: auto;
  margin-right: auto;
}

/* --- Fortune Cookie styles (scoped under .fortune-cookie to avoid global bleed) --- */
.fortune-cookie {
  --paper-bg: #fff;
  color: #fff;
  padding-right: 40px;
}
.fortune-cookie#fortune-cookie-container {
  margin-left: 1.5em;
}
.fortune-cookie .fortune-stage {
  display: flex;
  align-items: center;
  justify-content: center;
}
.fortune-cookie .fortune-cookie-stage {
  position: relative;
  width: 260px;
  height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fortune-cookie .fortune-cookie-img {
  position: absolute;
  max-width: 260px;
  max-height: 210px;
  z-index: 2;
  cursor: pointer;
}
@keyframes fortune-shake {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px) rotate(-3deg);
  }
  40% {
    transform: translateX(6px) rotate(3deg);
  }
  60% {
    transform: translateX(-4px) rotate(-2deg);
  }
  80% {
    transform: translateX(4px) rotate(2deg);
  }
  100% {
    transform: translateX(0) rotate(0);
  }
}
.fortune-cookie .shake {
  animation: fortune-shake 400ms ease-in-out;
}
.fortune-cookie .fortune-paper {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 210px;
  height: 48px;
  background: var(--paper-bg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  color: #111;
  z-index: 1;
  transform: translateX(-50%) translateY(-5px);
  opacity: 0;
  transition: transform 800ms ease-out, opacity 800ms ease-out;
}
.fortune-cookie .fortune-paper.show {
  transform: translateX(-50%) translateY(100px);
  opacity: 1;
}
.fortune-cookie .fortune-text {
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  color: #111;
}
/* End fortune cookie styles */

body {
  background: #181c24 !important;
  color: #e6e6ea;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Arial, sans-serif;
}
.cosmic-hexagram-summary,
.cosmic-hexagram-shadow {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0px,
    rgba(0, 0, 0, 0.1) 2px,
    transparent 2px,
    transparent 12px
  );
}
/* --- Cosmic/Imperial Hexagram Layout Enhancements --- */
.cosmic-hexagram-summary {
  background: linear-gradient(90deg, #2d223a 60%, #6a4fb6 100%);
  color: #b6a4e6;
  border-radius: 10px;
  box-shadow: 0 2px 8px #6a4fb622;
  text-align: center;
  /* max-width removed to allow full width */
  font-family: "Segoe UI", Arial, sans-serif;
}
.cosmic-hexagram-summary svg,
.cosmic-hexagram-shadow svg {
  display: block;
  margin: 0.5em 0 0.5em 0;
}
.cosmic-hexagram-summary .imperial-title {
  color: #c084fc;
}
.cosmic-hexagram-shadow {
  background: linear-gradient(90deg, #232136 60%, #444 100%);
  color: #b6b6cc;
  border-radius: 10px;
  box-shadow: 0 2px 8px #6a4fb622;
  text-align: center;
  /* max-width removed to allow full width */
  font-family: "Segoe UI", Arial, sans-serif;
}
.cosmic-hexagram-shadow .shadow-title {
  color: #a78bfa;
}
.mini-shadow-hexagram {
  margin-top: 1.2em;
  text-align: right;
  font-size: 1.5em;
  color: #b6b6cc;
  filter: grayscale(0.7);
}
.imperial-table-seal {
  /* Layout + visual styling consolidated into a single block */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 2em 0 1.5em 0;
  background: linear-gradient(90deg, #2d223a 60%, #3a2d22 100%);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(106, 79, 182, 0.08);
  padding: 1.2em 1.5em 1.2em 1.5em;
  text-align: center;
  border: 2px solid #ffd700;
}
.imperial-table-seal > .imperial-table-title {
  align-self: center;
}
.imperial-table-seal > div {
  width: 100%;
}
@media (max-width: 900px) {
  .imperial-table-seal > div[style*="display:flex"] {
    flex-direction: column !important;
    gap: 1em !important;
  }
  .cosmic-hexagram-summary,
  .cosmic-hexagram-shadow {
    max-width: 100%;
    text-align: center;
  }
  .mini-shadow-hexagram {
    text-align: center;
  }
}

/* Enhanced Hexagram Wisdom Cards Responsive Design */
@media (max-width: 768px) {
  /* Make header section single column on mobile */
  .hexagram-wisdom-header {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
    text-align: center;
  }

  /* Make cards section single column on mobile */
  .hexagram-wisdom-cards {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }

  /* Reduce hexagram visual size on mobile */
  .hexagram-visual-enhanced {
    width: 140px !important;
    height: 140px !important;
    margin: 0 auto;
  }

  /* Adjust card padding on mobile */
  .hexagram-content-card {
    padding: 12px !important;
  }
}
.kingwen-411 {
  color: #3ecfff;
  font-size: 1em;
  text-align: center;
}
.imperial-table-visual {
  margin: 0 auto;
}
/* Imperial Hexagram Table Seal */
.imperial-table-title {
  font-size: 1.1em;
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 0.7em;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px #ffd70044;
}
.imperial-table-visual {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.2em;
}
.imperial-table-row {
  transition: background 0.4s;
}
.imperial-table-row:hover {
  background: rgba(255, 215, 0, 0.08);
}
.imperial-table-num {
  font-weight: bold;
  color: #ffd700;
  width: 2em;
  font-size: 1.1em;
  text-align: right;
  padding-right: 0.7em;
}
.imperial-table-lines {
  font-size: 1.25em;
  color: #fff;
  letter-spacing: 0.12em;
  text-align: left;
  font-family: "Fira Mono", "Consolas", "Menlo", monospace;
  animation: imperialSealFadeIn 0.7s cubic-bezier(0.4, 2, 0.6, 1) both;
}
@keyframes imperialSealFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* I Ching Monitor/Terminal Unified Output */
.iching-monitor-container {
  background: #181c24;
  border-radius: 14px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.18), 0 1.5px 0 #ffd700 inset;
  padding: 2.2em 1.5em 1.5em 1.5em;
  margin: 2em 0 2em 0;
  width: 100%;
  color: #ffd700;
  font-family: "Fira Mono", "Consolas", "Menlo", monospace;
  position: relative;
  box-sizing: border-box;
  overflow-x: auto;
}
.iching-monitor-header {
  font-size: 1.25em;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-align: center;
  margin-bottom: 1.2em;
  color: #fff;
  background: linear-gradient(90deg, #ffd700 0%, #6a4fb6 100%);
  border-radius: 8px;
  padding: 0.5em 0;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.08);
}
.iching-hexagram-summary {
  display: flex;
  align-items: center;
  gap: 1.5em;
  margin-bottom: 1.5em;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 1em 1.2em;
  box-shadow: 0 1px 6px rgba(255, 215, 0, 0.04);
  justify-content: flex-end;
  text-align: right;
}
.hexagram-visual-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hexagram-line-vis {
  width: 60px;
  height: 8px;
  margin: 0 auto;
}
.hexagram-summary-text {
  font-size: 1em;
  color: #ffd700;
  line-height: 1.5;
}
.iching-breakdown-section {
  margin-top: 1.5em;
}
/* Duplicate light-theme body removed to preserve the dark theme declared above */

header {
  background: #383838;
  color: #ff0000;
  padding: 2rem 1rem 1rem 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

main {
  max-width: 1024px;
  width: 100%;
  margin: 0.1rem auto;
  padding: 0.3rem;
  background: #000000;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
  box-sizing: border-box;
}

/* Accessibility: visible focus for keyboard users */
:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid rgba(130, 87, 255, 0.9);
  outline-offset: 2px;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

#timeline-container {
  min-height: 300px;
  padding: 2rem 1rem;
  border: 2px dashed #b6a4e6;
  border-radius: 8px;
  background: #23242a;
  margin-top: 1rem;
  max-width: 1024px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

footer {
  text-align: center;
  color: #888;
  padding: 1rem 0;
  font-size: 0.9rem;
}

/* Utility text color helpers */
.white-text {
  color: #ffffff !important;
}

@media (max-width: 1100px) {
  #timeline-container,
  main {
    max-width: 98vw;
  }
}

#hexagram-output {
  margin-top: 270px; /* 240px button + 30px gap for safety */
}
