/* Custom Utilities not handled by inline Tailwind */
html {
  scroll-behavior: smooth;
  font-size: 13px; /* Scale down desktop */
}

@media (max-width: 640px) {
  html {
    font-size: 11px; /* Scale down mobile */
  }
}

.overflow-y-auto,
.overflow-x-auto,
.modal-content {
  -webkit-overflow-scrolling: touch;
}

/* Dedicated hardware-accelerated compositing for canvas background */
#pasture-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Foreground UI Layer Isolation */
.ui-layer-isolated {
  isolation: isolate;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

@keyframes bounce { 
  from { 
    transform: translate3d(0, 0, 0); 
    -webkit-transform: translate3d(0, 0, 0);
  } 
  to { 
    transform: translate3d(0, -4px, 0); 
    -webkit-transform: translate3d(0, -4px, 0);
  } 
}

.leader-crown {
  animation: bounce 1s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
  display: inline-block;
  will-change: transform;
  contain: layout style;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.5);
  }
  20% {
    transform: translate(-50%, -20px) scale(1.5);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -100px) scale(1);
  }
}

.floating-emoji {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  font-size: 2.5rem;
  z-index: 100;
  animation: floatUp 0.8s ease-out forwards;
  will-change: transform, opacity;
}

@keyframes popInCenter {
  0% { transform: translate(-50%, -50%) scale(0.1) rotate(-20deg); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(1.5) rotate(15deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.2) rotate(-5deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
}

.big-emoji-anim {
  position: fixed;
  top: 50%;
  left: 50%;
  font-size: 15rem;
  z-index: 9999;
  pointer-events: none;
  animation: popInCenter 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  filter: drop-shadow(0 20px 30px rgba(0,0,0,0.4));
}

@keyframes flashScreen {
  0% { background-color: transparent; }
  30% { background-color: var(--flash-color, rgba(255,255,255,0.3)); }
  100% { background-color: transparent; }
}

.flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  animation: flashScreen 1s ease-out forwards;
}

/* Base custom styles to support JS toggles */
.modal {
  display: none !important;
}

.modal.open {
  display: flex !important;
  visibility: visible;
  opacity: 1;
}

.modal.open .modal-content {
  transform: translateY(0) scale(1) !important;
}

.tab-pane { 
  display: none; 
}

.tab-pane.active { 
  display: block; 
}

.tab-btn.active {
  color: #1e293b; /* dark slate for playful style */
  border-bottom-color: #1e293b;
}

.dark .tab-btn.active {
  color: #f8fafc;
  border-bottom-color: #f8fafc;
}

.empty-state.is-visible { 
  display: flex !important; 
}

.scoreboard-wrapper.is-empty { 
  display: none !important; 
}

.control-btn.disabled { 
  opacity: 0.4; 
  cursor: not-allowed; 
  pointer-events: none; 
}

/* Pasture Pattern Background */
.bg-pasture {
  background-color: #4ade80; /* green-400 */
}

.dark .bg-pasture,
.dark.bg-pasture,
html.dark,
html.dark body {
  background-color: #022c22; /* emerald-950 deep midnight field */
}

/* Neo-brutalist / Fun UI additions */
.brutal-shadow {
  box-shadow: 4px 4px 0px 0px rgba(15, 23, 42, 1);
}

.dark .brutal-shadow {
  box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 1);
}

.brutal-btn:active:not(.disabled) {
  transform: translate(4px, 4px);
  box-shadow: 0px 0px 0px 0px rgba(15, 23, 42, 1);
}

/* SVG Chart styles */
.bar-chart { width: 100%; height: auto; }
.bar-label { fill: currentColor; font-size: 14px; font-weight: bold; font-family: 'Fredoka', sans-serif; }
.bar-rect { fill: #2563eb; stroke: #0f172a; stroke-width: 2px; rx: 8px; } /* blue-600 */
.bar-value { fill: #64748b; font-size: 14px; font-weight: bold; font-family: 'Fredoka', sans-serif; } /* slate-500 */
.dark .bar-value { fill: #94a3b8; } /* slate-400 */

.timeline ul { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 12px 0; border-bottom: 2px dashed #cbd5e1; font-size: 1rem; }
.dark .timeline li { border-bottom-color: #334155; }
.c-add { color: #2563eb; } /* blue-600 */
.c-sub, .c-kill { color: #dc2626; } /* red-600 */
.c-marry { color: #ea580c; } /* orange-600 */
.c-bank { color: #0f766e; } /* teal-700 */

.dark .c-add { color: #60a5fa; } /* blue-400 */
.dark .c-sub, .dark .c-kill { color: #f87171; } /* red-400 */
.dark .c-marry { color: #fb923c; } /* orange-400 */
.dark .c-bank { color: #2dd4bf; } /* teal-400 */
