:root {
  /* Day Palette */
  --day-sky: oklch(0.7 0.15 220);
  --day-grass-light: oklch(0.7 0.25 140);
  --day-grass-dark: oklch(0.6 0.2 140);
  --day-hill: oklch(0.55 0.15 145);
  --day-sun: oklch(0.9 0.2 80);

  /* Night Palette */
  --night-sky: oklch(0.25 0.08 260);
  --night-grass-light: oklch(0.35 0.12 140);
  --night-grass-dark: oklch(0.25 0.1 140);
  --night-hill: oklch(0.2 0.05 145);
  --night-moon: oklch(0.95 0.02 100);

  --accent-color: #ff5722;
  --gold-accent: #ffd700;
  --mario-border: #000000;
  --font-pixel: "Press Start 2P", cursive;
  --font-main: "Fredoka", sans-serif;
  --transition-time: 1.5s;
  --poop-brown: #5d4037;
  --poop-gold: #ffd700;
}

[data-theme="day"] { --sky-bg: var(--day-sky); --grass-bg-light: var(--day-grass-light); --grass-bg-dark: var(--day-grass-dark); --hill-bg: var(--day-hill); --celestial-color: var(--day-sun); }
[data-theme="night"] { --sky-bg: var(--night-sky); --grass-bg-light: var(--night-grass-light); --grass-bg-dark: var(--night-grass-dark); --hill-bg: var(--night-hill); --celestial-color: var(--night-moon); }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; outline: none; }
body { font-family: var(--font-main); overflow-x: hidden; transition: background-color var(--transition-time) ease; background-color: #1a1a1a; }

/* View Handling */
.view-container { width: 100vw; min-height: 100vh; transition: opacity 0.5s ease, transform 0.5s ease; position: absolute; top: 0; left: 0; }
.view-container.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }
.view-container.active { opacity: 1; transform: translateY(0); pointer-events: auto; position: relative; }

/* Navigation */
.main-nav { position: fixed; top: 0; left: 0; width: 100%; padding: 20px; z-index: 2000; display: flex; justify: center; transition: all 0.3s ease; }
.nav-container { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(15px); padding: 10px 20px; border-radius: 40px; border: 1px solid rgba(255, 255, 255, 0.2); display: flex; gap: 15px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.nav-link { font-family: var(--font-pixel); font-size: 0.6rem; color: white; text-decoration: none; padding: 12px 18px; border-radius: 20px; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; min-width: 60px; min-height: 44px; cursor: pointer; }
.nav-link:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-2px); }
.nav-link:active { transform: scale(0.95); }
.nav-link.active { background: var(--accent-color); color: white; box-shadow: 0 0 15px var(--accent-color); }

/* Mobile Helpers */
.mobile-only { display: none; }
.collapsible-mobile { transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease; overflow: hidden; }

/* Desktop Hover Effects */
button, .cow-profile, .nav-link, .ad-btn, .submit-btn { cursor: pointer; transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
button:hover, .cow-profile:hover { transform: translateY(-3px) scale(1.05); filter: brightness(1.1); }
button:active, .cow-profile:active { transform: translateY(1px) scale(0.95); }

/* Meadow View */
.meadow { position: relative; width: 100%; height: 100vh; background: linear-gradient(to bottom, var(--sky-bg) 0%, var(--sky-bg) 60%, var(--grass-bg-light) 60%, var(--grass-bg-dark) 100%); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; transition: background var(--transition-time) ease; overflow: hidden; padding-bottom: 12vh; }
.meadow::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-image: radial-gradient(#00000011 1px, transparent 0); background-size: 8px 8px; pointer-events: none; z-index: 1; }

/* Environmental Elements */
.sky { position: absolute; top: 0; left: 0; width: 100%; height: 60%; overflow: hidden; z-index: 2; }
.celestial-body { position: absolute; top: 10%; right: 10%; width: 100px; height: 100px; border-radius: 50%; background-color: var(--celestial-color); box-shadow: 0 0 50px var(--celestial-color); transition: all 1.5s ease; z-index: 1; }
.clouds { position: absolute; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
.stars { position: absolute; width: 100%; height: 100%; z-index: 0; opacity: 0; transition: opacity 1.5s ease; }
[data-theme="night"] .stars { opacity: 1; background-image: radial-gradient(white 1px, transparent 0); background-size: 50px 50px; }

.mario-hills { position: absolute; bottom: 40%; left: 0; width: 100%; height: 200px; z-index: 4; pointer-events: none; }
.hill { position: absolute; bottom: 0; background-color: var(--hill-bg); border: 5px solid var(--mario-border); border-bottom: none; border-radius: 100px 100px 0 0; transition: background-color 1.5s ease; }
.hill-1 { width: 400px; height: 180px; left: -50px; }
.hill-2 { width: 300px; height: 120px; right: -30px; }
.hill-3 { width: 250px; height: 80px; left: 30%; }

/* Cloud Styling */
.cloud { position: absolute; z-index: 2; pointer-events: none; }
.cloud > div { position: absolute; background: white; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }

/* Stats Display */
.stats-toggle-btn { display: none; position: fixed; top: 85px; left: 50%; transform: translateX(-50%); background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(10px); border: 2px solid rgba(255, 255, 255, 0.3); color: white; padding: 12px 20px; border-radius: 25px; font-family: var(--font-pixel); font-size: 0.6rem; z-index: 110; cursor: pointer; min-height: 44px; }
.stats-toggle-btn:hover { background: rgba(255, 255, 255, 0.25); }

.live-stats { position: fixed; top: 100px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 20px; padding: 15px 35px; border-radius: 50px; min-height: auto; z-index: 100; border: 2px solid rgba(255,255,255,0.2); }
.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-label { font-family: var(--font-pixel); font-size: 0.45rem; opacity: 0.7; color: white; margin-bottom: 5px; }
.stat-value { font-family: var(--font-pixel); font-size: 0.8rem; color: var(--gold-accent); }
.stat-divider { width: 2px; height: 25px; background: rgba(255, 255, 255, 0.2); }

.cow-wrapper { display: flex; flex-direction: column; align-items: center; gap: 15px; z-index: 10; padding: 20px; transition: transform 0.3s ease; }

/* Risk Gauge */
.risk-gauge-container { width: 100%; max-width: 300px; background: rgba(0, 0, 0, 0.3); backdrop-filter: blur(10px); padding: 15px; border: 4px solid var(--mario-border); border-radius: 12px; position: relative; }
.risk-labels { display: flex; justify-content: space-between; font-family: var(--font-pixel); font-size: 0.5rem; color: white; margin-bottom: 8px; }
.risk-gauge { width: 100%; height: 20px; background: #222; border: 3px solid var(--mario-border); position: relative; overflow: visible; display: flex; align-items: center; }
.risk-gauge::after { content: "77"; position: absolute; left: 77%; top: -18px; transform: translateX(-50%); font-family: var(--font-pixel); font-size: 0.45rem; color: #ffd700; animation: pulse 1s infinite alternate; }
.risk-marker-77 { position: absolute; left: 77%; top: 0; width: 3px; height: 100%; background: #ffd700; z-index: 5; box-shadow: 0 0 8px #ffd700; }
.risk-fill { width: 0%; height: 100%; background-color: #4CAF50; transition: width 0.1s linear, background-color 0.3s ease; }
.risk-value-display { position: absolute; right: 15px; top: 15px; font-family: var(--font-pixel); font-size: 0.6rem; color: white; text-shadow: 2px 2px 0 #000; }

/* Poop Variations */
.poop-visual.gold .layer { background: #ffd700 !important; box-shadow: 0 0 15px #ffd700; border-color: #b8860b; }
.poop-visual.rainbow .layer { 
  background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3) !important; 
  background-size: 400% 400% !important;
  animation: rainbow-move 2s linear infinite, poop-spawn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
  border-color: #fff;
}
@keyframes rainbow-move { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* Input Bar & Cow Switcher */
.input-bar { position: fixed; bottom: 0; left: 0; width: 100%; padding: 30px 20px; display: flex; flex-direction: column; align-items: center; z-index: 1500; transition: transform 0.3s ease; background: linear-gradient(to top, rgba(0,0,0,0.2), transparent); }
.cow-switcher { display: flex; gap: 15px; margin-bottom: 15px; }
.cow-profile { width: 60px; height: 60px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border: 3px solid rgba(255, 255, 255, 0.2); cursor: pointer; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.cow-profile.active { background: var(--accent-color); border-color: white; transform: scale(1.15) translateY(-8px); box-shadow: 0 8px 20px rgba(255, 87, 34, 0.5); }

.liquid-glass { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(25px) saturate(180%); border: 1px solid rgba(255, 255, 255, 0.3); box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4); border-radius: 30px; padding: 15px; width: 100%; max-width: 800px; min-height: 90px; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; }
.ui-section { display: flex; gap: 15px; width: 100%; }
.ui-section.hidden { display: none; }
#idea-input { flex: 1; border: none; background: rgba(255, 255, 255, 0.08); padding: 18px 30px; font-size: 1.15rem; color: white; border-radius: 20px; border: 1px solid rgba(255,255,255,0.1); }
#idea-input:focus { background: rgba(255, 255, 255, 0.15); border-color: var(--accent-color); }
#feed-button, #reset-button { background: var(--accent-color); color: white; border: 3px solid var(--mario-border); padding: 0 35px; height: 60px; border-radius: 15px; font-size: 0.8rem; font-family: var(--font-pixel); cursor: pointer; box-shadow: 5px 5px 0 var(--mario-border); min-width: 150px; }

/* Poop & Modal */
.poop-container { position: absolute; cursor: pointer; z-index: 10; display: flex; flex-direction: column; align-items: center; transition: transform 0.2s ease; }
.poop-container:hover { transform: scale(1.2); }
.poop-visual { width: 50px; height: 40px; position: relative; animation: poop-spawn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.poop-visual .layer { background: var(--poop-brown); border: 2px solid var(--mario-border); border-radius: 50%; position: absolute; left: 50%; transform: translateX(-50%); }
.poop-visual .bottom { width: 50px; height: 20px; bottom: 0; }
.poop-visual .middle { width: 36px; height: 18px; bottom: 12px; }
.poop-visual .top { width: 20px; height: 14px; bottom: 22px; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(10px); z-index: 3000; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.4s ease; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { width: 90%; max-width: 600px; transform: scale(0.8); transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); text-align: center; padding: 50px 30px; border: 2px solid rgba(255,255,255,0.2); }
.modal-overlay.active .modal-content { transform: scale(1); }
.modal-close-btn { position: absolute; top: 20px; right: 25px; background: none; border: none; color: white; font-size: 2.5rem; cursor: pointer; transition: transform 0.2s ease; }
.modal-close-btn:hover { transform: rotate(90deg); color: var(--accent-color); }
.modal-badge { font-family: var(--font-pixel); font-size: 0.8rem; margin-bottom: 25px; letter-spacing: 1px; }
.modal-text { font-size: 1.8rem; color: white; margin-bottom: 40px; font-weight: 700; line-height: 1.5; }
.share-btn { background: var(--accent-color); color: white; border: 3px solid var(--mario-border); padding: 15px 35px; border-radius: 15px; font-family: var(--font-pixel); font-size: 0.85rem; cursor: pointer; box-shadow: 5px 5px 0 var(--mario-border); }

/* Hubs Styling */
.business-hub, .community-hub, .chat-hub { padding: 140px 20px 80px; max-width: 1100px; margin: 0 auto; color: white; }
.hub-header { margin-bottom: 50px; text-align: center; }
.hub-header h1 { font-family: var(--font-pixel); font-size: 2.5rem; color: var(--gold-accent); margin-bottom: 25px; text-shadow: 3px 3px 0 var(--mario-border); }
.hub-header p { font-size: 1.2rem; opacity: 0.8; }
.ad-grid, .ideas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 30px; margin-bottom: 50px; }
.ad-card, .idea-card { background: rgba(255, 255, 255, 0.07); backdrop-filter: blur(15px); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 25px; padding: 35px; box-shadow: 0 10px 20px rgba(0,0,0,0.2); transition: transform 0.3s ease; }
.ad-card:hover, .idea-card:hover { transform: translateY(-10px); background: rgba(255,255,255,0.1); border-color: var(--accent-color); }

/* Form Styling */
.inquiry-form-container { margin-top: 50px; padding: 40px; }
.inquiry-form-container h2 { font-family: var(--font-pixel); font-size: 1.2rem; color: var(--gold-accent); margin-bottom: 30px; text-align: center; }
.form-group { margin-bottom: 20px; }
.form-group input, .form-group textarea { width: 100%; background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 15px 20px; color: white; font-family: var(--font-main); font-size: 1.1rem; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent-color); outline: none; background: rgba(255,255,255,0.1); }
.submit-btn { width: 100%; background: var(--accent-color); color: white; border: 3px solid var(--mario-border); padding: 15px; border-radius: 12px; font-family: var(--font-pixel); font-size: 0.9rem; box-shadow: 4px 4px 0 var(--mario-border); margin-top: 10px; }

/* Mobile Optimizations */
@media (max-width: 768px) {
  .mobile-only { display: block; }
  
  /* Bottom Navigation */
  .main-nav { top: auto; bottom: 0; padding: 10px 15px 15px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(0,0,0,0.5), transparent); backdrop-filter: none; }
  .nav-container { width: 100%; max-width: none; border-radius: 25px; gap: 5px; padding: 6px; border: 1px solid rgba(255, 255, 255, 0.1); }
  .nav-link { font-size: 0.35rem; padding: 8px 5px; min-width: 0; flex: 1; min-height: 48px; border-radius: 15px; flex-direction: column; gap: 4px; }
  .nav-link::before { font-size: 1.1rem; display: block; margin-bottom: 2px; }
  #nav-meadow::before { content: "🐄"; }
  #nav-business::before { content: "💼"; }
  #nav-community::before { content: "🌐"; }
  #nav-chat::before { content: "💬"; }

  .input-bar { bottom: 85px; bottom: calc(85px + env(safe-area-inset-bottom)); padding: 10px; width: 100%; }
  
  .stats-toggle-btn { display: block; top: 20px; font-size: 0.55rem; padding: 10px 18px; position: fixed; }
  .live-stats { top: 70px; flex-direction: column; padding: 15px; border-radius: 25px; width: calc(100% - 30px); left: 50%; transform: translateX(-50%); gap: 10px; position: fixed; }
  .live-stats.mobile-hidden { display: none; }
  
  /* Collapsible Sections */
  .collapsible-mobile:not(.expanded) { max-height: 0; opacity: 0; margin: 0; pointer-events: none; }
  .collapsible-mobile.expanded { max-height: 2000px; opacity: 1; margin-bottom: 25px; }
  
  .toggle-btn { background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.2); color: white; width: 100%; padding: 15px; border-radius: 15px; font-family: var(--font-pixel); font-size: 0.6rem; margin-bottom: 15px; text-align: center; min-height: 50px; }
  .toggle-btn.active { border-color: var(--accent-color); background: rgba(255, 87, 34, 0.1); }

  .business-hub, .community-hub, .chat-hub { padding: 80px 15px 180px; }
  #view-meadow { padding-bottom: 180px; }
  
  .hub-header h1 { font-size: 1.5rem; }
  .ad-grid, .ideas-grid { grid-template-columns: 1fr; gap: 15px; }
  
  .cow-wrapper { transform: translateY(-30px) scale(0.7); padding: 0; }
  .risk-gauge-container { width: 240px; }
  .cow-profile { width: 50px; height: 50px; font-size: 1.3rem; }
  .ui-section { flex-direction: column; gap: 10px; }
  #idea-input { width: 100%; font-size: 1rem; text-align: center; padding: 15px; border-radius: 15px; }
  #feed-button, #reset-button { width: 100%; height: 50px; font-size: 0.7rem; min-height: 50px; }
  .modal-content { padding: 30px 15px; width: 95%; }
  .modal-text { font-size: 1.2rem; }
}

@media (max-height: 600px) {
  .cow-wrapper { transform: translateY(-40px) scale(0.5); }
  .input-bar { padding: 10px; }
  .cow-switcher { margin-bottom: 5px; }
}

@keyframes pulse { from { opacity: 0.6; transform: translateX(-50%) scale(0.9); } to { opacity: 1; transform: translateX(-50%) scale(1.1); } }
@keyframes poop-spawn { 0% { transform: scale(0) translateY(-20px); } 100% { transform: scale(1) translateY(0); } }
