/* ============================================================
   style.css — 农场游戏样式
   ============================================================ */

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

body {
  overflow: hidden;
  background: #1a1a2e;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  color: #FFF8E7;
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  --hud-font: clamp(14px, 1vw, 18px);
  --hud-count-font: clamp(13px, 0.95vw, 17px);
  --hud-icon-size: clamp(20px, 1.4vw, 26px);
  --toolbar-gap: clamp(6px, 0.5vw, 10px);
  --tool-font: clamp(11px, 0.8vw, 13px);
  --tool-icon-size: clamp(24px, 1.5vw, 30px);
  --action-font: clamp(12px, 0.9vw, 15px);
  --panel-font: clamp(13px, 0.95vw, 16px);
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ---- UI 层 ---- */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

#ui-layer > * {
  pointer-events: auto;
}

#help-button {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255,215,0,0.45);
  border-radius: 999px;
  background: rgba(60,40,20,0.82);
  color: #FFF8E7;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  z-index: 120;
  box-shadow: 0 4px 12px rgba(0,0,0,0.28);
}

#help-button:hover {
  background: rgba(100,70,30,0.92);
  border-color: #FFD700;
}

/* ---- 顶部 HUD ---- */
#hud {
  display: flex;
  gap: clamp(10px, 1vw, 16px);
  padding: clamp(8px, 1vh, 12px) clamp(14px, 1.6vw, 20px);
  flex-wrap: wrap;
  align-items: center;
  background: linear-gradient(180deg, rgba(30,20,10,0.9) 0%, rgba(30,20,10,0) 100%);
  pointer-events: none;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.5vw, 6px);
  font-size: var(--hud-font);
  font-weight: 600;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.hud-countdown {
  font-size: var(--hud-count-font);
  color: #FFF;
  background: rgba(0,0,0,0.3);
  padding: 2px clamp(8px, 0.9vw, 10px);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
}

.hud-icon,
.hud-icon canvas {
  width: var(--hud-icon-size);
  height: var(--hud-icon-size);
  display: block;
}

/* ---- 通知 ---- */
#notifications {
  position: absolute;
  top: clamp(50px, 7vh, 68px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 100;
  width: 400px;
  max-width: 90vw;
}

.notification {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: clamp(12px, 0.9vw, 14px);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  animation: notifIn 0.3s ease-out;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.notif-info {
  background: rgba(52, 152, 219, 0.85);
  color: #fff;
}

.notif-success {
  background: rgba(46, 204, 113, 0.85);
  color: #fff;
}

.notif-warning {
  background: rgba(243, 156, 18, 0.85);
  color: #fff;
}

.notif-danger {
  background: rgba(231, 76, 60, 0.85);
  color: #fff;
}

@keyframes notifIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 底部工具栏 ---- */
#toolbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(0deg, rgba(30,20,10,0.95) 0%, rgba(30,20,10,0.85) 80%, rgba(30,20,10,0) 100%);
  padding: 8px clamp(12px, 1.2vw, 16px) 12px;
}

#tool-buttons {
  display: flex;
  gap: var(--toolbar-gap);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: clamp(6px, 0.7vw, 8px) clamp(10px, 0.9vw, 12px);
  border: 2px solid rgba(139,105,20,0.4);
  border-radius: 8px;
  background: rgba(60,40,20,0.7);
  color: #FFF8E7;
  cursor: pointer;
  transition: all 0.15s;
  min-width: clamp(56px, 4.6vw, 68px);
}

.tool-btn:hover {
  background: rgba(100,70,30,0.8);
  border-color: rgba(139,105,20,0.8);
  transform: translateY(-2px);
}

.tool-btn.active {
  background: rgba(139,105,20,0.6);
  border-color: #FFD700;
  box-shadow: 0 0 10px rgba(255,215,0,0.3);
}

.tool-icon,
.tool-icon canvas {
  width: var(--tool-icon-size);
  height: var(--tool-icon-size);
  display: block;
}

.tool-name {
  font-size: var(--tool-font);
  opacity: 0.9;
}

/* ---- 工具选项 ---- */
#tool-options {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
  min-height: 28px;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.option-label {
  font-size: clamp(12px, 0.85vw, 14px);
  opacity: 0.7;
  margin-right: 4px;
}

.option-btn {
  padding: 3px clamp(8px, 0.8vw, 10px);
  border: 1px solid rgba(139,105,20,0.4);
  border-radius: 12px;
  background: rgba(60,40,20,0.5);
  color: #FFF8E7;
  cursor: pointer;
  font-size: clamp(12px, 0.85vw, 13px);
  transition: all 0.15s;
  white-space: nowrap;
}

.option-btn:hover {
  background: rgba(100,70,30,0.7);
}

.option-btn.active {
  background: rgba(139,105,20,0.6);
  border-color: #FFD700;
}

.option-btn small {
  opacity: 0.6;
}

/* ---- 操作按钮 ---- */
#action-buttons {
  display: flex;
  gap: var(--toolbar-gap);
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: clamp(6px, 0.7vw, 8px) clamp(14px, 1vw, 16px);
  border: 2px solid rgba(139,105,20,0.5);
  border-radius: 8px;
  background: rgba(60,40,20,0.7);
  color: #FFF8E7;
  cursor: pointer;
  font-size: var(--action-font);
  font-weight: 600;
  transition: all 0.15s;
}

.action-btn:hover {
  background: rgba(100,70,30,0.9);
  border-color: #FFD700;
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
}

/* ---- 面板 ---- */
.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: 92vw;
  max-height: 70vh;
  background: rgba(40,28,15,0.97);
  border: 2px solid #8B6914;
  border-radius: 12px;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(139,105,20,0.3);
  border-bottom: 1px solid rgba(139,105,20,0.5);
}

.panel-header h3 {
  font-size: clamp(15px, 1vw, 18px);
  color: #FFD700;
}

.panel-close {
  background: none;
  border: none;
  color: #FFF8E7;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.panel-close:hover {
  background: rgba(231,76,60,0.3);
}

#shop-content,
#upgrade-content,
#unlock-content,
#help-content {
  padding: 12px 16px;
  overflow-y: auto;
  max-height: calc(70vh - 50px);
}

.help-content h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #FFD700;
}

.help-content h4:not(:first-child) {
  margin-top: 14px;
}

.help-content p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255,248,231,0.92);
}

/* ---- 商店 ---- */
.shop-section {
  margin-bottom: 16px;
}

.shop-section h4 {
  font-size: 14px;
  color: #FFD700;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(139,105,20,0.3);
}

.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(60,40,20,0.4);
  border-radius: 8px;
  border: 1px solid rgba(139,105,20,0.2);
}

.shop-item-icon {
  font-size: 28px;
  min-width: 36px;
  text-align: center;
}

.shop-item-info {
  flex: 1;
}

.shop-item-name {
  font-size: var(--panel-font);
  font-weight: 600;
}

.shop-item-detail {
  font-size: clamp(11px, 0.8vw, 13px);
  opacity: 0.7;
  margin-top: 2px;
}

.shop-item-price {
  font-size: var(--panel-font);
  font-weight: 700;
  color: #FFD700;
  white-space: nowrap;
}

.shop-buy-btn {
  padding: 6px 12px;
  border: 1px solid #FFD700;
  border-radius: 6px;
  background: rgba(139,105,20,0.5);
  color: #FFD700;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.shop-buy-btn:hover:not(:disabled) {
  background: rgba(139,105,20,0.8);
}

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

.shop-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(80,60,30,0.55);
  color: rgba(255,248,231,0.75);
  font-size: 12px;
  font-weight: 600;
}

.shop-tag.owned {
  background: rgba(46,204,113,0.2);
  color: #A9F5BC;
}

/* ---- 解锁 ---- */
.unlock-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unlock-item {
  padding: 12px;
  background: rgba(60,40,20,0.4);
  border-radius: 8px;
  border: 1px solid rgba(139,105,20,0.3);
}

.unlock-item.unlocked {
  opacity: 0.6;
  border-color: rgba(46,204,113,0.3);
}

.unlock-item.cant-afford {
  opacity: 0.5;
}

.unlock-name {
  font-size: var(--panel-font);
  font-weight: 600;
}

.unlock-detail {
  font-size: clamp(12px, 0.85vw, 14px);
  opacity: 0.7;
  margin: 4px 0;
}

.unlock-status {
  font-size: clamp(12px, 0.9vw, 14px);
  color: #2ECC71;
}

.fertile-tag {
  color: #FFD700;
  font-size: clamp(12px, 0.85vw, 14px);
}

.unlock-btn {
  padding: 6px 16px;
  border: 1px solid #FFD700;
  border-radius: 6px;
  background: rgba(139,105,20,0.5);
  color: #FFD700;
  cursor: pointer;
  font-size: clamp(12px, 0.9vw, 14px);
  font-weight: 600;
  transition: all 0.15s;
}

.unlock-btn:hover:not(:disabled) {
  background: rgba(139,105,20,0.8);
  transform: translateY(-1px);
}

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

/* ---- 地块提示 ---- */
#tile-tooltip {
  position: absolute;
  top: clamp(50px, 7vh, 68px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(30,20,10,0.9);
  border: 1px solid rgba(139,105,20,0.5);
  border-radius: 8px;
  font-size: clamp(12px, 0.85vw, 13px);
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

#tile-tooltip.hidden {
  display: none;
}

/* ---- 滚动条 ---- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(30,20,10,0.3);
}

::-webkit-scrollbar-thumb {
  background: rgba(139,105,20,0.5);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(139,105,20,0.8);
}

/* ---- 响应式 ---- */
@media (max-width: 600px) {
  #help-button {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .hud-item {
    font-size: 13px;
  }

  .tool-btn {
    padding: 4px 8px;
    min-width: 48px;
  }

  .tool-icon {
    font-size: 18px;
  }

  .tool-name {
    font-size: 10px;
  }

  .action-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .panel {
    width: 96vw;
  }
}
