:root {
  --panel: #fffdf9;
  --panel-2: #fbf1e3;
  --panel-3: #f6e5da;
  --hairline: rgba(200, 140, 90, 0.24);
  --gold: #dba448;
  --gold-soft: #c0801f;
  --plum: #a56b8a;
  --plum-soft: #8a5170;
  --sage: #6f9a6a;
  --sage-soft: #557d51;
  --ink: #4a3428;
  --muted: #8a7360;
  --muted-dim: #ab9683;
  --shadow: rgba(180, 120, 80, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: linear-gradient(180deg, #fdf0dd 0%, #f9e6dd 45%, #f3dde6 100%);
  color: var(--ink);
  padding: 32px 16px 80px;
}

[hidden] { display: none !important; }

.app { max-width: 960px; margin: 0 auto; }

.site-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.nav-link {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--hairline);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.nav-link:hover { color: var(--gold-soft); border-color: rgba(219, 164, 72, 0.6); background: #fff; }

.header { text-align: center; margin-bottom: 10px; }

.header h1 {
  font-size: 2rem;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  color: var(--gold-soft);
}

.tagline {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.subtitle { color: var(--muted); font-size: 0.95rem; margin-bottom: 20px; }

.visit-counter { color: var(--muted-dim); font-size: 0.78rem; }

.controls {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 46px var(--shadow);
}

.draw-choice { display: flex; gap: 12px; }

.draw-btn {
  padding: 14px 28px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: rgba(165, 107, 138, 0.08);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, border-color 0.2s;
}

.draw-btn .count {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-soft);
  margin-bottom: 2px;
}

.draw-btn:hover { transform: translateY(-2px); background: rgba(165, 107, 138, 0.16); }
.draw-btn.active { border-color: var(--gold); background: rgba(219, 164, 72, 0.16); }
.draw-btn.active .count { color: var(--gold-soft); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn-primary, .btn-secondary {
  font-family: inherit;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
}

.btn-primary {
  padding: 13px 24px;
  border: none;
  background: linear-gradient(120deg, var(--gold), #c98a3a);
  color: #3a2a14;
  font-size: 0.95rem;
  box-shadow: 0 8px 22px rgba(219, 164, 72, 0.4);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(219, 164, 72, 0.55); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  padding: 13px 18px;
  border: 1px solid var(--hairline);
  background: #fff;
  color: var(--gold-soft);
  font-size: 0.9rem;
}

.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary:not(:disabled):hover { background: var(--panel-2); }

.status { text-align: center; margin: 36px 0; color: var(--muted); }

.shuffle-anim { position: relative; width: 100px; height: 140px; margin: 0 auto 12px; }

.shuffle-card {
  position: absolute;
  width: 70px;
  height: 100px;
  left: 15px;
  top: 20px;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--panel-2), var(--panel));
  border: 1px solid var(--hairline);
  box-shadow: 0 6px 16px var(--shadow);
  animation: shuffleMove 0.9s ease-in-out infinite;
}

.shuffle-card.c1 { animation-delay: 0s; }
.shuffle-card.c2 { animation-delay: 0.15s; }
.shuffle-card.c3 { animation-delay: 0.3s; }

@keyframes shuffleMove {
  0% { transform: translateX(-24px) rotate(-8deg); }
  50% { transform: translateX(24px) rotate(8deg); }
  100% { transform: translateX(-24px) rotate(-8deg); }
}

.reading { margin-top: 20px; }

.text-block { margin-top: 28px; }

.text-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold-soft);
  margin: 0 0 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.text-hint {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--muted-dim);
}

.result-textarea {
  width: 100%;
  max-width: 520px;
  display: block;
  resize: vertical;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
  background: #fffaf2;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.result-textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  justify-content: center;
}

.daily-card { width: 158px; cursor: pointer; }

.card-position {
  text-align: center;
  font-size: 0.76rem;
  color: var(--muted-dim);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 220px;
  transition: transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}

.daily-card.revealed .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 10px;
}

.card-back {
  background:
    radial-gradient(circle at 50% 30%, rgba(219, 164, 72, 0.22), transparent 55%),
    linear-gradient(150deg, var(--panel-2), var(--panel-3));
  border: 1.5px solid var(--hairline);
  box-shadow: 0 10px 26px var(--shadow);
}

.card-back::after {
  content: "\2600";
  font-size: 1.8rem;
  color: rgba(192, 128, 31, 0.7);
}

.card-front {
  background: linear-gradient(165deg, #fffaf2, #fbeee0);
  border: 1.5px solid var(--gold);
  transform: rotateY(180deg);
  box-shadow: 0 10px 26px var(--shadow);
}

.card-front .card-part {
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: var(--plum-soft);
  margin-bottom: 8px;
  line-height: 1.4;
}

.card-front .card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold-soft);
  line-height: 1.35;
}

.card-front .card-en {
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 5px;
  font-style: italic;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(90, 60, 40, 0.32);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.detail-card {
  max-width: 420px;
  width: 100%;
  background: linear-gradient(165deg, #fffaf2, #fbeee0);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 28px;
  position: relative;
  box-shadow: 0 30px 70px rgba(120, 80, 50, 0.28);
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
}
.detail-close:hover { color: var(--ink); }

.detail-card .detail-part {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--plum-soft);
  margin-bottom: 10px;
  line-height: 1.5;
}

.detail-card h3 {
  color: var(--gold-soft);
  margin: 0 0 4px;
  font-size: 1.3rem;
}

.detail-card .en-name {
  color: var(--muted);
  font-style: italic;
  margin-bottom: 18px;
  font-size: 0.85rem;
}

.detail-block { margin-bottom: 16px; }
.detail-block:last-child { margin-bottom: 0; }

.detail-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.detail-label.guide { color: var(--gold-soft); }
.detail-label.action { color: var(--sage-soft); }

.detail-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.7;
  font-size: 0.95rem;
}

.detail-block.guide p { font-style: italic; }

footer.note {
  text-align: center;
  color: var(--muted-dim);
  font-size: 0.76rem;
  margin-top: 46px;
}

@media (max-width: 560px) {
  .daily-card { width: 128px; }
  .card-inner { height: 178px; }
  .controls { padding: 20px; }
  .draw-choice { width: 100%; justify-content: center; }
}
