/* Global Design Tokens & Reset */
:root {
  --bg-gradient: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0f172a 60%, #020617 100%);
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.12);
  --card-glow: rgba(168, 85, 247, 0.35);
  
  --primary-purple: #9333ea;
  --primary-indigo: #6366f1;
  --accent-gold: #fbbf24;
  --accent-amber: #f59e0b;
  --accent-pink: #ec4899;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --glass-bg: rgba(15, 23, 42, 0.75);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-blur: blur(16px);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-glow: 0 0 25px rgba(147, 51, 234, 0.4);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  padding: 0.5rem 1rem 1.5rem;
}

/* Background Ambient Glows */
.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.25;
  animation: floatOrb 12s ease-in-out infinite alternate;
}

.glow-orb-1 {
  top: -10%;
  left: 20%;
  width: 450px;
  height: 450px;
  background: var(--primary-purple);
}

.glow-orb-2 {
  bottom: 10%;
  right: 15%;
  width: 400px;
  height: 400px;
  background: var(--accent-gold);
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.15); }
}

/* Container & Header */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.brand-badge {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-decoration: none;
  cursor: pointer;
}

.brand-logo-img {
  height: 42px;
  width: auto;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
}

.brand-logo-img:hover {
  transform: scale(1.04);
}

.title-group {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.utility-btns {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.title-group {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.title-logo {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Logo Interactive Ask Button */
.logo-ask-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  border-radius: var(--radius-md);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo-ask-btn:hover:not(:disabled) {
  transform: scale(1.06) translateY(-2px);
}

.logo-ask-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.logo-ask-btn:disabled {
  cursor: not-allowed;
  opacity: 0.75;
  animation: logoPulse 1.2s ease-in-out infinite alternate;
}

@keyframes logoPulse {
  0% { transform: scale(1); filter: brightness(1); }
  100% { transform: scale(1.04); filter: brightness(1.2) drop-shadow(0 0 20px rgba(168, 85, 247, 0.8)); }
}

.title-logo-img {
  max-width: 100%;
  width: clamp(160px, 28vw, 240px);
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  filter: drop-shadow(0 6px 20px rgba(147, 51, 234, 0.45));
  transition: filter 0.3s ease;
}

.logo-ask-btn:hover:not(:disabled) .title-logo-img {
  filter: drop-shadow(0 8px 30px rgba(168, 85, 247, 0.75));
}

/* Prompt Chips */
.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.chip-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--accent-gold);
  border-color: rgba(251, 191, 36, 0.3);
  transform: translateY(-1px);
}

/* 4x4 Grid Container - Scaled up by 25% */
.grid-wrapper {
  position: relative;
  width: 100%;
  max-width: 415px;
  padding: 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  width: 100%;
  aspect-ratio: 1 / 1;
}

/* Cat Card Styling */
.cat-card {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  user-select: none;
  will-change: transform;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cat-card:hover {
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px var(--card-glow);
}

.cat-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cat-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius-md) - 1px);
  pointer-events: none;
  transition: transform 0.4s ease;
}

.cat-card:hover .cat-img {
  transform: scale(1.06);
}

.card-shine {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
  pointer-events: none;
  border-radius: calc(var(--radius-md) - 1px);
}

.card-number-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--accent-gold);
  font-size: 0.75rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Shuffling State Effects */
.cat-grid.shuffling .cat-card {
  pointer-events: none;
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.6);
  border-color: var(--accent-gold);
}

/* Modal Window (<dialog>) */
.answer-modal {
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  background: transparent;
  max-width: 480px;
  width: 90vw;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(147, 51, 234, 0.3);
  overflow: hidden;
  margin: auto;
}

.answer-modal::backdrop {
  background-color: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(12px);
  animation: fadeInBackdrop 0.3s ease-out;
}

@keyframes fadeInBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: linear-gradient(160deg, #1e1b4b 0%, #0f172a 70%, #090d16 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  padding: 2rem 1.75rem;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
  position: relative;
  color: var(--text-main);
  animation: popInModal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popInModal {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-cat-avatar {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  padding: 4px;
  background: linear-gradient(135deg, var(--accent-gold), var(--primary-purple));
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.4);
}

.modal-cat-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid #0f172a;
}

.answer-badge {
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.answer-badge.yes {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.answer-badge.no {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.answer-badge.maybe {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.oracle-verdict-title {
  font-size: 1rem;
  color: var(--accent-gold);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.cat-commentary {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.5;
  color: #f1f5f9;
}

.modal-close-x {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close-x:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: scale(1.1);
}

/* History Modal Window */
.history-modal-content {
  padding: 1.75rem 1.5rem 1.5rem;
  width: 100%;
}

.history-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 0.75rem;
  margin-top: 0.5rem;
}

.history-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.clear-history-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.2rem 0.4rem;
}

.clear-history-btn:hover {
  color: #ef4444;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 280px;
  width: 100%;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateX(4px);
}

.history-cat-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, var(--accent-gold), var(--primary-purple));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.history-cat-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.history-q {
  color: var(--text-main);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.history-a {
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.history-a.yes { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.history-a.no { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.history-a.maybe { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

.empty-history {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0;
}

/* Cat Box fixed at bottom left of screen - Decreased 25% to 315px */
.cat-box-wrapper {
  position: fixed;
  bottom: -12px;
  left: 24px;
  width: 315px;
  height: auto;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 12px 25px rgba(0, 0, 0, 0.65));
  pointer-events: auto;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
}

.cat-box-wrapper.in-box {
  cursor: pointer;
}

.cat-box-wrapper.in-box:hover {
  transform: scale(1.08) rotate(-2deg);
  filter: drop-shadow(0 16px 35px rgba(168, 85, 247, 0.55));
}

.cat-box-img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  user-select: none;
  pointer-events: none;
}

/* Bounce / wiggle animation when a cat hops in/out of the box */
.cat-box-wrapper.box-bounce {
  animation: boxPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes boxPop {
  0% { transform: scale(1) rotate(0deg); }
  40% { transform: scale(1.16) rotate(-5deg); }
  70% { transform: scale(0.95) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Flying clones for WAAPI animation */
.flying-cat-card {
  position: fixed;
  pointer-events: none;
  z-index: 9500;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(251, 191, 36, 0.5);
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Continuous Walking Cat along the bottom from Right to the Cat Box */
.walking-cat-container {
  position: fixed;
  bottom: 24px;
  width: 105px;
  height: auto;
  z-index: 990;
  pointer-events: auto;
  cursor: pointer;
  animation: walkToCatBox 12s linear infinite;
}

.walking-cat-img {
  width: 100%;
  height: auto;
  display: block;
  transform: scaleX(1); /* Face forward (left) towards Cat Box */
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
}

@keyframes walkToCatBox {
  0% {
    left: calc(100vw + 20px);
    opacity: 1;
  }
  80% {
    left: 180px; /* Arrives in front of Cat Box */
    opacity: 1;
    transform: scale(1);
  }
  88% {
    left: 110px; /* Enters Cat Box */
    opacity: 0;
    transform: scale(0.3) translateY(24px);
  }
  89% {
    left: calc(100vw + 20px);
    opacity: 0;
  }
  100% {
    left: calc(100vw + 20px);
    opacity: 0;
  }
}

/* AdSense Banner Container below 4x4 Grid */
.ad-section-below-grid {
  width: 100%;
  max-width: 728px;
  margin: 1.5rem auto 7.5rem; /* 7.5rem bottom margin ensures full clearance from fixed cat box & walking cat */
  min-height: 90px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 5;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 0.5rem;
  box-shadow: var(--shadow-card);
}

.ad-section-below-grid .adsbygoogle {
  width: 100%;
}

/* Responsive Rules */
@media (max-width: 600px) {
  body {
    padding: 1rem 0.5rem;
  }
  
  .cat-grid {
    gap: 0.5rem;
  }
  
  .card-number-badge {
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    bottom: 4px;
    right: 4px;
  }
  
  .modal-actions {
    flex-direction: column;
  }
  
  .cat-box-wrapper {
    width: 195px;
    bottom: -6px;
    left: 12px;
  }

  .ad-section-below-grid {
    margin: 1rem auto 6rem;
    min-height: 50px;
    padding: 0.25rem;
  }
}
