:root {
  --paper: #f3ecdd;
  --paper-deep: #e9e0cc;
  --card: #fffaf1;
  --ink: #1f1a14;
  --ink-soft: #3d352b;
  --line: #d8cbb2;
  --red: #b23a2e;
  --red-deep: #8f2c23;
  --gold: #b8892f;
  --gold-soft: #d8b75f;
  --jade: #2f7d5b;
  --blue: #315f87;
  --el-wood: #2f7d5b;
  --el-fire: #c04438;
  --el-earth: #a57a24;
  --el-metal: #7d8773;
  --el-water: #2f5d8a;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(31, 26, 20, 0.025) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, rgba(31, 26, 20, 0.02) 0 1px, transparent 1px 26px),
    var(--paper);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  background:
    repeating-linear-gradient(115deg, rgba(216, 183, 95, 0.12) 0 1px, transparent 1px 14px),
    var(--ink);
  color: #f4ead6;
  padding: 16px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 3px solid var(--gold);
}

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

.brand-seal {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 2px solid var(--gold-soft);
  border-radius: 8px;
  color: var(--gold-soft);
  font-size: 30px;
  background: rgba(216, 183, 95, 0.08);
  box-shadow: inset 0 0 0 3px rgba(216, 183, 95, 0.12);
}

.brand-text h1 {
  font-family: "STKaiti", "KaiTi", "FangSong", serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-text p {
  font-size: 13px;
  color: #cbb98f;
  margin-top: 2px;
}

.topbar-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.chip-red { color: #ef9b8d; }
.chip-jade { color: #8cc4a8; }
.chip-gold { color: var(--gold-soft); }

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  position: sticky;
  top: 18px;
  box-shadow: 0 8px 24px rgba(60, 45, 20, 0.08);
}

.form-block + .form-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.block-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 4px solid var(--red);
  line-height: 1.2;
}

.field {
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.mini-field {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.field input,
.field select,
.mini-field input,
.mini-field select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus,
.mini-field input:focus,
.mini-field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 47, 0.18);
}

.upload-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  border: 2px dashed #c9b98f;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  cursor: pointer;
  background: #fbf6e9;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone svg {
  color: var(--red);
  flex: 0 0 auto;
}

.upload-zone:hover,
.upload-zone.busy {
  border-color: var(--red);
  background: #fdf1e8;
}

.upload-tools {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-ghost {
  flex: 1;
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  border-color: var(--gold);
  color: var(--ink);
  background: #fbf3df;
}

.btn-primary {
  width: 100%;
  margin-top: 16px;
  padding: 13px;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(180deg, #c64a3b, var(--red));
  border-color: var(--red-deep);
  box-shadow: 0 6px 16px rgba(178, 58, 46, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 8px 20px rgba(178, 58, 46, 0.38);
}

.ticket-count {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: right;
}

.mini-note {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  color: #8a7c63;
}

.stage {
  min-width: 0;
}

.hex-panel {
  background:
    repeating-linear-gradient(135deg, rgba(216, 183, 95, 0.07) 0 1px, transparent 1px 12px),
    var(--ink);
  color: #f2e8d3;
  border: 1px solid #3a3125;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 10px 28px rgba(31, 26, 20, 0.22);
}

.hex-panel-inner {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hex-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.hex-card {
  background: rgba(255, 250, 241, 0.04);
  border: 1px solid rgba(216, 183, 95, 0.35);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.hex-card.changed {
  opacity: 0.88;
}

.hex-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--gold-soft);
  border: 1px solid rgba(216, 183, 95, 0.45);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 12px;
}

.hex-glyph {
  display: flex;
  justify-content: center;
}

.hex-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.line {
  position: relative;
  width: 84px;
  height: 8px;
  border-radius: 2px;
}

.line.yang {
  background: var(--gold-soft);
}

.line.yin {
  background: linear-gradient(90deg, var(--gold-soft) 0 36%, transparent 36% 64%, var(--gold-soft) 64% 100%);
}

.line.move {
  background: #e67a6c;
  box-shadow: 0 0 8px rgba(230, 122, 108, 0.7);
}

.move-mark {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e67a6c;
  box-shadow: 0 0 6px rgba(230, 122, 108, 0.8);
}

.hex-title {
  margin-top: 12px;
  font-size: 21px;
  font-family: "STKaiti", "KaiTi", serif;
  color: #ffe9b0;
  font-weight: 700;
}

.hex-sub {
  margin-top: 4px;
  font-size: 12px;
  color: #b9a982;
}

.hex-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--gold-soft);
}

.move-chip {
  font-size: 13px;
  border: 1px solid rgba(216, 183, 95, 0.4);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.hex-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-block;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fbf5e8;
  color: var(--ink-soft);
  white-space: nowrap;
}

.pill.grade-大吉,
.pill.grade-吉 {
  color: var(--jade);
  border-color: rgba(47, 125, 91, 0.4);
  background: #eef7f1;
}

.pill.grade-凶 {
  color: var(--red);
  border-color: rgba(178, 58, 46, 0.4);
  background: #fbece9;
}

.tickets-section {
  margin-top: 22px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 18px;
  font-weight: 700;
}

.section-head > span {
  font-size: 13px;
  color: var(--red);
  font-weight: 600;
}

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

.ticket-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  animation: rise 0.4s ease both;
  transition: box-shadow 0.25s, border-color 0.25s;
}

.ticket-card:nth-child(2) { animation-delay: 0.04s; }
.ticket-card:nth-child(3) { animation-delay: 0.08s; }
.ticket-card:nth-child(4) { animation-delay: 0.12s; }
.ticket-card:nth-child(5) { animation-delay: 0.16s; }
.ticket-card:nth-child(6) { animation-delay: 0.2s; }
.ticket-card:nth-child(7) { animation-delay: 0.24s; }
.ticket-card:nth-child(8) { animation-delay: 0.28s; }

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

.ticket-card.best {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(184, 137, 47, 0.32),
    0 12px 30px rgba(120, 82, 16, 0.18);
  animation: glowPulse 2.4s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(184, 137, 47, 0.32),
      0 12px 30px rgba(120, 82, 16, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(184, 137, 47, 0.48),
      0 14px 36px rgba(120, 82, 16, 0.26);
  }
}

.pick-badge {
  position: absolute;
  top: 10px;
  right: -28px;
  transform: rotate(38deg);
  width: 96px;
  text-align: center;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pick-badge.best {
  background: var(--red);
}

.pick-badge.second {
  background: var(--jade);
}

.pick-badge.third {
  background: var(--blue);
}

.ticket-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
}

.ticket-idx {
  font-weight: 700;
  font-size: 13px;
}

.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.badge.el-badge {
  color: #fff;
  border-color: transparent;
}

.el-木 .badge.el-badge { background: var(--el-wood); }
.el-火 .badge.el-badge { background: var(--el-fire); }
.el-土 .badge.el-badge { background: var(--el-earth); }
.el-金 .badge.el-badge { background: var(--el-metal); }
.el-水 .badge.el-badge { background: var(--el-water); }

.rel-good {
  color: var(--jade);
  border-color: rgba(47, 125, 91, 0.4);
  background: #eef7f1;
}

.rel-flat {
  color: #8a7a55;
}

.rel-bad {
  color: var(--red);
  border-color: rgba(178, 58, 46, 0.4);
  background: #fbece9;
}

.ticket-art {
  height: 118px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.el-木 .ticket-art { background: linear-gradient(135deg, #2f7d5b, #a8d5b3); }
.el-火 .ticket-art { background: linear-gradient(135deg, #c04438, #f0a08b); }
.el-土 .ticket-art { background: linear-gradient(135deg, #b8892f, #ead7a5); }
.el-金 .ticket-art { background: linear-gradient(135deg, #7d8773, #e4e9e6); }
.el-水 .ticket-art { background: linear-gradient(135deg, #2f5d8a, #a8c4dc); }

.ticket-art.photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ticket-art.photo .ticket-name {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #fff;
  background: rgba(20, 15, 10, 0.55);
  border-radius: 4px;
  padding: 2px 8px;
}

.ticket-face {
  width: 148px;
  height: 86px;
  border-radius: 6px;
  background: #fffaf0;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 14px rgba(20, 15, 10, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: relative;
}

.ticket-name {
  font-weight: 700;
  font-size: 15px;
  color: #2c241a;
}

.ticket-no {
  font-size: 11px;
  color: #6f6250;
  font-family: Consolas, monospace;
}

.scratch-zone {
  width: 92px;
  height: 20px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0 5px, rgba(31, 26, 20, 0.5) 5px 10px);
  border: 1px solid rgba(31, 26, 20, 0.35);
}

.ticket-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 6px;
}

.mini-field select,
.mini-field input {
  padding: 6px 7px;
  font-size: 12px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 8px;
}

.score-num {
  font-size: 18px;
  font-weight: 800;
  min-width: 34px;
}

.meter {
  flex: 1;
  height: 9px;
  border-radius: 999px;
  background: #ece2cd;
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--jade), #6fae8c);
  transition: width 0.5s ease;
}

.ticket-card.el-火 .meter i { background: linear-gradient(90deg, var(--red), #e08372); }
.ticket-card.el-土 .meter i { background: linear-gradient(90deg, var(--gold), #d5b25f); }
.ticket-card.el-金 .meter i { background: linear-gradient(90deg, var(--el-metal), #aeb6a5); }
.ticket-card.el-水 .meter i { background: linear-gradient(90deg, var(--blue), #6f9cc4); }

.score-grade {
  font-size: 12px;
  font-weight: 700;
  min-width: 30px;
  text-align: right;
}

.g-大吉 { color: var(--jade); }
.g-吉 { color: var(--jade); }
.g-平 { color: #8a7a55; }
.g-慎 { color: var(--gold); }
.g-避 { color: var(--red); }

.ticket-tags {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 12px 12px;
  font-size: 11px;
  color: var(--ink-soft);
  border-top: 1px dashed var(--line);
}

.ticket-tags .sub {
  color: #8a7c63;
}

.empty {
  grid-column: 1 / -1;
  padding: 42px 20px;
  text-align: center;
  color: #8a7c63;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.5);
}

.reading-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.reading-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-head h3 {
  font-size: 15px;
  font-weight: 700;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.pillar {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 4px;
  text-align: center;
  background: #fffdf7;
}

.pillar-label {
  display: block;
  font-size: 11px;
  color: #8a7c63;
  margin-bottom: 4px;
}

.gan,
.zhi {
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
}

.zhi {
  margin-left: 2px;
}

.el-text-木 { color: var(--el-wood); }
.el-text-火 { color: var(--el-fire); }
.el-text-土 { color: var(--el-earth); }
.el-text-金 { color: var(--el-metal); }
.el-text-水 { color: var(--el-water); }

.reading-line {
  font-size: 13px;
  line-height: 1.75;
  margin-bottom: 6px;
}

.reading-line b {
  font-weight: 700;
}

.reading-line.sub {
  color: #8a7c63;
  font-size: 12px;
}

.tip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tip {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}

.tip span {
  flex: 0 0 52px;
  font-size: 12px;
  color: #8a7c63;
}

.tip b {
  font-weight: 600;
}

.method {
  margin-top: 22px;
  background: rgba(255, 250, 241, 0.65);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.method summary {
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 18px;
}

.method summary::after {
  content: "+";
  position: absolute;
  right: 0;
  color: var(--red);
  font-weight: 700;
}

.method[open] summary::after {
  content: "−";
}

.method p {
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-soft);
  margin-top: 10px;
}

.foot {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 22px 26px;
  text-align: center;
  font-size: 12px;
  color: #8a7c63;
  line-height: 1.8;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    position: static;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 620px) {
  .layout {
    padding: 14px;
  }

  .hex-main {
    grid-template-columns: 1fr;
  }

  .hex-mid {
    flex-direction: row;
  }

  .hex-mid svg {
    transform: rotate(90deg);
  }

  .upload-tools {
    flex-direction: column;
  }

  .ticket-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .ticket-grid {
    grid-template-columns: 1fr;
  }
}
