:root {
  --bg: #0b1120;
  --panel: rgba(17, 24, 39, 0.9);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #94a3b8;

  --wood: #22c55e;
  --fire: #ef4444;
  --earth: #eab308;
  --metal: #cbd5e1;
  --water: #38bdf8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100dvh;
  background: radial-gradient(circle at 25% 15%, #1e293b 0%, #0b1120 75%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  touch-action: manipulation;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
}

.brand h1 {
  font-size: 1.1rem;
  font-weight: 800;
}

.cycle-tabs {
  display: flex;
  gap: 6px;
}

.tab-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(245, 158, 11, 0.25);
  border-color: #fbbf24;
  color: #fde68a;
}

/* Main Grid */
.main-grid {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 14px;
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  backdrop-filter: blur(10px);
}

/* Wheel Card */
.wheel-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wheel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.wuxing-filters,
.anim-controls {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.wx-btn,
.mini-btn {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.wx-btn.active { background: rgba(255, 255, 255, 0.2); border-color: #fff; }
.wx-btn.wood.active { background: rgba(34, 197, 94, 0.28); border-color: var(--wood); }
.wx-btn.fire.active { background: rgba(239, 68, 68, 0.28); border-color: var(--fire); }
.wx-btn.earth.active { background: rgba(234, 179, 8, 0.28); border-color: var(--earth); }
.wx-btn.metal.active { background: rgba(203, 213, 225, 0.28); border-color: var(--metal); }
.wx-btn.water.active { background: rgba(56, 189, 248, 0.28); border-color: var(--water); }

.wheel-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
}

#zodiac-svg {
  width: 100%;
  max-width: 620px;
  height: auto;
  display: block;
}

.sector-group {
  cursor: pointer;
  transition: opacity 0.15s;
}

.sector-group.dimmed {
  opacity: 0.22;
}

/* Info Column */
.info-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.lookup-row {
  display: flex;
  gap: 6px;
}

input[type="number"] {
  flex: 1;
  min-width: 80px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.primary-btn,
.secondary-btn {
  min-height: 40px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}

.primary-btn { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.secondary-btn { background: rgba(255, 255, 255, 0.1); border: 1px solid var(--border); }
.full-w { width: 100%; margin-top: 8px; }

/* Detail Card */
.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.year-badge {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.ganzhi-title {
  font-size: 1.75rem;
  font-weight: 900;
  color: #fde68a;
}

.zodiac-hero {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 2.2rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.d-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 10px;
}

.d-box span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}

.d-box strong {
  font-size: 0.95rem;
}

.related-years {
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Quiz Card */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.quiz-score {
  font-size: 0.78rem;
  color: #34d399;
}

.quiz-q {
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 10px;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.quiz-opt {
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.quiz-opt.correct { background: rgba(16, 185, 129, 0.3); border-color: #34d399; }
.quiz-opt.wrong { background: rgba(239, 68, 68, 0.3); border-color: #f87171; }

.quiz-feedback {
  margin-top: 8px;
  font-size: 0.82rem;
  min-height: 18px;
  color: #fde68a;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }
}
