:root {
  --soil: #3a2618;
  --soil-2: #5c3d24;
  --gold: #e8c36a;
  --gold-2: #f4de9f;
  --leaf: #6fbf63;
  --leaf-dark: #2f6b32;
  --cream: #f7f0e1;
  --ink: #1b140f;
  --panel: rgba(22, 14, 10, 0.78);
  --panel-border: rgba(232, 195, 106, 0.28);
  --danger: #e06a4f;
  --ok: #7dce7a;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0a08;
  color: var(--cream);
  font-family: "DM Sans", system-ui, sans-serif;
}

#canvas-wrap, #game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#game-canvas { cursor: default; }
#game-canvas.build { cursor: crosshair; }

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud > * { pointer-events: auto; }

.top-bar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.brand, .stat, .hint-card, .panel, .inv, .shop, .toast {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}

.brand {
  padding: 6px 12px 6px 10px;
  border-radius: 12px;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(90,58,28,.55), rgba(28,16,8,.78)),
    repeating-linear-gradient(90deg, rgba(232,195,106,.08) 0 2px, transparent 2px 7px);
  border: 1px solid rgba(232, 195, 106, .4);
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,220,140,.18);
}
.brand::before {
  content: "🌾";
  font-size: 13px;
  margin-right: 6px;
}

.clock {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  text-align: center;
  padding: 4px 14px 5px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(72,46,20,.7), rgba(22,12,6,.82));
  border: 1px solid rgba(232, 195, 106, .42);
  box-shadow: 0 6px 16px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,220,140,.16);
  min-width: 86px;
}
.clock-day {
  font-size: 8px;
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: .7;
  color: #f4de9f;
}
.clock-time {
  font-family: "Fraunces", serif;
  font-size: 15px;
  color: var(--gold-2);
  line-height: 1.05;
}

#minimap {
  width: min(560px, 100%);
  height: auto;
  border-radius: 16px;
  border: 1px solid rgba(232,195,106,.22);
  background: #2d5a28;
  image-rendering: pixelated;
}
.map-card { align-items: stretch; }
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  font-size: 12px;
  opacity: .85;
}
.map-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.brand {
  display: flex;
  align-items: center;
}
.brand h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--gold-2);
  display: inline;
}
.brand p {
  display: none;
}

.stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat {
  padding: 4px 8px 4px 6px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(78,50,22,.62), rgba(24,14,8,.8));
  border: 1px solid rgba(232, 195, 106, .38);
  box-shadow: 0 4px 12px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,220,140,.14);
}

.stat .ico { font-size: 13px; }
.stat .ico-wrap { width: 18px; height: 18px; }
.stat .ico-wrap svg { width: 16px; height: 16px; }
.stat .lbl { font-size: 8px; letter-spacing: .14em; text-transform: uppercase; opacity: .62; color: #f4de9f; }
.stat .val { font-family: "Fraunces", serif; font-size: 13px; color: var(--gold); line-height: 1.05; }

.bottom-bar.slim {
  align-items: center;
}
.hunger-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  min-width: 168px;
}
.burger {
  font-size: 22px;
  line-height: 1;
  transform-origin: center bottom;
  transition: transform .25s ease, filter .25s ease;
}
.hunger-hud.low .burger { filter: grayscale(.6); }
.hunger-hud.empty .burger { filter: grayscale(1); animation: starve 0.7s ease-in-out infinite; }
@keyframes starve {
  50% { transform: scale(0.82); }
}
.hunger-track {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: #2a241c;
  overflow: hidden;
}
.hunger-track i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #c44536, #e8c36a, #6fbf63);
  transform-origin: left center;
  transition: transform .2s linear;
}
.hunger-hud span { font-size: 12px; color: var(--gold-2); min-width: 36px; }
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 4px 12px;
}
.menu-card { width: min(420px, 92vw); }
.btn.danger {
  background: linear-gradient(180deg, #8a2a22, #4a1210);
  border-color: #c44536;
  color: #f7e4d8;
  grid-column: 1 / -1;
}
.btn.danger:hover { filter: brightness(1.12); color: #fff; }
.night-banner {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20, 8, 8, .72);
  border: 1px solid rgba(180, 40, 30, .45);
  color: #e8c36a;
  font-size: 12px;
  letter-spacing: .08em;
  display: none;
  pointer-events: none;
}
.night-banner.show { display: block; }

.bottom-bar {
  position: absolute;
  bottom: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.hint-card {
  padding: 12px 14px;
  border-radius: 14px;
  max-width: 420px;
  font-size: 13px;
  line-height: 1.45;
}

.hint-card b { color: var(--gold-2); }

.hotbar {
  display: flex;
  gap: 8px;
}

.slot {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  position: relative;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .15s ease, border-color .15s ease;
}

.slot:hover { transform: translateY(-2px); border-color: var(--gold); }
.slot.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232,195,106,.35); }
.slot .qty {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 11px;
  color: var(--gold-2);
}
.slot .key {
  position: absolute;
  left: 6px;
  top: 4px;
  font-size: 10px;
  opacity: .45;
}
.slot .ico { font-size: 24px; }

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  pointer-events: auto;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--cream);
  border-radius: 12px;
  padding: 10px 14px;
  font: 600 13px "DM Sans", sans-serif;
  cursor: pointer;
  transition: .15s ease;
}
.btn:hover { border-color: var(--gold); color: var(--gold-2); }
.btn.primary { background: linear-gradient(180deg, #c9a24a, #8a6a22); border-color: #f0d58a; color: #1b140f; }
.btn.primary:hover { filter: brightness(1.08); color: #1b140f; }

.prompt {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 13px;
  display: none;
  white-space: nowrap;
}
.prompt.show { display: block; }
.prompt kbd {
  display: inline-block;
  background: rgba(232,195,106,.15);
  border: 1px solid rgba(232,195,106,.35);
  padding: 1px 6px;
  border-radius: 6px;
  margin-right: 6px;
  color: var(--gold-2);
  font-size: 12px;
}

/* Inventory */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,4,2,.55);
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay.open { display: flex; }

.inv, .shop {
  width: min(860px, 96vw);
  border-radius: 24px;
  padding: 22px 22px 18px;
  position: relative;
  max-height: min(90vh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.market-card {
  background:
    linear-gradient(180deg, rgba(62, 36, 18, 0.55), rgba(18, 11, 8, 0.88)),
    var(--panel);
  border-color: rgba(232, 195, 106, 0.4);
  padding-top: 28px;
}
.market-awning {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 14px;
  border-radius: 24px 24px 0 0;
  background: repeating-linear-gradient(
    90deg,
    #b33a2b 0 28px,
    #f0d58a 28px 56px
  );
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
}

.inv-head, .shop-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.inv h2, .shop h2 {
  font-family: "Fraunces", serif;
  font-size: 28px;
  color: var(--gold-2);
}

.sub { opacity: .65; font-size: 13px; margin-top: 4px; }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 4px 6px 8px 2px;
  min-height: 220px;
  max-height: min(52vh, 420px);
}

.inv-slot {
  min-height: 118px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,248,230,.07), rgba(0,0,0,.28));
  border: 1px solid rgba(232,195,106,.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 10px 12px;
  gap: 8px;
  cursor: pointer;
  position: relative;
}
.inv-slot.empty {
  min-height: 72px;
  opacity: .35;
  cursor: default;
}
.inv-slot:hover, .inv-slot.selected { border-color: var(--gold); background: linear-gradient(180deg, rgba(232,195,106,.14), rgba(0,0,0,.22)); }
.inv-slot .big { font-size: 28px; flex: 0 0 auto; }
.inv-slot .big .ico-svg { width: 42px; height: 42px; }
.inv-slot .name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  color: #f6ead0;
  padding: 0 4px;
  width: 100%;
}
.inv-slot .q {
  position: static;
  margin-top: auto;
  font-size: 13px;
  font-weight: 700;
  color: #1a1208;
  background: var(--gold);
  border-radius: 999px;
  min-width: 28px;
  padding: 2px 9px;
  text-align: center;
}

.detail {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(0,0,0,.22);
  min-height: 78px;
}
.detail h3 { font-size: 16px; color: var(--gold-2); margin-bottom: 4px; }
.detail p { font-size: 13px; opacity: .75; line-height: 1.45; }

.shop-cols {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) 1.15fr;
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.shop-pane {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  max-height: calc(88vh - 140px);
}
.shop-pane::-webkit-scrollbar { width: 8px; }
.shop-pane::-webkit-scrollbar-thumb {
  background: rgba(232,195,106,.35);
  border-radius: 99px;
}
.pane-title {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold-2);
  opacity: .8;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(18,11,8,.95), rgba(18,11,8,.7) 70%, transparent);
  padding: 2px 0 10px;
  z-index: 1;
}

.shop-list { display: flex; flex-direction: column; gap: 8px; }
.shop > .shop-list {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 6px;
}
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.18));
  border: 1px solid rgba(232,195,106,.16);
}
.shop-item .ico, .shop-item .ico-box {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 12px;
  background: rgba(0,0,0,.28);
  display: grid;
  place-items: center;
}
.shop-item .meta { flex: 1; min-width: 0; }
.shop-item .meta b { display: block; font-size: 14px; }
.shop-item .meta span { font-size: 12px; opacity: .65; line-height: 1.35; }
.price { color: var(--gold); font-family: "Fraunces", serif; font-size: 16px; margin-right: 8px; white-space: nowrap; }

.ico-svg { display: block; }
.ico-wrap { width: 28px; height: 28px; display: grid; place-items: center; }
.slot .ico, .inv-slot .big { display: grid; place-items: center; }
.slot .ico .ico-svg { width: 26px; height: 26px; }
.inv-slot .big .ico-svg { width: 30px; height: 30px; }

.car-sel {
  background: rgba(0,0,0,.35);
  color: var(--cream);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  font: 600 12px "DM Sans", sans-serif;
  max-width: 180px;
}

.close-x {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--cream);
  width: 36px; height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
}

.toasts {
  position: fixed;
  top: 86px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  animation: slide .35s ease;
}
@keyframes slide {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at 50% 30%, #3a2618, #0b0a08 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity .6s ease;
}
.loader.hide { opacity: 0; pointer-events: none; }
.loader h1 {
  font-family: "Fraunces", serif;
  font-size: 42px;
  color: var(--gold-2);
}
.loader p { opacity: .7; }
.bar {
  width: 220px; height: 4px;
  background: rgba(255,255,255,.08);
  border-radius: 99px;
  overflow: hidden;
}
.bar > i {
  display: block; height: 100%; width: 40%;
  background: var(--gold);
  animation: load 1.1s ease infinite;
}
@keyframes load {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.build-banner {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(111,191,99,.16);
  border: 1px solid rgba(111,191,99,.4);
  display: none;
  font-size: 13px;
}
.build-banner.show { display: block; }
.build-banner.danger {
  background: rgba(224, 106, 79, 0.18);
  border-color: rgba(224, 106, 79, 0.5);
}

@media (max-width: 820px) {
  .inv-grid { grid-template-columns: repeat(2, 1fr); }
  .shop-cols { grid-template-columns: 1fr; }
  .shop-pane { max-height: 38vh; }
  .brand h1 { font-size: 16px; }
}

.time-speed{display:flex;gap:3px;justify-content:center;margin-top:6px}.time-speed button{appearance:none;border:1px solid rgba(232,195,106,.3);background:rgba(8,17,12,.55);color:#e8d9ae;border-radius:5px;padding:3px 6px;font:700 9px system-ui;cursor:pointer}.time-speed button:hover{border-color:rgba(232,195,106,.7)}.time-speed button.active{background:#e8c36a;color:#173123;border-color:#f3d98e}
