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

:root {
  --sage-green: #9caf88;
  --sage-light: #b8c9a3;
  --sage-dark: #7a8f6e;
  --earth-brown: #8b7355;
  --earth-light: #a89078;
  --warm-white: #f5f2eb;
  --soft-cream: #ede8dc;
  --muted-gray: #9a9a8a;
  --soft-shadow: rgba(90, 80, 70, 0.15);
  --text-color: #4a4a40;
  --text-muted: #7a7a6a;
}

body {
  overflow: hidden;
  background-color: var(--soft-cream);
  font-family: "Georgia", serif;
  color: var(--text-color);
  cursor: default;
}

body.dark-mode {
  --soft-cream: #2a2a2a;
  --warm-white: #3a3a3a;
  --text-color: #e0e0e0;
  --text-muted: #a0a0a0;
  --soft-shadow: rgba(0, 0, 0, 0.3);
}

.hidden {
  display: none !important;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* Welcome Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--soft-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 3s ease-out;
  pointer-events: none;
}

.overlay.fade-out {
  opacity: 0;
}

.overlay.hidden {
  display: none;
}

.welcome-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 2.2;
  font-style: italic;
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px var(--soft-shadow);
  pointer-events: none;
  z-index: 100;
  max-width: 200px;
  transition: opacity 0.2s ease;
}

.tooltip.hidden {
  opacity: 0;
}

.tooltip-title {
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--sage-dark);
}

.tooltip-state {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 6px 20px var(--soft-shadow);
  z-index: 200;
  min-width: 150px;
}

.context-menu.hidden {
  display: none;
}

.menu-title {
  font-size: 0.9rem;
  color: var(--sage-dark);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--sage-light);
}

.menu-option {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background 0.15s ease;
}

.menu-option:hover {
  background: var(--sage-light);
}

.menu-option.disabled {
  color: var(--muted-gray);
  cursor: not-allowed;
}

.menu-option.disabled:hover {
  background: transparent;
}

/* Currency Display */
.currency-display {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.95rem;
  color: var(--text-white);
  box-shadow: 0 2px 8px var(--soft-shadow);
  opacity: 0.85;
  transition: opacity 0.3s ease;
}

.currency-display:hover {
  opacity: 1;
}

.currency-display.hidden {
  display: none;
}

/* Panels (Shop, Inventory) */
.panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 10px 40px var(--soft-shadow);
  z-index: 300;
  min-width: 320px;
  max-width: 90vw;
  max-height: 70vh;
  overflow: hidden;
}

.panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--sage-light);
  color: var(--text-color);
  font-size: 1.1rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s ease;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-color);
}

.panel-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(70vh - 60px);
}

.shop-item,
.inventory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--sage-light);
  border-radius: 10px;
  margin-bottom: 10px;
  transition: background 0.15s ease;
}

.shop-item:hover,
.inventory-item:hover {
  background: var(--soft-cream);
}

.item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-icon {
  font-size: 1.5rem;
}

.item-name {
  font-weight: normal;
  color: var(--text-color);
}

.item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-price,
.item-count {
  color: var(--sage-dark);
  font-size: 0.9rem;
}

.buy-btn,
.use-btn {
  background: var(--sage-green);
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  color: var(--warm-white);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.buy-btn:hover,
.use-btn:hover {
  background: var(--sage-dark);
}

.buy-btn:disabled {
  background: var(--muted-gray);
  cursor: not-allowed;
}

/* Toolbar */
.toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 30px;
  padding: 8px 16px;
  box-shadow: 0 4px 16px var(--soft-shadow);
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.toolbar:hover {
  opacity: 1;
}

.tool-btn {
  background: none;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.tool-btn:hover {
  background: var(--sage-light);
}

.tool-btn.active {
  background: var(--sage-green);
}

.tool-btn:active {
  transform: scale(0.95);
}

.tool-icon {
  font-size: 1.4rem;
}

.toolbar-divider {
  width: 1px;
  height: 30px;
  background: var(--sage-light);
  margin: 0 6px;
}

/* Dialogue Bubble */
.dialogue-bubble {
  position: fixed;
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 16px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--text-muted);
  box-shadow: 0 4px 12px var(--soft-shadow);
  max-width: 250px;
  z-index: 150;
  opacity: 1;
  transition: opacity 1s ease-out;
}

.dialogue-bubble.hidden {
  display: none;
}

.dialogue-bubble.fade-out {
  opacity: 0;
}

.dialogue-bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 20px;
  width: 16px;
  height: 16px;
  background: var(--warm-white);
  border-right: 1px solid var(--sage-light);
  border-bottom: 1px solid var(--sage-light);
  transform: rotate(45deg);
}

/* Cursor states */
body.cursor-water {
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><text y="18" font-size="18">💧</text></svg>')
      12 12,
    auto;
}

body.cursor-plant {
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><text y="18" font-size="18">🌱</text></svg>')
      12 12,
    auto;
}

body.cursor-harvest {
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><text y="18" font-size="18">🧺</text></svg>')
      12 12,
    auto;
}

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

::-webkit-scrollbar-track {
  background: var(--soft-cream);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--sage-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--sage-green);
}

/* Animations */
@keyframes gentle-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.needs-attention {
  animation: gentle-bounce 2s ease-in-out infinite;
}

/* Camera navigation arrows */
.camera-arrows {
  position: fixed;
  bottom: 100px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.camera-arrows:hover {
  opacity: 1;
}

.arrow-row {
  display: flex;
  gap: 4px;
}

.arrow-btn {
  width: 40px;
  height: 40px;
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--sage-dark);
  box-shadow: 0 2px 8px var(--soft-shadow);
  transition: background 0.15s ease, transform 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
}

.arrow-btn:hover {
  background: var(--sage-light);
}

.arrow-btn:active {
  background: var(--sage-green);
  color: var(--warm-white);
  transform: scale(0.95);
}

/* Hamburger menu button */
.hamburger-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  background: var(--warm-white);
  border: 1px solid var(--sage-light);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px;
  box-shadow: 0 2px 8px var(--soft-shadow);
  transition: background 0.15s ease;
  z-index: 100;
}

.hamburger-btn:hover {
  background: var(--sage-light);
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: var(--sage-dark);
  border-radius: 1px;
}

/* Main menu panel */
.main-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--warm-white);
  border-right: 1px solid var(--sage-light);
  box-shadow: 4px 0 16px var(--soft-shadow);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.main-menu:not(.hidden) {
  transform: translateX(0);
}

.main-menu .menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--sage-light);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--sage-dark);
}

.menu-items {
  padding: 10px;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 15px 20px;
  background: none;
  border: none;
  border-radius: 8px;
  text-align: left;
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s ease;
}

.menu-item:hover {
  background: var(--sage-light);
}

/* Confirm dialog */
.confirm-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.confirm-dialog:not(.hidden) {
  display: flex;
}

.confirm-content {
  background: var(--warm-white);
  padding: 30px;
  border-radius: 12px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px var(--soft-shadow);
}

.confirm-content p {
  margin-bottom: 20px;
  color: var(--text-primary);
  line-height: 1.5;
}

.confirm-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, transform 0.1s ease;
}

.confirm-btn:active {
  transform: scale(0.98);
}

.confirm-yes {
  background: var(--sage-green);
  color: white;
}

.confirm-yes:hover {
  background: var(--sage-dark);
}

.confirm-no {
  background: var(--muted-gray);
  color: var(--text-primary);
}

.confirm-no:hover {
  background: var(--sage-light);
}

/* Landscape selector */
.landscape-selector {
  display: flex;
  gap: 4px;
  margin-left: 6px;
}

.landscape-btn {
  width: 36px;
  height: 36px;
  background: var(--soft-cream);
  border: 1px solid var(--sage-light);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.landscape-btn:hover {
  background: var(--sage-light);
}

.landscape-btn.active {
  background: var(--sage-green);
  border-color: var(--sage-dark);
}

.landscape-btn:active {
  transform: scale(0.95);
}

/* Tool popover tooltip */
.tool-popover {
  position: fixed;
  background: var(--sage-dark);
  color: var(--warm-white);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -100%);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}

.tool-popover:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.tool-popover::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--sage-dark);
}
