:root {
  --bg-meadow: #e9f5db;
  --wood-dark: #4a2e1b;
  --wood-mid: #7f4f24;
  --wood-light: #b08968;
  --cream: #fffdf5;
  --accent-green: #588157;
  --accent-gold: #f4a261;
  --text-main: #2b2118;
  --shadow: 0 8px 24px rgba(43, 33, 24, 0.14);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #b8e0d2 0%, var(--bg-meadow) 100%);
  color: var(--text-main);
  min-height: 100vh;
}

.app-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-top {
  background: linear-gradient(135deg, #6f4526, #52321b);
  color: #fff8eb;
  border: 3px solid #9c6644;
  border-radius: 16px;
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-size: 2rem;
  background: rgba(255, 255, 255, 0.14);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.farm-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.farm-name-row h1 {
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
}

.xp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.level-badge {
  background: #f4a261;
  color: #2b2118;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.xp-bar-wrap {
  position: relative;
  width: 170px;
  height: 16px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #8ac926, #ffca3a);
  transition: width 0.3s ease;
}

.xp-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-pill small {
  opacity: 0.85;
  font-size: 0.75rem;
}

.mini-btn {
  background: #48cae4;
  color: #032b43;
  border: none;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn:hover {
  filter: brightness(1.08);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  border-radius: 10px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 1rem;
  color: inherit;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 14px;
  align-items: start;
}

@media (max-width: 1020px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.farm-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.canvas-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 4px solid var(--wood-mid);
  box-shadow: var(--shadow);
  background: #8ecae6;
}

#farmCanvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
}

.toast-container {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: rgba(43, 33, 24, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  animation: fadeSlide 2.6s ease forwards;
}

@keyframes fadeSlide {
  0% { opacity: 0; transform: translateY(-6px); }
  12% { opacity: 1; transform: translateY(0); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}

.toolbar {
  background: var(--cream);
  border: 3px solid var(--wood-light);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}

.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-btn {
  background: #f3ead8;
  border: 2px solid #d4bfa3;
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.1s ease, background 0.15s ease;
}

.tool-btn:hover {
  transform: translateY(-1px);
}

.tool-btn.active {
  background: #588157;
  border-color: #3a5a40;
  color: #fff;
}

.sub-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pick-chip {
  background: #fff;
  border: 2px solid #d4bfa3;
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pick-chip.active {
  border-color: #e76f51;
  background: #fff1e6;
}

.pick-chip.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.side-panel {
  background: var(--cream);
  border: 3px solid var(--wood-light);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 680px;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #eadbc8;
  border-bottom: 2px solid var(--wood-light);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 11px 6px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--cream);
  border-bottom: 3px solid #588157;
}

.tab-content {
  display: none;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: #fff;
  border: 1px solid #e2d4c0;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.action-btn {
  background: #588157;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.action-btn.secondary {
  background: #e76f51;
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--wood-mid);
  margin-top: 4px;
}

.ticker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 460px;
  overflow-y: auto;
}

.ticker-item {
  background: #f8f3e8;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.83rem;
}

.chat-form {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}

.chat-form input {
  flex: 1;
  border: 2px solid #d4bfa3;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.chat-form button {
  background: #588157;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
}
