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

:root {
  --sand: #D2B48C;
  --dark-wood: #5C4033;
  --rust: #8B4513;
  --denim: #4A6FA5;
  --parchment: #F5E6C8;
  --gunmetal: #535C68;
  --dark-bg: #2C1810;
  --wood-light: #8B6914;
  --gold-accent: #DAA520;
  --blood-red: #8B0000;
}

body {
  background: var(--dark-bg);
  font-family: 'Courier Prime', monospace;
  color: var(--parchment);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  position: relative;
}

#canvas {
  display: block;
  position: absolute;
  top: 48px;
  left: 0;
  cursor: crosshair;
}

/* Resource Bar */
#resource-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(180deg, #6B4226 0%, #4A2E1A 50%, #3D2415 100%);
  border-bottom: 3px solid #2C1810;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  z-index: 100;
  box-shadow: 0 3px 10px rgba(0,0,0,0.6);
  overflow-x: auto;
  flex-wrap: nowrap;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(0,0,0,0.3);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(218,165,32,0.2);
}

.res-icon {
  font-size: 14px;
}

.day-counter {
  font-family: 'Rye', serif;
  color: var(--gold-accent);
  font-size: 14px;
  font-weight: 400;
}

/* Weather indicator styling */
#res-weather {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Buttons */
.btn-leather {
  font-family: 'Rye', serif;
  background: linear-gradient(180deg, #8B6914 0%, #6B4226 100%);
  color: var(--parchment);
  border: 2px solid var(--gold-accent);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-leather:hover {
  background: linear-gradient(180deg, #A07D1A 0%, #7B5230 100%);
  box-shadow: 0 0 8px rgba(218,165,32,0.4);
  transform: translateY(-1px);
}

.btn-leather:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-leather:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-small {
  background: rgba(0,0,0,0.4);
  color: var(--parchment);
  border: 1px solid var(--gold-accent);
  width: 24px;
  height: 24px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-menu-corner {
  position: fixed;
  top: 56px;
  left: 8px;
  z-index: 90;
  padding: 4px 8px;
  font-size: 16px;
}

/* Floating Build Button */
.btn-build-floating {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  font-family: 'Rye', serif;
  background: linear-gradient(180deg, #B8860B 0%, #8B6914 50%, #5C4033 100%);
  color: #FFD700;
  border: 3px solid #FFD700;
  padding: 10px 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  box-shadow: 0 4px 20px rgba(218,165,32,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: all 0.2s;
  animation: build-pulse 3s ease-in-out infinite;
}

.btn-build-floating:hover {
  background: linear-gradient(180deg, #DAA520 0%, #B8860B 50%, #6B4226 100%);
  box-shadow: 0 6px 30px rgba(218,165,32,0.6), inset 0 1px 0 rgba(255,255,255,0.2);
  transform: translateX(-50%) translateY(-3px) scale(1.05);
}

.btn-build-floating:active {
  transform: translateX(-50%) translateY(1px) scale(0.97);
  box-shadow: 0 2px 10px rgba(218,165,32,0.3);
}

.btn-build-floating.hidden {
  display: none;
}

@keyframes build-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(218,165,32,0.3), inset 0 1px 0 rgba(255,255,255,0.15); }
  50% { box-shadow: 0 4px 30px rgba(218,165,32,0.6), inset 0 1px 0 rgba(255,255,255,0.15); }
}

/* Panels */
.panel {
  position: fixed;
  background: linear-gradient(180deg, #4A2E1A 0%, #3D2415 100%);
  border: 2px solid var(--gold-accent);
  z-index: 80;
  box-shadow: -4px 0 15px rgba(0,0,0,0.5);
}

.panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  font-family: 'Rye', serif;
  font-size: 14px;
  color: var(--gold-accent);
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(218,165,32,0.3);
}

/* Build Panel */
#build-panel {
  right: 0;
  top: 48px;
  bottom: 36px;
  width: 220px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s;
}

#build-panel.collapsed {
  transform: translateX(180px);
}

#build-tabs {
  display: flex;
  flex-wrap: wrap;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(218,165,32,0.2);
  gap: 0;
}

.tab-btn {
  flex: 1 1 auto;
  padding: 4px 1px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--parchment);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 0;
  font-size: 12px;
}

.tab-btn.active {
  border-bottom-color: var(--gold-accent);
  background: rgba(218,165,32,0.1);
}

.tab-btn:hover {
  background: rgba(218,165,32,0.15);
}

#build-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.build-item {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(218,165,32,0.15);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.build-item:hover {
  border-color: var(--gold-accent);
  background: rgba(218,165,32,0.1);
}

.build-item.selected {
  border-color: #FFD700;
  background: rgba(218,165,32,0.2);
  box-shadow: 0 0 8px rgba(218,165,32,0.3);
}

.build-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.build-item-name {
  font-family: 'Rye', serif;
  font-size: 11px;
  color: var(--gold-accent);
  margin-bottom: 3px;
}

.build-item-cost {
  font-size: 10px;
  color: #aaa;
}

.build-item-desc {
  font-size: 9px;
  color: #888;
  margin-top: 2px;
}

/* Drag handle on build items */
.drag-handle {
  float: right;
  cursor: grab;
  font-size: 12px;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s;
}

.drag-handle:hover {
  opacity: 1;
  transform: scale(1.3);
}

.build-item[draggable="true"] {
  cursor: grab;
}

.build-item[draggable="true"]:active {
  cursor: grabbing;
}

.drag-ghost {
  pointer-events: none;
  z-index: 9999;
}

/* Money Generator Button */
.btn-money {
  font-family: 'Rye', serif;
  background: linear-gradient(180deg, #2d8a2d 0%, #1a5c1a 100%);
  color: #FFD700;
  border: 2px solid #4aff4a;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  box-shadow: 0 0 6px rgba(74,255,74,0.2);
  animation: money-glow 2s ease-in-out infinite alternate;
}

.btn-money:hover {
  background: linear-gradient(180deg, #3aad3a 0%, #237023 100%);
  box-shadow: 0 0 14px rgba(74,255,74,0.5);
  transform: translateY(-1px) scale(1.05);
}

.btn-money:active {
  transform: translateY(1px) scale(0.95);
}

@keyframes money-glow {
  0% { box-shadow: 0 0 4px rgba(74,255,74,0.2); }
  100% { box-shadow: 0 0 10px rgba(74,255,74,0.4); }
}

.btn-money.money-printing {
  animation: money-print 0.6s ease-out;
}

@keyframes money-print {
  0% { transform: scale(1); }
  20% { transform: scale(1.3) rotate(-5deg); }
  40% { transform: scale(0.9) rotate(5deg); }
  60% { transform: scale(1.15) rotate(-3deg); }
  80% { transform: scale(0.95) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Building Info Panel */
#building-info {
  left: 8px;
  top: 100px;
  width: 200px;
  border-radius: 6px;
}

#info-body {
  padding: 10px;
  font-size: 12px;
}

#info-body .info-stat {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(218,165,32,0.1);
}

#info-body .info-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.hidden {
  display: none;
}

.modal-content.parchment {
  background: linear-gradient(135deg, #F5E6C8 0%, #E8D5A8 50%, #D4C090 100%);
  color: var(--dark-wood);
  border: 3px solid var(--rust);
  border-radius: 8px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), inset 0 0 20px rgba(139,69,19,0.1);
  text-align: center;
}

.modal-content.parchment h2 {
  font-family: 'Rye', serif;
  font-size: 20px;
  color: var(--rust);
  margin-bottom: 12px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.modal-content.parchment p {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.modal-content .btn-leather {
  margin: 4px;
}

/* Ticker */
#ticker-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: linear-gradient(180deg, #3D2415 0%, #2C1810 100%);
  border-top: 2px solid rgba(218,165,32,0.3);
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 100;
  overflow: hidden;
}

#ticker-text {
  font-family: 'Courier Prime', monospace;
  font-size: 12px;
  color: var(--gold-accent);
  white-space: nowrap;
  animation: ticker-scroll 20s linear infinite;
}

@keyframes ticker-scroll {
  0% { transform: translateX(100vw); }
  100% { transform: translateX(-100%); }
}

/* Footer */
#game-footer {
  position: fixed;
  bottom: 38px;
  right: 8px;
  z-index: 90;
}

#game-footer a {
  font-family: 'Rye', serif;
  font-size: 10px;
  color: rgba(218,165,32,0.3);
  text-decoration: none;
}

#game-footer a:hover {
  color: rgba(218,165,32,0.6);
}

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

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}

::-webkit-scrollbar-thumb {
  background: var(--rust);
  border-radius: 3px;
}

/* Command panel styles */
.command-section {
  margin-bottom: 10px;
}

.command-section h3 {
  font-family: 'Rye', serif;
  font-size: 11px;
  color: var(--gold-accent);
  margin-bottom: 4px;
}

.command-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 11px;
}

.btn-recruit {
  background: linear-gradient(180deg, #6B4226 0%, #4A2E1A 100%);
  color: var(--parchment);
  border: 1px solid var(--gold-accent);
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
  font-family: 'Courier Prime', monospace;
}

.btn-recruit:hover {
  background: linear-gradient(180deg, #7B5230 0%, #5A3E2A 100%);
}

.btn-recruit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Mob boss raid button pulse */
.mob-raid-btn:not(:disabled) {
  animation: raid-pulse 1.5s ease-in-out infinite alternate;
}

@keyframes raid-pulse {
  0% { box-shadow: 0 0 2px rgba(255,68,68,0.3); }
  100% { box-shadow: 0 0 10px rgba(255,68,68,0.6); }
}

.mob-raid-btn:hover:not(:disabled) {
  background: linear-gradient(180deg,#a00,#700) !important;
  transform: scale(1.02);
}

.stat-bar {
  height: 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 3px;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  #build-panel {
    width: 180px;
  }
  
  .resource-item {
    padding: 3px 5px;
    font-size: 11px;
  }
  
  #resource-bar {
    gap: 4px;
    padding: 0 4px;
  }
  
  .btn-leather {
    padding: 4px 10px;
    font-size: 10px;
  }
}

@media (max-width: 500px) {
  #build-panel {
    width: 160px;
  }
  
  .resource-item {
    padding: 2px 4px;
    font-size: 10px;
  }
}