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

:root {
  --bg-dark: #1a120b;
  --bg-medium: #2d1f14;
  --bg-light: #3d2b1f;
  --accent-gold: #d4a547;
  --accent-orange: #e07832;
  --accent-green: #4a7c32;
  --accent-purple: #9b59b6;
  --text-light: #f5e6d3;
  --text-dim: #a89080;
  --border-color: #5c4433;
  --panel-bg: rgba(26, 18, 11, 0.95);
}

body {
  font-family: 'Press Start 2P', cursive;
  background: var(--bg-dark);
  color: var(--text-light);
  min-height: 100vh;
  image-rendering: pixelated;
  overflow-x: hidden;
}

.game-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.1) 2px, rgba(0,0,0,0.1) 4px),
    linear-gradient(180deg, #1a120b 0%, #2d1f14 50%, #1a120b 100%);
  position: relative;
}

/* Falling leaves */
.falling-leaves {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.leaf {
  position: absolute;
  top: -50px;
  font-size: 20px;
  animation: fall linear infinite;
  opacity: 0.6;
}

@keyframes fall {
  0% { transform: translateY(-50px) rotate(0deg); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* Header */
.game-header {
  background: var(--bg-medium);
  border-bottom: 4px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  position: relative;
  z-index: 10;
}

.header-left, .header-right {
  width: 100px;
}

.berrry-badge {
  font-size: 6px;
  color: var(--accent-gold);
  background: var(--bg-dark);
  padding: 4px 6px;
  border: 2px solid var(--border-color);
}

.header-center {
  text-align: center;
}

.game-title {
  font-size: 14px;
  color: var(--accent-gold);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 0 0 10px rgba(212, 165, 71, 0.5);
  margin-bottom: 6px;
  animation: titleBob 2s ease-in-out infinite;
}

@keyframes titleBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.nut-display {
  margin-bottom: 4px;
}

.nut-count {
  font-size: 22px;
  color: var(--accent-orange);
  text-shadow: 2px 2px 0 #000;
  transition: transform 0.1s;
}

.nut-label {
  font-size: 8px;
  color: var(--text-dim);
}

.nps-display {
  font-size: 8px;
  color: var(--accent-green);
}

.sound-toggle {
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  padding: 6px;
  font-size: 14px;
  cursor: pointer;
}

.sound-toggle:hover {
  border-color: var(--accent-gold);
}

/* Mobile tabs */
.mobile-tabs {
  display: none;
  background: var(--bg-medium);
  border-bottom: 4px solid var(--border-color);
}

.mobile-tab {
  flex: 1;
  padding: 12px;
  font-size: 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-tab.active {
  background: var(--bg-light);
}

/* Main layout */
.game-main {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel-bg);
  border-right: 4px solid var(--border-color);
  overflow-y: auto;
  padding: 12px;
}

.panel:last-child {
  border-right: none;
  border-left: 4px solid var(--border-color);
}

.panel-title {
  font-size: 10px;
  color: var(--accent-gold);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--border-color);
  text-align: center;
}

/* Creatures panel */
.creatures-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.creature-card {
  background: var(--bg-light);
  border: 3px solid var(--border-color);
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.creature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--rarity-color);
  opacity: 0;
  transition: opacity 0.2s;
}

.creature-card.owned::before {
  opacity: 1;
}

.creature-card:hover:not(.locked) {
  border-color: var(--accent-gold);
  transform: translateX(2px);
}

.creature-card.locked {
  opacity: 0.4;
  cursor: default;
  filter: grayscale(1);
}

.creature-card-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.creature-sprite {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border: 2px solid var(--border-color);
}

.creature-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s;
}

.creature-sprite img.loading {
  opacity: 0;
}

.creature-sprite img.loaded {
  opacity: 1;
}

.creature-sprite.sleeping img {
  filter: brightness(0.5);
}

.zzz {
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 8px;
  color: #88f;
  animation: zzz 1s ease-in-out infinite;
}

@keyframes zzz {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(-3px); opacity: 0.5; }
}

.sprite-placeholder {
  position: absolute;
  font-size: 24px;
}

.locked-sprite {
  width: 48px;
  height: 48px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-dim);
}

.creature-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.creature-name {
  font-size: 8px;
  transition: color 0.2s;
}

.creature-rarity {
  font-size: 6px;
  color: var(--accent-gold);
  letter-spacing: -1px;
}

.creature-stats {
  display: flex;
  gap: 6px;
}

.level-badge, .dupe-badge {
  font-size: 6px;
  background: var(--bg-dark);
  padding: 2px 4px;
  border: 1px solid var(--border-color);
}

.level-badge {
  color: var(--accent-green);
}

.dupe-badge {
  color: var(--accent-purple);
}

.creature-card-right {
  text-align: right;
}

.creature-nps {
  font-size: 7px;
  color: var(--accent-green);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

.nps-icon {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.buy-button {
  font-family: inherit;
  font-size: 7px;
  padding: 6px 10px;
  border: 2px solid;
  cursor: pointer;
  transition: all 0.15s;
}

.buy-button.can-afford {
  background: var(--accent-green);
  border-color: #6aac52;
  color: white;
}

.buy-button.can-afford:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(74, 124, 50, 0.5);
}

.buy-button.cannot-afford {
  background: var(--bg-dark);
  border-color: var(--border-color);
  color: var(--text-dim);
  cursor: not-allowed;
}

/* Click panel */
.click-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: none !important;
  background: transparent;
}

.forest-bg {
  position: absolute;
  inset: 0;
  background: 
    url('/api/retrodiffusion/image/512/512/simple?prompt=pixel+art+forest+clearing+autumn+trees+fallen+leaves+peaceful+nature+scene+warm+colors&seed=1337') center/cover,
    linear-gradient(180deg, #2d4a1c 0%, #1a3312 100%);
  opacity: 0.35;
  filter: blur(1px);
}

.nut-button-container {
  position: relative;
  z-index: 1;
}

.nut-button {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f0d78c 0%, #c9a227 30%, #8b6914 70%, #5c4510 100%);
  border: 6px solid #3d2810;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 
    0 8px 0 #2d1a08,
    0 12px 30px rgba(0,0,0,0.6),
    inset 0 -15px 30px rgba(0,0,0,0.4),
    inset 0 5px 20px rgba(255,255,255,0.2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.nut-button:hover {
  transform: scale(1.03);
}

.nut-button:active, .nut-button.wiggle {
  transform: scale(0.95);
  box-shadow: 
    0 4px 0 #2d1a08,
    0 6px 15px rgba(0,0,0,0.6),
    inset 0 -10px 20px rgba(0,0,0,0.4);
}

.nut-button.cracked::after {
  content: '';
  position: absolute;
  inset: 20%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 10 L55 50 L90 45 L55 55 L60 90 L50 55 L10 60 L45 50 L40 10 Z' fill='%23ffffff' opacity='0.3'/%3E%3C/svg%3E") center/contain no-repeat;
  animation: crackFlash 0.2s ease-out;
}

@keyframes crackFlash {
  0% { opacity: 1; transform: scale(0.8); }
  100% { opacity: 0; transform: scale(1.2); }
}

.nut-shine {
  position: absolute;
  top: 15%;
  left: 20%;
  width: 30%;
  height: 20%;
  background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, transparent 60%);
  border-radius: 50%;
  pointer-events: none;
}

.nut-image {
  width: 140px;
  height: 140px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  animation: nutIdle 3s ease-in-out infinite;
}

@keyframes nutIdle {
  0%, 100% { transform: rotate(-2deg) scale(1); }
  50% { transform: rotate(2deg) scale(1.02); }
}

.floating-number {
  position: absolute;
  font-family: 'Press Start 2P', cursive;
  font-size: 14px;
  color: var(--accent-gold);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

.floating-number.crit {
  font-size: 20px;
  color: #ff6b6b;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 0 0 10px #ff6b6b;
}

.combo-indicator {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  color: #ff9500;
  text-shadow: 2px 2px 0 #000;
  animation: comboPopIn 0.2s ease-out;
}

@keyframes comboPopIn {
  0% { transform: translateX(-50%) scale(0); }
  50% { transform: translateX(-50%) scale(1.3); }
  100% { transform: translateX(-50%) scale(1); }
}

.particle {
  position: absolute;
  font-size: 12px;
  pointer-events: none;
  z-index: 15;
}

.click-power-display {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  font-size: 8px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.7);
  padding: 8px 14px;
  border: 2px solid var(--border-color);
}

.crit-chance {
  color: #ff6b6b;
}

/* Right panel tabs */
.panel-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.panel-tab {
  flex: 1;
  padding: 8px;
  font-family: inherit;
  font-size: 7px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.panel-tab.active {
  background: var(--bg-light);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Stats panel */
.stats-panel {
  padding: 8px;
}

.panel-subtitle {
  font-size: 9px;
  color: var(--accent-gold);
  margin-bottom: 10px;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  padding: 10px;
  margin-bottom: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 6px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 8px;
  color: var(--text-light);
}

.stat-value.nps {
  color: var(--accent-green);
}

.stat-value.time {
  font-family: monospace;
  color: var(--accent-orange);
}

.golden-acorns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
  padding: 10px;
  font-size: 7px;
  color: #1a1a1a;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

/* Upgrades panel */
.upgrades-panel {
  padding: 8px;
}

.upgrade-category {
  margin-bottom: 12px;
}

.category-title {
  font-size: 7px;
  color: var(--text-dim);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border-color);
}

.upgrade-button {
  width: 100%;
  font-family: inherit;
  font-size: 7px;
  padding: 8px;
  margin-bottom: 4px;
  border: 2px solid;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.upgrade-button.can-afford {
  background: var(--bg-light);
  border-color: var(--accent-gold);
  color: var(--text-light);
}

.upgrade-button.can-afford:hover {
  background: var(--bg-medium);
  box-shadow: 0 0 10px rgba(212, 165, 71, 0.3);
}

.upgrade-button.cannot-afford {
  background: var(--bg-dark);
  border-color: var(--border-color);
  color: var(--text-dim);
  cursor: not-allowed;
}

.upgrade-button.purchased {
  background: var(--accent-green);
  border-color: #6aac52;
  color: white;
  cursor: default;
  opacity: 0.8;
}

.upgrade-name {
  color: var(--accent-gold);
  flex: 1 1 100%;
}

.purchased .upgrade-name {
  color: white;
}

.upgrade-desc {
  font-size: 6px;
  color: var(--text-dim);
  flex: 1 1 100%;
}

.upgrade-cost {
  font-size: 7px;
  color: var(--accent-orange);
}

.upgrade-owned {
  font-size: 10px;
}

/* Prestige panel */
.prestige-panel {
  padding: 12px;
  text-align: center;
}

.prestige-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.prestige-icon {
  font-size: 20px;
  animation: starGlow 2s ease-in-out infinite;
}

@keyframes starGlow {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.2); filter: brightness(1.5); }
}

.prestige-header h3 {
  font-size: 12px;
  color: var(--accent-gold);
}

.prestige-info {
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  padding: 12px;
  margin-bottom: 16px;
}

.prestige-info p {
  font-size: 6px;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.6;
}

.prestige-current {
  font-size: 10px;
  color: var(--accent-gold);
  margin-top: 12px;
}

.prestige-potential {
  font-size: 8px;
  color: var(--accent-green);
  margin-top: 8px;
}

.prestige-button {
  width: 100%;
  font-family: inherit;
  font-size: 10px;
  padding: 16px;
  border: 3px solid;
  cursor: pointer;
  transition: all 0.2s;
}

.prestige-button.can-prestige {
  background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
  border-color: #ffd700;
  color: #1a1a1a;
  animation: prestigeGlow 2s ease-in-out infinite;
}

@keyframes prestigeGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
  50% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.8); }
}

.prestige-button.can-prestige:hover {
  transform: scale(1.02);
}

.prestige-button.cannot-prestige {
  background: var(--bg-dark);
  border-color: var(--border-color);
  color: var(--text-dim);
  cursor: not-allowed;
}

/* Footer */
.game-footer {
  background: var(--bg-medium);
  border-top: 4px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
}

.footer-btn {
  font-family: inherit;
  font-size: 7px;
  padding: 6px 12px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.footer-btn:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

.footer-link {
  font-size: 7px;
  color: var(--accent-gold);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* Toast container */
.toast-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievement-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-medium);
  border: 3px solid var(--accent-gold);
  padding: 10px 14px;
  animation: slideIn 0.3s ease-out, slideOut 0.3s ease-in 2.7s;
  box-shadow: 0 0 20px rgba(212, 165, 71, 0.4);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

.achievement-icon {
  font-size: 24px;
}

.achievement-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.achievement-title {
  font-size: 8px;
  color: var(--accent-gold);
}

.achievement-desc {
  font-size: 6px;
  color: var(--text-dim);
}

.achievement-reward {
  font-size: 7px;
  color: var(--accent-green);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-content {
  background: var(--bg-medium);
  border: 4px solid var(--accent-gold);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  position: relative;
  box-shadow: 0 0 60px rgba(212, 165, 71, 0.3);
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  color: var(--text-light);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 14px;
  margin: 12px 0 4px;
}

.creature-title {
  font-size: 7px;
  color: var(--text-dim);
  font-style: italic;
}

.creature-stars {
  font-size: 10px;
  color: var(--accent-gold);
  margin: 8px 0;
  letter-spacing: 2px;
}

.creature-lore {
  font-size: 6px;
  color: var(--text-dim);
  line-height: 1.8;
  background: var(--bg-dark);
  padding: 10px;
  border: 1px dashed var(--border-color);
  margin-top: 12px;
}

.modal-stats {
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  padding: 12px;
  margin-bottom: 20px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-color);
}

.stat-row:last-of-type {
  border-bottom: none;
}

.stat-row.highlight span:last-child {
  color: var(--accent-green);
}

.level-progress {
  height: 6px;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  margin: 4px 0 8px;
}

.level-progress-bar {
  height: 100%;
  background: var(--accent-green);
  transition: width 0.3s;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-button {
  font-family: inherit;
  font-size: 9px;
  padding: 14px;
  border: 3px solid;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  transition: all 0.15s;
}

.action-button.can-afford {
  background: var(--accent-green);
  border-color: #6aac52;
  color: white;
}

.action-button.can-afford:hover {
  transform: scale(1.02);
  box-shadow: 0 0 15px rgba(74, 124, 50, 0.5);
}

.action-button.cannot-afford {
  background: var(--bg-dark);
  border-color: var(--border-color);
  color: var(--text-dim);
  cursor: not-allowed;
}

.action-name {
  font-size: 9px;
}

.action-cost {
  font-size: 10px;
  color: var(--accent-gold);
}

.cannot-afford .action-cost {
  color: var(--text-dim);
}

.action-benefit {
  font-size: 7px;
  color: #90ee90;
}

.cannot-afford .action-benefit {
  color: var(--text-dim);
}

/* Mobile responsive */
@media (max-width: 900px) {
  .mobile-tabs {
    display: flex;
  }
  
  .game-main {
    grid-template-columns: 1fr;
  }
  
  .panel {
    border: none !important;
    display: none;
  }
  
  .panel.mobile-visible {
    display: block;
  }
  
  .click-panel.mobile-visible {
    display: flex;
    min-height: 55vh;
  }
  
  .nut-button {
    width: 160px;
    height: 160px;
  }
  
  .nut-image {
    width: 120px;
    height: 120px;
  }
  
  .header-left {
    display: none;
  }
  
  .toast-container {
    top: auto;
    bottom: 80px;
    right: 10px;
    left: 10px;
  }
  
  .achievement-toast {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 11px;
  }
  
  .nut-count {
    font-size: 18px;
  }
  
  .nut-button {
    width: 140px;
    height: 140px;
  }
  
  .nut-image {
    width: 100px;
    height: 100px;
  }
  
  .modal-content {
    padding: 16px;
  }
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border: 2px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}