:root {
  --bg: #2b2118;
  --panel: #3e3226;
  --accent: #f4a261;
  --text: #f1eadd;
  --error: #e76f51;
  --success: #2a9d8f;
  --sky-top: #87ceeb;
  --sky-bottom: #e0f7fa;
  --grass: #4a7c2e;
  --grass-light: #6c9a6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  overflow-x: hidden;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Animated farm background */
.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(180deg, #5d8c3a 0%, #4a7c2e 50%, #3a5f22 100%);
}

.ground {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 35vh;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 100%, rgba(255,255,255,0.25) 0%, transparent 25%),
    linear-gradient(180deg, var(--grass-light) 0%, var(--grass) 100%);
  clip-path: ellipse(120% 100% at 50% 100%);
}

#app {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem 2rem;
}

.top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  margin: 1rem 0 1.5rem;
  background: rgba(62, 50, 38, 0.95);
  border: 3px solid #5d4037;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.top-bar h1 {
  margin: 0;
  font-size: 1.7rem;
  color: var(--accent);
  text-shadow: 2px 2px 0 #5d4037;
  letter-spacing: 0.5px;
}

.stats span {
  margin-left: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #3e3226;
}

.panel {
  width: 100%;
  padding: 1.5rem;
}

.hidden { display: none !important; }

/* Farm card for auth panel */
.farm-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 253, 245, 0.96);
  color: #3e2723;
  border: 5px solid #8d6e63;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  max-width: 520px;
  padding: 2rem;
  position: relative;
}

.farm-card::before,
.farm-card::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: #c0392b;
  border-radius: 50%;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.15);
}

.farm-card::before { top: 14px; left: 14px; }
.farm-card::after { top: 14px; right: 14px; }

.illustration {
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #b3e5fc 0%, #e1f5fe 60%, #a5d6a7 60%, #81c784 100%);
  border: 3px solid #5d4037;
}

.illustration svg {
  display: block;
  width: 100%;
  height: auto;
}

.farm-title {
  margin: 0.3rem 0 0;
  font-size: 1.9rem;
  color: #5d4037;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.tagline {
  margin: 0 0 0.8rem;
  color: #6d4c41;
  font-size: 1.05rem;
  text-align: center;
  max-width: 360px;
  line-height: 1.4;
}

#authPanel input {
  padding: 0.85rem 1.2rem;
  font-size: 1.15rem;
  border: 3px solid #8d6e63;
  border-radius: 10px;
  background: #fff;
  color: #3e2723;
  width: 280px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#authPanel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(244, 162, 97, 0.3);
}

button {
  padding: 0.9rem 1.6rem;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent) 0%, #e07a3f 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #a0522d, 0 6px 12px rgba(0,0,0,0.2);
  transition: transform 0.1s ease, filter 0.2s ease, box-shadow 0.1s ease;
}

button:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #a0522d, 0 8px 16px rgba(0,0,0,0.22);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #a0522d, 0 3px 6px rgba(0,0,0,0.2);
}

.error {
  color: var(--error);
  margin: 0;
  min-height: 1.2em;
  font-weight: 600;
}

#gamePanel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#gameCanvas {
  background: #6c9a6b;
  border: 6px solid #4a3b2a;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-width: 100%;
  height: auto;
}

.message {
  margin-top: 1rem;
  font-size: 1.3rem;
  font-weight: 700;
  min-height: 1.6em;
  color: var(--success);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.controls {
  margin-top: 0.5rem;
  text-align: center;
}

.controls p {
  margin: 0.5rem 0;
  color: #3e2723;
  font-weight: 500;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

@media (max-width: 640px) {
  .top-bar {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  .stats span { margin: 0 0.6rem; }
  #gameCanvas { width: 100%; }
  .farm-card { padding: 1.5rem 1rem; }
  .farm-title { font-size: 1.5rem; }
}
