/* 每日祈願籤（fortune）樣式。全部以 .fortune- 前綴與大廳樣式隔離；
   視覺改編自 temp/抽籤.html（Tailwind 版），此處為純 CSS、零外部資源。
   毛筆字體：自架子集字型（見 pb_public/vendor/fonts/），缺字退化為系統楷體。 */

@font-face {
  font-family: "FortuneBrush";
  src: url("/vendor/fonts/fortune-brush.woff2") format("woff2");
  font-display: swap;
}

.fortune-brush {
  font-family: "FortuneBrush", "DFKai-SB", "BiauKai", "Kaiti TC", "STKaiti", serif;
}

/* 保險：不依賴全域 .is-hidden 定義 */
.fortune-overlay.is-hidden,
.fortune-overlay .is-hidden,
.fortune-card-extra .is-hidden {
  display: none !important;
}

/* ===== 大廳卡片左側：mini 籤筒 + 狀態列 ===== */
.fortune-card-extra {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fortune-mini {
  position: relative;
  flex: none;
  width: 46px;
  height: 62px;
  cursor: pointer;
}

.fortune-mini-sticks {
  position: absolute;
  top: -10px;
  left: 50%;
  display: flex;
  gap: 3px;
  transform: translateX(-50%);
}

.fortune-mini-sticks i {
  width: 5px;
  height: 20px;
  background: #cca95e;
  border-radius: 2px 2px 0 0;
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.15);
}

.fortune-mini-sticks i:nth-child(1) { transform: rotate(-10deg); height: 16px; }
.fortune-mini-sticks i:nth-child(3) { transform: rotate(9deg); height: 17px; }

.fortune-mini-body {
  position: absolute;
  inset: 6px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(105deg, #44403c, #292524 55%, #1c1917);
  border: 1px solid #57534e;
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--shadow, rgba(0, 0, 0, 0.35));
}

.fortune-mini-body::before,
.fortune-mini-body::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #b45309, #f59e0b, #b45309);
}

.fortune-mini-body::before { top: 0; border-radius: 7px 7px 0 0; }
.fortune-mini-body::after { bottom: 0; border-radius: 0 0 7px 7px; }

.fortune-mini-body span {
  color: #fde68a;
  font-size: 22px;
  line-height: 1;
}

.fortune-card-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fortune-card-state {
  font-size: 13px;
  font-weight: 700;
  color: #7a4a00;
}

.fortune-card-state.is-ready {
  color: #b91c1c;
}

.fortune-my-status {
  font-size: 12px;
  color: #555;
}

/* 每日榜：自己那一列高亮 */
.fortune-me {
  background: #fff3cf;
  outline: 1px solid #d9a13b;
}

.fortune-me-pinned {
  margin-top: 4px;
  border-top: 1px dashed #b8a06a;
}

.fortune-score-cell {
  font-variant-numeric: tabular-nums;
}

/* ===== 動畫 keyframes（移植自參考檔） ===== */
@keyframes fortuneShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  10% { transform: translate(-3px, -2px) rotate(-6deg); }
  20% { transform: translate(3px, 1px) rotate(5deg); }
  30% { transform: translate(-3px, -1px) rotate(-5deg); }
  40% { transform: translate(2px, 2px) rotate(4deg); }
  50% { transform: translate(-2px, -2px) rotate(-4deg); }
  60% { transform: translate(3px, 1px) rotate(3deg); }
  70% { transform: translate(-3px, 1px) rotate(-3deg); }
  80% { transform: translate(2px, -1px) rotate(2deg); }
  90% { transform: translate(-1px, 2px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.fortune-shake {
  animation: fortuneShake 1.5s ease-in-out infinite;
}

@keyframes fortuneStickUp {
  0% { transform: translate(-50%, 0) scale(1) rotate(0deg); opacity: 0.85; }
  30% { transform: translate(-50%, -80px) scale(1.1) rotate(5deg); opacity: 1; }
  60% { transform: translate(-50%, -200px) scale(1.3) rotate(-10deg); opacity: 1; }
  100% { transform: translate(-50%, -320px) scale(1.5) rotate(0deg); opacity: 0; }
}

.fortune-stick-draw {
  animation: fortuneStickUp 1.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes fortuneFadeIn {
  from { opacity: 0; transform: scale(0.92) translateY(24px); filter: blur(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

/* ===== Overlay 骨架 ===== */
.fortune-overlay {
  position: fixed;
  inset: 0;
  z-index: 260; /* 高於大廳內容即可；dialog 是 top-layer 不受影響 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.fortune-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 10, 9, 0.86);
}

.fortune-panel {
  position: relative;
  z-index: 1;
  max-width: 880px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.fortune-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border: 1px solid #a8a29e;
  border-radius: 50%;
  background: rgba(28, 25, 23, 0.8);
  color: #e7e5e4;
  font-size: 15px;
  cursor: pointer;
}

/* ===== 抽籤舞台（籤筒） ===== */
.fortune-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px 40px;
  color: #e7e5e4;
}

.fortune-stage-title {
  font-size: 40px;
  letter-spacing: 0.18em;
  color: #fde68a;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.6);
}

.fortune-stage-hint {
  font-size: 14px;
  letter-spacing: 0.12em;
  color: #d6d3d1;
}

.fortune-cylinder-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 96px; /* 留竹籤飛出的空間 */
}

/* 籤筒本體（176×256，配色移植參考檔的 stone/amber） */
.fortune-cylinder {
  position: relative;
  width: 176px;
  height: 256px;
}

.fortune-sticks {
  position: absolute;
  top: -58px;
  left: 50%;
  z-index: 0;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  transform: translateX(-50%);
}

.fortune-sticks i {
  width: 12px;
  background: #cca95e;
  border-right: 1px solid rgba(68, 52, 22, 0.25);
  border-radius: 3px 3px 0 0;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.25);
  transform-origin: bottom;
}

.fortune-sticks i:nth-child(1) { height: 92px; background: #d8b871; transform: rotate(-12deg) translateY(14px); }
.fortune-sticks i:nth-child(2) { height: 110px; transform: rotate(-5deg); }
.fortune-sticks i:nth-child(3) { height: 124px; transform: rotate(2deg) translateY(-6px); }
.fortune-sticks i:nth-child(4) { height: 102px; background: #be9c51; transform: rotate(8deg) translateY(8px); }
.fortune-sticks i:nth-child(5) { height: 92px; background: #aa873f; transform: rotate(15deg) translateY(18px); }

.fortune-cylinder-body {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(100deg, #44403c, #3b3734 45%, #1c1917);
  border: 2px solid #57534e;
  border-radius: 18px;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.5);
}

.fortune-cylinder-body::before,
.fortune-cylinder-body::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 14px;
  background: linear-gradient(90deg, #b45309, #f59e0b 50%, #b45309);
}

.fortune-cylinder-body::before { top: 0; border-radius: 16px 16px 0 0; border-bottom: 1px solid #1c1917; }
.fortune-cylinder-body::after { bottom: 0; border-radius: 0 0 16px 16px; border-top: 1px solid #1c1917; }

.fortune-cylinder-label {
  padding: 18px 10px;
  background: rgba(254, 243, 199, 0.92);
  border: 2px solid #92400e;
  border-radius: 6px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  color: #1c1917;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.3em;
  writing-mode: vertical-rl;
}

.fortune-cylinder-shadow {
  width: 190px;
  height: 18px;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  filter: blur(6px);
}

/* 飛出的單支竹籤 */
.fortune-stick-fly {
  position: absolute;
  bottom: 120px;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 210px;
  background: linear-gradient(180deg, #e5ca93, #cdab62 55%, #997733);
  border: 1px solid rgba(120, 88, 33, 0.4);
  border-radius: 9px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, 0);
}

.fortune-stick-fly span {
  color: #1c1917;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  writing-mode: vertical-rl;
}

/* ===== 結果視圖：左籤詩卡 + 右每日榜 ===== */
.fortune-result {
  display: flex;
  align-items: stretch;
  gap: 14px;
  animation: fortuneFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* 宣紙質感卡（noise 為內嵌 SVG，無外部請求） */
.fortune-result-card {
  flex: 1;
  min-width: 0;
  padding: 22px 22px 18px;
  background-color: #fdfaf2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  border: 6px double #292524;
  border-radius: 14px;
  box-shadow: inset 0 0 36px rgba(220, 210, 190, 0.5), 0 10px 30px rgba(0, 0, 0, 0.4);
  color: #292524;
}

.fortune-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.fortune-sign-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
  border-left: 4px solid #292524;
}

.fortune-sign-tag {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: #57534e;
}

.fortune-sign-no {
  font-size: 19px;
  letter-spacing: 0.12em;
  font-weight: 700;
}

/* 朱砂印章（等級決定顏色） */
.fortune-seal {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  min-height: 68px;
  padding: 4px;
  border: 3px double currentColor;
  border-radius: 10px;
  box-shadow: 0 0 0 2px #f8f9fa, inset 0 0 0 2px currentColor;
  background: rgba(201, 42, 42, 0.05);
  font-size: 26px;
  letter-spacing: 0.1em;
  transform: rotate(-5deg);
}

.fortune-seal.is-daji { color: #b81d22; }
.fortune-seal.is-ji { color: #d9480f; }
.fortune-seal.is-ping { color: #868e96; }
.fortune-seal.is-xiong { color: #1c1c1c; }

.fortune-score-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 4px;
}

.fortune-score-label {
  font-size: 12px;
  letter-spacing: 0.25em;
  color: #78716c;
}

.fortune-score-num {
  font-size: 72px;
  line-height: 1;
  font-weight: 800;
  color: #1c1917;
}

.fortune-score-unit {
  font-size: 13px;
  color: #78716c;
}

.fortune-poem {
  margin: 8px 0 12px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(214, 211, 209, 0.6);
  border-radius: 10px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.fortune-poem p {
  margin: 2px 0;
  font-size: 24px;
  letter-spacing: 0.14em;
  color: #292524;
}

.fortune-notice {
  margin: 0 0 10px;
  padding: 7px 10px;
  background: #f4f0e4;
  border: 1px dashed #b8a06a;
  border-radius: 8px;
  font-size: 13px;
  color: #7a4a00;
  text-align: center;
}

.fortune-notice.is-improved {
  background: #fdeaea;
  border-color: #c97979;
  color: #b81d22;
  font-weight: 700;
}

.fortune-analyses {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.fortune-analysis {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(231, 229, 228, 0.4);
  border: 1px solid rgba(214, 211, 209, 0.35);
  border-radius: 8px;
}

.fortune-analysis-tag {
  flex: none;
  margin-top: 1px;
  padding: 1px 7px;
  background: #292524;
  border-radius: 4px;
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.fortune-analysis p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: #44403c;
}

.fortune-accept {
  display: block;
  width: 100%;
  padding: 10px 0;
  background: #1c1917;
  border: 1px solid #92400e;
  border-radius: 999px;
  color: #fde68a;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.15em;
  cursor: pointer;
}

.fortune-accept:hover {
  background: #292524;
}

/* 右側：今日榜 */
.fortune-result-board {
  flex: none;
  display: flex;
  flex-direction: column;
  width: 252px;
  background: #f3efe4;
  border: 2px solid #d6cdb4;
  border-radius: 12px;
  overflow: hidden;
  animation: fortuneFadeIn 0.9s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.fortune-board-title {
  padding: 8px 12px;
  background: #292524;
  color: #fde68a;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.fortune-board-list {
  flex: 1;
  align-content: start; /* 覆蓋 .login-leaderboard-list 的 grid 拉伸，列數少時不撐開列距 */
  max-height: 460px;
  margin: 0;
  padding: 8px 10px 10px;
  overflow-y: auto;
  list-style: none;
  color: #292524;
}

/* ===== 手機版 ===== */
@media (max-width: 760px) {
  .fortune-stage-title { font-size: 30px; }
  .fortune-cylinder { width: 140px; height: 208px; }
  .fortune-cylinder-wrap { padding-top: 72px; }
  .fortune-stick-fly { height: 168px; bottom: 96px; }
  .fortune-cylinder-label { font-size: 21px; padding: 13px 8px; }

  .fortune-result {
    flex-direction: column;
  }

  .fortune-result-board {
    width: 100%;
  }

  .fortune-board-list {
    max-height: 220px;
  }

  .fortune-score-num { font-size: 58px; }
  .fortune-poem p { font-size: 20px; }
}
