* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: #1b241c; color: #f6f0e2; user-select: none;
  touch-action: none;
}

.farm-app { display: flex; flex-direction: column; width: 100%; height: 100%; }

/* Top Warm Timber Farm Header */
.top-bar {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: rgba(34, 28, 22, 0.96);
  border-bottom: 1px solid rgba(235, 198, 134, 0.28);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.32); z-index: 6;
}
.back-btn {
  text-decoration: none; font-weight: 700; font-size: 0.88rem; color: #f0e4cd;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(235, 198, 134, 0.25);
  padding: 6px 12px; border-radius: 10px; white-space: nowrap; transition: background 0.15s;
}
.back-btn:hover { background: rgba(255, 255, 255, 0.16); }
.title { font-size: 1.05rem; font-weight: 800; color: #fbf4e6; white-space: nowrap; }

.guide-pill {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(235, 198, 134, 0.12); border: 1px solid rgba(235, 198, 134, 0.3);
  border-radius: 999px; padding: 5px 14px; font-size: 0.85rem; font-weight: 600; color: #faf0da;
  overflow: hidden;
}
.guide-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.farmer-toggle-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  background: rgba(185, 72, 56, 0.26); border: 1px solid rgba(235, 145, 126, 0.48);
  color: #fdebe6; border-radius: 999px; font-family: inherit; font-size: 0.82rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.farmer-toggle-btn:hover { background: rgba(185, 72, 56, 0.4); }

.basket-pill {
  display: inline-flex; align-items: center; gap: 9px;
  background: rgba(232, 180, 82, 0.18); border: 1px solid rgba(232, 180, 82, 0.42);
  color: #fef0c8; font-size: 0.82rem; font-weight: 700; padding: 5px 12px;
  border-radius: 999px; white-space: nowrap;
}
.basket-pill strong { color: #fff; font-weight: 800; }

.ctrl-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(235, 198, 134, 0.24);
  background: rgba(255, 255, 255, 0.08); color: #f6f0e2; cursor: pointer; font-size: 0.95rem;
  display: grid; place-items: center; transition: all 0.15s;
}
.ctrl-btn:hover { background: rgba(255, 255, 255, 0.16); }
.ctrl-btn.active { background: rgba(114, 174, 96, 0.3); border-color: rgba(154, 212, 134, 0.58); }

/* Open 3D Stage */
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#farmCanvas { display: block; width: 100%; height: 100%; cursor: pointer; }
#farmCanvas.caress-cursor { cursor: grab; }
#farmCanvas.caress-cursor:active { cursor: grabbing; }

/* Gentle Camera Orbit & Bell Controls */
.cam-controls {
  position: absolute; top: 14px; left: 14px; z-index: 5;
  display: flex; gap: 6px; padding: 5px;
  background: rgba(36, 29, 22, 0.78); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(235, 198, 134, 0.28); border-radius: 14px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}
.cam-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08); color: #fbf3e4; cursor: pointer; font-size: 1rem;
  display: grid; place-items: center; transition: all 0.14s;
}
.cam-btn:hover { background: rgba(232, 180, 82, 0.28); border-color: rgba(232, 180, 82, 0.6); transform: translateY(-1px); }

/* Cozy Warm Animal Friend Card (replaces clinical Barn Cam) */
.friend-card {
  position: absolute; top: 14px; right: 14px; width: 274px; z-index: 5;
  background: rgba(38, 31, 23, 0.89); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(235, 198, 134, 0.36); border-radius: 20px; overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
  transition: transform 0.24s ease, border-color 0.24s ease, box-shadow 0.24s ease;
}
.friend-card.close-bond {
  border-color: #f4c45a;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(244, 196, 90, 0.22);
}

.friend-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; background: rgba(26, 21, 16, 0.9);
  border-bottom: 1px solid rgba(235, 198, 134, 0.16);
}
.friend-tag { font-size: 0.72rem; font-weight: 700; color: #f7deb0; letter-spacing: 0.02em; }
.friend-hearts { font-size: 0.84rem; letter-spacing: 1px; }

.friend-photo-wrap { position: relative; width: 100%; height: 126px; overflow: hidden; background: #1e1a14; }
.friend-photo-wrap::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 -22px 26px rgba(24, 19, 14, 0.55);
}
.friend-photo-wrap img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 30%;
  filter: contrast(1.03) saturate(1.08); transition: transform 0.5s ease;
}
.friend-card:hover .friend-photo-wrap img { transform: scale(1.04); }

.friend-mood-pill {
  position: absolute; bottom: 8px; left: 10px; z-index: 2;
  background: rgba(34, 52, 32, 0.88); border: 1px solid rgba(154, 216, 138, 0.55);
  color: #dcfce7; font-size: 0.69rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}

.friend-info { padding: 10px 12px 12px; }
.friend-title-row h3 { font-size: 1.02rem; font-weight: 800; color: #fffaf0; line-height: 1.15; }
.friend-subtitle { font-size: 0.74rem; color: #d5e8c2; font-weight: 600; margin-top: 2px; }

.friend-meters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 9px 0 10px;
}
.meter-item { display: flex; flex-direction: column; gap: 3px; }
.meter-label { font-size: 0.68rem; font-weight: 700; color: #e8dcc4; }
.meter-track { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.meter-fill.bond { background: linear-gradient(90deg, #f59e0b, #fb7185); }
.meter-fill.food { background: linear-gradient(90deg, #84cc16, #22c55e); }

.friend-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.action-pill {
  font-family: inherit; font-size: 0.78rem; font-weight: 700;
  padding: 7px 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
  color: #fff; transition: all 0.14s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.action-pill:hover { filter: brightness(1.1); transform: translateY(-1px); }
.action-pill.caress {
  background: linear-gradient(135deg, #d95d7a, #b43e5c);
  border-color: rgba(253, 186, 200, 0.4);
}
.action-pill.feed {
  background: linear-gradient(135deg, #c97728, #9e5316);
  border-color: rgba(252, 211, 138, 0.42);
}
.action-pill.collect {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #328c56, #216b3f);
  border-color: rgba(154, 230, 180, 0.48);
  padding: 8px 10px; font-size: 0.83rem;
}

.friend-tip {
  margin-top: 8px; font-size: 0.70rem; color: #d8ccb4; line-height: 1.3; text-align: center;
}

/* Floating Harvest & Cuddle Toast */
.harvest-toast {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%) translateY(-18px);
  background: linear-gradient(135deg, rgba(44, 76, 46, 0.96), rgba(28, 52, 32, 0.96));
  border: 1.5px solid #f0c25c; color: #fef6d8; font-size: 1.02rem; font-weight: 800;
  padding: 8px 20px; border-radius: 999px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  opacity: 0; pointer-events: none; z-index: 8; transition: opacity 0.24s ease, transform 0.28s ease;
}
.harvest-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Cozy Welcome Overlay */
.start-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(18, 22, 16, 0.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 10;
}
.start-overlay.hidden { display: none; }
.start-card {
  background: linear-gradient(165deg, rgba(44, 38, 30, 0.97) 0%, rgba(28, 26, 20, 0.98) 100%);
  border: 1.5px solid rgba(235, 198, 134, 0.34); border-radius: 26px; padding: 24px 32px;
  text-align: center; max-width: 604px; width: 92%;
  box-shadow: 0 28px 68px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.start-photo-strip {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px;
}
.start-photo-strip img {
  width: 100%; height: 56px; border-radius: 12px; object-fit: cover; object-position: center 28%;
  border: 1.5px solid rgba(235, 198, 134, 0.44); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}
.start-card h2 { font-size: 1.66rem; color: #fbf4e6; margin-bottom: 3px; font-weight: 800; }
.start-subtitle {
  font-size: 0.82rem; font-weight: 700; color: #e4c17a; letter-spacing: 0.05em;
  text-transform: uppercase; margin-bottom: 12px;
}

.farmer-select-row {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  margin: 8px 0 14px; padding: 12px 16px; background: rgba(255, 255, 255, 0.045);
  border-radius: 16px; border: 1px solid rgba(235, 198, 134, 0.2);
}
.select-label {
  font-size: 0.76rem; font-weight: 700; color: #d1c6b0; text-transform: uppercase; letter-spacing: 0.08em;
}
.farmer-options { display: flex; gap: 12px; justify-content: center; width: 100%; max-width: 440px; }
.farmer-opt {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 9px 14px; border-radius: 13px; border: 1.5px solid rgba(235, 198, 134, 0.22);
  background: rgba(255, 255, 255, 0.04); cursor: pointer; font-family: inherit; transition: all 0.15s ease;
}
.farmer-opt .opt-avatar { font-size: 1.9rem; line-height: 1; }
.farmer-opt .opt-text { text-align: left; line-height: 1.25; }
.farmer-opt .opt-text strong { font-size: 0.92rem; color: #f6efe0; display: block; font-weight: 700; }
.farmer-opt .opt-text small { font-size: 0.74rem; font-weight: 500; color: #b5ab98; }
.farmer-opt:hover { transform: translateY(-1px); border-color: rgba(235, 198, 134, 0.5); }
.farmer-opt.active {
  border-color: #e08a5c; background: rgba(185, 72, 56, 0.24);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

.farmer-name-row { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 440px; margin-top: 3px; }
.farmer-name-label { font-size: 0.84rem; font-weight: 700; color: #f0e4cd; white-space: nowrap; }
.farmer-name-input {
  flex: 1; font-family: inherit; font-size: 0.95rem; font-weight: 600; color: #fcf8ef;
  background: rgba(18, 22, 16, 0.76); border: 1.5px solid rgba(235, 198, 134, 0.38);
  border-radius: 11px; padding: 8px 13px; outline: none; transition: all 0.2s ease;
}
.farmer-name-input::placeholder { color: #9c9485; font-weight: 500; }
.farmer-name-input:focus {
  border-color: #eab856; background: rgba(20, 26, 18, 0.92);
  box-shadow: 0 0 0 3px rgba(234, 184, 86, 0.22);
}
.farmer-name-hint { font-size: 0.76rem; color: #c4dfa9; font-weight: 500; line-height: 1.35; }

.start-keys { font-size: 0.81rem; font-weight: 600; color: #c4bca9; margin-bottom: 15px; }
.kbd {
  display: inline-block; min-width: 26px; padding: 2px 7px; margin: 0 2px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(235, 198, 134, 0.28);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); font-size: 0.77rem; color: #f5eedf;
}
.kbd.wide { padding: 2px 9px; }

.start-btn {
  font-family: inherit; font-size: 1.06rem; font-weight: 700; color: #fdf8ee; cursor: pointer;
  background: linear-gradient(135deg, #b84a39, #8f3426);
  border: 1px solid rgba(244, 192, 158, 0.45); border-radius: 14px;
  padding: 12px 28px; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); transition: all 0.15s ease;
}
.start-btn small { font-size: 0.78rem; font-weight: 500; opacity: 0.86; }
.start-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.loading-note { margin-top: 9px; font-size: 0.78rem; color: #a89f8f; }
.loading-note.error { color: #f87171; font-weight: 700; }

/* Bottom Hands-On Farm Tool Dock & Free-Roam Animal Stroll Portraits */
.farm-dock {
  height: 74px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 14px; background: rgba(34, 28, 22, 0.96);
  border-top: 1px solid rgba(235, 198, 134, 0.26); z-index: 6; overflow-x: auto; scrollbar-width: none;
}
.farm-dock::-webkit-scrollbar { display: none; }

.tool-dock { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
  border-radius: 14px; border: 1.5px solid rgba(235, 198, 134, 0.24);
  background: rgba(255, 255, 255, 0.06); color: #f5ede0; font-family: inherit;
  font-size: 0.84rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: all 0.15s ease;
}
.tool-btn .tool-icon { font-size: 1.15rem; line-height: 1; }
.tool-btn:hover { background: rgba(255, 255, 255, 0.13); transform: translateY(-1px); }
.tool-btn.active {
  background: linear-gradient(135deg, rgba(232, 174, 72, 0.34), rgba(185, 114, 38, 0.26));
  border-color: #f3c460; color: #fff8e2;
  box-shadow: 0 4px 16px rgba(232, 174, 72, 0.25);
}

.dock-divider {
  width: 1px; height: 38px; background: rgba(235, 198, 134, 0.22); flex-shrink: 0;
}

.animal-stroll-bar { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.stroll-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 6px;
  border-radius: 999px; border: 1.5px solid rgba(235, 198, 134, 0.22);
  background: rgba(255, 255, 255, 0.05); color: #f2ead9; font-family: inherit;
  cursor: pointer; white-space: nowrap; transition: all 0.15s ease;
}
.stroll-chip:hover {
  transform: translateY(-2px); border-color: rgba(235, 198, 134, 0.55);
  background: rgba(255, 255, 255, 0.11);
}
.stroll-chip.near {
  border-color: #90d67a; background: rgba(94, 166, 86, 0.22);
  box-shadow: 0 4px 12px rgba(94, 166, 86, 0.22);
}
.stroll-photo {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid rgba(235, 198, 134, 0.45); background: #262018;
}
.stroll-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.stroll-name { font-size: 0.79rem; font-weight: 700; color: #faf2e2; }
.stroll-sub { font-size: 0.66rem; font-weight: 600; color: #c7d9b5; }

@media (max-width: 1120px) {
  .title { display: none; }
  .tool-label { display: none; }
  .tool-btn { padding: 9px 12px; }
  .friend-card { width: 242px; }
  .friend-photo-wrap { height: 106px; }
}
@media (max-width: 720px) {
  .friend-card { width: 204px; top: 8px; right: 8px; }
  .friend-photo-wrap { height: 84px; }
  .friend-tip { display: none; }
  .start-photo-strip { grid-template-columns: repeat(3, 1fr); }
  .stroll-sub { display: none; }
}
