/* =====================================================
   盧恩符文搖盅 — rune-shake.css
   ===================================================== */

/* === 全螢幕兌換代碼覆蓋層 === */
.redemption-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 2, 12, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.redemption-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.redemption-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding: 3rem 2.5rem;
  background: linear-gradient(145deg, rgba(20, 15, 30, 0.85), rgba(10, 5, 15, 0.95));
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(212, 175, 55, 0.04);
  max-width: 440px;
  width: 90%;
  animation: overlay-appear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlay-appear {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.redemption-overlay-icon {
  font-size: 3rem;
  color: #d4af37;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
  animation: slow-pulse 3s ease-in-out infinite;
}

@keyframes slow-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

.redemption-overlay-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #d4af37;
  letter-spacing: 0.15em;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
  margin: 0;
}

.redemption-overlay-desc {
  font-family: 'Noto Serif TC', serif;
  font-size: 0.9rem;
  color: #a0a0b0;
  margin: 0;
}

.redemption-overlay-input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(10, 5, 20, 0.7);
  border: 1px solid rgba(155, 93, 229, 0.35);
  border-radius: 12px;
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.redemption-overlay-input:focus {
  border-color: #d4af37;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.2);
}

.redemption-overlay-input::placeholder {
  color: rgba(160, 160, 176, 0.4);
  font-weight: 400;
  letter-spacing: 0.12em;
}

.redemption-overlay-btn {
  padding: 12px 36px;
  background: transparent;
  color: #d4af37;
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 30px;
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.redemption-overlay-btn:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.15);
  border-color: #d4af37;
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
  transform: translateY(-2px);
  color: #fff;
}

.redemption-overlay-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.redemption-overlay-error {
  font-family: 'Noto Serif TC', serif;
  font-size: 0.85rem;
  color: #ff6b6b;
  margin: 0;
  text-align: center;
}

.redemption-overlay-error.hidden {
  display: none;
}

/* === 固定頂部狀態列 === */
.top-status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8888;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  background: rgba(8, 4, 18, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  font-family: 'Noto Serif TC', serif;
  animation: bar-slide-down 0.4s ease-out;
}

@keyframes bar-slide-down {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

.top-status-bar.hidden {
  display: none;
}

.top-bar-back-btn {
  background: rgba(155, 93, 229, 0.12);
  border: 1px solid rgba(155, 93, 229, 0.35);
  color: var(--accent-glow, #d4a8ff);
  font-family: 'Noto Serif TC', serif;
  font-size: 0.82rem;
  padding: 0.3rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.top-bar-back-btn:hover {
  background: rgba(155, 93, 229, 0.25);
  box-shadow: 0 0 10px rgba(155, 93, 229, 0.3);
  transform: translateY(-1px);
}

.top-bar-divider {
  width: 1px;
  height: 20px;
  background: rgba(160, 160, 176, 0.25);
  flex-shrink: 0;
}

.top-bar-code {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #d4af37;
  letter-spacing: 0.12em;
  text-shadow: 0 0 6px rgba(212, 175, 55, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.top-bar-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.top-bar-toggle-label {
  font-size: 0.75rem;
  color: #a0a0b0;
}

.top-bar-remaining {
  font-size: 0.82rem;
  color: var(--gold, #f0c040);
  background: rgba(155, 93, 229, 0.12);
  padding: 0.25rem 0.7rem;
  border-radius: 16px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

/* Toggle switch (共用) */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(60, 60, 80, 0.6);
  transition: 0.3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #a0a0b0;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: rgba(212, 175, 55, 0.4);
  border-color: rgba(212, 175, 55, 0.6);
}

input:checked + .slider:before {
  transform: translateX(16px);
  background-color: #d4af37;
}

.slider.round {
  border-radius: 20px;
  border: 1px solid rgba(160, 160, 176, 0.3);
}

.slider.round:before {
  border-radius: 50%;
}

/* 頂部狀態列存在時，container 增加上方間距 */
body.has-top-bar .container {
  padding-top: 5.5rem;
}

/* --- 設計令牌 --- */
:root {
  --bg-deep:     #0a0612;
  --bg-mid:      #120820;
  --accent-1:    #9b5de5;
  --accent-2:    #c77dff;
  --accent-glow: #d4a8ff;
  --gold:        #f0c040;
  --gold-dark:   #c89a20;
  --text-main:   #e8d8ff;
  --text-muted:  #9980bb;
  --card-bg:     rgba(26, 14, 48, 0.92);
  --card-border: rgba(155, 93, 229, 0.45);
  --bag-brown:   #5c2d0a;
  --bag-mid:     #7a3d12;
  --bag-light:   #a05a28;
  --bag-tie:     #3b1a06;
  --radius-card: 16px;
  --shadow-glow: 0 0 24px rgba(155, 93, 229, 0.35);
}

/* --- 重置 & 基底 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Noto Serif TC', serif;
  color: var(--text-main);
  position: relative;
}

/* --- 星空背景 --- */
/* Removed .stars as global background-effects is used */

/* --- 版面容器 --- */
.container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Subtitle style is handled by hero.subtitle in styles.css */
.hero .subtitle {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  letter-spacing: 0.3em;
  color: #d4af37;
  margin-bottom: 1rem;
  text-transform: uppercase;
  font-weight: 400;
}

.hero .title {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #fff, #a0a0b0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.1em;
}

/* --- 數量控制 --- */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}

.count-label {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.count-select {
  appearance: none;
  width: fit-content;
  min-width: 160px;
  background: rgba(20, 20, 30, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  color: #d4af37;
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 0.6rem 2.5rem 0.6rem 1.2rem;
  cursor: pointer;
  outline: none;
  transition: all 0.4s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 1.2rem;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5), 0 4px 15px rgba(0,0,0,0.3);
}

.count-select:hover {
  background-color: rgba(30, 30, 45, 0.7);
  border-color: #d4af37;
  box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.1), 0 0 20px rgba(212, 175, 55, 0.2);
  transform: translateY(-2px);
}

.count-select:focus {
  border-color: #f0e68c;
  box-shadow: inset 0 0 20px rgba(212, 175, 55, 0.2), 0 0 25px rgba(212, 175, 55, 0.4);
}

.count-select option {
  background: rgba(20, 20, 30, 0.95);
  color: #f0f0f5;
  font-family: 'Noto Serif TC', serif;
}

/* --- 解說者人格選擇器 --- */
.persona-selector {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.persona-selector input[type="radio"] {
  display: none;
}

.persona-selector label {
  background: rgba(20, 20, 30, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(160, 160, 176, 0.3);
  border-radius: 12px;
  color: #a0a0b0;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  min-width: 110px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.persona-selector label::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at top, rgba(212,175,55,0.1), transparent 70%);
  opacity: 0;
  transition: opacity 0.4s;
}

.persona-selector label:hover {
  background-color: rgba(40, 40, 55, 0.6);
  border-color: #d4af37;
  color: #fff;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), 0 0 15px rgba(212, 175, 55, 0.2);
  transform: translateY(-2px);
}

.persona-selector label:hover::before {
  opacity: 1;
}

.persona-selector input[type="radio"]:checked + label {
  background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(155,93,229,0.2));
  border-color: #d4af37;
  color: #d4af37;
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
  box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.1), 0 8px 20px rgba(0, 0, 0, 0.5), 0 0 25px rgba(212, 175, 55, 0.3);
  transform: translateY(-4px);
}

/* --- 布袋區域 --- */
.bag-section {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.bag-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

/* --- 布袋本體 SVG 風格 (純 CSS) --- */
.bag {
  width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 8px 24px rgba(92, 45, 10, 0.6)) drop-shadow(0 0 12px rgba(155, 93, 229, 0.3));
  transition: filter 0.3s;
  outline: none;
}

.bag:focus-visible {
  filter: drop-shadow(0 8px 24px rgba(92, 45, 10, 0.6)) drop-shadow(0 0 20px rgba(212, 168, 255, 0.6));
}

/* 布袋外部容器 */
.bag {
  width: 150px;
  height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  outline: none;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.6));
}

/* 頂部荷葉邊皺褶 */
.bag-ruffle {
  width: 80px;
  height: 25px;
  background: #110720;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  position: relative;
  z-index: 2;
  box-shadow: 
    inset 0 4px 10px rgba(0,0,0,0.8),
    inset 5px 0 5px rgba(155,93,229,0.1);
}

.bag-ruffle::before {
  content: '';
  position: absolute;
  inset: -2px 5px 0;
  border-radius: 40% 40% 0 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 8px, rgba(0,0,0,0.6) 9px, rgba(0,0,0,0.6) 10px);
}

/* 束口處 */
.bag-neck {
  width: 72px;
  height: 15px;
  background: #0a0414;
  position: relative;
  z-index: 4;
  margin-top: -5px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 抽繩 */
.bag-string {
  position: absolute;
  top: 50%;
  width: 60px;
  height: 2px;
  background: #d4af37;
  box-shadow: 0 0 5px rgba(212,175,55,0.5);
  z-index: 3;
}

.bag-string.left {
  right: 100%;
  transform: rotate(-15deg);
  transform-origin: right center;
}

.bag-string.right {
  left: 100%;
  transform: rotate(15deg);
  transform-origin: left center;
}

/* 木珠 */
.bag-bead {
  width: 14px;
  height: 14px;
  background: radial-gradient(circle at 35% 35%, #f0c040, #a07a10);
  border-radius: 50%;
  position: absolute;
  bottom: -6px;
  box-shadow: 0 2px 6px rgba(212,175,55,0.6);
}

.bag-string.left .bag-bead { left: -5px; }
.bag-string.right .bag-bead { right: -5px; }

/* 符文偷窺 */
.bag-runes-peek {
  position: absolute;
  top: -25px;
  display: flex;
  gap: 0.2rem;
  font-size: 1.2rem;
  color: #d4af37;
  text-shadow: 0 0 8px rgba(212,175,55,0.8);
  pointer-events: none;
  transition: opacity 0.3s;
}

/* 袋身 */
.bag-body {
  width: 130px;
  height: 170px;
  background: radial-gradient(ellipse at 40% 30%, #36175c 0%, #15062a 50%, #050110 100%);
  border-radius: 30px 30px 50px 50px / 20px 20px 40px 40px;
  margin-top: -2px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 
    inset -10px -15px 25px rgba(0,0,0,0.8),
    inset 10px 10px 20px rgba(155,93,229,0.15),
    0 15px 25px rgba(0,0,0,0.6);
}

.bag-body::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* 金色紋章 */
.bag-emblem {
  width: 70px;
  height: 70px;
  border: 2px solid rgba(212,175,55,0.8);
  border-radius: 50%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, rgba(212,175,55,0.15), transparent 60%);
  box-shadow: 0 0 15px rgba(212,175,55,0.3), inset 0 0 10px rgba(212,175,55,0.2);
  transition: all 0.5s ease;
}

.emblem-inner {
  width: 50px;
  height: 50px;
  border: 1px dashed rgba(212,175,55,0.6);
  border-radius: 50%;
  position: relative;
  animation: slow-spin 20s linear infinite;
}

.emblem-inner::before,
.emblem-inner::after {
  content: '';
  position: absolute;
  background: rgba(212,175,55,0.5);
}

.emblem-inner::before {
  inset: -1px 48%;
}

.emblem-inner::after {
  inset: 48% -1px;
}

.bag-emblem::before {
  content: 'ᛟ';
  color: #d4af37;
  font-size: 1.8rem;
  position: absolute;
  text-shadow: 0 0 10px rgba(212,175,55,0.8);
}

.bag-wrapper:hover .bag-emblem {
  box-shadow: 0 0 25px rgba(212,175,55,0.6), inset 0 0 15px rgba(212,175,55,0.4);
  transform: scale(1.05);
}

@keyframes slow-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.bag-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  transition: color 0.3s;
}

.bag-wrapper:hover .bag-hint { color: var(--accent-glow); }

/* --- 搖晃動畫 --- */
@keyframes shake {
  0%   { transform: rotate(0deg)   translateY(0); }
  10%  { transform: rotate(-12deg) translateY(-4px); }
  20%  { transform: rotate(14deg)  translateY(-8px); }
  30%  { transform: rotate(-16deg) translateY(-5px); }
  40%  { transform: rotate(12deg)  translateY(-9px); }
  50%  { transform: rotate(-14deg) translateY(-6px); }
  60%  { transform: rotate(16deg)  translateY(-8px); }
  70%  { transform: rotate(-10deg) translateY(-4px); }
  80%  { transform: rotate(8deg)   translateY(-6px); }
  90%  { transform: rotate(-5deg)  translateY(-2px); }
  100% { transform: rotate(0deg)   translateY(0); }
}

.bag.shaking {
  animation: shake 0.9s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  transform-origin: center bottom;
}

/* --- 粒子 --- */
.shake-particles {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  pointer-events: none;
}

.particle {
  position: absolute;
  top: 50%; left: 50%;
  font-size: 1.2rem;
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold);
  animation: fly-out 0.8s ease-out forwards;
  opacity: 0;
}

@keyframes fly-out {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0); opacity: 0; }
}

/* --- 結果區 --- */
.results-section {
  width: 100%;
  max-width: 600px; /* 與占卜內容輸入框寬度一致 */
  margin: 2rem auto;
  background: radial-gradient(circle at center, rgba(30, 20, 50, 0.85), rgba(10, 5, 20, 0.95));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(155, 93, 229, 0.2);
  border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(155, 93, 229, 0.05);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 3rem 1rem 3rem; /* 調整內距 */
  scrollbar-width: thin;
  scrollbar-color: var(--accent-1) transparent;
}

/* 自定義 Webkit 捲軸 (Chrome/Edge/Safari) */
.results-section::-webkit-scrollbar {
  height: 6px;
}
.results-section::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}
.results-section::-webkit-scrollbar-thumb {
  background: var(--accent-1);
  border-radius: 10px;
  box-shadow: 0 0 10px var(--accent-glow);
}

.results-grid {
  display: flex;
  flex-wrap: nowrap; /* 預設不折行，以支援左右滑動 */
  gap: 1.2rem;
  justify-content: safe center; /* 雖然支援度較新，但對排版很重要 */
  min-width: min-content; /* 確保內容能撐開容器以滾動 */
  margin: 0 auto;
}

/* 當螢幕較小時，確保從左側開始排，避免 center 導致左側被裁切 */
@media (max-width: 768px) {
  .results-grid {
    justify-content: flex-start;
    padding: 0 1rem;
  }
}

/* 5 張符文：調整間距與縮放 */
.results-grid[data-count="5"] {
  gap: 0.6rem;
}

.results-grid[data-count="5"] .rune-card-wrapper {
  width: 130px;
  height: 205px;
  flex-shrink: 0;
}

.results-grid[data-count="5"] .rune-glyph { font-size: 2.5rem; }
.results-grid[data-count="5"] .rune-name-en { font-size: 0.72rem; }
.results-grid[data-count="5"] .rune-meaning { font-size: 0.67rem; }

/* --- 符文石頭 CSS (精緻 3D 版) --- */
.rune-card-wrapper {
  width: 100px; /* 寬度也跟著縮小 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  perspective: 1200px;
}

.rune-card {
  width: 80px;  /* 尺寸縮小約一半 (140 -> 80) */
  height: 80px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(180deg);
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 多樣化形狀定義 */
.rune-card.shape-1 { border-radius: 40% 60% 50% 50% / 45% 45% 55% 55%; }
.rune-card.shape-2 { border-radius: 60% 40% 60% 40% / 50% 50% 50% 50%; }
.rune-card.shape-3 { border-radius: 50% 50% 30% 70% / 40% 60% 70% 30%; }
.rune-card.shape-4 { border-radius: 30% 70% 70% 30% / 50% 50% 50% 50%; }
.rune-card.shape-5 { border-radius: 45% 55% 45% 55% / 55% 45% 55% 45%; }

.rune-card.revealed {
  transform: rotateY(0deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(155, 93, 229, 0.15);
  background: 
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08) 0%, transparent 70%),
    linear-gradient(135deg, #1e1e32 0%, #0d0d1a 100%);
  border-radius: inherit; /* 繼承 .rune-card 的隨機形狀 */
}

 /* 3D 厚度特效：透過層疊陰影營造側面感 */
.card-front {
  box-shadow: 
    var(--shadow-glow), 
    inset 0 0 15px rgba(0,0,0,0.6),
    2px 2px 0px #0a0a14,
    4px 4px 0px #08080f,
    6px 6px 0px #05050a,
    8px 8px 0px #030305; /* 增加到 8px 厚度 */
}

.card-back {
  background: 
    radial-gradient(circle at 50% 50%, #2a2a40 0%, #1a1a2e 100%);
  transform: rotateY(180deg);
  font-size: 1.2rem;
  color: rgba(155, 93, 229, 0.2);
  text-shadow: 0 0 8px rgba(155, 93, 229, 0.3);
  box-shadow: 
    -2px 2px 0px #0a0a14,
    -4px 4px 0px #08080f,
    -6px 6px 0px #05050a,
    -8px 8px 0px #030305;
}

.rune-glyph {
  font-size: 2.2rem; /* 配合石頭縮小 adjust size */
  color: var(--gold);
  text-shadow: 
    0 0 10px rgba(240, 192, 64, 0.6),
    0 0 3px rgba(240, 192, 64, 0.4),
    1px 1px 1px rgba(0,0,0,0.8);
  line-height: 1;
  transition: transform 0.3s;
}

.rune-card.is-reversed .rune-glyph {
  transform: rotate(180deg);
}

/* 石頭下方的資訊區 */
.rune-details {
  width: 140px; /* 資訊寬度可略大於石頭 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease 0.3s;
}

/* 翻開後顯示資訊 */
.rune-card.revealed + .rune-details {
  opacity: 1;
  transform: translateY(0);
}

.rune-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.rune-name-en {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent-glow);
  text-transform: uppercase;
}

.rune-name-zh {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.rune-status {
  font-size: 0.55rem;
  padding: 1px 8px;
  border-radius: 10px;
  margin-top: 0.2rem;
  letter-spacing: 0.05em;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-upright {
  background: rgba(46, 204, 113, 0.1);
  color: #2ecc71;
  border-color: rgba(46, 204, 113, 0.2);
}

.status-reversed {
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
  border-color: rgba(231, 76, 60, 0.2);
}

.rune-divider {
  width: 40px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--card-border), transparent);
  margin: 0.2rem 0;
  opacity: 0.4;
}

.rune-meaning {
  font-size: 0.65rem;
  color: var(--text-main);
  line-height: 1.5;
  text-align: center;
  opacity: 0.85;
}

/* 卡牌出現動畫 */
@keyframes card-appear {
  from { opacity: 0; transform: translateY(30px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.rune-card-wrapper {
  animation: card-appear 0.5s ease both;
  transition: transform 0.3s ease;
}

/* 佔位槽樣式 */
.rune-card-wrapper.placeholder {
  animation: none;
  opacity: 0.4;
}

.rune-card-wrapper.placeholder .rune-card {
  transform: none;
  background: rgba(155, 93, 229, 0.05);
  border: 1px dashed rgba(155, 93, 229, 0.3);
  box-shadow: none;
}

.rune-card-wrapper.placeholder .card-back {
  background: transparent;
  box-shadow: none;
  border: none;
}

.rune-card-wrapper.placeholder .rune-details {
  display: none; /* 隱藏佔位槽的資訊區 */
}

/* --- 重置按鈕 --- */
.reset-btn {
  display: none;
  border: 1px solid var(--card-border);
  background: rgba(155, 93, 229, 0.12);
  color: var(--accent-glow);
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  padding: 0.7rem 2rem;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.25s, box-shadow 0.25s, transform 0.15s;
  margin-top: 0.5rem;
}

.reset-btn:hover {
  background: rgba(155, 93, 229, 0.25);
  box-shadow: 0 0 16px rgba(155, 93, 229, 0.35);
  transform: translateY(-2px);
}

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

.reset-btn.visible { display: block; }

/* --- 響應式 --- */
@media (max-width: 480px) {
  .rune-card-wrapper { width: 140px; height: 200px; }
  .rune-glyph { font-size: 2.5rem; }
  .bag-body { width: 120px; min-height: 110px; }
  .bag { width: 140px; }
}

/* --- New UI Components for Divination & Gemini --- */

.input-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center; /* 改為置中 */
  gap: 12px;
  width: 100%;
}

.input-label {
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem;
  color: #d4af37;
  text-shadow: 0 0 5px rgba(212, 175, 55, 0.3);
}

.text-input {
  background: rgba(15, 10, 20, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(155, 93, 229, 0.3);
  border-radius: 12px;
  padding: 16px 20px;
  color: #fff;
  font-size: 1.05rem;
  font-family: 'Noto Serif TC', serif;
  transition: all 0.4s ease;
  width: 100%;
  max-width: 600px;
  box-sizing: border-box;
  resize: vertical;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
  line-height: 1.6;
}

.text-input::placeholder {
  color: rgba(160, 160, 176, 0.5);
  font-style: italic;
}

.text-input:focus {
  outline: none;
  background: rgba(20, 15, 30, 0.8);
  border-color: #d4af37;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5), 0 0 20px rgba(212, 175, 55, 0.2);
}

.save-btn:hover {
  background: rgba(212, 175, 55, 0.2);
}

.ai-section {
  margin-top: 60px; /* 增加間距以區分區塊 */
  padding: 35px 40px;
  background: linear-gradient(145deg, rgba(20, 15, 30, 0.8), rgba(10, 5, 15, 0.95));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-top: 3px solid #d4af37;
  border-bottom: 3px solid #d4af37;
  border-radius: 12px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.6), inset 0 0 30px rgba(212, 175, 55, 0.05);
  transition: all 0.5s ease;
  width: 100%;
  max-width: 600px; /* 與 .results-section 和輸入框保持一致 */
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.ai-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h20v20H0z' fill='none'/%3E%3Cpath d='M10 0v20' stroke='rgba(212,175,55,0.03)' stroke-width='1'/%3E%3Cpath d='M0 10h20' stroke='rgba(212,175,55,0.03)' stroke-width='1'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: 12px;
}

.ai-section.hidden {
  display: none;
}

.ai-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 25px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  padding-bottom: 15px;
}

.ai-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.6));
}

.ai-title {
  font-family: 'Cinzel Decorative', 'Noto Serif TC', serif;
  color: #d4af37;
  margin: 0;
  letter-spacing: 3px;
  font-size: 1.5rem;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.ai-content {
  font-family: 'Noto Serif TC', serif;
  line-height: 1.9;
  color: #e8d8ff;
  font-size: 1.15rem;
  min-height: 100px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.ai-content p {
  margin: 0 0 18px 0;
}

.loading-text {
  color: #a0a0b0;
  font-style: italic;
  text-align: center;
  animation: pulse-glow-gold 2s infinite;
}

@keyframes pulse-glow-gold {
  0% { opacity: 0.5; text-shadow: 0 0 10px rgba(212,175,55,0); }
  50% { opacity: 1; text-shadow: 0 0 15px rgba(212,175,55,0.4); color: #d4af37; }
  100% { opacity: 0.5; text-shadow: 0 0 10px rgba(212,175,55,0); }
}

.ai-btn {
  display: block;
  margin: 30px auto 0;
  padding: 14px 40px;
  background: transparent;
  color: #d4af37;
  border: 1px solid rgba(212, 175, 55, 0.5);
  border-radius: 30px;
  font-family: 'Noto Serif TC', serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.ai-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.2), transparent);
  transition: left 0.5s ease;
}

.ai-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: #d4af37;
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3), inset 0 0 10px rgba(212, 175, 55, 0.2);
  transform: translateY(-2px);
  color: #fff;
}

.ai-btn:hover::before {
  left: 100%;
}

.ai-btn:disabled {
  background: rgba(30, 30, 40, 0.8);
  border-color: rgba(160, 160, 176, 0.3);
  color: rgba(160, 160, 176, 0.5);
  cursor: not-allowed;
  box-shadow: none;
}
