/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f0e8;
  --bg-card: #faf7f0;
  --bg-deep: #ede7d9;
  --ink: #2c2418;
  --ink-mid: #5a4f3e;
  --ink-light: #8a7d6a;
  --accent: #8b2020;
  --accent-warm: #c4540a;
  --wood: #9a7c55;
  --border: #d4c9b0;
  --border-light: #e8e0d0;
  --yang: #2c2418;
  --yin: #2c2418;
  --dynamic-mark: #8b2020;
  --hand-skin: #f5e8d5;
  --hand-line: #8b6a45;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(44, 36, 24, 0.08);
  --shadow-card: 0 4px 20px rgba(44, 36, 24, 0.12);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

/* ===== PAGE SYSTEM ===== */
.page {
  display: none;
  min-height: 100vh;
}

.page.active {
  display: block;
}

/* ===== HOME PAGE ===== */
.home-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.8rem;
}

.home-header {
  text-align: center;
}

.title-ornament {
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.3em;
}

.app-title {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.15em;
  margin-bottom: 0.4rem;
}

.app-subtitle {
  font-size: 0.9rem;
  color: var(--ink-light);
  letter-spacing: 0.2em;
}

.home-description {
  text-align: center;
  color: var(--ink-mid);
  line-height: 2;
  font-size: 0.9rem;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding: 1rem 0;
  width: 100%;
}

.question-section {
  width: 100%;
}

.question-label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-light);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.question-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.8;
}

.question-input:focus {
  border-color: var(--accent);
}

.question-input::placeholder {
  color: var(--ink-light);
  opacity: 0.7;
}

.home-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-light);
  line-height: 1.9;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 2.5rem;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--accent);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-action:disabled {
  background: #c9c0ad;
  color: rgba(250, 247, 240, 0.82);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-primary:disabled:hover,
.btn-secondary:disabled:hover,
.btn-action:disabled:hover {
  background: #c9c0ad;
  color: rgba(250, 247, 240, 0.82);
}

.btn-secondary {
  background: transparent;
  color: var(--ink-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 2rem;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--ink-mid);
  color: var(--ink);
}

/* ===== DIVINATION PAGE ===== */
.divination-container {
  width: min(100%, 520px);
  max-width: 520px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.div-header,
.scene-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.scene-status {
  padding: 0 0 0.8rem;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: none;
}

.progress-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.yao-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.1em;
}

.bian-label {
  font-size: 0.9rem;
  color: var(--ink-mid);
  letter-spacing: 0.05em;
}

.sep {
  color: var(--border);
}

.stalks-count {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
}

.stalks-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stalks-unit {
  font-size: 0.85rem;
  color: var(--ink-light);
}

/* Yao progress */
.yao-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1.2rem;
  box-shadow: var(--shadow-card);
}

.progress-title {
  font-size: 0.75rem;
  color: var(--ink-light);
  letter-spacing: 0.1em;
  margin-bottom: 0.6rem;
}

.yao-dots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.8rem;
  align-items: center;
}

.yao-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 0;
  background: transparent;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}

.yao-dot-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--ink-light);
  transition: all 0.2s;
}

.yao-dot.done .yao-dot-circle {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.yao-dot.active .yao-dot-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 0 3px rgba(139, 32, 32, 0.15);
}

.yao-dot.expanded .yao-dot-circle {
  box-shadow: 0 0 0 3px rgba(122, 92, 58, 0.16);
}

.yao-dot-name {
  font-size: 0.65rem;
  color: var(--ink-light);
}

.yao-bian-panel {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border-light);
  margin-top: 0.2rem;
  padding-top: 0.65rem;
}

.yao-bian-empty {
  color: var(--ink-light);
  font-size: 0.78rem;
  text-align: center;
}

/* Bian history */
.bian-history {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bian-history-details {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: rgba(250, 247, 240, 0.72);
  overflow: hidden;
}

.bian-history-details summary {
  cursor: pointer;
  list-style: none;
  padding: 0.55rem 0.8rem;
  color: var(--ink-light);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.bian-history-details summary::-webkit-details-marker {
  display: none;
}

.bian-history-details summary::after {
  content: "+";
  float: right;
  color: var(--accent);
}

.bian-history-details[open] summary::after {
  content: "-";
}

.bian-history-item {
  background: var(--bg-deep);
  border-top: 1px solid var(--border-light);
  border-radius: 0;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  color: var(--ink-mid);
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.bian-history-item .bh-tag {
  color: var(--ink-light);
  font-size: 0.75rem;
}

.bian-history-item .bh-num {
  color: var(--ink);
  font-weight: 600;
}

/* Split section */
.split-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.2rem;
  box-shadow: var(--shadow);
}

.split-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.15em;
  text-align: center;
  margin-bottom: 1.2rem;
}

.split-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 80px;
}

.pile-label {
  font-size: 0.8rem;
  color: var(--ink-light);
  letter-spacing: 0.2em;
}

.pile-count {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  min-width: 3ch;
  text-align: center;
}

.pile-left .pile-count { color: var(--wood); }
.pile-right .pile-count { color: var(--accent-warm); }

.pile-unit {
  font-size: 0.75rem;
  color: var(--ink-light);
}

.pile-divider {
  color: var(--border);
  font-size: 2rem;
  line-height: 1;
}

.slider-section {
  margin-bottom: 1.5rem;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--ink-light);
  margin-bottom: 0.4rem;
}

.slider-hint {
  color: var(--ink-light);
  opacity: 0.7;
}

.stalk-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(to right, var(--wood) 0%, var(--wood) var(--pct, 50%), var(--border) var(--pct, 50%));
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.stalk-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--bg-card);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.2s;
}

.stalk-slider::-webkit-slider-thumb:hover {
  border-color: var(--accent);
}

.stalk-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--bg-card);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}

/* Calc result */
.calc-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.calc-title {
  font-size: 0.85rem;
  color: var(--ink-light);
  letter-spacing: 0.1em;
  margin-bottom: 0.8rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin-bottom: 0.8rem;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.calc-key {
  color: var(--ink-light);
}

.calc-val {
  color: var(--ink);
  font-weight: 600;
}

.calc-summary {
  font-size: 0.9rem;
  color: var(--accent-warm);
  font-weight: 600;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-light);
  margin-bottom: 1rem;
}

/* Yao result */
.yao-result {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.2rem;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.yao-result-title {
  font-size: 0.85rem;
  color: var(--ink-light);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.yao-result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
}

.yao-result-value.dynamic {
  color: var(--accent);
}

.yao-result-desc {
  font-size: 0.9rem;
  color: var(--ink-mid);
  margin-bottom: 0.3rem;
}

.yao-result-calc {
  font-size: 0.82rem;
  color: var(--ink-light);
  margin-bottom: 1.2rem;
}

.yao-symbol-preview {
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  color: var(--ink);
  margin-bottom: 1.2rem;
  font-family: monospace;
}

/* ===== RESULT PAGE ===== */
.result-container {
  max-width: 560px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.result-header {
  text-align: center;
  margin-bottom: 2rem;
}

.result-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
}

.result-question {
  font-size: 0.9rem;
  color: var(--ink-mid);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  display: inline-block;
  max-width: 100%;
}

/* Hexagram display */
.hexagram-section {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.hex-column {
  flex: 1;
  max-width: 200px;
  text-align: center;
}

.hex-label {
  font-size: 0.75rem;
  color: var(--ink-light);
  letter-spacing: 0.2em;
  margin-bottom: 0.4rem;
}

.hex-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.hex-lines {
  display: flex;
  flex-direction: column-reverse;
  gap: 7px;
  margin-bottom: 1rem;
  align-items: center;
}

.hex-line-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hex-line-name {
  font-size: 0.7rem;
  color: var(--ink-light);
  width: 2.5em;
  text-align: right;
}

.hex-line {
  display: flex;
  gap: 6px;
  align-items: center;
  position: relative;
  width: 82px;
  height: 8px;
  justify-content: center;
}

.line-solid,
.line-broken {
  height: 6px;
  background: var(--ink);
  border-radius: 999px;
  display: block;
}

.line-solid {
  width: 82px;
}

.line-broken {
  width: 34px;
}

.dynamic-dot {
  min-width: 1.6em;
  font-size: 0.7rem;
  color: #9f1f1f;
  font-weight: 700;
  margin-left: 4px;
}

.hex-line.dynamic .line-solid,
.hex-line.dynamic .line-broken {
  background: #9f1f1f;
}

.hex-judgment {
  font-size: 0.78rem;
  color: var(--ink-mid);
  line-height: 1.8;
  text-align: left;
  border-top: 1px solid var(--border-light);
  padding-top: 0.6rem;
}

.hex-symbol {
  font-size: 2.6rem;
  line-height: 1;
  color: var(--ink);
  text-align: center;
  margin-bottom: 0.5rem;
}

.hex-meta {
  color: var(--wood);
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.45rem;
}

.hex-trigrams {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0.65rem;
  color: var(--ink-light);
  margin-bottom: 0.6rem;
}

.hex-text,
.hex-desc {
  margin-top: 0.45rem;
}

.hex-desc {
  color: var(--ink);
}

.hex-arrow {
  font-size: 1.5rem;
  color: var(--ink-light);
  margin-top: 3rem;
  flex-shrink: 0;
}

/* Dynamic lines section */
.dong-yao-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 0.8rem;
  color: var(--ink-light);
  letter-spacing: 0.15em;
  margin-bottom: 0.8rem;
}

.dong-yao-item {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--ink-mid);
  padding: 0.3rem 0;
}

.dong-yao-item:last-child {
  border-bottom: none;
}

.dong-yao-pos {
  color: var(--accent);
  font-weight: 600;
  min-width: 2.5em;
}

/* Process log */
.log-section {
  margin-bottom: 1.5rem;
}

.btn-log-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1.2rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--ink-mid);
  cursor: pointer;
  letter-spacing: 0.05em;
  width: 100%;
  text-align: left;
  transition: all 0.2s;
}

.btn-log-toggle:hover {
  background: var(--bg-card);
}

.log-content {
  border: 0;
  border-top: none;
  border-radius: 0;
  background: transparent;
  padding: 0.8rem 0.1rem 0;
  font-size: 0.82rem;
  color: var(--ink-mid);
  line-height: 2;
}

.log-yao-block {
  margin-bottom: 1.2rem;
}

.log-yao-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border-light);
}

.log-bian-block {
  padding-left: 0.8rem;
  margin-bottom: 0.6rem;
}

.log-bian-title {
  color: var(--ink-light);
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

.log-bian-detail {
  color: var(--ink-mid);
}

.log-yao-result {
  color: var(--accent-warm);
  font-weight: 600;
  margin-top: 0.3rem;
}

/* ===== UTILITIES ===== */
.hidden {
  display: none !important;
}

/* ===== ANIMATIONS ===== */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .scene-card {
    min-height: 650px;
  }

  .ritual-board {
    height: 300px;
  }

  .hexagram-section {
    gap: 1rem;
  }
  .hex-arrow {
    margin-top: 2.5rem;
    font-size: 1.2rem;
  }
  .hex-name {
    font-size: 1rem;
  }
}

/* ===== PHASE CONTAINER ===== */
.phase-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  align-items: stretch;
}

/* ===== SCENE CARD (wraps each phase) ===== */
.scene-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.2rem 1.6rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== TAIJI ROW ===== */
.taiji-row {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0.5rem 0 0.2rem;
  background: transparent;
  border: 0;
}

.taiji-text {
  display: none;
}

.taiji-stick-bar {
  width: 180px;
  height: 18px;
  overflow: visible;
  opacity: 0.86;
}

.taiji-stick-shadow,
.taiji-stick-core,
.taiji-stick-highlight {
  fill: none;
  stroke-linecap: round;
}

.taiji-stick-shadow {
  stroke: rgba(44, 36, 24, 0.2);
  stroke-width: 5.2;
  transform: translate(1.8px, 1.6px);
}

.taiji-stick-core {
  stroke: var(--wood);
  stroke-width: 4.1;
}

.taiji-stick-highlight {
  stroke: rgba(250, 247, 240, 0.33);
  stroke-width: 0.75;
}

/* ===== PHASE HEADER ===== */
.phase-header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.phase-tag {
  font-size: 0.72rem;
  color: var(--ink-light);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.phase-title {
  font-size: 1.0rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.08em;
  line-height: 1.4;
}

/* ===== STICKS DISPLAY ===== */
.sticks-bundle-area {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.8rem 0;
}

.sticks-svg {
  width: 100%;
  max-width: 280px;
  height: auto;
}

/* ===== LOOSE STALK INTERACTION ===== */
.ritual-board {
  position: relative;
  height: 300px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: #f7f2e8;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.taiji-board {
  cursor: default;
}

.taiji-rest {
  position: absolute;
  left: 50%;
  top: 28px;
  width: 172px;
  height: 38px;
  transform: translateX(-50%);
  border: 1px dashed rgba(122, 92, 58, 0.48);
  border-radius: 999px;
  pointer-events: none;
}

.split-taiji-rest {
  z-index: 2;
}

.split-taiji-rest .taiji-stick-bar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.split-taiji-stick {
  position: absolute;
  left: 50%;
  top: 28px;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
}

.split-board.gua-yi-active .split-taiji-stick,
.split-board.die-si-active .split-taiji-stick {
  top: 29px;
}

.split-board.gua-yi-active .split-taiji-stick .taiji-stick-bar,
.split-board.die-si-active .split-taiji-stick .taiji-stick-bar {
  width: 122px;
  height: 13px;
}

.split-board.gua-yi-active .split-taiji-stick .taiji-stick-core,
.split-board.die-si-active .split-taiji-stick .taiji-stick-core {
  stroke-width: 3.2;
}

.split-board.gua-yi-active .split-taiji-stick .taiji-stick-shadow,
.split-board.die-si-active .split-taiji-stick .taiji-stick-shadow {
  stroke-width: 4.1;
}

.split-board.gua-yi-active .split-taiji-stick .taiji-stick-highlight,
.split-board.die-si-active .split-taiji-stick .taiji-stick-highlight {
  stroke-width: 0.55;
}

.taiji-rest::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 152px;
  height: 9px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(122, 92, 58, 0.08);
}

.loose-stick {
  position: absolute;
  width: 18px;
  height: 180px;
  border-radius: 999px;
  overflow: visible;
  color: var(--wood);
  filter: brightness(var(--stick-tone, 1));
  transform-origin: center;
  transition:
    left 0.48s ease,
    top 0.48s ease,
    transform 0.48s ease,
    color 0.18s,
    filter 0.18s,
    opacity 0.18s;
}

.stick-shadow,
.stick-core,
.stick-highlight {
  fill: none;
  stroke-linecap: round;
}

.stick-shadow {
  stroke: rgba(44, 36, 24, 0.1);
  stroke-width: 4.8;
  transform: translate(1.6px, 1.8px);
}

.stick-core {
  stroke: currentColor;
  stroke-width: 3.7;
}

.stick-highlight {
  stroke: rgba(250, 247, 240, 0.28);
  stroke-width: 0.65;
}

.taiji-draggable-stick {
  cursor: grab;
  z-index: 3;
}

.taiji-draggable-stick.dragging {
  cursor: grabbing;
  z-index: 5;
  filter: brightness(var(--stick-tone, 1)) drop-shadow(0 8px 10px rgba(44, 36, 24, 0.24));
}

.taiji-draggable-stick.placed {
  pointer-events: none;
}

.taiji-board.taiji-ready .taiji-draggable-stick:not(.placed) {
  pointer-events: none;
}

.split-board {
  cursor: crosshair;
}

.split-board.drawing .loose-stick {
  opacity: 0.9;
}

.split-draw-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.split-gesture-path {
  fill: none;
  stroke: rgba(139, 32, 32, 0.68);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.82;
}

.split-board.split-grouped .split-gesture-path {
  opacity: 0;
}

.split-board.split-grouped.drawing .split-gesture-path {
  opacity: 0.82;
}

.loose-stick.stick-left {
  color: var(--wood);
}

.loose-stick.stick-right {
  color: var(--wood);
}

.split-hand-stage {
  position: absolute;
  left: 3%;
  bottom: -74px;
  width: 210px;
  height: 210px;
  z-index: 4;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  animation: handEnter 0.42s ease forwards;
  pointer-events: none;
}

.split-hand-stage .hand-caption {
  display: none;
}

.loose-stick.gua-yi-stick {
  z-index: 6;
  color: var(--wood);
  filter: brightness(var(--stick-tone, 1)) drop-shadow(0 6px 8px rgba(44, 36, 24, 0.22));
}

.loose-stick.hidden-stick {
  opacity: 0;
  pointer-events: none;
}

.loose-stick.clickable-stick,
.loose-stick.clickable-remainder {
  cursor: pointer;
  pointer-events: auto;
}

.loose-stick.clickable-remainder {
  animation: remainderPulse 0.88s ease-in-out infinite;
  z-index: 7;
}

.loose-stick.clickable-gua-yi {
  animation: remainderPulse 0.88s ease-in-out infinite;
}

.loose-stick.clickable-remainder .stick-core,
.loose-stick.clickable-gua-yi .stick-core {
  stroke: #9f1f1f;
}

.loose-stick.clickable-remainder .stick-shadow,
.loose-stick.clickable-gua-yi .stick-shadow {
  stroke: rgba(159, 31, 31, 0.28);
}

.split-board.die-si-active {
  cursor: default;
}

.split-board.die-si-active .loose-stick {
  width: 15px;
  height: 154px;
  transition:
    left 0.72s cubic-bezier(0.2, 0.72, 0.25, 1),
    top 0.72s cubic-bezier(0.2, 0.72, 0.25, 1),
    transform 0.72s cubic-bezier(0.2, 0.72, 0.25, 1),
    opacity 0.2s;
}

.split-board.die-si-active .stick-core {
  stroke-width: 3.2;
}

.split-board.die-si-active .stick-shadow {
  stroke-width: 4.1;
}

.split-board.die-si-active .stick-highlight {
  stroke-width: 0.55;
}

.die-si-hand-stage {
  left: 3%;
  bottom: -74px;
  width: 210px;
  height: 210px;
  z-index: 4;
}

/* ===== SPLIT LEGEND ===== */
.split-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.78rem;
}

.legend-left { color: var(--wood); }
.legend-right { color: var(--wood); }

/* ===== SPLIT CONTROLS ===== */
.split-controls {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.split-counts {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding: 0 3.2rem;
}

.taiji-count-placeholder {
  visibility: hidden;
}

.sc-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 70px;
}

.sc-label {
  font-size: 0.78rem;
  color: var(--ink-light);
  letter-spacing: 0.2em;
}

.sc-num {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
}

.sc-pile-left .sc-num { color: var(--wood); }
.sc-pile-right .sc-num { color: var(--wood); }

.sc-unit {
  font-size: 0.72rem;
  color: var(--ink-light);
}

.sc-divider {
  color: var(--border);
  font-size: 1.8rem;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.slider-endpoint {
  font-size: 0.72rem;
  color: var(--ink-light);
  min-width: 1.5em;
  text-align: center;
}

.slider-hint {
  font-size: 0.75rem;
  color: var(--ink-light);
  text-align: center;
  opacity: 0.8;
  min-height: 2.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== ACTION BUTTON ===== */
.btn-action {
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 2rem;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  align-self: center;
  min-width: 160px;
}

.btn-action:hover { background: var(--accent); }
.btn-action:active { transform: scale(0.97); }

/* ===== PHASE HINT ===== */
.phase-hint {
  font-size: 0.82rem;
  color: var(--ink-mid);
  line-height: 1.8;
  text-align: left;
  border: 0;
  padding: 0.15rem 0 0;
  margin-top: 0.2rem;
}

.phase-hint strong {
  color: var(--accent);
}

/* ===== PROCESS LAYOUT (piles + hand) ===== */
.process-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.piles-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
}

.hand-side {
  flex-shrink: 0;
  width: 140px;
}

/* ===== MINI PILE CARDS ===== */
.mini-pile-card {
  background: var(--bg-deep);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.left-pile-card { border-left: 3px solid var(--wood); }
.right-pile-card { border-left: 3px solid var(--wood); }

.mp-header {
  font-size: 0.72rem;
  color: var(--ink-light);
  letter-spacing: 0.1em;
}

.mp-count {
  font-size: 0.82rem;
  color: var(--ink-mid);
  font-weight: 600;
}

.mini-sticks-svg {
  height: 28px;
  width: auto;
  max-width: 100%;
}

.mini-empty {
  font-size: 0.8rem;
  color: var(--ink-light);
  height: 28px;
  display: flex;
  align-items: center;
}

/* ===== GROUPS DISPLAY (揲四) ===== */
.groups-row {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.groups-svg {
  height: 26px;
  width: auto;
  max-width: 120px;
}

.rem-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.rem-label {
  font-size: 0.7rem;
  color: var(--accent-warm);
  font-weight: 600;
}

.group-note {
  font-size: 0.72rem;
  color: var(--ink-light);
}

/* ===== DIE-SI DISPLAY ===== */
.die-si-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.2rem 0;
}

.die-si-math {
  font-size: 0.82rem;
  color: var(--ink-mid);
  white-space: nowrap;
  font-family: monospace;
  font-weight: 600;
}

.die-si-rem {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.die-si-rem-label {
  font-size: 0.75rem;
  color: var(--ink-light);
}

.die-si-rem-n {
  font-size: 0.85rem;
  color: var(--accent-warm);
  font-weight: 700;
  min-width: 1em;
}

/* ===== GUIQI TABLE ===== */
.guiqi-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.8rem;
}

.gq-row {
  display: grid;
  grid-template-columns: 2.5em 1em 1fr auto;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
}

.gq-step {
  color: var(--accent);
  font-weight: 600;
}

.gq-arrow {
  color: var(--ink-light);
}

.gq-finger {
  color: var(--ink-mid);
  font-size: 0.78rem;
}

.gq-val {
  color: var(--ink);
  font-weight: 700;
  text-align: right;
}

.gq-total {
  border-top: 1px solid var(--border-light);
  padding-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--accent-warm);
  margin-top: 0.2rem;
}

.gq-total strong {
  font-size: 1.05rem;
}

/* ===== HAND SVG ===== */
.hand-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.hand-svg {
  width: 140px;
  height: auto;
  filter: drop-shadow(0 2px 6px rgba(44, 36, 24, 0.12));
}

.hand-line-art {
  overflow: visible;
  filter: none;
}

.hand-outline,
.hand-detail {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hand-outline {
  stroke-width: 3;
}

.hand-detail {
  stroke-width: 1.7;
  opacity: 0.9;
}

.hand-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.hand-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.94;
  mix-blend-mode: multiply;
}


.hand-caption {
  font-size: 0.68rem;
  color: var(--ink-light);
  letter-spacing: 0.1em;
}

/* Slider inside flex row needs flex:1 */
.slider-row .stalk-slider {
  flex: 1;
  min-width: 0;
}

@keyframes handEnter {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes remainderPulse {
  0%, 100% {
    filter: brightness(var(--stick-tone, 1)) drop-shadow(0 0 0 rgba(159, 31, 31, 0));
  }
  50% {
    filter: brightness(1.08) drop-shadow(0 0 10px rgba(159, 31, 31, 0.65));
  }
}

/* ===== RESPONSIVE: narrow screens ===== */
@media (max-width: 400px) {
  .process-layout {
    flex-direction: column;
  }

  .hand-side {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .hand-svg {
    width: 160px;
  }

  .gq-row {
    grid-template-columns: 2.5em 0.8em 1fr auto;
    font-size: 0.76rem;
  }
}
