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

:root {
  --bg1: #fdf3e0;
  --bg2: #f6e3c5;
  --apricot: #e28743;
  --apricot-dark: #c76a28;
  --leaf: #5d9c4a;
  --leaf-dark: #3f7a30;
  --text: #4a3524;
  --panel: #fffdf8;
  --border: #e8d5b5;
  --shadow: 0 6px 18px rgba(140, 90, 30, 0.14);
  --radius: 16px;
}

html, body { height: 100%; }

body {
  font-family: 'Cairo', 'Tahoma', sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  color: var(--text);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: linear-gradient(120deg, var(--apricot-dark), var(--apricot));
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; margin-inline-end: auto; }
.brand-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.18);
  display: grid; place-items: center;
}
.brand h1 { font-size: 22px; font-weight: 800; line-height: 1.1; }
.brand h1 span { color: #ffe2b0; }
.tagline { font-size: 12px; opacity: 0.9; margin-top: 2px; }

.hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-item {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.16);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.hud-item b { color: #fff; }
.hud-item span { opacity: 0.8; font-size: 12px; }
.level-block { flex-direction: column; align-items: flex-start; gap: 4px; padding: 6px 14px; }
.xpbar { width: 120px; height: 8px; background: rgba(255,255,255,0.25); border-radius: 99px; overflow: hidden; }
#xp-fill { height: 100%; background: #ffe2b0; border-radius: 99px; width: 0%; transition: width .4s; }

.icon-btn {
  background: rgba(255,255,255,0.16);
  border: none;
  border-radius: 10px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  color: #fff;
  transition: transform .12s, background .2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.28); transform: translateY(-1px); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  padding: 18px 20px 30px;
  max-width: 1200px;
  margin: 0 auto;
}

.game-panel { display: flex; flex-direction: column; gap: 12px; }

.canvas-wrap {
  position: relative;
  background: #8cbf6e;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}
#farm { display: block; width: 100%; height: auto; touch-action: manipulation; }

.tooltip {
  position: absolute;
  background: rgba(70, 45, 20, 0.92);
  color: #ffe9cc;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  z-index: 5;
}

.scene-clock {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.hint-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}
.hint-bar .dot { opacity: .4; }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { font-size: 15px; font-weight: 800; }
.badge {
  background: var(--apricot);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.map-frame {
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #e6eef3;
}
.map-frame iframe { display: block; width: 100%; height: 220px; border: 0; }

.seed-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.seed-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #fbf3e2;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 4px;
  transition: transform .12s, border-color .15s, box-shadow .15s;
  position: relative;
}
.seed-card:hover { transform: translateY(-2px); }
.seed-card.selected { border-color: var(--apricot); box-shadow: 0 0 0 3px rgba(226,135,67,.25); }
.seed-card.locked { opacity: .45; filter: grayscale(.7); cursor: not-allowed; }
.seed-card .seed-ico { font-size: 26px; line-height: 1; }
.seed-card .seed-name { font-size: 12px; font-weight: 800; }
.seed-card .seed-cost { font-size: 11px; font-weight: 700; color: #a06a2b; }
.seed-card .seed-lock { position: absolute; top: -7px; inset-inline-end: -5px; background: #5b4632; color:#fff; font-size:10px; font-weight:700; padding:2px 7px; border-radius:999px; }

.primary-btn {
  background: linear-gradient(120deg, var(--apricot), var(--apricot-dark));
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(199,106,40,.3);
  transition: transform .12s, filter .2s;
}
.primary-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary-btn:disabled { filter: grayscale(.6); opacity: .6; cursor: not-allowed; transform: none; }
.primary-btn.wide { width: 100%; }

.owned-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.owned-list li {
  font-size: 12px;
  font-weight: 700;
  background: #eef5e7;
  color: var(--leaf-dark);
  border: 1px solid #cfe3c0;
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(70, 45, 20, 0.5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal-card {
  background: var(--panel);
  border-radius: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 86vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 2px solid var(--border);
}
.modal-head h2 { font-size: 18px; font-weight: 800; }
.close-btn {
  background: #f0e2cc;
  border: none;
  border-radius: 10px;
  width: 34px; height: 34px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.close-btn:hover { background: #e6d2b4; }
.modal-body { padding: 18px 20px 22px; }
.modal-sub { font-size: 13px; opacity: .8; margin-bottom: 14px; }

.upgrade-list { display: flex; flex-direction: column; gap: 12px; }
.upgrade-item {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fdf8ee;
}
.upgrade-item .u-ico {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: #f2e2c6;
  display: grid; place-items: center;
  font-size: 22px;
}
.upgrade-item .u-info { flex: 1; }
.upgrade-item .u-name { font-weight: 800; font-size: 14px; }
.upgrade-item .u-desc { font-size: 12px; opacity: .8; margin-top: 2px; }
.upgrade-item .u-cost { font-size: 12px; font-weight: 800; color: #a06a2b; margin-top: 3px; }
.upgrade-item button { flex-shrink: 0; }
.upgrade-item.owned { opacity: .65; }
.upgrade-item.owned button { display: none; }

.help-body ol { padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.7; }
.help-body li::marker { color: var(--apricot); font-weight: 800; }
.tip { margin-top: 14px; background: #eef5e7; color: var(--leaf-dark); padding: 10px 14px; border-radius: 12px; font-size: 13px; font-weight: 700; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  bottom: 20px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: rgba(70, 45, 20, 0.95);
  color: #ffe9cc;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  animation: toast-in .25s ease;
}
.toast.good { background: rgba(61, 122, 48, 0.95); }
.toast.bad { background: rgba(160, 62, 40, 0.95); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .map-frame iframe { height: 180px; }
  .brand .tagline { display: none; }
}
