/* ===== CSS Variables & Reset ===== */
:root {
  --red: #E74C3C;
  --red-dark: #C0392B;
  --red-light: #FADBD8;
  --blue: #3498DB;
  --blue-dark: #2980B9;
  --blue-light: #D4E6F1;
  --green: #27AE60;
  --orange: #F39C12;
  --purple: #8E44AD;
  --bg: #F0F2F5;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6C757D;
  --border: #E2E8F0;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius: 14px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, #E74C3C 0%, #C0392B 50%, #922B21 100%);
  color: white;
  padding: 18px 0;
  box-shadow: 0 4px 20px rgba(231,76,60,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo { font-size: 22px; font-weight: 800; letter-spacing: 1px; }

.update-tag {
  font-size: 12px;
  background: rgba(255,255,255,0.2);
  padding: 4px 14px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* ===== Latest ===== */
.latest-section {
  max-width: 960px;
  margin: 20px auto 0;
  padding: 0 20px;
}

.latest-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.latest-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.latest-label { font-size: 17px; font-weight: 800; }
.latest-issue { font-size: 14px; color: var(--red); font-weight: 700; }
.latest-date { font-size: 13px; color: var(--text-secondary); }

/* ===== Ball ===== */
.ball-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ball-row.wrap { flex-wrap: wrap; }

.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 16px; font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.ball:hover { transform: scale(1.1); }

.ball.red {
  background: radial-gradient(circle at 35% 35%, #FF6B6B, var(--red) 60%, var(--red-dark));
  box-shadow: 0 3px 8px rgba(231,76,60,0.35);
}

.ball.blue {
  background: radial-gradient(circle at 35% 35%, #5DADE2, var(--blue) 60%, var(--blue-dark));
  box-shadow: 0 3px 8px rgba(52,152,219,0.35);
}

.ball.sm { width: 36px; height: 36px; font-size: 14px; }
.ball.xs { width: 30px; height: 30px; font-size: 12px; }
.ball-sep { font-size: 20px; color: var(--text-secondary); margin: 0 4px; }

/* ===== Tab Bar ===== */
.tab-bar {
  max-width: 960px;
  margin: 16px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 12px 24px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

.tab-btn:hover { color: var(--red); }

/* ===== Content ===== */
.content-section {
  max-width: 960px;
  margin: 0 auto 20px;
  padding: 0 20px;
}

.content-section > div {
  background: var(--card);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ===== Section Title ===== */
.section-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}

.section-subtitle {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

/* ===== Picks Header ===== */
.picks-header { margin-bottom: 20px; }

.picks-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.picks-mode-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn {
  flex: 1;
  min-width: 100px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
  text-align: center;
}

.mode-btn:hover { border-color: var(--red); color: var(--red); }

.mode-btn.active {
  background: var(--red);
  color: white;
  border-color: var(--red);
}


/* ===== Plan Cards ===== */
.plan-list {
  display: grid;
  gap: 12px;
  transition: opacity 0.3s, transform 0.3s;
}

.plan-list.plans-refreshing {
  opacity: 0.3;
  transform: scale(0.98);
}

.plan-card {
  padding: 14px 16px;
  background: linear-gradient(135deg, #FAFAFA, #FFF);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.plan-card:hover {
  border-color: var(--red-light);
  box-shadow: 0 4px 16px rgba(231,76,60,0.08);
}

.plan-card.complex {
  border-left: 4px solid var(--blue);
}

.plan-card.complex:hover {
  border-color: var(--blue-light);
  border-left-color: var(--blue);
  box-shadow: 0 4px 16px rgba(52,152,219,0.08);
}

.plan-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.plan-name {
  font-size: 14px;
  font-weight: 700;
}

.plan-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
}

.plan-badge.single {
  background: var(--red-light);
  color: var(--red-dark);
}

.plan-badge.complex {
  background: var(--blue-light);
  color: var(--blue-dark);
}

.plan-cost {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
}

.plan-method {
  margin-top: 8px;
}

.method-label {
  font-size: 12px;
  color: var(--purple);
  font-weight: 600;
}

/* ===== Refresh ===== */
.btn-refresh-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh-sm:hover {
  border-color: var(--red);
  background: #FEF5F5;
}


.refresh-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.refresh-bar.top {
  border-top: none;
  border-bottom: 1px solid var(--border);
  margin-top: 0;
  margin-bottom: 12px;
  padding-top: 0;
}

.refresh-bar.right-align {
  justify-content: flex-end;
}

.refresh-bar.right-align .refresh-hint {
  margin-right: auto;
}

.refresh-bar.with-config {
  flex-wrap: wrap;
  gap: 8px;
}

.inline-complex-config {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #F8F9FA;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.config-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.config-label-sm {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.stepper.mini {
  border-width: 1px;
  border-radius: 6px;
}

.stepper.mini button {
  width: 26px;
  height: 26px;
  font-size: 14px;
}

.stepper.mini .stepper-input {
  width: 34px;
  font-size: 13px;
}

.btn-regen {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 2px 8px rgba(231,76,60,0.25);
}

.btn-regen:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(231,76,60,0.4);
}

.refresh-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Complex Balls ===== */
.complex-balls { display: grid; gap: 10px; }

.cg {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cg-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ===== Tips Box ===== */
.tips-box {
  padding: 12px 16px;
  background: #F8F9FA;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.tips-formula {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* ===== DIY Picks ===== */
.weight-panel {
  margin-bottom: 16px;
}

.weight-panel h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.weight-sliders { display: grid; gap: 10px; }

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-row label {
  width: 90px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.slider-row input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--red);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(231,76,60,0.3);
}

.weight-val {
  width: 40px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  text-align: right;
}

/* ===== Stepper ===== */

.stepper {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper button {
  width: 36px; height: 36px;
  border: none;
  background: #F8F9FA;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text);
}

.stepper button:hover { background: var(--red-light); color: var(--red); }

.stepper-input {
  width: 44px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
  border: none;
  outline: none;
  background: transparent;
  -moz-appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}


.diy-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Random ===== */
.random-opts {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}


/* ===== Shaking ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-8px) rotate(-2deg); }
  20% { transform: translateX(8px) rotate(2deg); }
  30% { transform: translateX(-6px) rotate(-1deg); }
  40% { transform: translateX(6px) rotate(1deg); }
  50% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.shaking { animation: shake 0.6s ease-in-out; }

/* ===== Search ===== */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--red); }

.year-select {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  background: white;
  cursor: pointer;
}

.loading-hint {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== History Table ===== */
.history-table-wrap { overflow-x: auto; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.history-table th {
  background: #F8F9FA;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.history-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.history-table tr:hover td { background: #FEF5F5; }
.issue-cell { font-weight: 600; color: var(--red); white-space: nowrap; }
.date-cell { color: var(--text-secondary); white-space: nowrap; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0 4px;
}

.pagination button {
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 14px; color: var(--text-secondary); }

/* ===== Chart ===== */
.chart-section { margin-bottom: 24px; }

.chart-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chart-tab {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-tab.active {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.chart-container {
  position: relative;
  height: 300px;
  margin-bottom: 20px;
}

.chart-container canvas { max-height: 300px; }

/* ===== Structure ===== */
.structure-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.struct-grid { display: grid; gap: 10px; }

.struct-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.struct-label {
  width: 80px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.struct-bar {
  flex: 1;
  height: 22px;
  background: #F0F0F0;
  border-radius: 11px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 11px;
  transition: width 0.6s ease;
}

.bar-fill.zone1 { background: linear-gradient(90deg, #E74C3C, #FF6B6B); }
.bar-fill.zone2 { background: linear-gradient(90deg, #F39C12, #F1C40F); }
.bar-fill.zone3 { background: linear-gradient(90deg, #3498DB, #5DADE2); }
.bar-fill.odd { background: linear-gradient(90deg, #9B59B6, #BB8FCE); }
.bar-fill.even { background: linear-gradient(90deg, #1ABC9C, #48C9B0); }

.struct-val {
  width: 45px;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

/* ===== Methods Section ===== */
.methods-intro {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.methods-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.method-card {
  padding: 16px;
  background: #F8F9FA;
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.method-card:hover {
  border-color: var(--purple);
  box-shadow: 0 4px 12px rgba(142,68,173,0.08);
}

.mc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.mc-icon { font-size: 24px; }

.mc-head h4 {
  font-size: 14px;
  font-weight: 700;
}

.mc-source {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-secondary);
  background: white;
  padding: 1px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.mc-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.mc-detail {
  font-size: 12px;
  color: var(--text);
  background: white;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  line-height: 1.6;
}

.mc-detail-label {
  font-weight: 700;
  color: var(--orange);
}

.mc-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mc-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--purple);
  font-weight: 600;
}

.methods-disclaimer {
  margin-top: 16px;
  padding: 14px 16px;
  background: #FFF3CD;
  border-radius: var(--radius-sm);
  border: 1px solid #FFE082;
}

.methods-disclaimer p {
  font-size: 12px;
  color: #856404;
  line-height: 1.6;
}

/* ===== Footer ===== */
.footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 30px;
  text-align: center;
}

.footer p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.footer-info { margin-top: 6px; }
.footer a { color: var(--blue); text-decoration: none; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .logo { font-size: 18px; }
  .ball { width: 36px; height: 36px; font-size: 14px; }
  .ball.sm { width: 30px; height: 30px; font-size: 12px; }
  .ball.xs { width: 26px; height: 26px; font-size: 11px; }
  .tab-btn { padding: 10px 14px; font-size: 13px; }
  .search-bar { flex-direction: column; }
  .mode-btn { min-width: 80px; padding: 8px 10px; font-size: 13px; }
  .slider-row label { width: 80px; }
  .methods-grid { grid-template-columns: 1fr; }
  .plan-cost { margin-left: 0; }
}
