/* index.css - Custom Styling for Psychological Tarot Mirror */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  /* Colors */
  --bg-primary: #FAF8FD;
  --bg-secondary: #F4EEFB;
  --color-primary: #4B306A;
  /* Deep warm purple */
  --color-primary-light: #6C4E93;
  --color-secondary: #957BBE;
  /* Soft mid lavender */
  --color-secondary-light: #BCAFDB;
  --color-accent-warm: #EAA89B;
  /* Rose gold/Peach sunset accent */
  --color-accent-gold: #D6AF55;
  /* Warm gold details */
  --color-accent-pink: #F8BBD0;
  /* Healing soft pink */

  --text-dark: #2C1842;
  --text-muted: #6E538B;
  --text-light: #FFFFFF;

  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(149, 123, 190, 0.25);
  --card-glow-warm: rgba(234, 168, 155, 0.4);
  --card-glow-purple: rgba(75, 48, 106, 0.15);

  --gradient-bg-accent: radial-gradient(circle at 10% 20%, rgba(250, 224, 218, 0.6) 0%, rgba(230, 210, 245, 0.6) 90%);
  --gradient-main: linear-gradient(135deg, #4B306A 0%, #76559C 60%, #957BBE 100%);
  --gradient-healing: linear-gradient(135deg, #EAA89B 0%, #C3A6DA 100%);

  --shadow-sm: 0 4px 6px -1px rgba(75, 48, 106, 0.05), 0 2px 4px -1px rgba(75, 48, 106, 0.03);
  --shadow-md: 0 10px 15px -3px rgba(75, 48, 106, 0.08), 0 4px 6px -2px rgba(75, 48, 106, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(75, 48, 106, 0.1), 0 10px 10px -5px rgba(75, 48, 106, 0.04);

  /* Fonts */
  --font-family: 'Outfit', 'Sarabun', sans-serif;

  /* Layout */
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: var(--gradient-bg-accent);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-secondary-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-secondary);
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-md);
}

/* Header styling */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  z-index: 10;
  border-bottom: 1px solid rgba(149, 123, 190, 0.15);
  background: rgba(250, 248, 253, 0.7);
  backdrop-filter: blur(8px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.logo span {
  background: var(--gradient-healing);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  width: 42px;
  height: 42px;
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--color-primary-light);
  transform: rotate(30deg);
}

/* Layout views */
main {
  flex: 1;
  display: flex;
  position: relative;
  width: 100%;
}

.view-container {
  display: none;
  width: 100%;
  padding: 2rem;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.view-container.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

/* Setup View */
#view-setup {
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.setup-card {
  max-width: 600px;
  width: 100%;
  padding: 2.5rem;
  border-radius: var(--border-radius-lg);
  text-align: center;
}

.setup-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}

.setup-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: left;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-primary);
}

.textarea-mystic {
  width: 100%;
  height: 120px;
  padding: 1rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-secondary-light);
  background: rgba(255, 255, 255, 0.6);
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--text-dark);
  resize: none;
  transition: all 0.3s ease;
}

.textarea-mystic:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(75, 48, 106, 0.15);
  background: white;
}

.btn-mystic {
  background: var(--gradient-main);
  color: var(--text-light);
  border: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: var(--shadow-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-mystic:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(75, 48, 106, 0.2);
  filter: brightness(1.1);
}

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

/* Card Drawing View */
#view-drawing {
  align-items: center;
  justify-content: space-between;
}

.drawing-header {
  text-align: center;
  margin-bottom: 2rem;
}

.drawing-header h2 {
  font-size: 1.8rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.drawing-header p {
  color: var(--text-muted);
}

.deck-container {
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
  min-height: 250px;
  width: 100%;
  margin: 2rem 0;
  position: relative;
}

/* Pile Tabs Switcher Styling */
.pile-tabs {
  display: flex;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  max-width: 750px;
  margin: 0 auto 1.5rem auto;
  padding: 0 1rem;
}

.pile-tab {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  text-align: left;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pile-tab:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: translateY(-2px);
  border-color: var(--color-secondary-light);
  box-shadow: var(--shadow-md);
}

.pile-tab.active {
  background: white;
  border-color: var(--color-accent-warm);
  box-shadow: 0 0 18px var(--card-glow-warm), var(--shadow-md);
  transform: translateY(-2px);
}

.pile-icon {
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.pile-tab.active .pile-icon {
  transform: scale(1.15) rotate(-5deg);
}

.pile-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pile-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-primary);
}

.pile-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.cards-fan {
  display: flex;
  justify-content: center;
  position: absolute;
  width: 100%;
  max-width: 800px;
  height: 240px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(15px) scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.cards-fan.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
  z-index: 10;
}

.card-draw-wrapper {
  width: 130px;
  height: 210px;
  position: absolute;
  transform-origin: bottom center;
  cursor: pointer;
  transition: z-index 0.2s ease;
  will-change: transform;
}

.tarot-card-draw {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  background: var(--gradient-healing);
  border: 4px solid white;
  overflow: hidden;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.3s ease, box-shadow 0.3s ease;
  will-change: transform;
}

/* Celestial design on back of card */
.tarot-card-draw::after {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  right: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  pointer-events: none;
}

/* Card back pattern */
.card-back-pattern {
  width: 100%;
  height: 100%;
  background-color: var(--color-primary);
  background-image:
    radial-gradient(circle at center, rgba(234, 168, 155, 0.15) 0%, transparent 60%),
    linear-gradient(45deg, rgba(149, 123, 190, 0.1) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(149, 123, 190, 0.1) 25%, transparent 25%);
  background-size: 100% 100%, 20px 20px, 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent-gold);
  font-size: 2rem;
  transition: all 0.3s ease;
}

/* Hover effects via wrapper */
.card-draw-wrapper:hover {
  z-index: 150 !important;
}

.card-draw-wrapper:hover .tarot-card-draw {
  transform: translateY(-28px) scale(1.06);
  box-shadow: 0 15px 30px rgba(75, 48, 106, 0.25), 0 0 15px var(--card-glow-warm);
  border-color: var(--color-secondary);
}

/* Selected state */
.card-draw-wrapper.selected {
  pointer-events: none;
  z-index: 120 !important;
}

.card-draw-wrapper.selected .tarot-card-draw {
  transform: translateY(-60px) scale(1.02);
  border-color: var(--color-accent-gold);
  box-shadow: 0 0 25px rgba(214, 175, 85, 0.6);
}

.selected-slots {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 600px;
}

.slot {
  width: 110px;
  height: 180px;
  border: 2px dashed var(--color-secondary-light);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
  text-align: center;
  padding: 0.5rem;
  box-sizing: border-box;
}

.slot.filled {
  border-style: solid;
  border-color: var(--color-accent-warm);
  background: white;
}

.slot span {
  display: block;
  width: 100%;
  text-align: center;
}

.action-bar {
  margin-top: 2rem;
  min-height: 50px;
}

.hidden {
  display: none !important;
}

/* Main Session View (Split view: Left = Cards, Right = Chat) */
#view-session {
  padding: 0;
  display: none;
}

#view-session.active {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 78px);
}

.left-panel {
  flex: 4;
  background: rgba(244, 238, 251, 0.4);
  border-right: 1px solid rgba(149, 123, 190, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 2rem;
}

.right-panel {
  flex: 6;
  display: flex;
  flex-direction: column;
  background: white;
  height: 100%;
}

.session-cards-container {
  display: grid;
  grid-template-columns: repeat(3, 140px);
  justify-content: center;
  gap: 1rem 1.5rem;
  width: 100%;
}

/* 3D Flip Card representation */
.tarot-card-3d {
  width: 140px;
  height: 270px;
  perspective: 1000px;
  cursor: pointer;
}

.tarot-card-inner {
  position: relative;
  width: 100%;
  height: 230px;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
  box-shadow: var(--shadow-md);
  border-radius: 12px;
}

.tarot-card-3d.flipped .tarot-card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 12px;
  border: 4px solid white;
  overflow: hidden;
}

.card-back {
  background-color: var(--color-primary);
  background-image:
    radial-gradient(circle at center, rgba(234, 168, 155, 0.2) 0%, transparent 65%),
    linear-gradient(45deg, rgba(149, 123, 190, 0.15) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(149, 123, 190, 0.15) 25%, transparent 25%);
  background-size: 100% 100%, 20px 20px, 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent-gold);
  font-size: 2.2rem;
}

.card-back::after {
  content: '';
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  right: 5px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
}

.card-front {
  background: white;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.75rem;
  border: 4px solid var(--color-primary);
  box-shadow: inset 0 0 15px rgba(149, 123, 190, 0.15);
}

.card-front.gold-border {
  border-color: var(--color-accent-gold);
}

.card-header-symbol {
  font-size: 1.1rem;
  display: flex;
  justify-content: space-between;
  color: var(--color-secondary);
}

.card-artwork {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.card-artwork-icon {
  font-size: 3rem;
  filter: drop-shadow(0 2px 5px rgba(75, 48, 106, 0.2));
  animation: float-slow 4s ease-in-out infinite alternate;
}

.card-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-primary);
  text-align: center;
  line-height: 1.2;
}

.card-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  border-top: 1px solid rgba(149, 123, 190, 0.15);
  padding-top: 0.4rem;
}

.drawn-label-badge {
  background: var(--gradient-healing);
  color: var(--color-primary);
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  border: 1px solid white;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

/* User Context display on left side */
.left-context-box {
  width: 100%;
  max-width: 450px;
  padding: 1.5rem;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
}

.left-context-box h4 {
  color: var(--color-primary);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.left-context-box p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-dark);
  font-style: italic;
}

/* Chat container styling */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--bg-primary) 100%);
}

.chat-bubble {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1.5rem;
  border-radius: var(--border-radius-md);
  line-height: 1.7;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.4s ease-out forwards;
}

.chat-bubble.ai {
  align-self: flex-start;
  background-color: white;
  border-left: 4px solid var(--color-accent-warm);
  color: var(--text-dark);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--gradient-main);
  color: var(--text-light);
  border-bottom-right-radius: 4px;
}

.chat-bubble-header {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ai .chat-bubble-header {
  color: var(--color-primary);
}

.user .chat-bubble-header {
  color: var(--color-accent-warm);
}

/* Typography / markdown render styling inside bubbles */
.chat-bubble h3 {
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem 0;
  color: var(--color-primary);
  border-bottom: 1px solid rgba(149, 123, 190, 0.15);
  padding-bottom: 0.25rem;
}

.chat-bubble ul,
.chat-bubble ol {
  margin-left: 1.25rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.chat-bubble li {
  margin-bottom: 0.3rem;
}

/* Initial reflection sections style */
.reflection-section {
  background: rgba(149, 123, 190, 0.04);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  margin-top: 0.75rem;
  border: 1px solid rgba(149, 123, 190, 0.08);
}

.reflection-section h4 {
  color: var(--color-primary-light);
  margin-bottom: 0.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Typing indicator spinner */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: white;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-secondary);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* Chat input field */
.chat-input-area {
  padding: 1.25rem 2rem;
  background: white;
  border-top: 1px solid rgba(149, 123, 190, 0.15);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-mystic {
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: 30px;
  border: 1px solid var(--color-secondary-light);
  background: var(--bg-primary);
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--text-dark);
  transition: all 0.3s ease;
}

.input-mystic:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(75, 48, 106, 0.15);
  background: white;
}

.btn-send {
  background: var(--color-primary);
  color: white;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: var(--shadow-md);
}

.btn-send:hover {
  background: var(--color-primary-light);
  transform: scale(1.08);
}

.btn-send:active {
  transform: scale(0.95);
}

/* Modal Settings Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(44, 24, 66, 0.4);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--border-radius-lg);
  padding: 2.2rem;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.4rem;
  color: var(--color-primary);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 0.5rem;
}

.select-mystic {
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--color-secondary-light);
  font-family: var(--font-family);
  font-size: 0.95rem;
  background: white;
  color: var(--text-dark);
}

.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
}

.toggle-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-primary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-secondary-light);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--color-primary);
}

input:checked+.slider:before {
  transform: translateX(24px);
}

.modal-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  flex-shrink: 0;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float-slow {
  0% {
    transform: translateY(0px) rotate(0deg);
  }

  100% {
    transform: translateY(-8px) rotate(3deg);
  }
}

@keyframes typing-bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* Responsive constraints */
@media (max-width: 900px) {
  #view-session.active {
    flex-direction: column;
    height: auto;
    overflow-y: auto;
  }

  .left-panel {
    flex: none;
    border-right: none;
    border-bottom: 1px solid rgba(149, 123, 190, 0.15);
    padding: 1.5rem;
  }

  .right-panel {
    flex: none;
    height: 600px;
  }

  .tarot-card-3d {
    width: 100px;
    height: 165px;
  }

  .card-artwork-icon {
    font-size: 2rem;
  }

  .card-label {
    font-size: 0.8rem;
  }
}

@media (max-width: 500px) {
  .logo {
    font-size: 1.1rem;
  }

  .setup-card {
    padding: 1.5rem;
  }

  .card-draw-wrapper {
    width: 95px;
    height: 155px;
  }

  .cards-fan {
    height: 180px;
  }

  .session-cards-container {
    gap: 0.75rem;
  }

  .chat-input-area {
    padding: 1rem;
  }
}

@media (max-width: 650px) {
  .pile-tabs {
    gap: 0.5rem;
    padding: 0 0.5rem;
  }

  .pile-tab {
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
    border-radius: 10px;
  }

  .pile-icon {
    font-size: 1.25rem;
  }

  .pile-name {
    font-size: 0.8rem;
  }

  .pile-desc {
    display: none;
  }
}

/* --- Omise Payment System Styles --- */
.payment-env-banner {
  width: 100%;
  background: rgba(75, 48, 106, 0.06);
  border-bottom: 1px solid rgba(149, 123, 190, 0.15);
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  z-index: 5;
  box-sizing: border-box;
}

.env-banner-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.env-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
}

.env-badge.dev {
  background: var(--gradient-healing);
  color: var(--color-primary);
  border: 1px solid rgba(234, 168, 155, 0.5);
}

.env-badge.prod {
  background: linear-gradient(135deg, #D6AF55 0%, #EAA89B 100%);
  color: var(--text-dark);
  border: 1px solid rgba(214, 175, 85, 0.5);
  box-shadow: 0 0 10px rgba(214, 175, 85, 0.2);
}

.btn-quick-toggle {
  background: white;
  border: 1px solid var(--color-secondary-light);
  color: var(--color-primary-light);
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-quick-toggle:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Packages Selection Screen */
.packages-header {
  text-align: center;
  margin-bottom: 2.5rem;
  width: 100%;
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto 3rem auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

.package-card {
  border-radius: var(--border-radius-lg);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15);
  overflow: hidden;
  height: 100%;
  background: rgba(255, 255, 255, 0.75);
  box-sizing: border-box;
}

.package-card:hover {
  transform: translateY(-8px);
  border-color: var(--color-accent-warm);
  box-shadow: 0 15px 30px rgba(75, 48, 106, 0.12), 0 0 20px var(--card-glow-warm);
}

.package-card.popular {
  border: 2px solid var(--color-accent-warm);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(244, 238, 251, 0.9));
  box-shadow: var(--shadow-lg), 0 0 15px rgba(234, 168, 155, 0.2);
}

.package-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
}

.popular-badge {
  background: var(--gradient-healing);
  color: var(--color-primary);
  box-shadow: 0 2px 5px rgba(234, 168, 155, 0.3);
}

.package-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  margin-top: 0.5rem;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05));
}

.package-name {
  font-size: 1.5rem;
  color: var(--color-primary);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.package-price {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
}

.package-price .currency {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-muted);
}

.package-features {
  list-style: none;
  width: 100%;
  margin-bottom: 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0;
}

.package-features li {
  font-size: 0.95rem;
  color: var(--text-dark);
  line-height: 1.4;
  border-bottom: 1px dashed rgba(149, 123, 190, 0.15);
  padding-bottom: 0.5rem;
}

.package-features li:last-child {
  border-bottom: none;
}

.btn-package {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  border-radius: var(--border-radius-md);
  margin-top: auto;
}

/* Payment View */
#view-payment {
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.payment-card {
  max-width: 500px;
  width: 100%;
  padding: 2.5rem;
  border-radius: var(--border-radius-lg);
  text-align: center;
  box-sizing: border-box;
}

.payment-title {
  font-size: 1.8rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.payment-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.payment-summary {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  text-align: left;
  border: 1px solid rgba(149, 123, 190, 0.15);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.95rem;
  color: var(--text-dark);
}

.summary-row.total {
  border-top: 1px solid var(--color-secondary-light);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
}

.summary-row .price-amount {
  font-size: 1.4rem;
  color: var(--color-primary);
}

/* QR Code Container and animation */
.qr-payment-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: 1.5rem 0 2rem 0;
}

.qr-wrapper {
  background: white;
  padding: 1.5rem;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md), 0 0 15px rgba(75, 48, 106, 0.05);
  border: 1px solid var(--color-secondary-light);
  width: 240px;
  height: 240px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.qr-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.qr-image.hidden {
  display: none;
}

/* Custom simulated QR code design */
.qr-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.promptpay-header-logo {
  font-size: 0.9rem;
  font-weight: 800;
  font-style: italic;
  display: flex;
  margin-bottom: 0.25rem;
}

.promptpay-header-logo .pp-p {
  color: #003666;
}

.promptpay-header-logo .pp-pay {
  color: #03a5e1;
}

.qr-placeholder-gfx {
  flex: 1;
  width: 140px;
  height: 140px;
  border: 2px dashed var(--color-secondary-light);
  border-radius: 8px;
  position: relative;
  background: radial-gradient(circle, rgba(75, 48, 106, 0.03) 0%, rgba(0, 0, 0, 0) 80%);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  margin: 0.5rem 0;
}

.qr-box-corner {
  position: absolute;
  width: 25px;
  height: 25px;
  border: 4px solid var(--color-primary);
}

.qr-box-corner.top-left {
  top: 10px;
  left: 10px;
  border-right: none;
  border-bottom: none;
}

.qr-box-corner.top-right {
  top: 10px;
  right: 10px;
  border-left: none;
  border-bottom: none;
}

.qr-box-corner.bottom-left {
  bottom: 10px;
  left: 10px;
  border-right: none;
  border-top: none;
}

.qr-center-icon {
  font-size: 2.2rem;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.qr-mock-dots {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  background-image: radial-gradient(var(--color-secondary-light) 20%, transparent 20%),
    radial-gradient(var(--color-secondary-light) 20%, transparent 20%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
  opacity: 0.25;
}

.qr-scan-line {
  position: absolute;
  width: 100%;
  height: 3px;
  background: var(--gradient-healing);
  top: 0;
  box-shadow: 0 0 8px var(--color-accent-warm);
  animation: qr-scan 2.5s infinite linear;
}

@keyframes qr-scan {
  0% {
    top: 0%;
  }

  50% {
    top: 100%;
  }

  100% {
    top: 0%;
  }
}

.payment-status-box {
  width: 100%;
}

.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.4rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-accent-gold);
}

.status-dot.pulsing {
  animation: dot-pulse 1.5s infinite ease-in-out;
}

.status-dot.success {
  background-color: #2e7d32;
  box-shadow: 0 0 8px rgba(46, 125, 50, 0.4);
}

.status-dot.fail {
  background-color: #d32f2f;
  box-shadow: 0 0 8px rgba(211, 47, 47, 0.4);
}

@keyframes dot-pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
    box-shadow: 0 0 0 0 rgba(214, 175, 85, 0.4);
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
    box-shadow: 0 0 8px 3px rgba(214, 175, 85, 0.4);
  }

  100% {
    transform: scale(0.8);
    opacity: 0.5;
    box-shadow: 0 0 0 0 rgba(214, 175, 85, 0.4);
  }
}

.status-help {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Dev Sandbox Tools Panel */
.dev-tools-panel {
  background: rgba(234, 168, 155, 0.08);
  border: 1px dashed var(--color-accent-warm);
  border-radius: var(--border-radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
  text-align: left;
  box-sizing: border-box;
}

.dev-tools-panel h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.dev-tools-panel p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.dev-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-dev {
  flex: 1;
  border: none;
  padding: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  transition: all 0.2s ease;
}

.btn-dev-success {
  background: #2e7d32;
}

.btn-dev-success:hover {
  background: #1b5e20;
}

.btn-dev-fail {
  background: #c62828;
}

.btn-dev-fail:hover {
  background: #b71c1c;
}

.btn-cancel-payment {
  background: transparent;
  border: 1px solid var(--color-secondary-light);
  color: var(--color-primary);
  padding: 0.5rem 1.5rem;
  font-size: 0.9rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-cancel-payment:hover {
  background: var(--bg-secondary);
  border-color: var(--color-primary);
}

/* Chat Quota indicator in session */
.chat-quota-badge {
  background: rgba(75, 48, 106, 0.06);
  border-bottom: 1px solid rgba(149, 123, 190, 0.12);
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chat-quota-badge.hidden {
  display: none !important;
}

.chat-quota-badge strong {
  color: var(--color-primary);
  background: var(--color-secondary-light);
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

/* Settings divider styling */
.settings-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 700;
  margin: 1.5rem 0 1rem 0;
}

.settings-divider::before,
.settings-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(149, 123, 190, 0.25);
}

.settings-divider:not(:empty)::before {
  margin-right: .5em;
}

.settings-divider:not(:empty)::after {
  margin-left: .5em;
}

/* Payment loading overlay */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.overlay .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.overlay.hidden {
  display: none;
}

/* Custom password field masking using standard browser webkit-text-security */
.password-masked {
  -webkit-text-security: disc !important;
  text-security: disc !important;
}

/* Booking Container for Package 3 (Line Add) */
.booking-line-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: 1.5rem 0 2rem 0;
  text-align: center;
}

.booking-details-text {
  width: 100%;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(149, 123, 190, 0.2);
  box-sizing: border-box;
}

.booking-details-text h3 {
  font-size: 1.25rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.booking-details-text p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.booking-divider {
  font-size: 0.85rem;
  color: var(--color-accent-gold);
  margin: 1.25rem 0;
  letter-spacing: 2px;
}

.booking-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
  max-width: 420px;
  margin: 0 auto;
}

.booking-item {
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  border-left: 3px solid var(--color-accent-gold);
}

.booking-item strong {
  color: var(--color-accent-warm);
}

.line-qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.line-qr-image {
  width: 180px;
  height: 180px;
  background: white;
  padding: 1rem;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md), 0 0 15px rgba(46, 125, 50, 0.1);
  border: 1px solid rgba(46, 125, 50, 0.2);
}

.line-id-badge {
  font-size: 0.9rem;
  font-weight: 700;
  color: #06c755;
  background: rgba(6, 199, 85, 0.08);
  padding: 0.35rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(6, 199, 85, 0.2);
}

.btn-line-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #06c755 0%, #05b04b 100%) !important;
  color: white !important;
  text-decoration: none;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-pill);
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.3);
  transition: all 0.3s ease;
  margin-top: 0.5rem;
}

.btn-line-add:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(6, 199, 85, 0.4);
}