* {
  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;
  --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%);
}

/* Header */
.game-header {
  background: var(--bg-medium);
  border-bottom: 4px solid var(--border-color);
  padding: 12px 16px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
}

.game-title {
  font-size: 16px;
  color: var(--accent-gold);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
  margin-bottom: 8px;
  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: 24px;
  color: var(--accent-orange);
  text-shadow: 2px 2px 0 #000;
}

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

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

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

.mobile-tab {
  flex: 1;
  padding: 10px;
  font-family: inherit;
  font-size: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.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;
}

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

.creature-card.locked {
  opacity: 0.5;
  cursor: default;
}

.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;
}

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

.creature-sprite img.loaded {
  opacity: 1;
  animation: creatureIdle 2s ease-in-out infinite;
}

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

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

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

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

.creature-rarity {
  font-size: 6px;
}

.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);
}

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

.creature-nps {
  font-size: 7px;
  color: var(--accent-green);
  margin-bottom: 4px;
}

.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);
}

.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&seed=1337') center/cover,
    linear-gradient(180deg, #2d4a1c 0%, #1a3312 100%);
  opacity: 0.4;
  filter: blur(1px);
}

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

.nut-button {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #e8c36a 0%, #b8862b 50%, #8b5a1b 100%);
  border: 6px solid #5c3d1e;
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: 
    0 8px 0 #3d2810,
    0 12px 20px rgba(0,0,0,0.5),
    inset 0 -10px 20px rgba(0,0,0,0.3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.nut-button:active, .nut-button.wiggle {
  transform: scale(0.95);
  box-shadow: 
    0 4px 0 #3d2810,
    0 6px 10px rgba(0,0,0,0.5),
    inset 0 -10px 20px rgba(0,0,0,0.3);
}

.nut-image {
  width: 120px;
  height: 120px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

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

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

/* Stats & Upgrades panel */
.stats-box {
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  padding: 10px;
  margin-bottom: 16px;
}

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

.stat-item:last-child {
  border-bottom: none;
}

.stat-item span:first-child {
  color: var(--text-dim);
}

.stat-item span:last-child {
  color: var(--accent-orange);
}

.upgrades-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upgrade-button {
  font-family: inherit;
  font-size: 7px;
  padding: 10px;
  border: 3px solid;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  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);
}

.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;
}

.upgrade-name {
  color: var(--accent-gold);
}

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

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

.purchased .upgrade-desc {
  color: rgba(255,255,255,0.8);
}

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

.upgrade-owned {
  font-size: 8px;
  color: white;
}

/* 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;
}

.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: var(--accent-orange);
  color: var(--accent-orange);
}

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

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

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

.modal-content {
  background: var(--bg-medium);
  border: 4px solid var(--accent-gold);
  padding: 20px;
  max-width: 320px;
  width: 100%;
  position: relative;
  box-shadow: 0 0 40px rgba(212, 165, 71, 0.3);
}

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

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

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

.modal-header h2 {
  font-size: 12px;
  color: var(--accent-gold);
  margin: 10px 0 8px;
}

.creature-lore {
  font-size: 7px;
  color: var(--text-dim);
  line-height: 1.6;
}

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

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  padding: 4px 0;
}

.stat-row span:first-child {
  color: var(--text-dim);
}

.stat-row span:last-child {
  color: var(--text-light);
}

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

.action-button {
  font-family: inherit;
  font-size: 8px;
  padding: 12px;
  border: 3px solid;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  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);
}

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

.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: 50vh;
  }
  
  .nut-button {
    width: 140px;
    height: 140px;
  }
  
  .nut-image {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 12px;
  }
  
  .nut-count {
    font-size: 20px;
  }
  
  .nut-button {
    width: 120px;
    height: 120px;
  }
  
  .nut-image {
    width: 80px;
    height: 80px;
  }
}

/* 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);
}