/* Import Calligraphy Fonts */
@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Serif+SC:wght@300;400;700&family=Zhi+Mang+Xing&display=swap');

:root {
  /* Temple Theme Colors - Refined */
  --bg-color: #1a0b0b;
  --text-color: #f3e5ab; /* Parchment */
  --accent-gold: #e6cca0; /* Muted Gold (less yellow) */
  --cinnabar-red: #b71c1c; /* Seal Red */
  --ink-black: #212121;
  --jade-green: #2e7d32;
  
  --wood-primary: #4e342e;
  --wood-light: #795548;

  /* Rarities Colors */
  --color-n: #757575;
  --color-r: #bdbdbd;
  --color-sr: #66bb6a;
  --color-ssr: #42a5f5;
  --color-ur: #ab47bc;
  --color-sp: #ffb300;
  --color-god: #f50057;

  /* Fonts */
  /* Using Zhi Mang Xing for a more elegant cursive, or fallback to Ma Shan Zheng */
  --font-title: 'Ma Shan Zheng', cursive; 
  --font-body: 'Noto Serif SC', serif;     
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Deep vignetted background */
  background: radial-gradient(circle at 50% 40%, #3e2723 0%, #1a0b0b 90%);
}

/* Ambient Floating Dust/Incense Particles */
.particle {
  position: absolute;
  background: rgba(255, 255, 255, 0.4); /* Slightly brighter */
  border-radius: 50%;
  pointer-events: none;
  animation: float-particle linear infinite;
}

@keyframes float-particle {
  0% { transform: translateY(100vh) translateX(0); opacity: 0; }
  50% { opacity: 0.6; }
  100% { transform: translateY(-20vh) translateX(20px); opacity: 0; }
}

/* Lotus Pattern Overlay (Abstract) */
body::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  /* Abstract Lotus/Petal SVG Pattern */
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d4af37' stroke-opacity='0.05' stroke-width='1'%3E%3Cpath d='M40 10 Q60 30 40 50 Q20 30 40 10' /%3E%3Cpath d='M40 50 Q70 40 60 10' /%3E%3Cpath d='M40 50 Q10 40 20 10' /%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

#app {
  z-index: 2;
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 40px 20px 20px;
}

/* Header */
header {
  text-align: center;
  position: relative;
  margin-bottom: 20px;
}

/* Vertical text decoration - Toned down */
header::before {
  content: "有求必应";
  position: absolute;
  left: -20px;
  top: 10px;
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: var(--accent-gold);
  opacity: 0.15; /* Reduced opacity */
  writing-mode: vertical-rl;
  letter-spacing: 5px;
}

header::after {
  content: "心诚则灵";
  position: absolute;
  right: -20px;
  top: 10px;
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: var(--accent-gold);
  opacity: 0.15; /* Reduced opacity */
  writing-mode: vertical-rl;
  letter-spacing: 5px;
}

h1 {
  font-family: var(--font-title);
  font-size: 3.2rem;
  color: var(--accent-gold);
  /* Simplified shadows for cleaner look */
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  margin-bottom: 10px;
  letter-spacing: 6px;
  font-weight: normal;
  /* Removed flashy gradient for solid gold */
}

.subtitle {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: #a1887f;
  letter-spacing: 4px;
  font-weight: 400;
  border-top: 1px solid rgba(161, 136, 127, 0.2);
  border-bottom: 1px solid rgba(161, 136, 127, 0.2);
  padding: 8px 12px;
  display: inline-block;
}

/* Wooden Fish Area */
#wooden-fish-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
}

#wooden-fish {
  width: 260px;
  height: 240px;
  cursor: pointer;
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 10;
  filter: drop-shadow(0 25px 35px rgba(0,0,0,0.7));
}

#wooden-fish:active {
  transform: scale(0.92) rotate(-2deg);
}

/* SVG Styles */
.fish-body { fill: url(#woodGradient); stroke: #2d1e17; stroke-width: 2; }

.ripple {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(212, 175, 55, 0.6); /* Gold ring */
  transform: scale(0.5);
  animation: ripple-expand 0.8s cubic-bezier(0, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
  z-index: 5; /* Below fish content but visible */
}

@keyframes ripple-expand {
  to {
    transform: scale(2.5);
    opacity: 0;
    border-width: 0;
  }
}

/* Floating Text - Ink Style */
.float-text {
  position: absolute;
  color: var(--text-color);
  font-family: var(--font-title);
  font-size: 2rem;
  pointer-events: none;
  animation: float-fade 1.5s ease-out forwards;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  /* Fix for visibility */
  z-index: 100; 
  width: 200px;
  text-align: center;
  /* Center it */
  left: 50%;
  margin-left: -100px; 
}

@keyframes float-fade {
  0% { opacity: 0; transform: translateY(0) scale(0.8); }
  20% { opacity: 1; transform: translateY(-20px) scale(1); }
  100% { opacity: 0; transform: translateY(-120px) scale(1.1); }
}

/* Footer Status */
footer {
  font-family: var(--font-body);
  color: rgba(255,255,255,0.25);
  font-size: 0.8rem;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

/* --- Charm Modal --- */
#charm-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s ease;
  backdrop-filter: blur(8px);
}

#charm-modal.visible {
  opacity: 1;
  visibility: visible;
}

.charm-card-container {
  width: 320px;
  perspective: 1200px;
}

/* The Talisman Card - Paper Texture with Dynamic Rarity Borders */
.charm-card {
  position: relative;
  /* Warm Parchment Background - Matches Temple Theme */
  background: #e4d5b7; 
  border-radius: 8px;
  /* Default Border (will be overridden by rarity) */
  border: 8px solid var(--wood-primary);
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  overflow: hidden;
  transform: translateY(100px) rotateX(10deg);
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
  
  /* Subtle Paper Noise */
  background-image: url('https://www.transparenttextures.com/patterns/cream-paper.png'); 
  /* Warm overlay to blend */
  background-blend-mode: multiply;
}

/* Rarity Specific Styling */
.charm-card[data-rarity="N"] {
  border-color: var(--color-n);
  box-shadow: 0 0 15px rgba(117, 117, 117, 0.3), 0 20px 50px rgba(0,0,0,0.8);
}

.charm-card[data-rarity="R"] {
  border-color: var(--color-r);
  box-shadow: 0 0 15px rgba(189, 189, 189, 0.3), 0 20px 50px rgba(0,0,0,0.8);
}

.charm-card[data-rarity="SR"] {
  border-color: var(--color-sr); /* Jade Green */
  box-shadow: 0 0 20px rgba(102, 187, 106, 0.4), 0 20px 50px rgba(0,0,0,0.8);
}

.charm-card[data-rarity="SSR"] {
  border-color: var(--accent-gold); /* Gold */
  box-shadow: 0 0 25px rgba(212, 175, 55, 0.6), 0 20px 50px rgba(0,0,0,0.8);
}

.charm-card[data-rarity="UR"] {
  border-color: var(--color-ur); /* Purple */
  box-shadow: 0 0 30px rgba(171, 71, 188, 0.6), 0 20px 50px rgba(0,0,0,0.8);
}

.charm-card[data-rarity="SP"] {
  border-color: var(--color-sp); /* Amber */
  box-shadow: 0 0 35px rgba(255, 179, 0, 0.7), 0 20px 50px rgba(0,0,0,0.8);
}

.charm-card[data-rarity="GOD"] {
  border-color: var(--color-god); /* Divine Red/Pink */
  box-shadow: 0 0 50px rgba(245, 0, 87, 0.8), 0 20px 50px rgba(0,0,0,0.8);
  animation: god-pulse 3s infinite ease-in-out;
}

@keyframes god-pulse {
  0%, 100% { box-shadow: 0 0 50px rgba(245, 0, 87, 0.8), 0 20px 50px rgba(0,0,0,0.8); border-color: var(--color-god); }
  50% { box-shadow: 0 0 80px rgba(245, 0, 87, 0.9), 0 20px 50px rgba(0,0,0,0.8); border-color: #ff80ab; }
}

/* Inner Frame Decoration - Optional, keeps it looking structured */
.charm-card::after {
  content: "";
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 4px;
  pointer-events: none;
}

/* Red Seal Decorations */
.charm-card::before {
  content: "";
  position: absolute;
  width: 30px;
  height: 30px;
  border: 2px solid var(--cinnabar-red);
  border-radius: 4px;
  opacity: 0.6; /* Clearer seal */
  z-index: 0;
  top: 12px; left: 12px; 
  border-right: none; border-bottom: none;
}

#charm-modal.visible .charm-card {
  transform: translateY(0) rotateX(0);
  opacity: 1;
}

/* Card Content */
.card-header {
  padding: 40px 20px 20px;
  text-align: center;
  position: relative;
  border-bottom: 1px dashed rgba(78, 52, 46, 0.2); 
}

/* Rarity Stamp Style */
.rarity-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--cinnabar-red);
  border: 2px solid var(--cinnabar-red);
  padding: 2px 6px;
  border-radius: 4px;
  transform: rotate(12deg);
  opacity: 0.8;
  mix-blend-mode: multiply;
  background: rgba(255, 255, 255, 0.5); /* Slight background to pop */
}

.charm-visual {
  font-size: 4.5rem;
  margin: 10px 0 15px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.charm-title {
  font-family: var(--font-title);
  font-size: 2.4rem;
  color: #212121; 
  margin-bottom: 10px;
  letter-spacing: 3px;
  text-shadow: none;
}

.charm-desc {
  font-size: 1rem;
  color: #5d4037; 
  line-height: 1.6;
  font-family: var(--font-body);
  font-style: italic;
  padding: 0 15px;
  font-weight: 400;
}

/* Footer - Centered & Styled */
.card-footer {
  background: rgba(0, 0, 0, 0.05); /* Slightly darker to separate from main body */
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  border-top: 1px solid rgba(78, 52, 46, 0.1);
}

.date-info {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: #5d4037; /* Darker */
  border-bottom: 1px solid rgba(93, 64, 55, 0.3);
  padding-bottom: 8px;
  margin-bottom: 4px;
  width: 100%;
  text-align: center;
  font-weight: 600;
}

/* GRID LAYOUT FOR FORTUNE ROW: Circle Left, Text Center */
.fortune-row {
  display: grid;
  grid-template-columns: 40px 1fr; /* Fixed width for circle, rest for text */
  align-items: center;
  gap: 8px;
  width: 100%;
}

.fortune-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-family: var(--font-title);
  font-size: 1rem;
  color: #fffbf0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  /* Align self to start of cell not strictly needed as cell is fixed size */
}

.fortune-label.yi { background-color: var(--jade-green); border: 2px solid #1b5e20; }
.fortune-label.buyi { background-color: var(--cinnabar-red); border: 2px solid #b71c1c; }

.fortune-content {
  font-family: var(--font-title);
  font-size: 1.2rem; /* Slightly larger */
  color: #2d1e17; /* High contrast */
  text-align: center; 
  display: flex;         /* Flexbox to ensure perfect centering */
  justify-content: center;
  align-items: center;
  width: 100%;
  font-weight: bold; /* Bold for readability */
  transform: translateX(-10px); /* Visual hack: pull back left slightly to balance the circle's weight */
}

.close-hint {
  position: absolute;
  bottom: -40px;
  width: 100%;
  text-align: center;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  letter-spacing: 2px;
  animation: pulse-hint 2s infinite;
}

@keyframes pulse-hint {
  50% { opacity: 0.6; }
}

/* Flash Overlay - Golden */
#flash-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle, rgba(255,215,0,0.8) 0%, rgba(255,215,0,0) 70%);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
}
#flash-overlay.flash { animation: flash-anim 0.6s ease-out; }

@keyframes flash-anim {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; }

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}
